Commit f0cd920
af_key: do not use GFP_KERNEL in atomic contexts
[ Upstream commit 36f41f8 ]
pfkey_broadcast() might be called from non process contexts,
we can not use GFP_KERNEL in these cases [1].
This patch partially reverts commit ba51b6b ("net: Fix RCU splat in
af_key"), only keeping the GFP_ATOMIC forcing under rcu_read_lock()
section.
[1] : syzkaller reported :
in_atomic(): 1, irqs_disabled(): 0, pid: 2932, name: syzkaller183439
3 locks held by syzkaller183439/2932:
#0: (&net->xfrm.xfrm_cfg_mutex){+.+.+.}, at: [<ffffffff83b43888>] pfkey_sendmsg+0x4c8/0x9f0 net/key/af_key.c:3649
hardkernel#1: (&pfk->dump_lock){+.+.+.}, at: [<ffffffff83b467f6>] pfkey_do_dump+0x76/0x3f0 net/key/af_key.c:293
hardkernel#2: (&(&net->xfrm.xfrm_policy_lock)->rlock){+...+.}, at: [<ffffffff83957632>] spin_lock_bh include/linux/spinlock.h:304 [inline]
hardkernel#2: (&(&net->xfrm.xfrm_policy_lock)->rlock){+...+.}, at: [<ffffffff83957632>] xfrm_policy_walk+0x192/0xa30 net/xfrm/xfrm_policy.c:1028
CPU: 0 PID: 2932 Comm: syzkaller183439 Not tainted 4.13.0-rc4+ hardkernel#24
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:16 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:52
___might_sleep+0x2b2/0x470 kernel/sched/core.c:5994
__might_sleep+0x95/0x190 kernel/sched/core.c:5947
slab_pre_alloc_hook mm/slab.h:416 [inline]
slab_alloc mm/slab.c:3383 [inline]
kmem_cache_alloc+0x24b/0x6e0 mm/slab.c:3559
skb_clone+0x1a0/0x400 net/core/skbuff.c:1037
pfkey_broadcast_one+0x4b2/0x6f0 net/key/af_key.c:207
pfkey_broadcast+0x4ba/0x770 net/key/af_key.c:281
dump_sp+0x3d6/0x500 net/key/af_key.c:2685
xfrm_policy_walk+0x2f1/0xa30 net/xfrm/xfrm_policy.c:1042
pfkey_dump_sp+0x42/0x50 net/key/af_key.c:2695
pfkey_do_dump+0xaa/0x3f0 net/key/af_key.c:299
pfkey_spddump+0x1a0/0x210 net/key/af_key.c:2722
pfkey_process+0x606/0x710 net/key/af_key.c:2814
pfkey_sendmsg+0x4d6/0x9f0 net/key/af_key.c:3650
sock_sendmsg_nosec net/socket.c:633 [inline]
sock_sendmsg+0xca/0x110 net/socket.c:643
___sys_sendmsg+0x755/0x890 net/socket.c:2035
__sys_sendmsg+0xe5/0x210 net/socket.c:2069
SYSC_sendmsg net/socket.c:2080 [inline]
SyS_sendmsg+0x2d/0x50 net/socket.c:2076
entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x445d79
RSP: 002b:00007f32447c1dc8 EFLAGS: 00000202 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000445d79
RDX: 0000000000000000 RSI: 000000002023dfc8 RDI: 0000000000000008
RBP: 0000000000000086 R08: 00007f32447c2700 R09: 00007f32447c2700
R10: 00007f32447c2700 R11: 0000000000000202 R12: 0000000000000000
R13: 00007ffe33edec4f R14: 00007f32447c29c0 R15: 0000000000000000
Fixes: ba51b6b ("net: Fix RCU splat in af_key")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: David Ahern <dsa@cumulusnetworks.com>
Acked-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 982ce2a commit f0cd920
1 file changed
Lines changed: 26 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
1396 | 1396 | | |
1397 | 1397 | | |
1398 | 1398 | | |
1399 | | - | |
| 1399 | + | |
1400 | 1400 | | |
1401 | 1401 | | |
1402 | 1402 | | |
| |||
1483 | 1483 | | |
1484 | 1484 | | |
1485 | 1485 | | |
1486 | | - | |
| 1486 | + | |
1487 | 1487 | | |
1488 | 1488 | | |
1489 | 1489 | | |
| |||
1596 | 1596 | | |
1597 | 1597 | | |
1598 | 1598 | | |
1599 | | - | |
| 1599 | + | |
1600 | 1600 | | |
1601 | 1601 | | |
1602 | 1602 | | |
| |||
1701 | 1701 | | |
1702 | 1702 | | |
1703 | 1703 | | |
1704 | | - | |
1705 | | - | |
| 1704 | + | |
| 1705 | + | |
1706 | 1706 | | |
1707 | 1707 | | |
1708 | 1708 | | |
| |||
1720 | 1720 | | |
1721 | 1721 | | |
1722 | 1722 | | |
1723 | | - | |
| 1723 | + | |
| 1724 | + | |
1724 | 1725 | | |
1725 | 1726 | | |
1726 | 1727 | | |
| |||
1741 | 1742 | | |
1742 | 1743 | | |
1743 | 1744 | | |
1744 | | - | |
| 1745 | + | |
1745 | 1746 | | |
1746 | 1747 | | |
1747 | 1748 | | |
| |||
1798 | 1799 | | |
1799 | 1800 | | |
1800 | 1801 | | |
1801 | | - | |
| 1802 | + | |
1802 | 1803 | | |
1803 | 1804 | | |
1804 | 1805 | | |
| |||
1886 | 1887 | | |
1887 | 1888 | | |
1888 | 1889 | | |
1889 | | - | |
| 1890 | + | |
1890 | 1891 | | |
1891 | 1892 | | |
1892 | 1893 | | |
| |||
2219 | 2220 | | |
2220 | 2221 | | |
2221 | 2222 | | |
2222 | | - | |
| 2223 | + | |
2223 | 2224 | | |
2224 | 2225 | | |
2225 | 2226 | | |
| |||
2439 | 2440 | | |
2440 | 2441 | | |
2441 | 2442 | | |
2442 | | - | |
| 2443 | + | |
2443 | 2444 | | |
2444 | 2445 | | |
2445 | 2446 | | |
| |||
2695 | 2696 | | |
2696 | 2697 | | |
2697 | 2698 | | |
2698 | | - | |
| 2699 | + | |
2699 | 2700 | | |
2700 | 2701 | | |
2701 | 2702 | | |
| |||
2752 | 2753 | | |
2753 | 2754 | | |
2754 | 2755 | | |
2755 | | - | |
| 2756 | + | |
2756 | 2757 | | |
2757 | 2758 | | |
2758 | 2759 | | |
| |||
2814 | 2815 | | |
2815 | 2816 | | |
2816 | 2817 | | |
2817 | | - | |
| 2818 | + | |
2818 | 2819 | | |
2819 | 2820 | | |
2820 | 2821 | | |
| |||
3036 | 3037 | | |
3037 | 3038 | | |
3038 | 3039 | | |
3039 | | - | |
| 3040 | + | |
| 3041 | + | |
3040 | 3042 | | |
3041 | 3043 | | |
3042 | 3044 | | |
| |||
3226 | 3228 | | |
3227 | 3229 | | |
3228 | 3230 | | |
3229 | | - | |
| 3231 | + | |
| 3232 | + | |
3230 | 3233 | | |
3231 | 3234 | | |
3232 | 3235 | | |
| |||
3424 | 3427 | | |
3425 | 3428 | | |
3426 | 3429 | | |
3427 | | - | |
| 3430 | + | |
| 3431 | + | |
3428 | 3432 | | |
3429 | 3433 | | |
3430 | 3434 | | |
| |||
3616 | 3620 | | |
3617 | 3621 | | |
3618 | 3622 | | |
3619 | | - | |
| 3623 | + | |
3620 | 3624 | | |
3621 | 3625 | | |
3622 | 3626 | | |
| |||
0 commit comments