diff mbox series

module/decompress: Fix error checking on zstd decompression

Message ID 20230601212331.567483-1-lucas.demarchi@intel.com (mailing list archive)
State New, archived
Headers show
Series module/decompress: Fix error checking on zstd decompression | expand

Commit Message

Lucas De Marchi June 1, 2023, 9:23 p.m. UTC
While implementing support for in-kernel decompression in kmod,
finit_module() was returning a very suspicious value:

	finit_module(3, "", MODULE_INIT_COMPRESSED_FILE) = 18446744072717407296

It turns out the check for module_get_next_page() failing is wrong,
and hence the decompression was not really taking place. Invert
the condition to fix it.

Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
Cc: stable@kernel.org
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 kernel/module/decompress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luis Chamberlain June 1, 2023, 9:40 p.m. UTC | #1
On Thu, Jun 01, 2023 at 02:23:31PM -0700, Lucas De Marchi wrote:
> While implementing support for in-kernel decompression in kmod,
> finit_module() was returning a very suspicious value:
> 
> 	finit_module(3, "", MODULE_INIT_COMPRESSED_FILE) = 18446744072717407296
> 
> It turns out the check for module_get_next_page() failing is wrong,
> and hence the decompression was not really taking place. Invert
> the condition to fix it.
> 
> Fixes: 169a58ad824d ("module/decompress: Support zstd in-kernel decompression")
> Cc: stable@kernel.org
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Applied and pushed, will send a pull to Linus right away, thanks!

  Luis
diff mbox series

Patch

diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
index e97232b125eb..8a5d6d63b06c 100644
--- a/kernel/module/decompress.c
+++ b/kernel/module/decompress.c
@@ -257,7 +257,7 @@  static ssize_t module_zstd_decompress(struct load_info *info,
 	do {
 		struct page *page = module_get_next_page(info);
 
-		if (!IS_ERR(page)) {
+		if (IS_ERR(page)) {
 			retval = PTR_ERR(page);
 			goto out;
 		}