From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD75C433EF for ; Thu, 6 Jan 2022 12:46:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 447946B007B; Thu, 6 Jan 2022 07:46:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CF106B007E; Thu, 6 Jan 2022 07:46:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 248326B0080; Thu, 6 Jan 2022 07:46:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 0EDBF6B007B for ; Thu, 6 Jan 2022 07:46:50 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BC9B0181C9BB7 for ; Thu, 6 Jan 2022 12:46:49 +0000 (UTC) X-FDA: 78999836538.02.A0C9065 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 0F73616000D for ; Thu, 6 Jan 2022 12:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641473208; 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: in-reply-to:in-reply-to:references:references; bh=QIcy/hKgWsl8HLsYFT8VKTJz9iU+YZ837pHBIwXvv1Q=; b=Ear/wLgA+7HeY6mKH9kAOIeIOP/+arm5YmtBmfjZ2IeBYppZHkphDGnt+7A3BQSHwUMH8r YeByODxj9FHytczhO0y27q8vJ2x/9blH6FBX7Uz0usbVBso5lC7+KxLcaZtYszcfWruEAp zd6BjnoPinHnS2CGOX6Ms0kVqKdyfo8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-qcLNc5hwOJy20lGMaTZVOg-1; Thu, 06 Jan 2022 07:46:45 -0500 X-MC-Unique: qcLNc5hwOJy20lGMaTZVOg-1 Received: by mail-wr1-f70.google.com with SMTP id r1-20020adfb1c1000000b001a4852a806cso1221134wra.9 for ; Thu, 06 Jan 2022 04:46:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QIcy/hKgWsl8HLsYFT8VKTJz9iU+YZ837pHBIwXvv1Q=; b=gZG/UrIH1WLLqDWSUH0FgVFlxQiZZN8Ana3Pqs4XOX8I4XMVpFxFwj3/B9Y6xPUcKT H3Kw/sBtWIOls5lnwVvHxeFT3vo5uDYWK/lat4Gwzx6LBKBmYsuDXMPlNmfsApLpCE9i YCYB4EFGgiTFki1MpB05MgXZtPwGNfF9qxR3juvtOqwChSJqghPrEI8v3IGMJu8I8hDG rdoU6rXBfRRZXDUjg60btDGCFqkStzfUmVfg36wtDWe8GktTgOsY5KTI3JBp5otPmWZS x5Mlpn5HBbTlzsR1tGz80EvB5ILyX5j+pT2mdhAxK4D6Edp5UeNaGHvcWmvpN6+WMUns yzEQ== X-Gm-Message-State: AOAM530CMn9kz8kzo0jrWjSUCQzJw36RVRWioAKp0U2EiswtMZj8tk7a AbSBmlr7KMkwW5NA+Qo+yO/pCpYau+WJk7WVF4o/iYUBhwxR38xmb9LHYnbZHs80W02L4jB4C4p gClgHyipb2yo= X-Received: by 2002:a05:600c:1e05:: with SMTP id ay5mr6993352wmb.131.1641473204167; Thu, 06 Jan 2022 04:46:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIetGTra+THB/8z93McN+42aVUsQxDpvJa2rz7fYmmyJpcjeJUiqxg8dTKkWQkvBsgXuZRAA== X-Received: by 2002:a05:600c:1e05:: with SMTP id ay5mr6993312wmb.131.1641473203945; Thu, 06 Jan 2022 04:46:43 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id g12sm2308053wrd.71.2022.01.06.04.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 04:46:43 -0800 (PST) Date: Thu, 6 Jan 2022 07:46:37 -0500 From: "Michael S. Tsirkin" To: Alexander Potapenko Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Matthew Wilcox , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 26/43] kmsan: virtio: check/unpoison scatterlist in vring_map_one_sg() Message-ID: <20220106074032-mutt-send-email-mst@kernel.org> References: <20211214162050.660953-1-glider@google.com> <20211214162050.660953-27-glider@google.com> MIME-Version: 1.0 In-Reply-To: <20211214162050.660953-27-glider@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ear/wLgA"; spf=none (imf08.hostedemail.com: domain of mst@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=mst@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Queue-Id: 0F73616000D X-Stat-Signature: eot9cmjg4mjtxhbqpsopuoargte9o89g X-Rspamd-Server: rspam04 X-HE-Tag: 1641473194-583353 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Dec 14, 2021 at 05:20:33PM +0100, Alexander Potapenko wrote: > If vring doesn't use the DMA API, KMSAN is unable to tell whether the > memory is initialized by hardware. Explicitly call kmsan_handle_dma() > from vring_map_one_sg() in this case to prevent false positives. > > Signed-off-by: Alexander Potapenko OK I guess Acked-by: Michael S. Tsirkin IIUC this depends on the rest of the patchset, so feel free to merge. > --- > Link: https://linux-review.googlesource.com/id/I211533ecb86a66624e151551f83ddd749536b3af > --- > drivers/virtio/virtio_ring.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 6d2614e34470f..bf4d5b331e99d 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -331,8 +332,15 @@ static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq, > struct scatterlist *sg, > enum dma_data_direction direction) > { > - if (!vq->use_dma_api) > + if (!vq->use_dma_api) { > + /* > + * If DMA is not used, KMSAN doesn't know that the scatterlist > + * is initialized by the hardware. Explicitly check/unpoison it > + * depending on the direction. > + */ > + kmsan_handle_dma(sg_page(sg), sg->offset, sg->length, direction); > return (dma_addr_t)sg_phys(sg); > + } > > /* > * We can't use dma_map_sg, because we don't use scatterlists in > -- > 2.34.1.173.g76aa8bc2d0-goog