]> git.baikalelectronics.ru Git - kernel.git/commit
xen/netback: fix rx queue stall detection
authorJuergen Gross <jgross@suse.com>
Thu, 16 Dec 2021 07:25:12 +0000 (08:25 +0100)
committerJuergen Gross <jgross@suse.com>
Thu, 16 Dec 2021 07:42:56 +0000 (08:42 +0100)
commita9b1f10d3714a6a4d179480cad1084a257038e3b
treef9a0bc2f1b47cd0c333e5bae0b644213ea2db65b
parentc4b56b468d1ed2c79285c539e745a5a5b805ab90
xen/netback: fix rx queue stall detection

Commit 175d87c3d0a976f ("xen-netback: require fewer guest Rx slots when
not using GSO") introduced a security problem in netback, as an
interface would only be regarded to be stalled if no slot is available
in the rx queue ring page. In case the SKB at the head of the queued
requests will need more than one rx slot and only one slot is free the
stall detection logic will never trigger, as the test for that is only
looking for at least one slot to be free.

Fix that by testing for the needed number of slots instead of only one
slot being available.

In order to not have to take the rx queue lock that often, store the
number of needed slots in the queue data. As all SKB dequeue operations
happen in the rx queue kernel thread this is safe, as long as the
number of needed slots is accessed via READ/WRITE_ONCE() only and
updates are always done with the rx queue lock held.

Add a small helper for obtaining the number of free slots.

This is part of XSA-392

Fixes: 175d87c3d0a976f ("xen-netback: require fewer guest Rx slots when not using GSO")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
drivers/net/xen-netback/common.h
drivers/net/xen-netback/rx.c