Skip to content

Commit e1dbbc5

Browse files
Liping Zhangummakynes
authored andcommitted
netfilter: nf_reject_ipv4: don't send tcp RST if the packet is non-TCP
In iptables, if the user add a rule to send tcp RST and specify the non-TCP protocol, such as UDP, kernel will reject this request. But in nftables, this validity check only occurs in nft tool, i.e. only in userspace. This means that user can add such a rule like follows via nfnetlink: "nft add rule filter forward ip protocol udp reject with tcp reset" This will generate some confusing tcp RST packets. So we should send tcp RST only when it is TCP packet. Signed-off-by: Liping Zhang <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 9847371 commit e1dbbc5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/netfilter/nf_reject_ipv4.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
2424
if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
2525
return NULL;
2626

27+
if (ip_hdr(oldskb)->protocol != IPPROTO_TCP)
28+
return NULL;
29+
2730
oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb),
2831
sizeof(struct tcphdr), _oth);
2932
if (oth == NULL)

0 commit comments

Comments
 (0)