Skip to content

Commit a194c98

Browse files
committed
vsock/virtio: use GFP_ATOMIC under RCU read lock
virtio_transport_send_pkt in now called on transport fast path, under RCU read lock. In that case, we have a bug: virtio_add_sgs is called with GFP_KERNEL, and might sleep. Pass the gfp flags as an argument, and use GFP_ATOMIC on the fast path. Link: https://lore.kernel.org/all/hfcr2aget2zojmqpr4uhlzvnep4vgskblx5b6xf2ddosbsrke7@nt34bxgp7j2x Fixes: efcd71a ("vsock/virtio: avoid queuing packets when intermediate queue is empty") Reported-by: Christian Brauner <brauner@kernel.org> Cc: Stefano Garzarella <sgarzare@redhat.com> Cc: Luigi Leonardi <luigi.leonardi@outlook.com> Message-ID: <3fbfb6e871f625f89eb578c7228e127437b1975a.1727876449.git.mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Luigi Leonardi <luigi.leonardi@outlook.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
1 parent b9efbe2 commit a194c98

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

net/vmw_vsock/virtio_transport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static u32 virtio_transport_get_local_cid(void)
9696

9797
/* Caller need to hold vsock->tx_lock on vq */
9898
static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq,
99-
struct virtio_vsock *vsock)
99+
struct virtio_vsock *vsock, gfp_t gfp)
100100
{
101101
int ret, in_sg = 0, out_sg = 0;
102102
struct scatterlist **sgs;
@@ -140,7 +140,7 @@ static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq,
140140
}
141141
}
142142

143-
ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, GFP_KERNEL);
143+
ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, gfp);
144144
/* Usually this means that there is no more space available in
145145
* the vq
146146
*/
@@ -178,7 +178,7 @@ virtio_transport_send_pkt_work(struct work_struct *work)
178178

179179
reply = virtio_vsock_skb_reply(skb);
180180

181-
ret = virtio_transport_send_skb(skb, vq, vsock);
181+
ret = virtio_transport_send_skb(skb, vq, vsock, GFP_KERNEL);
182182
if (ret < 0) {
183183
virtio_vsock_skb_queue_head(&vsock->send_pkt_queue, skb);
184184
break;
@@ -221,7 +221,7 @@ static int virtio_transport_send_skb_fast_path(struct virtio_vsock *vsock, struc
221221
if (unlikely(ret == 0))
222222
return -EBUSY;
223223

224-
ret = virtio_transport_send_skb(skb, vq, vsock);
224+
ret = virtio_transport_send_skb(skb, vq, vsock, GFP_ATOMIC);
225225
if (ret == 0)
226226
virtqueue_kick(vq);
227227

0 commit comments

Comments
 (0)