kernel_samsung_a53x/net/ipv6
Eric Dumazet ec98d49424 netfilter: nf_tables: prevent nf_skb_duplicated corruption
[ Upstream commit 92ceba94de6fb4cee2bf40b485979c342f44a492 ]

syzbot found that nf_dup_ipv4() or nf_dup_ipv6() could write
per-cpu variable nf_skb_duplicated in an unsafe way [1].

Disabling preemption as hinted by the splat is not enough,
we have to disable soft interrupts as well.

[1]
BUG: using __this_cpu_write() in preemptible [00000000] code: syz.4.282/6316
 caller is nf_dup_ipv4+0x651/0x8f0 net/ipv4/netfilter/nf_dup_ipv4.c:87
CPU: 0 UID: 0 PID: 6316 Comm: syz.4.282 Not tainted 6.11.0-rc7-syzkaller-00104-g7052622fccb1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
  __dump_stack lib/dump_stack.c:93 [inline]
  dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
  check_preemption_disabled+0x10e/0x120 lib/smp_processor_id.c:49
  nf_dup_ipv4+0x651/0x8f0 net/ipv4/netfilter/nf_dup_ipv4.c:87
  nft_dup_ipv4_eval+0x1db/0x300 net/ipv4/netfilter/nft_dup_ipv4.c:30
  expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline]
  nft_do_chain+0x4ad/0x1da0 net/netfilter/nf_tables_core.c:288
  nft_do_chain_ipv4+0x202/0x320 net/netfilter/nft_chain_filter.c:23
  nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline]
  nf_hook_slow+0xc3/0x220 net/netfilter/core.c:626
  nf_hook+0x2c4/0x450 include/linux/netfilter.h:269
  NF_HOOK_COND include/linux/netfilter.h:302 [inline]
  ip_output+0x185/0x230 net/ipv4/ip_output.c:433
  ip_local_out net/ipv4/ip_output.c:129 [inline]
  ip_send_skb+0x74/0x100 net/ipv4/ip_output.c:1495
  udp_send_skb+0xacf/0x1650 net/ipv4/udp.c:981
  udp_sendmsg+0x1c21/0x2a60 net/ipv4/udp.c:1269
  sock_sendmsg_nosec net/socket.c:730 [inline]
  __sock_sendmsg+0x1a6/0x270 net/socket.c:745
  ____sys_sendmsg+0x525/0x7d0 net/socket.c:2597
  ___sys_sendmsg net/socket.c:2651 [inline]
  __sys_sendmmsg+0x3b2/0x740 net/socket.c:2737
  __do_sys_sendmmsg net/socket.c:2766 [inline]
  __se_sys_sendmmsg net/socket.c:2763 [inline]
  __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2763
  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
  do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4ce4f7def9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4ce5d4a038 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f4ce5135f80 RCX: 00007f4ce4f7def9
RDX: 0000000000000001 RSI: 0000000020005d40 RDI: 0000000000000006
RBP: 00007f4ce4ff0b76 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4ce5135f80 R15: 00007ffd4cbc6d68
 </TASK>

Fixes: d877f07112f1 ("netfilter: nf_tables: add nft_dup expression")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:21:35 +01:00
..
ila ila: call nf_unregister_net_hooks() sooner 2024-11-23 23:21:00 +01:00
netfilter netfilter: nf_tables: prevent nf_skb_duplicated corruption 2024-11-23 23:21:35 +01:00
addrconf.c ipv6: take care of scope when choosing the src addr 2024-11-23 23:20:12 +01:00
addrconf_core.c ipv6: Ensure natural alignment of const ipv6 loopback and router addresses 2024-11-18 12:13:22 +01:00
addrlabel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
af_inet6.c ipv6: annotate some data-races around sk->sk_prot 2024-11-19 14:19:35 +01:00
ah6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
anycast.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
calipso.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
datagram.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esp6.c net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP 2024-11-23 23:20:06 +01:00
esp6_offload.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exthdrs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exthdrs_core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exthdrs_offload.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fib6_notifier.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fib6_rules.c ipv6: fib6_rules: avoid possible NULL dereference in fib6_rule_action() 2024-11-19 11:32:46 +01:00
fou6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
icmp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet6_connection_sock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet6_hashtables.c net: remove duplicate reuseport_lookup functions 2024-11-19 12:26:55 +01:00
ip6_checksum.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_fib.c ipv6: fix possible race in __fib6_drop_pcpu_from() 2024-11-19 14:19:01 +01:00
ip6_flowlabel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_gre.c erspan: make sure erspan_base_hdr is present in skb->head 2024-11-19 09:22:47 +01:00
ip6_icmp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_input.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_offload.c gro: remove rcu_read_lock/rcu_read_unlock from gro_complete handlers 2024-11-23 23:21:04 +01:00
ip6_offload.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_output.c ipv6: prevent UAF in ip6_send_skb() 2024-11-23 23:20:49 +01:00
ip6_tunnel.c ip6_tunnel: Fix broken GRO 2024-11-23 23:20:48 +01:00
ip6_udp_tunnel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_vti.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6mr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipcomp6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipv6_sockglue.c tcp: Fix data races around icsk->icsk_af_ops. 2024-11-19 14:19:35 +01:00
Kconfig net: ipv6: select DST_CACHE from IPV6_RPL_LWTUNNEL 2024-11-23 23:21:28 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mcast.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mcast_snoop.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mip6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ndisc.c ipv6: fix ndisc_is_useropt() handling for PIO 2024-11-23 23:20:20 +01:00
netfilter.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
output_core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ping.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
proc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
protocol.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
raw.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
reassembly.c net: ipv6: fix wrong start position when receive hop-by-hop fragment 2024-11-19 12:26:56 +01:00
route.c ipv6: prevent possible NULL dereference in rt6_probe() 2024-11-19 14:19:08 +01:00
rpl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rpl_iptunnel.c net: ipv6: rpl_iptunnel: Fix memory leak in rpl_input 2024-11-23 23:21:19 +01:00
seg6.c ipv6: sr: fix invalid unregister error path 2024-11-19 12:26:57 +01:00
seg6_hmac.c ipv6: sr: fix memleak in seg6_hmac_init_algo 2024-11-19 12:27:09 +01:00
seg6_iptunnel.c ipv6: sr: block BH in seg6_output_core() and seg6_input_core() 2024-11-19 14:19:00 +01:00
seg6_local.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
syncookies.c dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses. 2024-11-18 11:43:07 +01:00
sysctl_net_ipv6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tcp_ipv6.c tcp: Fix data races around icsk->icsk_af_ops. 2024-11-19 14:19:35 +01:00
tcpv6_offload.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tunnel6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udp.c udp: Avoid call to compute_score on multiple sites 2024-11-19 12:26:55 +01:00
udp_impl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udp_offload.c gro: remove rcu_read_lock/rcu_read_unlock from gro_receive handlers 2024-11-23 23:21:04 +01:00
udplite.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xfrm6_input.c xfrm: Preserve vlan tags for transport mode software GRO 2024-11-19 11:32:45 +01:00
xfrm6_output.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xfrm6_policy.c xfrm6: check ip6_dst_idev() return value in xfrm6_get_saddr() 2024-11-19 14:19:08 +01:00
xfrm6_protocol.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xfrm6_state.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xfrm6_tunnel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00