Message ID | 20200325161249.55095-32-glider@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=qMZt=5K=kvack.org=owner-linux-mm@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 025716CA for <patchwork-linux-mm@patchwork.kernel.org>; Wed, 25 Mar 2020 16:14:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C503820409 for <patchwork-linux-mm@patchwork.kernel.org>; Wed, 25 Mar 2020 16:14:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ap6VLbh1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C503820409 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 694F86B00A8; Wed, 25 Mar 2020 12:14:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61DDF6B00AA; Wed, 25 Mar 2020 12:14:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4743E6B00AB; Wed, 25 Mar 2020 12:14:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 24D996B00A8 for <linux-mm@kvack.org>; Wed, 25 Mar 2020 12:14:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 01FB95676D for <linux-mm@kvack.org>; Wed, 25 Mar 2020 16:14:36 +0000 (UTC) X-FDA: 76634382552.30.brass10_7f6d17edb5942 X-Spam-Summary: 2,0,0,0ce7b8571e659bb1,d41d8cd98f00b204,3aon7xgykcfk7c945i7ff7c5.3fdc9elo-ddbm13b.fi7@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3867:3870:3871:3872:3874:4250:4321:5007:6261:6653:6742:6743:7903:8660:9969:10004:10400:11026:11232:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13069:13148:13230:13255:13311:13357:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:21990:30054:30064:30070,0,RBL:209.85.160.201:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: brass10_7f6d17edb5942 X-Filterd-Recvd-Size: 5305 Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by imf13.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Wed, 25 Mar 2020 16:14:35 +0000 (UTC) Received: by mail-qt1-f201.google.com with SMTP id k46so2365726qta.2 for <linux-mm@kvack.org>; Wed, 25 Mar 2020 09:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=J+h0iEnWTkRG2NLExxLPCnEChpv3/sAmomh7lQSL40I=; b=Ap6VLbh1nr/g7HPsN85bH+He50TVNZKjm8mbQ67XUjm7N5GYD3YJI4IkP40aduyrl+ xwjd5PLEboIdfAlynCr2s0bHLCAb9/MFGyAJLO6Dx1INC68alDj08z4Eg3GDiKEXwQjT vqOs8uri5xwH/VytQTSzdcqNDMdRds3xw6cyeR8CaauCTy8PNm9Fx2kEC5FQxByGHyuN v/HM33BPhxYyZqLfWySi1CjPLB2VsIQ9DMPxrDswCNO18NWJNDOc9TUF9A5LE2PV45vL 5z8E7pv8OjWLy8BuiU/sWK+u1/HqEAuJ9oAjEvfqVe3lhbrh6KMOQwPlG5Qc4uV0pjI4 gYYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=J+h0iEnWTkRG2NLExxLPCnEChpv3/sAmomh7lQSL40I=; b=C9VtnVK30dSC1XBM3A/zkjLekdwBK3LtJi57Gi9YNZCgE6/XuQhNm9v44SSTc44s8P bpyEYg9MRk80GCRFbVIfXOZ807DHvduw+NyQCUG1/ntk8Guk551Qk2JKZKH8OmBB2BpN wlXlW75IAkYXjWEcO0wfVo7QchrwGfw5wWe+pDiTm6qQiT9CVgZqy6UdA4P7f/mbMZTW VY0RL6JVpcl9maN9JYGs6bpCQrRXcXm5+F0wQl4wlQeo4V4Bw+LNQL9VxBdl+YaSWtGL iTKJDdyORvl6VVwnhxsToxUZBA4Z/KpOFscwXBf/RkZTm6nXFvt+VFrRCKQYO9ccHu3e 8deg== X-Gm-Message-State: ANhLgQ0SC76Rbf3exF2qYWK0U8QvyZZuDMLH0imSlceb4hI40WSP6VPL i2bjOdylfkGm/3S/0mBtghc88byPoPk= X-Google-Smtp-Source: ADFU+vtc3ssCRbxQQhTVV5kqjyH/E8hfiLbgFgdTIhyuHgKj4w3GvV01MQ0MpCGx8nekkibvHTvg7Uf104c= X-Received: by 2002:a05:6214:186c:: with SMTP id eh12mr3770740qvb.131.1585152874479; Wed, 25 Mar 2020 09:14:34 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:42 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-32-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 31/38] kmsan: virtio: check/unpoison scatterlist in vring_map_one_sg() From: glider@google.com To: Vegard Nossum <vegard.nossum@oracle.com>, Dmitry Vyukov <dvyukov@google.com>, Marco Elver <elver@google.com>, Andrey Konovalov <andreyknvl@google.com>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, axboe@kernel.dk, m.szyprowski@samsung.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mhocko@suse.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de Content-Type: text/plain; charset="UTF-8" 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: <linux-mm.kvack.org> |
Series |
Add KernelMemorySanitizer infrastructure
|
expand
|
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 58b96baa8d488..8b6dee1dfde58 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -11,6 +11,7 @@ #include <linux/module.h> #include <linux/hrtimer.h> #include <linux/dma-mapping.h> +#include <linux/kmsan-checks.h> #include <xen/xen.h> #ifdef DEBUG @@ -326,8 +327,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_virt(sg), sg->length, direction); return (dma_addr_t)sg_phys(sg); + } /* * We can't use dma_map_sg, because we don't use scatterlists in
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 <glider@google.com> Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Marco Elver <elver@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Cc: linux-mm@kvack.org --- Change-Id: Icc8678289b7084139320fc503898a67aa9803458 --- drivers/virtio/virtio_ring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)