]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nfnetlink_osf: fix possible bogus match in nf_osf_find()
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 7 Sep 2022 08:26:18 +0000 (10:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:10:30 +0000 (11:10 +0200)
[ Upstream commit 559c36c5a8d730c49ef805a72b213d3bba155cc8 ]

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: 22c7652cdaa8 ("netfilter: nft_osf: Add version option support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nfnetlink_osf.c

index 79fbf37291f389835691eb08eab55e61ad7a7aa3..51e3953b414c0497f7d99fd4c249e49d5415e065 100644 (file)
@@ -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);