Thread (5 messages) 5 messages, 3 authors, 2023-08-31

Re: [PATCH nf v2] netfilter/osf: avoid OOB read

From: Florian Westphal <fw@strlen.de>
Date: 2023-08-31 13:38:08
Also in: lkml, netfilter-devel

Wander Lairson Costa [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c
index 8f1bfa6ccc2d..13fedf2aaa0f 100644
--- a/net/netfilter/nfnetlink_osf.c
+++ b/net/netfilter/nfnetlink_osf.c
@@ -315,6 +315,9 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,
 
 	f = nla_data(osf_attrs[OSF_ATTR_FINGER]);
 
+	if (f->opt_num > ARRAY_SIZE(f->opt))
+		return -EINVAL;
+
Hmm, this isn't enough; as far as I can see there is no validation
whatsover.

This should also check that all of:

 char    genre[MAXGENRELEN];
 char    version[MAXGENRELEN];
 char    subtype[MAXGENRELEN];

... have a NUL byte.  You could use strnlen() == ARRAY_SIZE() -> EINVAL
for those.

Maybe there is more to be validated, I did not followup with all the
nested structures buried in user_finger struct.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help