acrn-kernel/net/bridge
Florian Westphal 7997eff828 netfilter: ebtables: reject blobs that don't provide all entry points
Harshit Mogalapalli says:
 In ebt_do_table() function dereferencing 'private->hook_entry[hook]'
 can lead to NULL pointer dereference. [..] Kernel panic:

general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
[..]
RIP: 0010:ebt_do_table+0x1dc/0x1ce0
Code: 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 5c 16 00 00 48 b8 00 00 00 00 00 fc ff df 49 8b 6c df 08 48 8d 7d 2c 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 88
[..]
Call Trace:
 nf_hook_slow+0xb1/0x170
 __br_forward+0x289/0x730
 maybe_deliver+0x24b/0x380
 br_flood+0xc6/0x390
 br_dev_xmit+0xa2e/0x12c0

For some reason ebtables rejects blobs that provide entry points that are
not supported by the table, but what it should instead reject is the
opposite: blobs that DO NOT provide an entry point supported by the table.

t->valid_hooks is the bitmask of hooks (input, forward ...) that will see
packets.  Providing an entry point that is not support is harmless
(never called/used), but the inverse isn't: it results in a crash
because the ebtables traverser doesn't expect a NULL blob for a location
its receiving packets for.

Instead of fixing all the individual checks, do what iptables is doing and
reject all blobs that differ from the expected hooks.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
2022-08-23 18:23:15 +02:00
..
netfilter netfilter: ebtables: reject blobs that don't provide all entry points 2022-08-23 18:23:15 +02:00
Kconfig
Makefile
br.c
br_arp_nd_proxy.c
br_cfm.c
br_cfm_netlink.c
br_device.c net: bridge: fdb: add ndo_fdb_del_bulk 2022-04-13 12:46:26 +01:00
br_fdb.c rtnetlink: add extack support in fdb del handlers 2022-05-09 11:58:20 +01:00
br_forward.c
br_if.c net: rename reference+tracking helpers 2022-06-09 21:52:55 -07:00
br_input.c net: bridge: Clear offload_fwd_mark when passing frame up bridge interface. 2022-05-19 09:20:44 +02:00
br_ioctl.c
br_mdb.c net: bridge: allow add/remove permanent mdb entries on disabled ports 2022-06-15 09:35:21 +01:00
br_mrp.c
br_mrp_netlink.c
br_mrp_switchdev.c
br_mst.c
br_multicast.c
br_multicast_eht.c
br_netfilter_hooks.c netfilter: br_netfilter: do not skip all hooks with 0 priority 2022-06-27 19:23:27 +02:00
br_netfilter_ipv6.c
br_netlink.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-28 18:21:16 -07:00
br_netlink_tunnel.c
br_nf_core.c
br_private.h rtnetlink: add extack support in fdb del handlers 2022-05-09 11:58:20 +01:00
br_private_cfm.h
br_private_mcast_eht.h
br_private_mrp.h
br_private_stp.h
br_private_tunnel.h
br_stp.c
br_stp_bpdu.c
br_stp_if.c
br_stp_timer.c
br_switchdev.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-04-28 13:02:01 -07:00
br_sysfs_br.c net: bridge: fdb: add support for fine-grained flushing 2022-04-13 12:46:26 +01:00
br_sysfs_if.c
br_vlan.c net: adopt u64_stats_t in struct pcpu_sw_netstats 2022-06-09 21:53:11 -07:00
br_vlan_options.c
br_vlan_tunnel.c