Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp293193lqo; Thu, 16 May 2024 06:38:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzyvaUJY+zrKiEGYirQ+bVFLZjC2tb+MJvQ6P1KBvKLqbmLTFQNuHuIzo0zAN05hD0vwSxi150N77wsCy4Wm2zz+x+sg1gO/b1kGIF2w== X-Google-Smtp-Source: AGHT+IHAfKCsN0EYI+x1xm9CKeBHD5zm/2J0n6xVT1Ow80U80A8ZI6DjBnmxvHFF0By4CEsjdF8f X-Received: by 2002:ac8:7e95:0:b0:43a:8877:e372 with SMTP id d75a77b69052e-43dfdd1b465mr213451621cf.48.1715866721379; Thu, 16 May 2024 06:38:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715866721; cv=pass; d=google.com; s=arc-20160816; b=tj8sdmCXUpsDVLd75XtumzQOgs/z5tvU+ar8vpKRLFhKdIXT/U5BbuK0C2PGoUjDSu pFw5htjQDmJwPW6+iaT0qzoBzMmlqeK1GuDmunrkeuYJw+11aQUKnnjzm60r2JcBoY4U 84TR1h05S32vUy2x8zdQeaQipcSeq+fpKJk1F1dXHXX7AdqUVOWZ/smDLoDSBRcTKg6N +5ypb8GQzIBdyNvouXd2GuVaK4cffIN3KasjR3fBf5/phwFoIMLImcUmJzW6sUT92zmI nttcHuooJfFu6Y42roBKv2ikjEKXKqK/iL0eZAbjkBWuO/c/QAIasmLcKqI5Y0t7ubre AcpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9MotCgp3e2fj15EogMUNC34bh/DK0Sdeid+nwujT2pQ=; fh=iwjmozN4W5a6uAAB0vmwHFHWvlnYT5Vwnxez+4AEQ9I=; b=Vou8qQKMVlgL5Pkio+JTK92ix3vvl8Q6qZyD+/bK/zyYqRCVK54Iz5MuMesGBhZg5M 7ACFCndJdjmT4pzen2fYR5E28FeeIF+2qegf5yH5JqgHyACHOY41Xlp01/L/ZNXnpIoG DqevXT5R2RFxs92JtT+8+lHCmIlua9vxVEO5Cpie4sHq/KKH9BXZ4uQOVe0yu4YTqIN2 PyN75s+pwJo85XAp9aqBVFg6Lz3pPvhsWTMd5vgAhPiMd+9xzWnfN+iVgpazx/l824lY H3nJSlx5Wjc/d/L4omBukTKJqd+mH+xFjexk10ZGEUGkCIhLXBqqCFIX32jz9xVaK+nl nRrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b7lFkxFm; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-181129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df56b90e9si168591261cf.600.2024.05.16.06.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 06:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b7lFkxFm; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-181129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 100051C2134D for ; Thu, 16 May 2024 13:38:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69FD1148FE8; Thu, 16 May 2024 13:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b7lFkxFm" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 00085147C6E for ; Thu, 16 May 2024 13:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715866708; cv=none; b=SfMvjPoCycnyrtqt4lIq/tJcZV3Hj6bltrhR6R62NaCSgYYAViOrcuDx6hy/MBAgmCXH4FD0NERFZuSYG/GSG8oGexgWw+3W1Hwwoa+i5Xyz76xdRX3M2cqxQCDtVyL12adaZepL/U1hqlKY79WsOqnpVPbyfsRltvBXvdMY+9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715866708; c=relaxed/simple; bh=H4uJfIWjhvWKU9/lF6/ReCaGNL4KXA9cAwJNwXPUNXM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iAq/V/nfoyAWY8c6EOHhFogpewyFRDJam7l5QJMIIfJvYatfEC/HaAk70/xAmX7FYYzqZXR3yj1PEyZ9ekQpxIatocUJadYdMz34LJDfXjk1b+VRBJHXIHrnAAKs5JEKXd/qN4v3MT2hAu697LUFgOV47/bwAxkMKokt1Rtf2s0= 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=b7lFkxFm; arc=none smtp.client-ip=170.10.133.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715866703; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9MotCgp3e2fj15EogMUNC34bh/DK0Sdeid+nwujT2pQ=; b=b7lFkxFm8nK/6bydZdP3RcIqstGre374Xew1FrxPDZgtdnKwxyM3ox/wELTpIcB4F8xLJS Tnx3GiqMjEuSM6PGPZEIqaLWBWbg9kQhX99LxkzaMHD9lCdvDN2dEZvLJQZJ39Yg+1tilK nvjMALwimQjNH8jGTd8ACafSwhHF3Ss= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-L8x8YlNZNkakAcPWn3akgw-1; Thu, 16 May 2024 09:38:22 -0400 X-MC-Unique: L8x8YlNZNkakAcPWn3akgw-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-6207c483342so143613117b3.1 for ; Thu, 16 May 2024 06:38:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715866699; x=1716471499; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9MotCgp3e2fj15EogMUNC34bh/DK0Sdeid+nwujT2pQ=; b=iw3uEHAWIWFlHyIp7/PbUmUpLrzzGzGrX578dl8MY1JJi8dSl/L7loahGYZSvTFpHr FYRcEebVBG6VmsqM1a3q7KH1PlAti4msdOKJdGhDFPKwkcYyJNuDym9ZhyOjE4u38GtU FCWdxu84pP/GDaKQJ4g4IuaiNjukkHUqa5CevK4of0C4G/Yt6m4X/KvZR1/LEoohQuOv hbYRUaSzYiAOiAWWMQK5Ld7UBMgPYnfs0jxvGHwSwieWJkHWCMnjTqjpozX1pbcQRFr9 AkaH4U6cg0GUovZ3lHbOLbR6p5TrNw0+ykM38PUoO2VgvmOaYFep7BZRMvKLyEpPi65+ CkjQ== X-Gm-Message-State: AOJu0Yy8b0QgDXhHGVb5EVQaX8Kj22nAaeKo2oknbyvy3w0TAH4HipI9 FxiwXW2Xs6Y0oIyPPI923FU5FrbhELxPgr/hUJGPPTEUWb3iWI2iyhBYFsoYEIfsgEhg46UgLVj qWUgPCGPFQth5ECZJeQR+uwhtajyC1jGWd9cXLSq5pltRxr+dXjdHSudBEhUxQCHmprfnALj6VW H8HELALUWaWQfFnTOnAPw/O7TKKr1wFVjhSwKT X-Received: by 2002:a05:690c:b9d:b0:615:8c1:d7ec with SMTP id 00721157ae682-622b00218ccmr188220097b3.33.1715866699399; Thu, 16 May 2024 06:38:19 -0700 (PDT) X-Received: by 2002:a05:690c:b9d:b0:615:8c1:d7ec with SMTP id 00721157ae682-622b00218ccmr188219907b3.33.1715866699113; Thu, 16 May 2024 06:38:19 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Eugenio Perez Martin Date: Thu, 16 May 2024 15:37:42 +0200 Message-ID: Subject: Re: [PATCH] vhost/vsock: always initialize seqpacket_allow To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, syzbot+6c21aeb59d0e82eb2782@syzkaller.appspotmail.com, Jeongjun Park , Arseny Krasnov , "David S . Miller" , Stefan Hajnoczi , Stefano Garzarella , Jason Wang , kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2024 at 5:05=E2=80=AFPM Michael S. Tsirkin = wrote: > > 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"). > Cc: Arseny Krasnov > Cc: David S. Miller > Cc: Stefan Hajnoczi > Signed-off-by: Michael S. Tsirkin > Acked-by: Arseniy Krasnov > Tested-by: Arseniy Krasnov > Reviewed-by: Eugenio P=C3=A9rez Thanks! > --- > > > Reposting now it's been tested. > > 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 ec20ecff85c7..bf664ec9341b 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 =3D 0; /* no CID assigned yet */ > + vsock->seqpacket_allow =3D false; > > atomic_set(&vsock->queued_replies, 0); > > @@ -810,8 +811,7 @@ static int vhost_vsock_set_features(struct vhost_vsoc= k *vsock, u64 features) > goto err; > } > > - if (features & (1ULL << VIRTIO_VSOCK_F_SEQPACKET)) > - vsock->seqpacket_allow =3D true; > + vsock->seqpacket_allow =3D features & (1ULL << VIRTIO_VSOCK_F_SEQ= PACKET); > > for (i =3D 0; i < ARRAY_SIZE(vsock->vqs); i++) { > vq =3D &vsock->vqs[i]; > -- > MST >