1
0
Fork 0
alistair23-linux/include/linux/netfilter
Subash Abhinov Kasiviswanathan b17244cebb netfilter: x_tables: Switch synchronization to RCU
[ Upstream commit cc00bcaa58 ]

When running concurrent iptables rules replacement with data, the per CPU
sequence count is checked after the assignment of the new information.
The sequence count is used to synchronize with the packet path without the
use of any explicit locking. If there are any packets in the packet path using
the table information, the sequence count is incremented to an odd value and
is incremented to an even after the packet process completion.

The new table value assignment is followed by a write memory barrier so every
CPU should see the latest value. If the packet path has started with the old
table information, the sequence counter will be odd and the iptables
replacement will wait till the sequence count is even prior to freeing the
old table info.

However, this assumes that the new table information assignment and the memory
barrier is actually executed prior to the counter check in the replacement
thread. If CPU decides to execute the assignment later as there is no user of
the table information prior to the sequence check, the packet path in another
CPU may use the old table information. The replacement thread would then free
the table information under it leading to a use after free in the packet
processing context-

Unable to handle kernel NULL pointer dereference at virtual
address 000000000000008e
pc : ip6t_do_table+0x5d0/0x89c
lr : ip6t_do_table+0x5b8/0x89c
ip6t_do_table+0x5d0/0x89c
ip6table_filter_hook+0x24/0x30
nf_hook_slow+0x84/0x120
ip6_input+0x74/0xe0
ip6_rcv_finish+0x7c/0x128
ipv6_rcv+0xac/0xe4
__netif_receive_skb+0x84/0x17c
process_backlog+0x15c/0x1b8
napi_poll+0x88/0x284
net_rx_action+0xbc/0x23c
__do_softirq+0x20c/0x48c

This could be fixed by forcing instruction order after the new table
information assignment or by switching to RCU for the synchronization.

Fixes: 80055dab5d ("netfilter: x_tables: make xt_replace_table wait until old rules are not used anymore")
Reported-by: Sean Tranchetti <stranche@codeaurora.org>
Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-12-30 11:50:54 +01:00
..
ipset netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports 2020-03-05 16:43:44 +01:00
nf_conntrack_amanda.h netfilter: add missing includes to a number of header-files. 2019-08-13 12:14:39 +02:00
nf_conntrack_common.h netfilter: conntrack: move code to linux/nf_conntrack_common.h. 2019-09-13 12:47:11 +02:00
nf_conntrack_dccp.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_ftp.h netfilter: add missing includes to a number of header-files. 2019-08-13 12:14:39 +02:00
nf_conntrack_h323.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_h323_asn1.h netfilter: add missing includes to a number of header-files. 2019-08-13 12:14:39 +02:00
nf_conntrack_h323_types.h netfilter: add include guard to nf_conntrack_h323_types.h 2019-08-19 13:59:57 +02:00
nf_conntrack_irc.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_pptp.h netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build 2020-06-03 08:21:39 +02:00
nf_conntrack_proto_gre.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_sane.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_sctp.h netfilter: conntrack: allow sctp hearbeat after connection re-use 2020-09-17 13:47:45 +02:00
nf_conntrack_sip.h netfilter: remove "#ifdef __KERNEL__" guards from some headers. 2019-08-13 12:15:28 +02:00
nf_conntrack_snmp.h netfilter: add missing includes to a number of header-files. 2019-08-13 12:14:39 +02:00
nf_conntrack_tcp.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nf_conntrack_tftp.h netfilter: add missing includes to a number of header-files. 2019-08-13 12:14:39 +02:00
nf_conntrack_zones_common.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfnetlink.h netfilter: nf_tables: missing validation from the abort path 2020-11-18 19:20:17 +01:00
nfnetlink_acct.h netfilter: nfnetlink_acct: remove useless parameter 2018-03-05 23:15:43 +01:00
nfnetlink_osf.h netfilter: nft_osf: Add version option support 2019-04-08 23:27:12 +02:00
x_tables.h netfilter: x_tables: Switch synchronization to RCU 2020-12-30 11:50:54 +01:00