From: Pablo Neira Ayuso Date: Wed, 7 Sep 2022 08:26:18 +0000 (+0200) Subject: netfilter: nfnetlink_osf: fix possible bogus match in nf_osf_find() X-Git-Tag: baikal/aarch64/sdk6.1~3077^2~54^2 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=cf16113b65bbd6dd2c966039d8e17338196a4a7a;p=kernel.git netfilter: nfnetlink_osf: fix possible bogus match in nf_osf_find() nf_osf_find() incorrectly returns true on mismatch, this leads to copying uninitialized memory area in nft_osf which can be used to leak stale kernel stack data to userspace. Fixes: 32660bfd7e29 ("netfilter: nft_osf: Add version option support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Florian Westphal --- diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c index 0fa2e20304272..ee6840bd59337 100644 --- a/net/netfilter/nfnetlink_osf.c +++ b/net/netfilter/nfnetlink_osf.c @@ -269,6 +269,7 @@ bool nf_osf_find(const struct sk_buff *skb, struct nf_osf_hdr_ctx ctx; const struct tcphdr *tcp; struct tcphdr _tcph; + bool found = false; memset(&ctx, 0, sizeof(ctx)); @@ -283,10 +284,11 @@ bool nf_osf_find(const struct sk_buff *skb, data->genre = f->genre; data->version = f->version; + found = true; break; } - return true; + return found; } EXPORT_SYMBOL_GPL(nf_osf_find);