All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings
@ 2021-05-04 11:33 syzbot
  2021-05-04 11:38 ` Marco Elver
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2021-05-04 11:33 UTC (permalink / raw)
  To: dhowells, jarkko, jmorris, keyrings, linux-kernel,
	linux-security-module, serge, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    5e321ded Merge tag 'for-5.13/parisc' of git://git.kernel.o..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=111cafb9d00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a4da2ebcb6e8f526
dashboard link: https://syzkaller.appspot.com/bug?extid=e4eb6db47eb0f80308c6
compiler:       Debian clang version 11.0.1-2

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e4eb6db47eb0f80308c6@syzkaller.appspotmail.com

==================================================================
BUG: KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings

write to 0xffff8881065ffc10 of 8 bytes by task 30966 on cpu 1:
 assoc_array_apply_edit+0x3e/0x660 lib/assoc_array.c:1357
 __key_link+0x8a/0xc0 security/keys/keyring.c:1372
 __key_instantiate_and_link+0x15b/0x290 security/keys/key.c:459
 key_create_or_update+0x750/0x990 security/keys/key.c:941
 __do_sys_add_key security/keys/keyctl.c:134 [inline]
 __se_sys_add_key+0x26f/0x300 security/keys/keyctl.c:74
 __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
 do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae

read to 0xffff8881065ffc10 of 8 bytes by task 30971 on cpu 0:
 search_nested_keyrings+0x34f/0x920 security/keys/keyring.c:751
 keyring_search_rcu+0xf4/0x180 security/keys/keyring.c:922
 search_cred_keyrings_rcu+0x135/0x240 security/keys/process_keys.c:480
 search_process_keyrings_rcu security/keys/process_keys.c:544 [inline]
 lookup_user_key+0xab6/0xd40 security/keys/process_keys.c:762
 __do_sys_add_key security/keys/keyctl.c:126 [inline]
 __se_sys_add_key+0x23a/0x300 security/keys/keyctl.c:74
 __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
 do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 30971 Comm: syz-executor.1 Not tainted 5.12.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings
  2021-05-04 11:33 [syzbot] KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings syzbot
@ 2021-05-04 11:38 ` Marco Elver
  2021-05-04 17:01   ` Eric Biggers
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Elver @ 2021-05-04 11:38 UTC (permalink / raw)
  To: syzbot
  Cc: David Howells, jarkko, jmorris, keyrings, LKML,
	linux-security-module, serge, syzkaller-bugs

Hello,

On Tue, 4 May 2021 at 13:33, syzbot
<syzbot+e4eb6db47eb0f80308c6@syzkaller.appspotmail.com> wrote:
> HEAD commit:    5e321ded Merge tag 'for-5.13/parisc' of git://git.kernel.o..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=111cafb9d00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=a4da2ebcb6e8f526
> dashboard link: https://syzkaller.appspot.com/bug?extid=e4eb6db47eb0f80308c6
> compiler:       Debian clang version 11.0.1-2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+e4eb6db47eb0f80308c6@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings
>
> write to 0xffff8881065ffc10 of 8 bytes by task 30966 on cpu 1:
>  assoc_array_apply_edit+0x3e/0x660 lib/assoc_array.c:1357
>  __key_link+0x8a/0xc0 security/keys/keyring.c:1372
>  __key_instantiate_and_link+0x15b/0x290 security/keys/key.c:459
>  key_create_or_update+0x750/0x990 security/keys/key.c:941
>  __do_sys_add_key security/keys/keyctl.c:134 [inline]
>  __se_sys_add_key+0x26f/0x300 security/keys/keyctl.c:74
>  __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
>  do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> read to 0xffff8881065ffc10 of 8 bytes by task 30971 on cpu 0:
>  search_nested_keyrings+0x34f/0x920 security/keys/keyring.c:751
>  keyring_search_rcu+0xf4/0x180 security/keys/keyring.c:922
>  search_cred_keyrings_rcu+0x135/0x240 security/keys/process_keys.c:480
>  search_process_keyrings_rcu security/keys/process_keys.c:544 [inline]
>  lookup_user_key+0xab6/0xd40 security/keys/process_keys.c:762
>  __do_sys_add_key security/keys/keyctl.c:126 [inline]
>  __se_sys_add_key+0x23a/0x300 security/keys/keyctl.c:74
>  __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
>  do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
>  entry_SYSCALL_64_after_hwframe+0x44/0xae

I found this interesting because the code around
security/keys/keyring.c:751 is diligent in marking concurrency
accesses with READ_ONCE(). So on the off-chance there is unexpected
concurrency here, I thought it'd be worth double-checking as I wasn't
able to conclude if this is just missing a READ_ONCE().

Thank you!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings
  2021-05-04 11:38 ` Marco Elver
