Skip to content

Commit a3d0f89

Browse files
walacgregkh
authored andcommitted
netfilter: nfnetlink_osf: avoid OOB read
[ Upstream commit f4f8a78 ] The opt_num field is controlled by user mode and is not currently validated inside the kernel. An attacker can take advantage of this to trigger an OOB read and potentially leak information. BUG: KASAN: slab-out-of-bounds in nf_osf_match_one+0xbed/0xd10 net/netfilter/nfnetlink_osf.c:88 Read of size 2 at addr ffff88804bc64272 by task poc/6431 CPU: 1 PID: 6431 Comm: poc Not tainted 6.0.0-rc4 #1 Call Trace: nf_osf_match_one+0xbed/0xd10 net/netfilter/nfnetlink_osf.c:88 nf_osf_find+0x186/0x2f0 net/netfilter/nfnetlink_osf.c:281 nft_osf_eval+0x37f/0x590 net/netfilter/nft_osf.c:47 expr_call_ops_eval net/netfilter/nf_tables_core.c:214 nft_do_chain+0x2b0/0x1490 net/netfilter/nf_tables_core.c:264 nft_do_chain_ipv4+0x17c/0x1f0 net/netfilter/nft_chain_filter.c:23 [..] Also add validation to genre, subtype and version fields. Fixes: 11eeef4 ("netfilter: passive OS fingerprint xtables match") Reported-by: Lucas Leong <[email protected]> Signed-off-by: Wander Lairson Costa <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent c8f2923 commit a3d0f89

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net/netfilter/nfnetlink_osf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,
315315

316316
f = nla_data(osf_attrs[OSF_ATTR_FINGER]);
317317

318+
if (f->opt_num > ARRAY_SIZE(f->opt))
319+
return -EINVAL;
320+
321+
if (!memchr(f->genre, 0, MAXGENRELEN) ||
322+
!memchr(f->subtype, 0, MAXGENRELEN) ||
323+
!memchr(f->version, 0, MAXGENRELEN))
324+
return -EINVAL;
325+
318326
kf = kmalloc(sizeof(struct nf_osf_finger), GFP_KERNEL);
319327
if (!kf)
320328
return -ENOMEM;

0 commit comments

Comments
 (0)