Skip to content

Commit

Permalink
netfilter: nfnetlink_osf: fix possible bogus match in nf_osf_find()
Browse files Browse the repository at this point in the history
[ Upstream commit 559c36c ]

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: 22c7652 ("netfilter: nft_osf: Add version option support")
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
ummakynes authored and gregkh committed Sep 28, 2022
1 parent 510ea9e commit 633c81c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/netfilter/nfnetlink_osf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);

Expand Down

0 comments on commit 633c81c

Please sign in to comment.