Skip to contentSkip to conversation

netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check

PATCH New Pablo Neira Ayuso 1 participant 1 message May 5, 2021

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check

Do not assume that the tcph->doff field is correct when parsing for TCP options, skb_header_pointer() might fail to fetch these bits.

Fixes 11eeef41d5f6 ("netfilter: passive OS fingerprint xtables match")
---
 net/netfilter/nfnetlink_osf.c | 2 ++
 1 file changed, 2 insertions(+)
net/netfilter/nfnetlink_osf.c +2 -0
index e8f8875c6884..0fa2e2030427 100644
@@ -186,6 +186,8 @@ static const struct tcphdr *nf_osf_hdr_ctx_init(struct nf_osf_hdr_ctx *ctx,
 
 		ctx->optp = skb_header_pointer(skb, ip_hdrlen(skb) +
 				sizeof(struct tcphdr), ctx->optsize, opts);
+		if (!ctx->optp)
+			return NULL;
 	}
 
 	return tcp;
Signature · 1 line
2.30.2