module: Fix NULL vs IS_ERR checking for module_get_next_page
PATCH 1/1 module: Fix NULL vs IS_ERR checking for module_get_next_page
The module_get_next_page() function return error pointers on error instead of NULL.
Use IS_ERR() to check the return value to fix this.
--- kernel/module/decompress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/module/decompress.c +4 -4
@@ -114,8 +114,8 @@ static ssize_t module_gzip_decompress(struct load_info *info, do { struct page *page = module_get_next_page(info); - if (!page) { - retval = -ENOMEM; + if (IS_ERR(page)) { + retval = PTR_ERR(page); goto out_inflate_end; }
@@ -173,8 +173,8 @@ static ssize_t module_xz_decompress(struct load_info *info, do { struct page *page = module_get_next_page(info); - if (!page) { - retval = -ENOMEM; + if (IS_ERR(page)) { + retval = PTR_ERR(page); goto out; }
Signature · 1 line
2.37.3.671.ge2130fe6da78.dirty
Luis Chamberlain
maintainerQuoted 7 lines · Miaoqian Lin
The
module_get_next_page()function return error pointers on error instead of NULL.
UseIS_ERR()to check the return value to fix this.Fixes b1ae6dc41eaa ("module: add in-kernel support for decompressing")Signed-off-by Miaoqian Lin <[email protected]>---
Thanks queued up. How did you find out? Just code inspection? I see chances are low of this triggering, but just curious how you found it.
Luis
Hi,
Quoted 10 lines · Luis Chamberlain
Quoted 7 lines · Miaoqian Lin
The
module_get_next_page()function return error pointers on error instead of NULL.
UseIS_ERR()to check the return value to fix this.Fixes b1ae6dc41eaa ("module: add in-kernel support for decompressing")Signed-off-by Miaoqian Lin <[email protected]>---
Thanks queued up. How did you find out? Just code inspection? I see chances are low of this triggering, but just curious how you found it.
I found this by static analysis, specifically, I obtained functions that return error pointers and
inspected whether their callers followed the correct specification.
Quoted 1 line
Luis
Luis Chamberlain
maintainerQuoted 8 lines · Miaoqian Lin
Hi,
Quoted 5 lines · Luis Chamberlain
Quoted 4 lines · Miaoqian Lin
The
module_get_next_page()function return error pointers on error instead of NULL.
UseIS_ERR()to check the return value to fix this.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes b1ae6dc41eaa ("module: add in-kernel support for decompressing")Signed-off-by Miaoqian Lin <[email protected]>---
Thanks queued up. How did you find out? Just code inspection? I see chances are low of this triggering, but just curious how you found it.
I found this by static analysis, specifically, I obtained functions that return error pointers and inspected whether their callers followed the correct specification.
Which one did you use?
Luis
Quoted 9 lines · Luis Chamberlain
Quoted 8 lines · Miaoqian Lin
Hi,
Quoted 5 lines · Luis Chamberlain
Quoted 4 lines · Miaoqian Lin
The
module_get_next_page()function return error pointers on error instead of NULL.
UseIS_ERR()to check the return value to fix this.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes b1ae6dc41eaa ("module: add in-kernel support for decompressing")Signed-off-by Miaoqian Lin <[email protected]>---
Thanks queued up. How did you find out? Just code inspection? I see chances are low of this triggering, but just curious how you found it.
I found this by static analysis, specifically, I obtained functions that return error pointers and inspected whether their callers followed the correct specification.
Which one did you use?
I wrote custom checker based on the weggli tool (https://github.com/googleprojectzero/weggli).
Quoted 1 line
Luis
Quoted 6 lines · Miaoqian Lin
The
module_get_next_page()function return error pointers on error instead of NULL.
UseIS_ERR()to check the return value to fix this.Fixes b1ae6dc41eaa ("module: add in-kernel support for decompressing")Signed-off-by Miaoqian Lin <[email protected]>
Thank you for spotting this.
Signature · 1 line
Dmitry