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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2C51C433F5 for ; Thu, 6 Jan 2022 12:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239029AbiAFMqt (ORCPT ); Thu, 6 Jan 2022 07:46:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32365 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239012AbiAFMqr (ORCPT ); Thu, 6 Jan 2022 07:46:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641473206; 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=IhKCWiVxKmma4hx7vqrpgPZKqQEgMlj0ozvKJe1VJnjX1UKqK4Vo1Eb3Q3VBdB29U53/dL guRtLa6WXqXbsn/BhSr2Xi+y3+B+TMzJ8pd95v797/h0PURVRwYIPEfxMbxrvE9GLMM1o4 MmLb/c1sb9eBxA1lvZm9atUNeX5H+Bo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-5Q5Kid_tMxGfbsHzbmaxTQ-1; Thu, 06 Jan 2022 07:46:45 -0500 X-MC-Unique: 5Q5Kid_tMxGfbsHzbmaxTQ-1 Received: by mail-wr1-f71.google.com with SMTP id h12-20020adfa4cc000000b001a22dceda69so1202470wrb.16 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=xskPsQoIaQDpQ+Vn5zo9bk5ySmfkyoVGiDjG+t7RSzgV8ddHFxSJA/5xkvdkDupIkb cQE4ol0UvTanvC5gtwDo4zkIcUtAWWPCTYsJymfGwA0U58/H1I6R7/FsU4aouHZpfu4G 4w8zaRO6OlTxWYj2XvOmoVzl1jnGFDFZ4X20E/d/yX+vlGL8muNG/FTlgy+wiTOnLeed 2ry3luNVBWkxThvVC1+z7BJ3l+EGqxHB8lk0Y/QlBIABfTdeVZYQmG02BrTNiMcMLF5Y OHQKw7QUriUM4XTy82Cj2NVr+PVeOB6IxmtEZFn9VZ+qKZNcY6tklBSO5ei4POSkgIU9 g2vQ== X-Gm-Message-State: AOAM532ys8Ix0b4Asmxm2176hT35l+LmCLl67dwjKafIJGkEmDPLWHtv zIwLu3j1Dl5ODrdLrlEr0KvbCZiBlqebEIvhn4ccOEkChnbxHA+N27oay9vqbbF5qKkKer18TQ6 M4RzKwlIKd5vrQ2JbPkFp/870 X-Received: by 2002:a05:600c:1e05:: with SMTP id ay5mr6993338wmb.131.1641473204126; 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211214162050.660953-27-glider@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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