Eric Dumazet
ad39d09190
kcm: avoid potential race in kcm_tx_work
...
commit ec7eede369fe5b0d085ac51fdbb95184f87bfc6c upstream.
syzbot found that kcm_tx_work() could crash [1] in:
/* Primarily for SOCK_SEQPACKET sockets */
if (likely(sk->sk_socket) &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
<<*>> clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
sk->sk_write_space(sk);
}
I think the reason is that another thread might concurrently
run in kcm_release() and call sock_orphan(sk) while sk is not
locked. kcm_tx_work() find sk->sk_socket being NULL.
[1]
BUG: KASAN: null-ptr-deref in instrument_atomic_write include/linux/instrumented.h:86 [inline]
BUG: KASAN: null-ptr-deref in clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline]
BUG: KASAN: null-ptr-deref in kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742
Write of size 8 at addr 0000000000000008 by task kworker/u4:3/53
CPU: 0 PID: 53 Comm: kworker/u4:3 Not tainted 5.19.0-rc3-next-20220621-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: kkcmd kcm_tx_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
instrument_atomic_write include/linux/instrumented.h:86 [inline]
clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline]
kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742
process_one_work+0x996/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
</TASK>
Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <tom@herbertland.com>
Link: https://lore.kernel.org/r/20221012133412.519394-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-25 17:42:21 +01:00
..
2021-09-15 09:47:31 +02:00
2022-08-25 11:18:17 +02:00
2021-07-31 08:19:38 +02:00
2021-12-01 09:23:34 +01:00
2021-04-07 14:47:41 +02:00
2022-10-29 10:20:35 +02:00
2022-04-20 09:19:40 +02:00
2022-05-18 09:47:24 +02:00
2022-11-25 17:42:13 +01:00
2022-09-05 10:27:46 +02:00
2021-07-14 16:53:33 +02:00
2022-09-28 11:04:07 +02:00
2022-11-25 17:42:15 +01:00
2022-11-25 17:42:10 +01:00
2020-11-05 11:43:34 +01:00
2022-11-25 17:42:04 +01:00
2022-03-08 19:07:51 +01:00
2022-08-25 11:17:49 +02:00
2021-07-28 13:30:56 +02:00
2020-04-23 10:36:45 +02:00
2022-03-23 09:12:07 +01:00
2020-01-09 10:20:06 +01:00
2021-05-14 09:44:10 +02:00
2022-11-03 23:56:54 +09:00
2022-11-25 17:42:21 +01:00
2022-11-25 17:42:05 +01:00
2021-03-07 12:20:42 +01:00
2022-11-25 17:42:21 +01:00
2022-09-05 10:27:40 +02:00
2022-06-22 14:11:21 +02:00
2022-04-27 13:50:47 +02:00
2021-02-10 09:25:28 +01:00
2022-03-28 08:46:48 +02:00
2022-10-26 13:22:22 +02:00
2022-11-03 23:56:53 +09:00
2021-12-08 09:01:12 +01:00
2022-01-05 12:37:45 +01:00
2022-11-10 17:57:51 +01:00
2022-04-15 14:18:35 +02:00
2022-05-18 09:47:25 +02:00
2021-07-28 13:30:56 +02:00
2022-06-14 18:11:33 +02:00
2022-11-03 23:56:56 +09:00
2022-09-05 10:27:48 +02:00
2022-01-11 15:23:33 +01:00
2019-12-04 22:30:54 +01:00
2021-09-03 10:08:12 +02:00
2022-10-26 13:22:26 +02:00
2020-11-24 13:29:05 +01:00
2022-11-10 17:57:51 +01:00
2022-09-28 11:03:58 +02:00
2022-11-10 17:57:50 +01:00
2022-10-26 13:22:26 +02:00
2022-09-15 12:04:50 +02:00
2021-11-17 09:48:48 +01:00
2022-09-05 10:27:40 +02:00
2021-10-27 09:54:24 +02:00
2022-11-25 17:42:05 +01:00
2022-07-29 17:14:12 +02:00
2022-10-26 13:22:59 +02:00
2022-10-26 13:22:25 +02:00
2022-11-25 17:42:04 +01:00
2022-11-25 17:42:16 +01:00
2021-12-22 09:29:40 +01:00
2022-10-26 13:22:49 +02:00
2021-06-18 09:59:00 +02:00
2020-04-01 11:02:18 +02:00
2022-09-05 10:27:42 +02:00