Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp654301pxb; Tue, 5 Apr 2022 17:28:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ83zCa7A+nhFtI1YxbWqIkn30WheozTQZTcxE0XI8LLzXqBUDO2xVCPKNLk5vnJPydFR/ X-Received: by 2002:a63:770c:0:b0:386:361f:ecce with SMTP id s12-20020a63770c000000b00386361feccemr4904282pgc.202.1649204905756; Tue, 05 Apr 2022 17:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204905; cv=none; d=google.com; s=arc-20160816; b=e/2izTj1YHM7JsTGuhJb14oMs7dkuFaI/gIsQ0IP4t5B24dI10MHjMFaFdoWxLA0gl wy4432/TFYuDqvoFmkorwKCUwTI1Nd2Ex2FMCFNSOj9zJqCVO5lPXWfJ6zpPVPhrQnD+ ncWVlMP2/Y16QaM7tovf/eKWK+/hk3AZv412dUKyvug3x51hM6E9bnVlQUx5v5fM5f0z dxCrkJFS1W7Jo9xW4gF/cC0W/WBqx46tzFkU3tEQw1auLtxl69Osu09xIyXkm5g++IuE Mg18fhinqpVsuB30GfKbHgAL/Q4ordTwJeIptFjWIM7AxwkfoiPe/QQcZUye6WoF2Mfh H2tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qK/tOvWXlRuc3N5/G2sQz6H5dW5j5q4/1ARycTGFgeg=; b=Niljf/IY8ZZ57XM6gTngpEu4Qq5sFDC8yMku0PMU1cxBDklMdIJY7bIH4Is7QcVNzi 4oys12o7ntF/WE7z5HoMI+1IAMSXh9JK5KppwthSi5DltxZvi1z8WN+qttoxrX1tOcr3 NBDTzjHWKKiNzjbJhfIso3o3U3RBHkRfMSLuU2yHLnwAhw0UCp/Wky0+N+4zLbQxQsDp DfQrk4jQshHQ1lAI6e07wrORttvfi46kfUbALp9a6uLHVP9NRPvyLjT8a/xHu8nnA6ir wug2Kf/S6u0gmh6aYSq7S/ZFvOQD7tvMobT6As9yXBWux7Hj5NZX7vtiN7aM2FrfskrS E3HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0qPZBBiz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 4-20020a630504000000b003816043efe6si1754553pgf.475.2022.04.05.17.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:28:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0qPZBBiz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0E3E275ED; Tue, 5 Apr 2022 17:14:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357406AbiDENIn (ORCPT + 99 others); Tue, 5 Apr 2022 09:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344120AbiDEJSS (ORCPT ); Tue, 5 Apr 2022 05:18:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4673E39163; Tue, 5 Apr 2022 02:04:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D5B8D61573; Tue, 5 Apr 2022 09:04:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEB19C385A1; Tue, 5 Apr 2022 09:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149459; bh=Z2fRyKtO0unBo5yv4F+hHOmM6Dx9c+nDJFB8oxsdOnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0qPZBBiz/cH26Hr3xI4fE3V601XLwqsE2LDGyGXrc4uk1pSDPACtl2dpqRhSEQyum P6rNnyoBsVQeuZ6JtSNzUxXqESAxoubsthRiI74d/qwe1MQZaeU9Y3CAXKLhmcyHBi RYNaK/jv7ulAxeIhm6m2dF21C9WfcIs+35pQw4Pg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , Stefano Garzarella , Stefan Hajnoczi , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.16 0723/1017] vsock/virtio: initialize vdev->priv before using VQs Date: Tue, 5 Apr 2022 09:27:16 +0200 Message-Id: <20220405070415.727670051@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefano Garzarella [ Upstream commit 4b5f1ad5566ada230aaa2ce861b28d1895f1ea68 ] When we fill VQs with empty buffers and kick the host, it may send an interrupt. `vdev->priv` must be initialized before this since it is used in the virtqueue callbacks. Fixes: 0deab087b16a ("vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock") Suggested-by: Michael S. Tsirkin Signed-off-by: Stefano Garzarella Acked-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/vmw_vsock/virtio_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index dad9ca65f4f9..fb1b8f99f679 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -622,6 +622,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev) INIT_WORK(&vsock->event_work, virtio_transport_event_work); INIT_WORK(&vsock->send_pkt_work, virtio_transport_send_pkt_work); + vdev->priv = vsock; + mutex_lock(&vsock->tx_lock); vsock->tx_run = true; mutex_unlock(&vsock->tx_lock); @@ -639,7 +641,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev) if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET)) vsock->seqpacket_allow = true; - vdev->priv = vsock; rcu_assign_pointer(the_virtio_vsock, vsock); mutex_unlock(&the_virtio_vsock_mutex); -- 2.34.1