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 64FB11A6192; Tue, 30 Jul 2024 17:05:59 +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=1722359159; cv=none; b=fcG+EQpWxzRZyatQGhC/FmHD3CIrE4Y0/ufhITaVoiQaCAm0tvgJcy4/jLGPEKq7JEz1tw351LRDOdXYLMhvNIE2W2r682WjdCRvNFf/SYStTQWarvwQAuEtz+1rja+CuRAYlgutnhSwow2jjIh/CQ52BuV0RcMnsk5Jw39iNus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722359159; c=relaxed/simple; bh=9i2vCvDup8mgfydrSfjcFXSytGhTA5ISYYFeO5dhiNQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nJOOGdA/AcC2Z7WtVbS1PJJnAExi81R6CcUd5YrsUp2lss+Jjqwboo8IAySEkOkOOK3ttJap7xPM+EFS4ZWnHwAB+1z9DybbXe/XZ61td5z+kT6kEPCizsmVU5nzcCcUJnJ8CFqyjq7Mepfku4dHUSJPNDsZuhKuxJ6Uqzr4RFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XFtc5mNL; 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="XFtc5mNL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4A20C32782; Tue, 30 Jul 2024 17:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722359159; bh=9i2vCvDup8mgfydrSfjcFXSytGhTA5ISYYFeO5dhiNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XFtc5mNLYxkSHc/PLqZY6QZkGGDi5TntBtmUvr11wEgpm6jGlVrGWLFAt8qptucoS Y4RAWFK52gqQIh+96kfBUgWKb5ZsxVvq8mwH3pndWKfDdBSMvlCXwiHpY51whuyoiD 2Nw7h3yRpKQ4lfIzuxR+aY7HaigzY7DtLnjwPMQQ= 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 6.10 444/809] vhost/vsock: always initialize seqpacket_allow Date: Tue, 30 Jul 2024 17:45:20 +0200 Message-ID: <20240730151742.240054343@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151724.637682316@linuxfoundation.org> References: <20240730151724.637682316@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.10-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 ec20ecff85c7f..bf664ec9341b3 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -667,6 +667,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); @@ -810,8 +811,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