Ubuntu-focal-kernel/net/netfilter
Eric Dumazet 0f5c44a3da netfilter: nfnetlink_queue: acquire rcu_read_lock() in instance_destroy_rcu()
BugLink: https://bugs.launchpad.net/bugs/2071668

[ Upstream commit dc21c6cc3d6986d938efbf95de62473982c98dec ]

syzbot reported that nf_reinject() could be called without rcu_read_lock() :

WARNING: suspicious RCU usage
6.9.0-rc7-syzkaller-02060-g5c1672705a1a #0 Not tainted

net/netfilter/nfnetlink_queue.c:263 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz-executor.4/13427:
  #0: ffffffff8e334f60 (rcu_callback){....}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:329 [inline]
  #0: ffffffff8e334f60 (rcu_callback){....}-{0:0}, at: rcu_do_batch kernel/rcu/tree.c:2190 [inline]
  #0: ffffffff8e334f60 (rcu_callback){....}-{0:0}, at: rcu_core+0xa86/0x1830 kernel/rcu/tree.c:2471
  #1: ffff88801ca92958 (&inst->lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:356 [inline]
  #1: ffff88801ca92958 (&inst->lock){+.-.}-{2:2}, at: nfqnl_flush net/netfilter/nfnetlink_queue.c:405 [inline]
  #1: ffff88801ca92958 (&inst->lock){+.-.}-{2:2}, at: instance_destroy_rcu+0x30/0x220 net/netfilter/nfnetlink_queue.c:172

stack backtrace:
CPU: 0 PID: 13427 Comm: syz-executor.4 Not tainted 6.9.0-rc7-syzkaller-02060-g5c1672705a1a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Call Trace:
 <IRQ>
  __dump_stack lib/dump_stack.c:88 [inline]
  dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
  lockdep_rcu_suspicious+0x221/0x340 kernel/locking/lockdep.c:6712
  nf_reinject net/netfilter/nfnetlink_queue.c:323 [inline]
  nfqnl_reinject+0x6ec/0x1120 net/netfilter/nfnetlink_queue.c:397
  nfqnl_flush net/netfilter/nfnetlink_queue.c:410 [inline]
  instance_destroy_rcu+0x1ae/0x220 net/netfilter/nfnetlink_queue.c:172
  rcu_do_batch kernel/rcu/tree.c:2196 [inline]
  rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2471
  handle_softirqs+0x2d6/0x990 kernel/softirq.c:554
  __do_softirq kernel/softirq.c:588 [inline]
  invoke_softirq kernel/softirq.c:428 [inline]
  __irq_exit_rcu+0xf4/0x1c0 kernel/softirq.c:637
  irq_exit_rcu+0x9/0x30 kernel/softirq.c:649
  instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline]
  sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1043
 </IRQ>
 <TASK>

