Skip to content

Commit dfb36e4

Browse files
Waiman-LongKAGA-KOKO
authored andcommitted
futex: Use user_write_access_begin/_end() in futex_put_value()
Commit cec199c ("futex: Implement FUTEX2_NUMA") introduced the futex_put_value() helper to write a value to the given user address. However, it uses user_read_access_begin() before the write. For architectures that differentiate between read and write accesses, like PowerPC, futex_put_value() fails with -EFAULT. Fix that by using the user_write_access_begin/user_write_access_end() pair instead. Fixes: cec199c ("futex: Implement FUTEX2_NUMA") Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent e703b7e commit dfb36e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/futex/futex.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ static __always_inline int futex_put_value(u32 val, u32 __user *to)
319319
{
320320
if (can_do_masked_user_access())
321321
to = masked_user_access_begin(to);
322-
else if (!user_read_access_begin(to, sizeof(*to)))
322+
else if (!user_write_access_begin(to, sizeof(*to)))
323323
return -EFAULT;
324324
unsafe_put_user(val, to, Efault);
325-
user_read_access_end();
325+
user_write_access_end();
326326
return 0;
327327
Efault:
328-
user_read_access_end();
328+
user_write_access_end();
329329
return -EFAULT;
330330
}
331331

0 commit comments

Comments
 (0)