提交 4c7ab054 编写于 作者: M Michael S. Tsirkin 提交者: David S. Miller

macvtap: fix recovery from gup errors

get user pages might fail partially in macvtap zero copy
mode. To recover we need to put all pages that we got,
but code used a wrong index resulting in double-free
errors.
Reported-by: NBrad Hubbard <bhubbard@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7e24bfbe
...@@ -524,8 +524,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from, ...@@ -524,8 +524,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
return -EMSGSIZE; return -EMSGSIZE;
num_pages = get_user_pages_fast(base, size, 0, &page[i]); num_pages = get_user_pages_fast(base, size, 0, &page[i]);
if (num_pages != size) { if (num_pages != size) {
for (i = 0; i < num_pages; i++) int j;
put_page(page[i]);
for (j = 0; j < num_pages; j++)
put_page(page[i + j]);
return -EFAULT; return -EFAULT;
} }
truesize = size * PAGE_SIZE; truesize = size * PAGE_SIZE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册