From patchwork Thu Sep 2 16:50:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12472167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 490F2C83026 for ; Thu, 2 Sep 2021 16:53:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B30960FDC for ; Thu, 2 Sep 2021 16:53:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0B30960FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLpyC-0006ev-7l for qemu-devel@archiver.kernel.org; Thu, 02 Sep 2021 12:53:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLpvc-0001x9-4t for qemu-devel@nongnu.org; Thu, 02 Sep 2021 12:51:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLpvZ-0000Tv-VP for qemu-devel@nongnu.org; Thu, 02 Sep 2021 12:51:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630601461; 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=H/DdrcNaA1sjw+SjVVOjviZlZFfCN8qQqe79eeHNdv7ifFafQdv6G4m2fvOpZ1fx7IXgYP 99/xkf85GypYGZMFikzxbSSk/r2pxsrsynIhTwmlPkHT9XvvukF83dWrDQibIVTOXgTF6C 2/H0DlEfxHsuTBl37ln7iDhq1AkZoNA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-RVdAuWNsOzuJezT50lpmRw-1; Thu, 02 Sep 2021 12:51:00 -0400 X-MC-Unique: RVdAuWNsOzuJezT50lpmRw-1 Received: by mail-wr1-f70.google.com with SMTP id h6-20020a5d4fc6000000b00157503046afso749886wrw.3 for ; Thu, 02 Sep 2021 09:51:00 -0700 (PDT) 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=uS8KdUlWHXIp4mhcfRoM4R/HXnoPIuU9oflhRVS9ahLlEhrBxqwx+5Zzp1Epn3jHIi pfvR77U9EEo7V1dnvnUiAPG7fYKeEXXtyCALGu99XkTzdgTQiLG8UyfJ0Eg7o2wSLn0Z jFZJAwvkATrEACXoYvkoHZ9LbIPESvmSw/BuhVc61nB2TciH9rB03pzP+BS+iMocg517 PG5uHVGjCFArmaMjBc5SUmrVVcXNT7joOeuWEBVyh4TjaLg8mB/mIUewzDnZyTXf0aoN WqlI2kevBFBZSc6n5C7pNGIC+23k+euOSpzSCvw2XZeLALyyEDaDoT+SU8lus4CpsSVQ JcQg== X-Gm-Message-State: AOAM531N7Radx7+9Lz6MLs+USMdGcDr8hUWB+LE3UwBOwww7pfdGtuGO r93gYGly1Yde/DCnLJ4ZsWnNxpxLT1yLZJhiAiJ1CWITst2hLvSv8VAeDGMarEkybpcq6x1/LU9 s1H7SonqHzE5p31cgtmIUWF6TCKrtr2GDzkbInoLNr/lWZMLp63FgvmWoVWGTce8b X-Received: by 2002:adf:c405:: with SMTP id v5mr4922742wrf.183.1630601459025; Thu, 02 Sep 2021 09:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsxF6ASqU+vuAstoHC6qZ4CFufNOz4O5rFfyQl1kKl5jUCnlfv2zuQ3t5UWCXVSXXQq2K+Gw== X-Received: by 2002:adf:c405:: with SMTP id v5mr4922718wrf.183.1630601458855; Thu, 02 Sep 2021 09:50:58 -0700 (PDT) Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id s1sm2386940wrs.53.2021.09.02.09.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 09:50:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] hw/virtio: Acquire RCU read lock in virtqueue_packed_drop_all() Date: Thu, 2 Sep 2021 18:50:38 +0200 Message-Id: <20210902165039.432786-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902165039.432786-1-philmd@redhat.com> References: <20210902165039.432786-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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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(VirtQueue *vq) VirtIODevice *vdev = vq->vdev; VRingPackedDesc desc; + RCU_READ_LOCK_GUARD(); + caches = vring_get_region_caches(vq); if (!caches) { return 0;