Skip to content

Commit ebb966d

Browse files
iazzummakynes
authored andcommitted
netfilter: fix regression in looped (broad|multi)cast's MAC handling
In commit 5648b5e ("netfilter: nfnetlink_queue: fix OOB when mac header was cleared"), the test for non-empty MAC header introduced in commit 2c38de4 ("netfilter: fix looped (broad|multi)cast's MAC handling") has been replaced with a test for a set MAC header. This breaks the case when the MAC header has been reset (using skb_reset_mac_header), as is the case with looped-back multicast packets. As a result, the packets ending up in NFQUEUE get a bogus hwaddr interpreted from the first bytes of the IP header. This patch adds a test for a non-empty MAC header in addition to the test for a set MAC header. The same two tests are also implemented in nfnetlink_log.c, where the initial code of commit 2c38de4 ("netfilter: fix looped (broad|multi)cast's MAC handling") has not been touched, but where supposedly the same situation may happen. Fixes: 5648b5e ("netfilter: nfnetlink_queue: fix OOB when mac header was cleared") Signed-off-by: Ignacy Gawędzki <[email protected]> Reviewed-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0f7d9b3 commit ebb966d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/netfilter/nfnetlink_log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ __build_packet_message(struct nfnl_log_net *log,
556556
goto nla_put_failure;
557557

558558
if (indev && skb->dev &&
559-
skb->mac_header != skb->network_header) {
559+
skb_mac_header_was_set(skb) &&
560+
skb_mac_header_len(skb) != 0) {
560561
struct nfulnl_msg_packet_hw phw;
561562
int len;
562563

net/netfilter/nfnetlink_queue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
560560
goto nla_put_failure;
561561

562562
if (indev && entskb->dev &&
563-
skb_mac_header_was_set(entskb)) {
563+
skb_mac_header_was_set(entskb) &&
564+
skb_mac_header_len(entskb) != 0) {
564565
struct nfqnl_msg_packet_hw phw;
565566
int len;
566567

0 commit comments

Comments
 (0)