From patchwork Wed Oct 2 13:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13819823 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 842451D07B2 for ; Wed, 2 Oct 2024 13:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727876514; cv=none; b=ZkmAbFZdCkxE7qK60yeAwHtENekw3DjNN/OPDATh0WzKFyneqGr3hPkn346h0uMPe5vgPTthlppvzSmrrvHNZKIqj5upFiygpg/vJX4rjmF2QWc/OtKGrv/A4gvgVu2Q4KASLFpOZ27h3MV+GCt1H/AYp9p//8CA15NENIuV7aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727876514; c=relaxed/simple; bh=5OZTexW1N2cYsiipBckmnTsow8NYUZJeFd0Dc1g6Amk=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=iwzuoOZ9VGre0MTrp6L8D99ncQaMXmhYsR+Jj6OZ9C3+YLrSIkIJbQKkz9j432xG1rR6u7WwM7IuccCvA2J8SBjkUO7agVNwrtDWSQexdDTcsq8H6HqYzn8aw86MCUoRFNNzIl3BVtRYDroRK2pCS0Ix2LR9o/O/s/H2Xhx8M2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YmWb6biI; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YmWb6biI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727876511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=UWQpm0mcyr3iomDUG9qlXZHim5cqJMh8ETQLI86SlcY=; b=YmWb6biINfbxXUdiYW+epZidj5ckg/LJeYCOUreVuLMhUbm8z4/7fH/WOSAJj5FyeK7VBj X4i+uy8iHAKJG7/ZTA0WHSaL+arWshdrGUeA0LF1xtlinZ3qADB/Cuoa924JN8YkZoxczZ YFqtVE6Dc/ph6/E+uYOfrMR8QPMxfVA= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-EPsa89v5Nx-osvOsJp8g0g-1; Wed, 02 Oct 2024 09:41:50 -0400 X-MC-Unique: EPsa89v5Nx-osvOsJp8g0g-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a8d34e41915so428462166b.2 for ; Wed, 02 Oct 2024 06:41:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727876509; x=1728481309; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UWQpm0mcyr3iomDUG9qlXZHim5cqJMh8ETQLI86SlcY=; b=qlRZ2PnPlVot3ZU7UmfaZRW/1O4w8oV7AV1pIBINyNRCMnvve2n32C+6as9Oz93uJX 5rosGK6u0jghq5gr51GUmlf5P3/0SZ+0bMMKOnxRwebewFVSXP7hrkIQZOc4lnD8jlbc SU5pMh+WxGep+/M3yF7tW/bEppf06vxhTOF/HyqqZgVEZnH72tpeUIk63Bm6Kxzum8R8 s82SU3yPJNPhCCelSZktqn6Bf0U+16sI9Tszq9Ro6vWNaerA6jDe6KGyegOKjX8ioFq2 +GU/I47cPFCkkXzQuS8pCkUzt3mk2T4eUt7WKRnLgOF2SjOU7O2gwI6kimIdaT9vPy7t hNLw== X-Forwarded-Encrypted: i=1; AJvYcCVoEdkmevWh4BvhJbyhe/j3ri+EuTTvX357c9xvxqnetsMuDe0keG6nS+9hQJWyH+49/s3Jph8=@vger.kernel.org X-Gm-Message-State: AOJu0YyZmQdh7IzXbS03jyp59A3RdK6COVBK+FqFYtNwo9Karg2ABl1I tr9PxdjOjJjmZ2W0M61OLSGFNHCUrPYo68YtbvHqbmt1iRYldCzjF9iQcNWEPdLOeRw8tKBWhZ/ bUto670l7fi3uLibJbK1nHcpeZByT8Km7p1ZWpg0I4dT/nAN7ZFEPyw== X-Received: by 2002:a17:907:6d1e:b0:a86:8917:fcd6 with SMTP id a640c23a62f3a-a98f838de30mr290163366b.60.1727876508863; Wed, 02 Oct 2024 06:41:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwRbtorkfQnEgLoH126u7jMASiHc1X3K7k60KPoDf4Uvq08XhmDqGPPCIGAMX5Sl2hbplPTQ== X-Received: by 2002:a17:907:6d1e:b0:a86:8917:fcd6 with SMTP id a640c23a62f3a-a98f838de30mr290159466b.60.1727876508383; Wed, 02 Oct 2024 06:41:48 -0700 (PDT) Received: from redhat.com ([2a02:14f:17d:4f25:dd73:e931:ef00:4c45]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29844a1sm885087666b.172.2024.10.02.06.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 06:41:47 -0700 (PDT) Date: Wed, 2 Oct 2024 09:41:42 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Christian Brauner , Stefano Garzarella , Luigi Leonardi , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?b?UMOpcmV6?= , Stefan Hajnoczi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Marco Pinna , virtualization@lists.linux.dev, kvm@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] vsock/virtio: use GFP_ATOMIC under RCU read lock Message-ID: <3fbfb6e871f625f89eb578c7228e127437b1975a.1727876449.git.mst@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Patchwork-Delegate: kuba@kernel.org 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: efcd71af38be ("vsock/virtio: avoid queuing packets when intermediate queue is empty") Reported-by: Christian Brauner Cc: Stefano Garzarella Cc: Luigi Leonardi Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella Reviewed-by: Luigi Leonardi Reviewed-by: Christian Brauner Reviewed-by: Pankaj Gupta --- Lightly tested. Christian, could you pls confirm this fixes the problem for you? Stefano, it's a holiday here - could you pls help test! Thanks! net/vmw_vsock/virtio_transport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index f992f9a216f0..0cd965f24609 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -96,7 +96,7 @@ static u32 virtio_transport_get_local_cid(void) /* Caller need to hold vsock->tx_lock on vq */ static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq, - struct virtio_vsock *vsock) + struct virtio_vsock *vsock, gfp_t gfp) { int ret, in_sg = 0, out_sg = 0; struct scatterlist **sgs; @@ -140,7 +140,7 @@ static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq, } } - ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, GFP_KERNEL); + ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, gfp); /* Usually this means that there is no more space available in * the vq */ @@ -178,7 +178,7 @@ virtio_transport_send_pkt_work(struct work_struct *work) reply = virtio_vsock_skb_reply(skb); - ret = virtio_transport_send_skb(skb, vq, vsock); + ret = virtio_transport_send_skb(skb, vq, vsock, GFP_KERNEL); if (ret < 0) { virtio_vsock_skb_queue_head(&vsock->send_pkt_queue, skb); break; @@ -221,7 +221,7 @@ static int virtio_transport_send_skb_fast_path(struct virtio_vsock *vsock, struc if (unlikely(ret == 0)) return -EBUSY; - ret = virtio_transport_send_skb(skb, vq, vsock); + ret = virtio_transport_send_skb(skb, vq, vsock, GFP_ATOMIC); if (ret == 0) virtqueue_kick(vq);