Message ID | 20221229170545.718264-1-ben-linux@fluff.org (mailing list archive) |
---|---|
State | Accepted |
Commit | b9b916aee6715cd7f3318af6dc360c4729417b94 |
Delegated to: | Palmer Dabbelt |
Headers | show |
Series | riscv: uaccess: fix type of 0 variable on error in get_user() | expand |
Context | Check | Description |
---|---|---|
conchuod/patch_count | success | Link |
conchuod/cover_letter | success | Single patches do not need cover letters |
conchuod/tree_selection | success | Guessed tree name to be for-next |
conchuod/fixes_present | success | Fixes tag not required for -next series |
conchuod/maintainers_pattern | success | MAINTAINERS pattern errors before the patch: 13 and now 13 |
conchuod/verify_signedoff | success | Signed-off-by tag matches author and committer |
conchuod/kdoc | success | Errors and warnings before: 0 this patch: 0 |
conchuod/module_param | success | Was 0 now: 0 |
conchuod/alphanumeric_selects | success | Out of order selects before the patch: 57 and now 57 |
conchuod/build_rv32_defconfig | success | Build OK |
conchuod/build_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/dtb_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/header_inline | success | No static functions without inline keyword in header files |
conchuod/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
conchuod/source_inline | success | Was 0 now: 0 |
conchuod/build_rv64_nommu_k210_defconfig | success | Build OK |
conchuod/verify_fixes | success | No Fixes tag |
conchuod/build_rv64_nommu_virt_defconfig | success | Build OK |
On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.org wrote: > If the get_user(x, ptr) has x as a pointer, then the setting > of (x) = 0 is going to produce the following sparse warning, > so fix this by forcing the type of 'x' when access_ok() fails. > > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer > > Signed-off-by: Ben Dooks <ben-linux@fluff.org> > --- > arch/riscv/include/asm/uaccess.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h > index 855450bed9f5..ec0cab9fbddd 100644 > --- a/arch/riscv/include/asm/uaccess.h > +++ b/arch/riscv/include/asm/uaccess.h > @@ -165,7 +165,7 @@ do { \ > might_fault(); \ > access_ok(__p, sizeof(*__p)) ? \ > __get_user((x), __p) : \ > - ((x) = 0, -EFAULT); \ > + ((x) = (__force __typeof__(x))0, -EFAULT); \ > }) > > #define __put_user_asm(insn, x, ptr, err) \ Looks like arm64 has a pretty similar pattern. They've got the __force __typeof__ already, but given the similarity it might be worth refactoring these to share the error checking code. Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> I'll give this a bit of time like usual, unless anyone's opposed I'll put it on fixes. I wasn't planning on sending a PR this week anyway due to the holidays. Thanks!
On Thu, Dec 29, 2022 at 09:31:27AM -0800, Palmer Dabbelt wrote: > On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.org wrote: > > If the get_user(x, ptr) has x as a pointer, then the setting > > of (x) = 0 is going to produce the following sparse warning, > > so fix this by forcing the type of 'x' when access_ok() fails. > > > > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer > > > > Signed-off-by: Ben Dooks <ben-linux@fluff.org> > > --- > > arch/riscv/include/asm/uaccess.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h > > index 855450bed9f5..ec0cab9fbddd 100644 > > --- a/arch/riscv/include/asm/uaccess.h > > +++ b/arch/riscv/include/asm/uaccess.h > > @@ -165,7 +165,7 @@ do { \ > > might_fault(); \ > > access_ok(__p, sizeof(*__p)) ? \ > > __get_user((x), __p) : \ > > - ((x) = 0, -EFAULT); \ > > + ((x) = (__force __typeof__(x))0, -EFAULT); \ > > }) > > > > #define __put_user_asm(insn, x, ptr, err) \ > > Looks like arm64 has a pretty similar pattern. They've got the __force > __typeof__ already, but given the similarity it might be worth refactoring > these to share the error checking code. I looked there for an idea on how to fix. > Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> > > I'll give this a bit of time like usual, unless anyone's opposed I'll put it > on fixes. I wasn't planning on sending a PR this week anyway due to the > holidays. Ok, it's a warning which would be nice to be fixed.
On Thu, 29 Dec 2022 17:05:45 +0000, Ben Dooks wrote: > If the get_user(x, ptr) has x as a pointer, then the setting > of (x) = 0 is going to produce the following sparse warning, > so fix this by forcing the type of 'x' when access_ok() fails. > > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer > > > [...] Applied, thanks! [1/1] riscv: uaccess: fix type of 0 variable on error in get_user() https://git.kernel.org/palmer/c/b9b916aee671 Best regards,
Hello: This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <palmer@rivosinc.com>: On Thu, 29 Dec 2022 17:05:45 +0000 you wrote: > If the get_user(x, ptr) has x as a pointer, then the setting > of (x) = 0 is going to produce the following sparse warning, > so fix this by forcing the type of 'x' when access_ok() fails. > > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer > > Signed-off-by: Ben Dooks <ben-linux@fluff.org> > > [...] Here is the summary with links: - riscv: uaccess: fix type of 0 variable on error in get_user() https://git.kernel.org/riscv/c/b9b916aee671 You are awesome, thank you!
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h index 855450bed9f5..ec0cab9fbddd 100644 --- a/arch/riscv/include/asm/uaccess.h +++ b/arch/riscv/include/asm/uaccess.h @@ -165,7 +165,7 @@ do { \ might_fault(); \ access_ok(__p, sizeof(*__p)) ? \ __get_user((x), __p) : \ - ((x) = 0, -EFAULT); \ + ((x) = (__force __typeof__(x))0, -EFAULT); \ }) #define __put_user_asm(insn, x, ptr, err) \
If the get_user(x, ptr) has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' when access_ok() fails. fs/aio.c:2073:21: warning: Using plain integer as NULL pointer Signed-off-by: Ben Dooks <ben-linux@fluff.org> --- arch/riscv/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)