netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] filter: use unsigned int to silence static checker warning
@ 2011-10-18  7:04 Dan Carpenter
  2011-10-19 23:36 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-10-18  7:04 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Eric Dumazet, Changli Gao, kernel-janitors

This is just a cleanup.

My testing version of Smatch warns about this:
net/core/filter.c +380 check_load_and_stores(6)
	warn: check 'flen' for negative values

flen comes from the user.  We try to clamp the values here between 1
and BPF_MAXINSNS but the clamp doesn't work because it could be
negative.  This is a bug, but it's not exploitable.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 741956f..8eeb205 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -155,7 +155,7 @@ extern unsigned int sk_run_filter(const struct sk_buff *skb,
 				  const struct sock_filter *filter);
 extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
 extern int sk_detach_filter(struct sock *sk);
-extern int sk_chk_filter(struct sock_filter *filter, int flen);
+extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
 
 #ifdef CONFIG_BPF_JIT
 extern void bpf_jit_compile(struct sk_filter *fp);
diff --git a/net/core/filter.c b/net/core/filter.c
index 8fcc2d7..5dea452 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -436,7 +436,7 @@ error:
  *
  * Returns 0 if the rule set is legal or -EINVAL if not.
  */
-int sk_chk_filter(struct sock_filter *filter, int flen)
+int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
 {
 	/*
 	 * Valid instructions are initialized to non-0.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] filter: use unsigned int to silence static checker warning
  2011-10-18  7:04 [patch] filter: use unsigned int to silence static checker warning Dan Carpenter
@ 2011-10-19 23:36 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-10-19 23:36 UTC (permalink / raw)
  To: dan.carpenter; +Cc: netdev, eric.dumazet, xiaosuo, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Tue, 18 Oct 2011 10:04:20 +0300

> This is just a cleanup.
> 
> My testing version of Smatch warns about this:
> net/core/filter.c +380 check_load_and_stores(6)
> 	warn: check 'flen' for negative values
> 
> flen comes from the user.  We try to clamp the values here between 1
> and BPF_MAXINSNS but the clamp doesn't work because it could be
> negative.  This is a bug, but it's not exploitable.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied to net-next, thanks Dan.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-19 23:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-18  7:04 [patch] filter: use unsigned int to silence static checker warning Dan Carpenter
2011-10-19 23:36 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).