Re: [PATCH v2] cred: annotate data race on non_rcu when copying a cred

From
sashiko-bot@kernel.org
Date
2026-11-14 05:38:03
Reply to
Babanpreet Singh, 2026-11-14
prepare_creds() copies the current cred while another task can be in
get_cred() on it, clearing non_rcu. KCSAN reports:

  BUG: KCSAN: data-race in io_prep_async_work / prepare_creds

  write to 0xffff8881046cea68 of 4 bytes by task 3646 on cpu 1:
   get_cred_many include/linux/cred.h:222 [inline]
   get_cred include/linux/cred.h:238 [inline]
   io_prep_async_work+0x9b/0x3c0 io_uring/io_uring.c:367

  read to 0xffff8881046ce9c0 of 184 bytes by task 3645 on cpu 0:
   prepare_creds+0x71/0x550 kernel/cred.c:192

The race is harmless. non_rcu and usage are the only fields that change
on a published cred, and both are reset on the new cred right after the
copy.

Annotate the copy with data_race(). prepare_kernel_cred() makes the
same copy, so annotate it too and switch it to memcpy() to match.

Reported-by: <redacted>
Closes: https://syzkaller.appspot.com/bug?extid=ee58b040032d8bed63d9
Reported-by: <redacted>
Closes: https://syzkaller.appspot.com/bug?extid=557fdc985d6ac3831e14
Signed-off-by: Babanpreet Singh <redacted>
Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261114052900.7-1-bbnpreetsingh@gmail.com?part=1
Thread (3 messages) 3 messages, 3 authors, last reply 4d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help