]> git.baikalelectronics.ru Git - kernel.git/commit
xen-netfront: do not use ~0U as error return value for xennet_fill_frags()
authorDongli Zhang <dongli.zhang@oracle.com>
Tue, 1 Oct 2019 13:56:41 +0000 (21:56 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Oct 2019 01:49:51 +0000 (21:49 -0400)
commit0a6d72af91c12e97932acfd8d5f67ab352fc606c
treedceb25348ded697e2aa79597d9036670bdb37a97
parent0895639b5f3886c3eef11749b4c6c4bf4465959f
xen-netfront: do not use ~0U as error return value for xennet_fill_frags()

xennet_fill_frags() uses ~0U as return value when the sk_buff is not able
to cache extra fragments. This is incorrect because the return type of
xennet_fill_frags() is RING_IDX and 0xffffffff is an expected value for
ring buffer index.

In the situation when the rsp_cons is approaching 0xffffffff, the return
value of xennet_fill_frags() may become 0xffffffff which xennet_poll() (the
caller) would regard as error. As a result, queue->rx.rsp_cons is set
incorrectly because it is updated only when there is error. If there is no
error, xennet_poll() would be responsible to update queue->rx.rsp_cons.
Finally, queue->rx.rsp_cons would point to the rx ring buffer entries whose
queue->rx_skbs[i] and queue->grant_rx_ref[i] are already cleared to NULL.
This leads to NULL pointer access in the next iteration to process rx ring
buffer entries.

The symptom is similar to the one fixed in
commit 2b19b220720b ("xen-netfront: do not assume sk_buff_head list is
empty in error handling").

This patch changes the return type of xennet_fill_frags() to indicate
whether it is successful or failed. The queue->rx.rsp_cons will be
always updated inside this function.

Fixes: 9599865ca75b ("xen/netfront: don't bug in case of too many frags")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/xen-netfront.c