Skip to content

uaccess: Prepare for masked user access on powerpc

Christophe Leroy linux-block linux-fsdevel linuxppc-dev lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 Latest4 patches 1 replyIn review

Changes in v5 from the cover letter

- Taken comments from tglx
- Only include core preparatory patches, powerpc patches are kept for following kernel development cycle
- Reworded patch 1 to make it more explicit it needs to come before patch 2
- Added patch 3 to convert put_cmsg() to scoped user access instead of just fixing the direction of the uacess
- Renamed patch 4 as it now only handles fonctions from lib/strn*.c

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4iov_iter: Convert copy_from_user_iter() to masked user accesslib/iov_iter.c+10 -60 replies
2/4iov_iter: Add missing speculation barrier to copy_from_user_iter()lib/iov_iter.c+11 -30 replies
3/4scm: Convert put_cmsg() to scoped user accessnet/core/scm.c+7 -130 replies
4/4lib/strn*,uaccess: Use masked_user_{read/write}_access_begin when requiredlib/strncpy_from_user.c lib/strnlen_user.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/4] uaccess: Prepare for masked user access on powerpc

This is v5 of the series "powerpc: Implement masked user access". This version only includes the preparatory patches to enable merging of powerpc architecture patches that depend on them on next cycle.

It applies on top of commit 6ec821f050e2 (tag: core-scoped-uaccess) from tip tree.

Thomas, Peter, could you please take those preparatory patches in tip tree for v6.19, then Maddy will take powerpc patches into powerpc-next for v6.20.

Masked user access avoids the address/size verification by access_ok(). Allthough its main purpose is to skip the speculation in the verification of user address and size hence avoid the need of spec mitigation, it also has the advantage to reduce the amount of instructions needed so it also benefits to platforms that don't need speculation mitigation, especially when the size of the copy is not know at build time.

Patches 1 and 2 are preparing to clean-up some redundant barrier_nospec() introduced by commit 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()"). To do that, a speculation barrier is added to copy_from_user_iter() so that the barrier in powerpc raw_copy_from_user() which is redundant with the one in copy_from_user() can be removed. To avoid impacting x86, copy_from_user_iter() is first converted to using masked user access.

Patch 3 convert put_cmsg() to scoped user access.

Patch 4 replaces remaining wrong calls to masked_user_access_begin() with calls to masked_user_read_access_begin() and masked_user_write_access_begin() to match with user_read_access_end() and user_write_access_end().

Entire series is availiable at https://git.kernel.org/pub/scm/linux/kernel/git/chleroy/linux branch masked-uaccess

Changes in v5:
- Taken comments from tglx
- Only include core preparatory patches, powerpc patches are kept for following kernel development cycle
- Reworded patch 1 to make it more explicit it needs to come before patch 2
- Added patch 3 to convert put_cmsg() to scoped user access instead of just fixing the direction of the uacess
- Renamed patch 4 as it now only handles fonctions from lib/strn*.c

Changes in v4:
- Rebased on top of commit 6ec821f050e2 (tag: core-scoped-uaccess) from tip tree
- Patch 3: Simplified as masked_user_read_access_begin() and masked_user_write_access_begin() are already there.
- Patch 10: Simplified mask_user_address_simple() as suggested by Gabriel.

Changes in v3:
- Rebased on top of v6.18-rc1
- Patch 3: Impact on recently modified net/core/scm.c
- Patch 10: Rewrite mask_user_address_simple() for a smaller result on powerpc64, suggested by Gabriel

Changes in v2:
- Converted copy_from_user_iter() to using masked user access.
- Cleaned up powerpc uaccess function to minimise code duplication when adding masked user access
- Automated TASK_SIZE calculation to minimise use of BUILD_BUG_ON()
- Tried to make some commit messages more clean based on feedback from version 1 of the series.

Christophe Leroy (4):
iov_iter: Convert copy_from_user_iter() to masked user access
iov_iter: Add missing speculation barrier to copy_from_user_iter()
scm: Convert put_cmsg() to scoped user access lib/strn*,uaccess: Use masked_user_{read/write}_access_begin when
required

 lib/iov_iter.c          | 22 +++++++++++++++++-----
 lib/strncpy_from_user.c |  2 +-
 lib/strnlen_user.c      |  2 +-
 net/core/scm.c          | 20 +++++++-------------
 4 files changed, 26 insertions(+), 20 deletions(-)
Signature · 1 line
2.49.0