From nobody Tue Dec 2 02:52:43 2025 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E651B326922 for ; Tue, 18 Nov 2025 02:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763431239; cv=none; b=GkDuTqxNyybQ4pgGIHQklI3WCSRCLKo5tt8sr8GQeFAW+flt0CFx4glmAQxhGxljhIStknYqL2upbETgSO2JUEmfTq1IF7Ay4n6zZX53ctdDBLmSM1dh5hzA6DPbjP65ivjKkMtgHmiOGmhVzKL1DUl30xW8taspF2gHnPLGPg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763431239; c=relaxed/simple; bh=uOW23oUD888uPdfswggyv7h4B3njoPEFvMHwF6iAAmo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FGiWzrjUEUw7V0/cdwZdhI9eEHyIcYdqYut/z4AhzX/Jh+hI2UF7VnYVqHbKEJeyTZSS+8EDaLlUEHNmEnyidD5I2pJmMs+wKs8QdsWr4KMy0vxvw3nhRiOyF3ANgLlWIHKGUOmh6oXQ3GE+3UKPd7cufVZtefwfjslIG1r5iTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YvGyitWm; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YvGyitWm" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-34372216275so5389385a91.2 for ; Mon, 17 Nov 2025 18:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763431235; x=1764036035; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mhLUPvGLtyJcQ25GpVmgIbln5JiS+qaXLLDnH3A077U=; b=YvGyitWm5HtOLWDkacHtkEzVwBo6bLmw5bjRI5KahdU6vYZpie2LhsE7QRjfFmqpvV S1sg5FIzB3hunXYdxg+hCYhSEAgUXsIPtpwJXINmLFPJAPlzURuGMtG+a0TwuueynZtg NgPJIs2To4xQ0lc2YFdM5/Q8mC4H3KHf0wcgy5MSkk6oC9EynLVuPp38TwDBx2i1J4ZS 30Xj+vjwRrDyfDdXluTBYdaZFK6rukvRYbcBdh6aIkVPcAYWOYKrHvrD6XC34IACdZ9d Q0kQllovX2O+ohhUwjZj+ldw2jfhzUrMKxBGUwYVoG4jQIeihUvdopAKjJsrsz59WBi7 izwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763431235; x=1764036035; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mhLUPvGLtyJcQ25GpVmgIbln5JiS+qaXLLDnH3A077U=; b=YhrWwZCJUk7cF7dPyFHqrxjiDu2Ltn2USP36sqvHjPyYQBhD0nlUxfyacrSDZmlxBJ F1u49awUQGbRhLvkNb3HRhFUfFzpx+O283wxwm92VDjNQ4pcr0GgjuBBi5TOjYPiJRKr zVTIQ4BACorNBvAvFnL3CTqTiUBKadjOLWeOPVwL8poFipcQZRZS9vq4SAA9/0rYBqmR nBrHXwamV+sPQSPTS4RQCHs1TWeqBZTIsR+I35iICvSKw8imDN4hNqsQG/JochkAnaJi 2ky8gMns3HK+U8I0WACrbiVuFAaR4mVRhwYbBm9J2U3KXBFWJ5SmmQ5p0bS7bXacNNDX wdPQ== X-Gm-Message-State: AOJu0YzJG27Fc69Gr4Qu8K0FCyrcYADCRyK882FDSoxubynlwspp2TYt 1qyqdC5BI4584LoMXDN58raLjR0hkw4S4eAXMdgXMxJ7E52gLeQqgXoG X-Gm-Gg: ASbGncs9LESW+EeWrJ481iaUwt5yBijomURXWkSXji/XRwNVN4GU6yZmk/O56/ofixZ I8hW3XcaOoWqwTMauYoZOH8sh5oDEr8zwElHs6UMHXBHoQCsooZA5ibUm2e9WsvgVmZzdOxyxNR 59jQ2VIsP2pHc2GoVQhpDWvQqi5q425Az/a7fkgQF3rOCEIs0diQ+On+urb8uUmwQN7SBCc8p+z nN+3l5tMkAfjnx6RJ4T6vOyP1rUWrGYuF0Ydsv51s+qbFBbSTgqlP+e9KOJ2Evg4FAXWrekPMFI clHrf7CkztcKaMrlxnnF5YUWCF+WMJiSUj+EwKuUjSlKbK+5mZwHD1X+gmOrKqQduWbIARu6+pc EQBX73s0V9IpAT6r/GU7LGfCv43Eh3DvSE7a+qTrD3jC5QSs8S9PSKxzItGgsckh65Ee58UGaLU rJ+mf+s3ACu+IYHPWVi1GEZJjRiXItig== X-Google-Smtp-Source: AGHT+IHLky6hFd2s4o/LoM/Lst3F8klAMSAkgSuH9Ql0+UHi5g9wFfThPyUZnxKhdSO4j0xQMtxpww== X-Received: by 2002:a17:90b:2d05:b0:32e:a10b:ce33 with SMTP id 98e67ed59e1d1-343fa6326e0mr15954772a91.21.1763431234714; Mon, 17 Nov 2025 18:00:34 -0800 (PST) Received: from localhost ([2a03:2880:2ff:9::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-343e06fe521sm20082011a91.1.2025.11.17.18.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 18:00:34 -0800 (PST) From: Bobby Eshleman Date: Mon, 17 Nov 2025 18:00:28 -0800 Subject: [PATCH net-next v10 05/11] virtio: set skb owner of virtio_transport_reset_no_sock() reply Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251117-vsock-vmtest-v10-5-df08f165bf3e@meta.com> References: <20251117-vsock-vmtest-v10-0-df08f165bf3e@meta.com> In-Reply-To: <20251117-vsock-vmtest-v10-0-df08f165bf3e@meta.com> To: Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , =?utf-8?q?Eugenio_P=C3=A9rez?= , Xuan Zhuo , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , Broadcom internal kernel review list , Shuah Khan Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kselftest@vger.kernel.org, Sargun Dhillon , Bobby Eshleman , berrange@redhat.com, Bobby Eshleman X-Mailer: b4 0.14.3 From: Bobby Eshleman Associate reply packets with the sending socket. When vsock must reply with an RST packet and there exists a sending socket (e.g., for loopback), setting the skb owner to the socket correctly handles reference counting between the skb and sk (i.e., the sk stays alive until the skb is freed). This allows the net namespace to be used for socket lookups for the duration of the reply skb's lifetime, preventing race conditions between the namespace lifecycle and vsock socket search using the namespace pointer. Signed-off-by: Bobby Eshleman --- Changes in v10: - break this out into its own patch for easy revert (Stefano) --- net/vmw_vsock/virtio_transport_common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio= _transport_common.c index 168e7517a3f0..5bb498caa19e 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1181,6 +1181,12 @@ static int virtio_transport_reset_no_sock(const stru= ct virtio_transport *t, .type =3D le16_to_cpu(hdr->type), .reply =3D true, =20 + /* Set sk owner to socket we are replying to (may be NULL for + * non-loopback). This keeps a reference to the sock and + * sock_net(sk) until the reply skb is freed. + */ + .vsk =3D vsock_sk(skb->sk), + /* net or net_mode are not defined here because we pass * net and net_mode directly to t->send_pkt(), instead of * relying on virtio_transport_send_pkt_info() to pass them to --=20 2.47.3