]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 5 May 2021 20:25:24 +0000 (22:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:59:44 +0000 (10:59 +0200)
[ Upstream commit 5e024c325406470d1165a09c6feaf8ec897936be ]

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")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nfnetlink_osf.c

index 131f9f8c0b0925c94d2f11092a57685e45289437..917f06110c823bdaa6c6420c6ebea04b6f163ed9 100644 (file)
@@ -191,6 +191,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;