From nobody Mon Feb 9 13:38:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630925012; cv=none; d=zohomail.com; s=zohoarc; b=EUglfXGejv9u04eEGNLV8aNydpzauZDzz6hVG+HERBAChR2NJ2jk1xFrddKT/M8NmhggcJSC81PDT9i1UBaKvsfZplUs+fK7eQGOGPHQww7bA7Q8hQqoApXwtEKio2gxKiahHQBsQdV0ANTiMz5nhpjMA2TcFqcqf7HGfqwyXmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630925012; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ydqzmpwIS7w421UnF6h3bFe+Afko4IEnGxAHt+H+82o=; b=CvE9hasXlppQJJkXM6OqLLc/873diOXKOAS+1c6b7unM7j9dOzHYsXy5TVoM4/TBhxlRql07CW02BnIJg9DGKZt+qc0Fsp3lDm1IUk8+hTvbUOOQKXvFBECtSiylDx9XZY3WA7QShZU/WsxAG02522JUdJbO7Y7eVnaZ4ChbEjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630925012269714.9888636606629; Mon, 6 Sep 2021 03:43:32 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-Xyte2GM-NYCJNutxBxqE4Q-1; Mon, 06 Sep 2021 06:43:30 -0400 Received: by mail-wm1-f71.google.com with SMTP id s197-20020a1ca9ce000000b002e72ba822dcso3745355wme.6 for ; Mon, 06 Sep 2021 03:43:30 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (21.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.21]) by smtp.gmail.com with ESMTPSA id c15sm6889020wmr.8.2021.09.06.03.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Sep 2021 03:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630925011; 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=ydqzmpwIS7w421UnF6h3bFe+Afko4IEnGxAHt+H+82o=; b=b4J2YUHOQqYRG+psoc24G3Poaf5im/8BqqHkepiiRrNxuVmGYzhHrgDZ6Uzye3QU0R3MUr C0+vgdJayLVNefsFHoRE1ZQEUQu7sPekLdO+KNTmSHgdFNlmlMwnaiag6DuS8wyYuGVV4f VHyqq9QTrdEaPUOhnEFFzhl41QzbBEg= X-MC-Unique: Xyte2GM-NYCJNutxBxqE4Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydqzmpwIS7w421UnF6h3bFe+Afko4IEnGxAHt+H+82o=; b=AM1NI4aXI/LVaArmPua5cGt6iuxvtuqlxLySkqmAVCmNqfJM1WljNPZSndm/867i4W 0f1/mRnzpqgP4pMr8eIOq2+ooNQ+4XDVZy59ly6QJvBGHW05kYDmHtT3sBs3RThpmJqp leg+MENUPC/8DzpafU6ikwKG6UqEpFbItyxKShGlQEPRbOtuejargqcVLoH+WhOHqmIU 6fflP6m9YwmocdQwvwTDfkInVLrEylAwwkSq0NHCwL/E0j1P+8a5axvBFXHjjUeuT6C2 +1UoBkCE+Tcy23fFOLa7m/78QJ4m1cD6BrTuzChNY27EM8lG3X6rp7BWFzLvTrBdTMlX WFIQ== X-Gm-Message-State: AOAM532mdwYgqsG/Kg/BEhV5u2sadBfHLMXy3pRknI9YiCbA/CONnfTA N4VralRY+VCT1NvyVUBpr75jcdxYh5kC3NcGt1I1mhcyg4S4rmpbM/2zyCeyHNkrkFJF455dmtm yNKuz1bx1YAaLyQ== X-Received: by 2002:adf:ce85:: with SMTP id r5mr12649796wrn.323.1630925009261; Mon, 06 Sep 2021 03:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHy4hCuzzCoHmbyOxXuF8aQv4fJfICXV4BR/P+IflP/4frkx1GgFT9uF0tP+AARXyUtB+1Jg== X-Received: by 2002:adf:ce85:: with SMTP id r5mr12649777wrn.323.1630925009082; Mon, 06 Sep 2021 03:43:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Cornelia Huck , Stefano Garzarella , "Michael S. Tsirkin" , Paolo Bonzini , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 2/3] hw/virtio: Acquire RCU read lock in virtqueue_packed_drop_all() Date: Mon, 6 Sep 2021 12:43:17 +0200 Message-Id: <20210906104318.1569967-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210906104318.1569967-1-philmd@redhat.com> References: <20210906104318.1569967-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630925014040100001 vring_get_region_caches() must be called with the RCU read lock acquired. virtqueue_packed_drop_all() does not, and uses the 'caches' pointer. Fix that by using the RCU_READ_LOCK_GUARD() macro. Reported-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 97f60017466..7d3bf9091ee 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1704,6 +1704,8 @@ static unsigned int virtqueue_packed_drop_all(VirtQue= ue *vq) VirtIODevice *vdev =3D vq->vdev; VRingPackedDesc desc; =20 + RCU_READ_LOCK_GUARD(); + caches =3D vring_get_region_caches(vq); if (!caches) { return 0; --=20 2.31.1