From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 73366189BB5; Thu, 15 Aug 2024 13:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729654; cv=none; b=mFKh3gwgjnpLdew7fJSE2Nk1We/BwlTfelCt14YsXzhAi3fScyAvb7dkz6a/sMqTxRhjxPUEiIV6U4B1r2kFVC2wx1j/u1Ggfo/W6HOsWTlshRL0UfE66Kk0K2wOOYBXIN51S9dZnlLX01R80xvhL+2GmutcTjGzmNRub3qhVLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729654; c=relaxed/simple; bh=RCi13kQA12bFjHkjczh8qz6SS5Yu4dKyUOjrH6aCjKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RD8f0tjKr39kOuFuZWsnmr0wShLFI0TspF51PEs4scaJ/CduamZmbU8KrRSKHHAlFJNna5vfRpP7WxfsEDjtnfbSPi1lDFD0TZ48J9+lrTpUST2L3VTvKryOJovSmlmOrB/dUWDY1LPI7F1RhpioxZOCh3P217mRGaFLic7cHj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FuqoXHTA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FuqoXHTA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC977C4AF0A; Thu, 15 Aug 2024 13:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723729654; bh=RCi13kQA12bFjHkjczh8qz6SS5Yu4dKyUOjrH6aCjKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuqoXHTA+iDtJkfXSDBfJ6VNTQU6Oi+f+koPaf3fQ8EAiLQHWbcjImAY/+Rtf8SHS PC7udx449oqLw1VJTKZ10RLxatJD0/0zSLg9C7Bf89dylGe1z6glWma3wTxLJi2fdI jru+O7d/M2aBWyhDT4RWJ98fPqRlHXk3Hjonwxog= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+6c21aeb59d0e82eb2782@syzkaller.appspotmail.com, Jeongjun Park , Arseny Krasnov , "David S. Miller" , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Stefano Garzarella , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 135/484] vhost/vsock: always initialize seqpacket_allow Date: Thu, 15 Aug 2024 15:19:53 +0200 Message-ID: <20240815131946.620287606@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131941.255804951@linuxfoundation.org> References: <20240815131941.255804951@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael S. Tsirkin [ Upstream commit 1e1fdcbdde3b7663e5d8faeb2245b9b151417d22 ] There are two issues around seqpacket_allow: 1. seqpacket_allow is not initialized when socket is created. Thus if features are never set, it will be read uninitialized. 2. if VIRTIO_VSOCK_F_SEQPACKET is set and then cleared, then seqpacket_allow will not be cleared appropriately (existing apps I know about don't usually do this but it's legal and there's no way to be sure no one relies on this). To fix: - initialize seqpacket_allow after allocation - set it unconditionally in set_features Reported-by: syzbot+6c21aeb59d0e82eb2782@syzkaller.appspotmail.com Reported-by: Jeongjun Park Fixes: ced7b713711f ("vhost/vsock: support SEQPACKET for transport"). Tested-by: Arseny Krasnov Cc: David S. Miller Cc: Stefan Hajnoczi Message-ID: <20240422100010-mutt-send-email-mst@kernel.org> Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Reviewed-by: Eugenio Pérez Acked-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/vhost/vsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 74ac0c28fe43a..531e3e139c0d0 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -684,6 +684,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) } vsock->guest_cid = 0; /* no CID assigned yet */ + vsock->seqpacket_allow = false; atomic_set(&vsock->queued_replies, 0); @@ -842,8 +843,7 @@ static int vhost_vsock_set_features(struct vhost_vsock *vsock, u64 features) goto err; } - if (features & (1ULL << VIRTIO_VSOCK_F_SEQPACKET)) - vsock->seqpacket_allow = true; + vsock->seqpacket_allow = features & (1ULL << VIRTIO_VSOCK_F_SEQPACKET); for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { vq = &vsock->vqs[i]; -- 2.43.0