Fixes: 9872bec773 ("[NETFILTER]: nfnetlink: use RCU for queue instances hash")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Portia Stephens <portia.stephens@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
2024-07-05 10:52:01 +02:00
..
ipset netfilter: ipset: Missing gc cancellations fixed 2024-03-28 15:18:44 +01:00
ipvs ipvs: Fix checksumming on GSO of SCTP packets 2024-06-07 15:01:45 +02:00
Kconfig netfilter: conntrack: NF_CONNTRACK_PROCFS should no longer default to y 2022-10-17 15:02:27 +02:00
Makefile
core.c Remove DECnet support from kernel 2023-09-01 14:48:44 +02:00
nf_conncount.c
nf_conntrack_acct.c
nf_conntrack_amanda.c
nf_conntrack_broadcast.c
nf_conntrack_core.c netfilter: conntrack: fix NULL pointer dereference in nf_confirm_cthelper 2023-09-01 14:48:41 +02:00
nf_conntrack_ecache.c
nf_conntrack_expect.c
nf_conntrack_extend.c
nf_conntrack_ftp.c treewide: Remove uninitialized_var() usage 2023-08-09 12:25:41 +02:00
nf_conntrack_h323_asn1.c netfilter: nf_conntrack_h323: Add protection for bmp length out of range 2024-06-07 15:01:21 +02:00
nf_conntrack_h323_main.c
nf_conntrack_h323_types.c
nf_conntrack_helper.c netfilter: conntrack: Avoid nf_ct_helper_hash uses after free 2023-10-02 12:12:09 +02:00
nf_conntrack_irc.c netfilter: nf_conntrack_irc: Tighten matching on DCC message 2022-11-24 10:28:45 +01:00
nf_conntrack_labels.c
nf_conntrack_netbios_ns.c
nf_conntrack_netlink.c netfilter: add helper function to set up the nfnetlink header and use it 2023-10-02 12:12:09 +02:00
nf_conntrack_pptp.c netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build 2020-06-22 17:23:46 -03:00
nf_conntrack_proto.c netfilter: conntrack: unregister ipv4 sockopts on error unwind 2021-07-15 19:27:01 +02:00
nf_conntrack_proto_dccp.c netfilter: conntrack: dccp: copy entire header to stack buffer, not just basic one 2023-10-02 12:12:03 +02:00
nf_conntrack_proto_generic.c
nf_conntrack_proto_gre.c netfilter: conntrack: Fix gre tunneling over ipv6 2021-04-23 12:01:42 +02:00
nf_conntrack_proto_icmp.c
nf_conntrack_proto_icmpv6.c netfilter: conntrack: set icmpv6 redirects as RELATED 2023-02-01 15:22:34 +01:00
nf_conntrack_proto_sctp.c netfilter: conntrack: check SCTP_CID_SHUTDOWN_ACK for vtag setting in sctp_new 2024-04-26 10:54:06 +02:00
nf_conntrack_proto_tcp.c netfilter: conntrack: do not renew entry stuck in tcp SYN_SENT state 2023-03-21 10:08:59 +01:00
nf_conntrack_proto_udp.c netfilter: conntrack: set on IPS_ASSURED if flows enters internal stream state 2022-01-13 18:42:15 +01:00
nf_conntrack_sane.c
nf_conntrack_seqadj.c
nf_conntrack_sip.c netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value. 2023-10-02 12:12:03 +02:00
nf_conntrack_snmp.c
nf_conntrack_standalone.c netfilter: conntrack: fix possible bug_on with enable_hooks=1 2023-08-09 12:25:27 +02:00
nf_conntrack_tftp.c
nf_conntrack_timeout.c
nf_conntrack_timestamp.c
nf_dup_netdev.c netfilter: nf_fwd_netdev: clear timestamp in forwarding path 2020-11-09 14:49:04 +01:00
nf_flow_table_core.c netfilter: flowtable: fix tcp and udp header checksum update 2021-03-24 11:14:30 +01:00
nf_flow_table_inet.c
nf_flow_table_ip.c netfilter: flowtable: reload ip{v6}h in nf_flow_tuple_ip{v6} 2020-04-03 15:17:23 +02:00
nf_internals.h
nf_log.c netfilter: nf_log: replace BUG_ON by WARN_ON_ONCE when putting logger 2024-03-28 15:18:39 +01:00
nf_log_common.c netfilter: nf_log: missing vlan offload tag and proto 2020-11-09 14:48:52 +01:00
nf_log_netdev.c
nf_nat_amanda.c
nf_nat_core.c netfilter: nf_nat: Fix memleak in nf_nat_init 2021-02-19 16:45:04 +01:00
nf_nat_ftp.c
nf_nat_helper.c
nf_nat_irc.c
nf_nat_masquerade.c netfilter: nf_nat_masquerade: defer conntrack walk to work queue 2021-11-22 14:27:01 +01:00
nf_nat_proto.c netfilter: nf_nat: undo erroneous tcp edemux lookup 2021-04-14 18:31:52 +02:00
nf_nat_redirect.c netfilter: nat: fix ipv6 nat redirect with mapped and scoped addresses 2024-02-02 14:13:06 +01:00
nf_nat_sip.c
nf_nat_tftp.c
nf_queue.c netfilter: nf_queue: fix possible use-after-free 2022-05-20 15:17:24 +02:00
nf_sockopt.c
nf_synproxy_core.c netfilter: synproxy: Fix out of bounds when parsing TCP options 2021-07-15 19:27:36 +02:00
nf_tables_api.c netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get() 2024-07-05 10:51:55 +02:00
nf_tables_core.c netfilter: nf_tables: initialize registers in nft_do_chain() 2022-04-14 11:31:53 +02:00
nf_tables_offload.c netfilter: nf_tables: use net_generic infra for transaction data 2023-10-02 12:12:09 +02:00
nf_tables_set_core.c
nf_tables_trace.c netfilter: add helper function to set up the nfnetlink header and use it 2023-10-02 12:12:09 +02:00
nfnetlink.c netfilter: nfnetlink: skip error delivery on batch in case of ENOMEM 2023-09-01 14:48:45 +02:00
nfnetlink_acct.c netfilter: add helper function to set up the nfnetlink header and use it 2023-10-02 12:12:09 +02:00
nfnetlink_cthelper.c netfilter: add helper function to set up the nfnetlink header and use it 2023-10-02 12:12:09 +02:00
nfnetlink_cttimeout.c netfilter: add helper function to set up the nfnetlink header and use it 2023-10-02 12:12:09 +02:00
nfnetlink_log.c netfilter: nfnetlink_log: silence bogus compiler warning 2024-02-02 14:13:00 +01:00
nfnetlink_osf.c netfilter: nfnetlink_osf: avoid OOB read 2023-10-30 11:42:20 +01:00
nfnetlink_queue.c netfilter: nfnetlink_queue: acquire rcu_read_lock() in instance_destroy_rcu() 2024-07-05 10:52:01 +02:00
nft_bitwise.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_byteorder.c netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() 2024-02-12 09:01:29 +01:00
nft_chain_filter.c netfilter: nf_tables: double hook unregistration in netns path 2024-02-02 14:13:13 +01:00
nft_chain_nat.c netfilter: nft_chain_nat: inet family is missing module ownership 2020-03-18 11:39:22 +01:00
nft_chain_route.c netfilter: use actual socket sk rather than skb sk when routing harder 2020-12-10 12:06:09 +01:00
nft_cmp.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_compat.c netfilter: nf_tables: allow NFPROTO_INET in nft_(match/target)_validate() 2024-04-26 10:54:10 +02:00
nft_connlimit.c
nft_counter.c
nft_ct.c netfilter: nft_ct: fix l3num expectations with inet pseudo family 2024-06-07 15:01:21 +02:00
nft_dup_netdev.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_dynset.c netfilter: nft_dynset: disallow object maps 2023-10-30 11:41:58 +01:00
nft_exthdr.c netfilter: nftables: exthdr: fix 4-byte stack OOB write 2023-10-02 12:12:17 +02:00
nft_fib.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_fib_inet.c
nft_fib_netdev.c
nft_flow_offload.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_fwd_netdev.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_hash.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_immediate.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_limit.c netfilter: nft_limit: avoid possible divide error in nft_limit_init 2021-05-04 16:13:35 +02:00
nft_log.c
nft_lookup.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_masq.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_meta.c netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() 2024-02-12 09:01:29 +01:00
nft_nat.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_numgen.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_objref.c netfilter: nf_tables: report use refcount overflow 2023-10-30 11:41:54 +01:00
nft_osf.c netfilter: nftables: add nft_parse_register_store() and use it 2023-08-09 12:25:32 +02:00
nft_payload.c netfilter: nft_payload: fix wrong mac header matching 2024-01-05 14:29:56 +01:00
nft_queue.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_quota.c
nft_range.c netfilter: nftables: add nft_parse_register_load() and use it 2023-08-09 12:25:32 +02:00
nft_redir.c netfilter: nft_redir: use `struct nf_nat_range2` throughout and deduplicate eval call-backs 2024-02-02 14:13:06 +01:00
nft_reject.c
nft_reject_inet.c
nft_rt.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_set_bitmap.c netfilter: nf_tables: drop map element references from preparation phase 2024-02-02 14:13:12 +01:00
nft_set_hash.c netfilter: nft_set_hash: try later when GC hits EAGAIN on iteration 2024-02-02 14:13:13 +01:00
nft_set_rbtree.c netfilter: nft_set_rbtree: skip end interval element from gc 2024-03-28 15:18:30 +01:00
nft_socket.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_synproxy.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_tproxy.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
nft_tunnel.c netfilter: nf_tables: restrict tunnel object to NFPROTO_NETDEV 2024-07-05 10:51:55 +02:00
nft_xfrm.c netfilter: nf_tables: validate NFPROTO_* family 2024-03-28 15:18:32 +01:00
utils.c netfilter: use actual socket sk rather than skb sk when routing harder 2020-12-10 12:06:09 +01:00
x_tables.c netfilter: x_tables: fix compat match/target pad out-of-bound write 2021-05-04 16:11:22 +02:00
xt_AUDIT.c
xt_CHECKSUM.c
xt_CLASSIFY.c
xt_CONNSECMARK.c
xt_CT.c
xt_DSCP.c
xt_HL.c
xt_HMARK.c
xt_IDLETIMER.c
xt_LED.c
xt_LOG.c
xt_MASQUERADE.c
xt_NETMAP.c
xt_NFLOG.c
xt_NFQUEUE.c
xt_RATEEST.c netfilter: xt_RATEEST: reject non-null terminated string from userspace 2021-02-19 16:44:06 +01:00
xt_REDIRECT.c netfilter: nft_redir: use `struct nf_nat_range2` throughout and deduplicate eval call-backs 2024-02-02 14:13:06 +01:00
xt_SECMARK.c netfilter: xt_SECMARK: add new revision to fix structure layout 2021-06-18 15:02:14 +02:00
xt_TCPMSS.c
xt_TCPOPTSTRIP.c
xt_TEE.c
xt_TPROXY.c
xt_TRACE.c
xt_addrtype.c
xt_bpf.c
xt_cgroup.c
xt_cluster.c
xt_comment.c
xt_connbytes.c
xt_connlabel.c
xt_connlimit.c
xt_connmark.c
xt_conntrack.c
xt_cpu.c
xt_dccp.c
xt_devgroup.c
xt_dscp.c
xt_ecn.c
xt_esp.c
xt_hashlimit.c netfilter: xt_hashlimit: unregister proc file before releasing mutex 2020-03-23 11:24:25 +01:00
xt_helper.c
xt_hl.c
xt_ipcomp.c
xt_iprange.c
xt_ipvs.c
xt_l2tp.c
xt_length.c
xt_limit.c
xt_mac.c
xt_mark.c
xt_multiport.c
xt_nat.c
xt_nfacct.c
xt_osf.c netfilter: nfnetlink_osf: fix module autoload 2023-10-02 12:11:58 +02:00
xt_owner.c netfilter: xt_owner: Fix for unsafe access of sk->sk_socket 2024-02-02 14:13:18 +01:00
xt_physdev.c
xt_pkttype.c
xt_policy.c
xt_quota.c
xt_rateest.c
xt_realm.c
xt_recent.c netfilter: xt_recent: fix (increase) ipv6 literal buffer length 2024-02-02 14:13:06 +01:00
xt_repldata.h
xt_sctp.c netfilter: xt_sctp: validate the flag_info count 2023-10-30 11:42:04 +01:00
xt_set.c
xt_socket.c
xt_state.c
xt_statistic.c
xt_string.c
xt_tcpmss.c
xt_tcpudp.c
xt_time.c
xt_u32.c netfilter: xt_u32: validate user space input 2023-10-30 11:42:04 +01:00