Blob Blame History Raw
From 559c36c5a8d730c49ef805a72b213d3bba155cc8 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Wed, 7 Sep 2022 10:26:18 +0200
Subject: [PATCH] netfilter: nfnetlink_osf: fix possible bogus match in
 nf_osf_find()
References: bsc#1204614
Git-commit: 559c36c5a8d730c49ef805a72b213d3bba155cc8
Patch-mainline: v6.0-rc7

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: Oscar Salvador <osalvador@suse.de>
---
 net/netfilter/nfnetlink_osf.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/net/netfilter/nfnetlink_osf.c
+++ b/net/netfilter/nfnetlink_osf.c
@@ -265,6 +265,7 @@ bool nf_osf_find(const struct sk_buff *s
 	const struct nf_osf_finger *kf;
 	struct nf_osf_hdr_ctx ctx;
 	const struct tcphdr *tcp;
+	bool found = false;
 
 	memset(&ctx, 0, sizeof(ctx));
 
@@ -279,10 +280,11 @@ bool nf_osf_find(const struct sk_buff *s
 
 		data->genre = f->genre;
 		data->version = f->version;
+		found = true;
 		break;
 	}
 
-	return true;
+	return found;
 }
 EXPORT_SYMBOL_GPL(nf_osf_find);