Skip to content

Commit

Permalink
x86: make the masked_user_access_begin() macro use its argument only …
Browse files Browse the repository at this point in the history
…once

This doesn't actually matter for any of the current users, but before
merging it mainline, make sure we don't have any surprising semantics.

We don't actually want to use an inline function here, because we want
to allow - but not require - const pointer arguments, and return them as
such.  But we already had a local auto-type variable, so let's just use
it to avoid any possible double evaluation.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Linus Torvalds committed Sep 22, 2024
1 parent 05f4216 commit 533ab22
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/include/asm/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm,
* for dense accesses starting at the address.
*/
#define mask_user_address(x) ((typeof(x))((long)(x)|((long)(x)>>63)))
#define masked_user_access_begin(x) ({ \
__auto_type __masked_ptr = mask_user_address(x); \
#define masked_user_access_begin(x) ({ \
__auto_type __masked_ptr = (x); \
__masked_ptr = mask_user_address(__masked_ptr); \
__uaccess_begin(); __masked_ptr; })

/*
Expand Down

0 comments on commit 533ab22

Please sign in to comment.