[PW_SID:1060024] uaccess: Updates to scoped_user_access()#1531
[PW_SID:1060024] uaccess: Updates to scoped_user_access()#1531linux-riscv-bot wants to merge 5 commits into
Conversation
If a 'const struct foo __user *ptr' is used for the address passed
to scoped_user_read_access() then you get a warning/error
uaccess.h:691:1: error: initialization discards 'const' qualifier
from pointer target type [-Werror=discarded-qualifiers]
for the
void __user *_tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)
assignment.
Fix by using 'auto' for both _tmpptr and the redeclaration of uptr.
Replace the CLASS() with explicit __cleanup() functions on uptr.
Fixes: e497310 "(uaccess: Provide scoped user access regions)"
Signed-off-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Autoterminating nested for() loops can be used inside #defines to declare variables that are scoped to the statement that follows. These are used by __scoped_user_access() but may have other uses and the gory details are best separated from the use. Using 'with (declaration)' and 'and_with (declaration)' seems to read reasonably well and doesn't seem to collide with any existing code. As an example the scoped user access definition becomes: with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \ /* Force modified pointer usage within the scope */ \ and_with (const auto uptr __cleanup(...) = _tmpptr) Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Wrappers for autoterminating nested for() loops have been added to compiler.h, use them to hide the gory details. Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
-Wshadow is enabled by W=2 builds and __scoped_user_access() quite deliberately creates a 'const' shadow of the 'user' address that references a 'guard page' when the application passes a kernel pointer. Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Mechanically change the access_ok() and __get/put_user() to use scoped_user_read/write_access() and unsafe_get/put_user(). This generates better code with fewer STAC/CLAC pairs. It also ensures that access_ok() is called near the user accesses. I failed to find the one for __save_altstack(). Looking at the change, perhaps there should be aliases: #define scoped_put_user unsafe_put_user #define scoped_get_user unsafe_get_user Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 1: "[v2,1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 2: "[v2,2/5] compiler.h: Add generic support for 'autoterminating nested for() loops'" |
|
Patch 3: "[v2,3/5] uaccess.h: Use with() and and_with() in __scoped_user_access()" |
|
Patch 3: "[v2,3/5] uaccess.h: Use with() and and_with() in __scoped_user_access()" |
|
Patch 3: "[v2,3/5] uaccess.h: Use with() and and_with() in __scoped_user_access()" |
|
Patch 3: "[v2,3/5] uaccess.h: Use with() and and_with() in __scoped_user_access()" |
|
Patch 3: "[v2,3/5] uaccess.h: Use with() and and_with() in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 4: "[v2,4/5] uaccess: Disable -Wshadow in __scoped_user_access()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
|
Patch 5: "[v2,next,5/5] signal: Use scoped_user_access() instead of __put/get_user()" |
PR for series 1060024 applied to workflow__riscv__fixes
Name: uaccess: Updates to scoped_user_access()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1060024
Version: 2