8000 macvtap: fix recovery from gup errors · codeguru85/linux@4c7ab05 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c7ab05

Browse files
mstsirkindavem330
authored andcommitted
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: Brad Hubbard <bhubbard@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7e24bfb commit 4c7ab05

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/macvtap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
524524
return -EMSGSIZE;
525525
num_pages = get_user_pages_fast(base, size, 0, &page[i]);
526526
if (num_pages != size) {
527-
for (i = 0; i < num_pages; i++)
528-
put_page(page[i]);
527+
int j;
528+
529+
for (j = 0; j < num_pages; j++)
530+
put_page(page[i + j]);
529531
return -EFAULT;
530532
}
531533
truesize = size * PAGE_SIZE;

0 commit comments

Comments
 (0)
0