| From b716ef2d9113847c893a292d9624a53b8b0d472f Mon Sep 17 00:00:00 2001 |
| From: "Michael S. Tsirkin" <mst@redhat.com> |
| Date: Sun, 23 Jun 2013 17:26:58 +0300 |
| Subject: macvtap: fix recovery from gup errors |
| |
| From: "Michael S. Tsirkin" <mst@redhat.com> |
| |
| [ Upstream commit 4c7ab054ab4f5d63625508ed6f8a607184cae7c2 ] |
| |
| 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> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/net/macvtap.c | 6 ++++-- |
| 1 file changed, 4 insertions(+), 2 deletions(-) |
| |
| --- a/drivers/net/macvtap.c |
| +++ b/drivers/net/macvtap.c |
| @@ -534,8 +534,10 @@ static int zerocopy_sg_from_iovec(struct |
| return -EMSGSIZE; |
| num_pages = get_user_pages_fast(base, size, 0, &page[i]); |
| if (num_pages != size) { |
| - for (i = 0; i < num_pages; i++) |
| - put_page(page[i]); |
| + int j; |
| + |
| + for (j = 0; j < num_pages; j++) |
| + put_page(page[i + j]); |
| } |
| truesize = size * PAGE_SIZE; |
| skb->data_len += len; |