Patch "vhost_net: revert upend_idx only on retriable error" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vhost_net: revert upend_idx only on retriable error

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vhost_net-revert-upend_idx-only-on-retriable-error.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e6aacda8106357dbdc51994c50a679534ace6585
Author: Andrey Smetanin <asmetanin@xxxxxxxxxxxxxx>
Date:   Mon Apr 24 23:44:11 2023 +0300

    vhost_net: revert upend_idx only on retriable error
    
    [ Upstream commit 1f5d2e3bab16369d5d4b4020a25db4ab1f4f082c ]
    
    Fix possible virtqueue used buffers leak and corresponding stuck
    in case of temporary -EIO from sendmsg() which is produced by
    tun driver while backend device is not up.
    
    In case of no-retriable error and zcopy do not revert upend_idx
    to pass packet data (that is update used_idx in corresponding
    vhost_zerocopy_signal_used()) as if packet data has been
    transferred successfully.
    
    v2: set vq->heads[ubuf->desc].len equal to VHOST_DMA_DONE_LEN
    in case of fake successful transmit.
    
    Signed-off-by: Andrey Smetanin <asmetanin@xxxxxxxxxxxxxx>
    Message-Id: <20230424204411.24888-1-asmetanin@xxxxxxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Andrey Smetanin <asmetanin@xxxxxxxxxxxxxx>
    Acked-by: Jason Wang <jasowang@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4c538b30fd76d..4418192ab8aaa 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -934,13 +934,18 @@ static void handle_tx_zerocopy(struct vhost_net *net, struct socket *sock)
 
 		err = sock->ops->sendmsg(sock, &msg, len);
 		if (unlikely(err < 0)) {
+			bool retry = err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS;
+
 			if (zcopy_used) {
 				if (vq->heads[ubuf->desc].len == VHOST_DMA_IN_PROGRESS)
 					vhost_net_ubuf_put(ubufs);
-				nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
-					% UIO_MAXIOV;
+				if (retry)
+					nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
+						% UIO_MAXIOV;
+				else
+					vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN;
 			}
-			if (err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS) {
+			if (retry) {
 				vhost_discard_vq_desc(vq, 1);
 				vhost_net_enable_vq(net, vq);
 				break;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux