Message ID | 20191122112621.204798-31-glider@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=DNi/=ZO=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 B480A14DB for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 22 Nov 2019 11:28:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8126120672 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 22 Nov 2019 11:28:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DFnslQ5W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8126120672 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 15F166B04F9; Fri, 22 Nov 2019 06:28:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 136226B04FB; Fri, 22 Nov 2019 06:28:02 -0500 (EST) 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 EA48B6B04FC; Fri, 22 Nov 2019 06:28:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id D1BE66B04F9 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 06:28:01 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id A01E134A3 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 11:28:01 +0000 (UTC) X-FDA: 76183689162.15.sign74_bd2be953080f X-Spam-Summary: 2,0,0,00866abdf922e322,d41d8cd98f00b204,3p8bxxqykccache9anckkcha.8kihejqt-iigr68g.knc@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com:mst@redhat.com:jasowang@redhat.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com: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:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org: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@li X-HE-Tag: sign74_bd2be953080f X-Filterd-Recvd-Size: 5167 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf50.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Fri, 22 Nov 2019 11:28:01 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id u14so3711749wrq.19 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 03:28:01 -0800 (PST) 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=7nu7H3g0ucfNBsp55PaOy6t4XvKDbHFZAWKT2bx4EQY=; b=DFnslQ5WZEXN20FoEMNzVcnDMCwXEN/xumjw5xjwJaup4knyhUKsznjHejyJhQJQO2 HN0g8+U6d8FZsZf47Gh3EPlVaFqjvPWw5m8QJLweotMOxcsvh8d+Z5sut448iTxHx17L OBHEdxmHeOc8qlwa4gK5Ho47/YKhYMrkvKgxi59WPevKzRjBT7r81jNZlVzqlJCQ8QIf FCJMzuTcC7NJfVNKZFaRqppHJOPH6tUpNH+uYuyEHEdYPiANhwR3/AF+2gVe79e5fIJP Vpdnk7Wb1HhCZlrpc/s8GjHs9lUlL+a67WJ2LT4QAH61RJCwiUFBEFmK1qwyy+CD3x45 gsug== 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=7nu7H3g0ucfNBsp55PaOy6t4XvKDbHFZAWKT2bx4EQY=; b=cExaGQzz9sKRgnnyRWInqnsqizjWGQoGYfyfQDgnj9pzsruGWLKYaKqPx8JT+YhCy/ pJvFhSylNcYT4tiMpHRjFABcNstjOC7ryfKOI2i0EuyWkvWm537txwNfYXSHHYWCQQ9N T4neVyeVu6NC/l7xQ71MHkKztYlPdME3J7REZ44VIaEabPJt4LaxeOy3Jg43ZlT+KSYV AlYoG0siewrbtRf8tOnzYtNsYs/nFaywpruBD92EZS9v6oZxtH6Eenqk61rVd2k8Lb/+ AIz+tfqFsgrqS16p4g15jfWp5h1Yiru9fh+MxkyhVmdBHQXW1RblYlt3rRXfWbGstoKQ WoNA== X-Gm-Message-State: APjAAAXMT+yG7brb+kuXFrcVgfLj7ne1kS4Xui40zlwmoJc+qND3b1Xh lBmdcHTK60IE6aPXky9PIhcOSKYXhak= X-Google-Smtp-Source: APXvYqxpaA4SlpPJZ4qjXYDsmGzH9Xz4gaGuiTdH/RznrhfaL7z49xoT0BHuh1f3VuHOCABWuFqUzJsSJBE= X-Received: by 2002:adf:e40e:: with SMTP id g14mr17993602wrm.264.1574422079737; Fri, 22 Nov 2019 03:27:59 -0800 (PST) Date: Fri, 22 Nov 2019 12:26:15 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-31-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 30/36] 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>, "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, andreyknvl@google.com, 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, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, 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 a8041e451e9e..2f8da5eeb3a0 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: "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(-)