mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
netfilter: nf_tables_ipv6: consider network offset in netdev/egress validation
[ Upstream commit 70c261d500951cf3ea0fcf32651aab9a65a91471 ]
From netdev/egress, skb->len can include the ethernet header, therefore,
subtract network offset from skb->len when validating IPv6 packet length.
Fixes: 42df6e1d22 ("netfilter: Introduce egress hook")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9bba5955ee
commit
1e101c2b4e
@@ -31,8 +31,8 @@ static inline int __nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt)
|
|||||||
struct ipv6hdr *ip6h, _ip6h;
|
struct ipv6hdr *ip6h, _ip6h;
|
||||||
unsigned int thoff = 0;
|
unsigned int thoff = 0;
|
||||||
unsigned short frag_off;
|
unsigned short frag_off;
|
||||||
|
u32 pkt_len, skb_len;
|
||||||
int protohdr;
|
int protohdr;
|
||||||
u32 pkt_len;
|
|
||||||
|
|
||||||
ip6h = skb_header_pointer(pkt->skb, skb_network_offset(pkt->skb),
|
ip6h = skb_header_pointer(pkt->skb, skb_network_offset(pkt->skb),
|
||||||
sizeof(*ip6h), &_ip6h);
|
sizeof(*ip6h), &_ip6h);
|
||||||
@@ -43,7 +43,8 @@ static inline int __nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pkt_len = ntohs(ip6h->payload_len);
|
pkt_len = ntohs(ip6h->payload_len);
|
||||||
if (pkt_len + sizeof(*ip6h) > pkt->skb->len)
|
skb_len = pkt->skb->len - skb_network_offset(pkt->skb);
|
||||||
|
if (pkt_len + sizeof(*ip6h) > skb_len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags);
|
protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user