@ 2021-05-04 17:01   ` Eric Biggers
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2021-05-04 17:01 UTC (permalink / raw)
  To: Marco Elver
  Cc: syzbot, David Howells, jarkko, jmorris, keyrings, LKML,
	linux-security-module, serge, syzkaller-bugs

On Tue, May 04, 2021 at 01:38:20PM +0200, 'Marco Elver' via syzkaller-bugs wrote:
> Hello,
> 
> On Tue, 4 May 2021 at 13:33, syzbot
> <syzbot+e4eb6db47eb0f80308c6@syzkaller.appspotmail.com> wrote:
> > HEAD commit:    5e321ded Merge tag 'for-5.13/parisc' of git://git.kernel.o..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=111cafb9d00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=a4da2ebcb6e8f526
> > dashboard link: https://syzkaller.appspot.com/bug?extid=e4eb6db47eb0f80308c6
> > compiler:       Debian clang version 11.0.1-2
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+e4eb6db47eb0f80308c6@syzkaller.appspotmail.com
> >
> > ==================================================================
> > BUG: KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings
> >
> > write to 0xffff8881065ffc10 of 8 bytes by task 30966 on cpu 1:
> >  assoc_array_apply_edit+0x3e/0x660 lib/assoc_array.c:1357
> >  __key_link+0x8a/0xc0 security/keys/keyring.c:1372
> >  __key_instantiate_and_link+0x15b/0x290 security/keys/key.c:459
> >  key_create_or_update+0x750/0x990 security/keys/key.c:941
> >  __do_sys_add_key security/keys/keyctl.c:134 [inline]
> >  __se_sys_add_key+0x26f/0x300 security/keys/keyctl.c:74
> >  __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
> >  do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
> >  entry_SYSCALL_64_after_hwframe+0x44/0xae
> >
> > read to 0xffff8881065ffc10 of 8 bytes by task 30971 on cpu 0:
> >  search_nested_keyrings+0x34f/0x920 security/keys/keyring.c:751
> >  keyring_search_rcu+0xf4/0x180 security/keys/keyring.c:922
> >  search_cred_keyrings_rcu+0x135/0x240 security/keys/process_keys.c:480
> >  search_process_keyrings_rcu security/keys/process_keys.c:544 [inline]
> >  lookup_user_key+0xab6/0xd40 security/keys/process_keys.c:762
> >  __do_sys_add_key security/keys/keyctl.c:126 [inline]
> >  __se_sys_add_key+0x23a/0x300 security/keys/keyctl.c:74
> >  __x64_sys_add_key+0x63/0x70 security/keys/keyctl.c:74
> >  do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
> >  entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> I found this interesting because the code around
> security/keys/keyring.c:751 is diligent in marking concurrency
> accesses with READ_ONCE(). So on the off-chance there is unexpected
> concurrency here, I thought it'd be worth double-checking as I wasn't
> able to conclude if this is just missing a READ_ONCE().
> 
> Thank you!
> 

It looks more like the problem is missing WRITE_ONCE(), not READ_ONCE().

smp_store_release() would also handle this properly, without the need for the
explicit smp_wmb().

- Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-04 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 11:33 [syzbot] KCSAN: data-race in assoc_array_apply_edit / search_nested_keyrings syzbot
2021-05-04 11:38 ` Marco Elver
2021-05-04 17:01   ` Eric Biggers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.