netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sock filter: fix copy of filter from userspace
@ 2012-10-13 18:40 Stephen Hemminger
  2012-10-13 19:19 ` Jiri Pirko
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2012-10-13 18:40 UTC (permalink / raw)
  To: Jiri Pirko, David S. Miller; +Cc: netdev

The sk_unattached_filter_create function is passed a socket
filter structure and the copies the contents of the filter from
userspace. Sparse detected that this code was incorrectly using
memcpy when it needed to use copy_from_user instead.

The only use of sk_unattached_filter_create at present is in
the team driver.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/net/core/filter.c	2012-10-09 10:35:03.183141638 -0700
+++ b/net/core/filter.c	2012-10-13 11:33:05.955531440 -0700
@@ -666,7 +666,9 @@ int sk_unattached_filter_create(struct s
 	fp = kmalloc(fsize + sizeof(*fp), GFP_KERNEL);
 	if (!fp)
 		return -ENOMEM;
-	memcpy(fp->insns, fprog->filter, fsize);
+
+	if (copy_from_user(fp->insns, fprog->filter, fsize))
+		return -EFAULT;
 
 	atomic_set(&fp->refcnt, 1);
 	fp->len = fprog->len;

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

end of thread, other threads:[~2012-10-15 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-13 18:40 [PATCH] sock filter: fix copy of filter from userspace Stephen Hemminger
2012-10-13 19:19 ` Jiri Pirko
2012-10-15 15:57   ` Stephen Hemminger

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).