[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1370307969.24311.196.camel@edumazet-glaptop>
Date: Mon, 03 Jun 2013 18:06:09 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: netdev <netdev@...r.kernel.org>
Subject: Re: [BUG] acess_ok() missing from zerocopy_sg_from_iovec()
On Mon, 2013-06-03 at 17:34 -0700, Eric Dumazet wrote:
> It looks like access_ok(VERIFY_READ, base, len) checks are missing in
> drivers/net/tun.c & drivers/net/macvtap.c before the
> get_user_pages_fast() calls.
>
> Or am I missing something ?
>
Patch would be :
[PATCH] tun/macvtap: use access_ok(VERIFY_READ)
Zero copy is good if only we make all needed security checks.
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 59e9605..d793b7d 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -522,6 +522,8 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
if (i + size > MAX_SKB_FRAGS)
return -EMSGSIZE;
+ if (!access_ok(VERIFY_READ, base, len))
+ return -EFAULT;
num_pages = get_user_pages_fast(base, size, 0, &page[i]);
if (num_pages != size) {
for (i = 0; i < num_pages; i++)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 89776c5..7a7b3b1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1008,6 +1008,8 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
if (i + size > MAX_SKB_FRAGS)
return -EMSGSIZE;
+ if (!access_ok(VERIFY_READ, base, len))
+ return -EFAULT;
num_pages = get_user_pages_fast(base, size, 0, &page[i]);
if (num_pages != size) {
for (i = 0; i < num_pages; i++)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists