2023-03-15 12:53:19

by Fabio M. De Francesco

[permalink] [raw]
Subject: [PATCH] module/decompress: Never use kunmap() for local un-mappings

Use kunmap_local() to unmap pages locally mapped with kmap_local_page().

kunmap_local() must be called on the kernel virtual address returned by
kmap_local_page(), differently from how we use kunmap() which instead
expects the mapped page as its argument.

In module_zstd_decompress() we currently map with kmap_local_page() and
unmap with kunmap(). This breaks the code and so it should be fixed.

Cc: Piotr Gorski <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Luis Chamberlain <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Ira Weiny <[email protected]>
Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
Signed-off-by: Fabio M. De Francesco <[email protected]>
---
kernel/module/decompress.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
index bb79ac1a6d8f..7ddc87bee274 100644
--- a/kernel/module/decompress.c
+++ b/kernel/module/decompress.c
@@ -267,7 +267,7 @@ static ssize_t module_zstd_decompress(struct load_info *info,
zstd_dec.size = PAGE_SIZE;

ret = zstd_decompress_stream(dstream, &zstd_dec, &zstd_buf);
- kunmap(page);
+ kunmap_local(zstd_dec.dst);
retval = zstd_get_error_code(ret);
if (retval)
break;
--
2.39.2



2023-03-15 18:16:44

by Ira Weiny

[permalink] [raw]
Subject: Re: [PATCH] module/decompress: Never use kunmap() for local un-mappings

Fabio M. De Francesco wrote:
> Use kunmap_local() to unmap pages locally mapped with kmap_local_page().
>
> kunmap_local() must be called on the kernel virtual address returned by
> kmap_local_page(), differently from how we use kunmap() which instead
> expects the mapped page as its argument.
>
> In module_zstd_decompress() we currently map with kmap_local_page() and
> unmap with kunmap(). This breaks the code and so it should be fixed.
>
> Cc: Piotr Gorski <[email protected]>
> Cc: Dmitry Torokhov <[email protected]>
> Cc: Luis Chamberlain <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Ira Weiny <[email protected]>

Reviewed-by: Ira Weiny <[email protected]>

> Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
> Signed-off-by: Fabio M. De Francesco <[email protected]>
> ---
> kernel/module/decompress.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
> index bb79ac1a6d8f..7ddc87bee274 100644
> --- a/kernel/module/decompress.c
> +++ b/kernel/module/decompress.c
> @@ -267,7 +267,7 @@ static ssize_t module_zstd_decompress(struct load_info *info,
> zstd_dec.size = PAGE_SIZE;
>
> ret = zstd_decompress_stream(dstream, &zstd_dec, &zstd_buf);
> - kunmap(page);
> + kunmap_local(zstd_dec.dst);
> retval = zstd_get_error_code(ret);
> if (retval)
> break;
> --
> 2.39.2
>



2023-03-17 19:04:17

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH] module/decompress: Never use kunmap() for local un-mappings

Quoting Fabio M. De Francesco (2023-03-15 05:52:56)
> Use kunmap_local() to unmap pages locally mapped with kmap_local_page().
>
> kunmap_local() must be called on the kernel virtual address returned by
> kmap_local_page(), differently from how we use kunmap() which instead
> expects the mapped page as its argument.
>
> In module_zstd_decompress() we currently map with kmap_local_page() and
> unmap with kunmap(). This breaks the code and so it should be fixed.
>
> Cc: Piotr Gorski <[email protected]>
> Cc: Dmitry Torokhov <[email protected]>
> Cc: Luis Chamberlain <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
> Signed-off-by: Fabio M. De Francesco <[email protected]>
> ---

Reviewed-by: Stephen Boyd <[email protected]>

2023-03-21 08:33:17

by Piotr Gorski

[permalink] [raw]
Subject: Re: [PATCH] module/decompress: Never use kunmap() for local un-mappings

Reviewed-by: Piotr Gorski <[email protected]>

W dniu 15.03.2023 o 13:52, Fabio M. De Francesco pisze:
> Use kunmap_local() to unmap pages locally mapped with kmap_local_page().
>
> kunmap_local() must be called on the kernel virtual address returned by
> kmap_local_page(), differently from how we use kunmap() which instead
> expects the mapped page as its argument.
>
> In module_zstd_decompress() we currently map with kmap_local_page() and
> unmap with kunmap(). This breaks the code and so it should be fixed.
>
> Cc: Piotr Gorski <[email protected]>
> Cc: Dmitry Torokhov <[email protected]>
> Cc: Luis Chamberlain <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
> Signed-off-by: Fabio M. De Francesco <[email protected]>
> ---
> kernel/module/decompress.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
> index bb79ac1a6d8f..7ddc87bee274 100644
> --- a/kernel/module/decompress.c
> +++ b/kernel/module/decompress.c
> @@ -267,7 +267,7 @@ static ssize_t module_zstd_decompress(struct load_info *info,
> zstd_dec.size = PAGE_SIZE;
>
> ret = zstd_decompress_stream(dstream, &zstd_dec, &zstd_buf);
> - kunmap(page);
> + kunmap_local(zstd_dec.dst);
> retval = zstd_get_error_code(ret);
> if (retval)
> break;

2023-03-21 08:34:30

by Piotr Gorski

[permalink] [raw]
Subject: Re: [PATCH] module/decompress: Never use kunmap() for local un-mappings

Reviewed-by: Piotr Gorski <[email protected]>

W dniu 15.03.2023 o 13:52, Fabio M. De Francesco pisze:
> Use kunmap_local() to unmap pages locally mapped with kmap_local_page().
>
> kunmap_local() must be called on the kernel virtual address returned by
> kmap_local_page(), differently from how we use kunmap() which instead
> expects the mapped page as its argument.
>
> In module_zstd_decompress() we currently map with kmap_local_page() and
> unmap with kunmap(). This breaks the code and so it should be fixed.
>
> Cc: Piotr Gorski <[email protected]>
> Cc: Dmitry Torokhov <[email protected]>
> Cc: Luis Chamberlain <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
> Signed-off-by: Fabio M. De Francesco <[email protected]>
> ---
> kernel/module/decompress.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
> index bb79ac1a6d8f..7ddc87bee274 100644
> --- a/kernel/module/decompress.c
> +++ b/kernel/module/decompress.c
> @@ -267,7 +267,7 @@ static ssize_t module_zstd_decompress(struct load_info *info,
> zstd_dec.size = PAGE_SIZE;
>
> ret = zstd_decompress_stream(dstream, &zstd_dec, &zstd_buf);
> - kunmap(page);
> + kunmap_local(zstd_dec.dst);
> retval = zstd_get_error_code(ret);
> if (retval)
> break;

2023-03-22 23:31:47

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH] module/decompress: Never use kunmap() for local un-mappings

From: Luis Chamberlain <[email protected]>

On Wed, 15 Mar 2023 13:52:56 +0100, Fabio M. De Francesco wrote:
> Use kunmap_local() to unmap pages locally mapped with kmap_local_page().
>
> kunmap_local() must be called on the kernel virtual address returned by
> kmap_local_page(), differently from how we use kunmap() which instead
> expects the mapped page as its argument.
>
> In module_zstd_decompress() we currently map with kmap_local_page() and
> unmap with kunmap(). This breaks the code and so it should be fixed.
>
> [...]

Applied, thanks!

[1/1] module/decompress: Never use kunmap() for local un-mappings
commit: 3c17655ab13704582fe25e8ea3200a9b2f8bf20a

Luis