Message ID | 20220826150807.723137-24-glider@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 171C0ECAAA3 for <linux-mm@archiver.kernel.org>; Fri, 26 Aug 2022 15:09:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DB8494000E; Fri, 26 Aug 2022 11:09:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 464DC940007; Fri, 26 Aug 2022 11:09:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 240E794000E; Fri, 26 Aug 2022 11:09:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 11ED3940007 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 11:09:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E731DC0E40 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:17 +0000 (UTC) X-FDA: 79842077154.13.1319C54 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf10.hostedemail.com (Postfix) with ESMTP id A9B82C0015 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:17 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-33931a5c133so29305947b3.17 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 08:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc; bh=XOIO6yMrJJaBLCVdiKJxecGrRstBRdkXKAU8JD1YObM=; b=RBRSbeDrL8qGQexUijKhcV3H7NuqN9uz8ZM5rQWAltRN3zhZJP9TKmmIf+p+yKdl6T 3Am09npoAEtHEWxF/Bl4GBV+lvaWA+zyaViXoAoS6FK+zkjAU0V2E1ILS8x3lB5fXtKj 9IHWzkzR0lKD9H/hxXtLbHPszHgU+gNR/ouI3pNZH7yhF0/W+C1cpcyiViY1J1iEBFY8 /rQ0ukMFzwE2rHptS3PuB+v+/gBN3s2bGa1zvZC9PEceq+oso9Jptib23PUbkHkaJtUF ybmLJcK3rBbne7ulW3JpsBkspXiEuaq15wUwrHaqYN3CJnLRo71eoIyBsvku5gZs6p/s mp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc; bh=XOIO6yMrJJaBLCVdiKJxecGrRstBRdkXKAU8JD1YObM=; b=q5MpQSHg+8yd0ZdXirIRjJrH8/2gY51VVgKwsHuIqa2rogM0bOY97Pbw9WSvmiMGAr C1cGlNGPLSuPM1ADintcqr4bELKmXdw1g7MQJLiL9AMhSWVHdzipTQntWcaX3xUimXaz geFqiGtOYNK1BhBhlHUiaX06Z7VRaRdJaD4rsc28m/PRbEC3aa1KaCmCOtV/d54lCAer 0P+LMUZBlAYkyE9xVw92HYnqlwW7Bp55C+Erq5fkOMhVQWzQwd5/MrvtEebvXP3IJV/g 8uLxhxxzDx12qaeZ9syZuwep+rg9Dp1bN6m72aJQfi+5mJx+wwnfWqJFlEeVisudgfXJ jG7g== X-Gm-Message-State: ACgBeo0P+A5S1xHX0o/S3HV1bvCURhHFHqHM9XhB45MQOT+5Pwa8l3lm MxUvmncLHFO4riiWtpp5J3uJM0QVecA= X-Google-Smtp-Source: AA6agR70pOgUYoVn/e77Ld0R/nqA9LDlWtFjFwsnYYnj15N1nfRnKaSK4PvjO0uXZsTDiRTt9eMo2zal+mA= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a0d:e6cc:0:b0:338:c82b:9520 with SMTP id p195-20020a0de6cc000000b00338c82b9520mr151356ywe.66.1661526556996; Fri, 26 Aug 2022 08:09:16 -0700 (PDT) Date: Fri, 26 Aug 2022 17:07:46 +0200 In-Reply-To: <20220826150807.723137-1-glider@google.com> Mime-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220826150807.723137-24-glider@google.com> Subject: [PATCH v5 23/44] virtio: kmsan: check/unpoison scatterlist in vring_map_one_sg() From: Alexander Potapenko <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Alexei Starovoitov <ast@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, Andrey Konovalov <andreyknvl@google.com>, Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@alien8.de>, Christoph Hellwig <hch@lst.de>, Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Dmitry Vyukov <dvyukov@google.com>, Eric Dumazet <edumazet@google.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Herbert Xu <herbert@gondor.apana.org.au>, Ilya Leoshkevich <iii@linux.ibm.com>, Ingo Molnar <mingo@redhat.com>, Jens Axboe <axboe@kernel.dk>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Kees Cook <keescook@chromium.org>, Marco Elver <elver@google.com>, Mark Rutland <mark.rutland@arm.com>, Matthew Wilcox <willy@infradead.org>, "Michael S. Tsirkin" <mst@redhat.com>, Pekka Enberg <penberg@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, Vasily Gorbik <gor@linux.ibm.com>, Vegard Nossum <vegard.nossum@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661526557; a=rsa-sha256; cv=none; b=zTMJitVZi/yGDpjBii6LSnq+90tRWAtmXsomoYjX9jaf3d/AkgbMrSOXiq/0LXsy/7p2zI /tHPXFSY6jQkBqFb2r0HS0FVQEKTDc609pQQJizp4EK5rwWZMSMjBBO/7oXvI4hS7AXskV 1Xop2lFxWgS/j2D9f+5Vp+K4LXFlZE0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RBRSbeDr; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3HOIIYwYKCCMFKHCDQFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--glider.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3HOIIYwYKCCMFKHCDQFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661526557; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XOIO6yMrJJaBLCVdiKJxecGrRstBRdkXKAU8JD1YObM=; b=X+fiXzF2r+Bs0hexJcojzof5SKgN6y3Wase3Ql8PjS8Zx4Hv92ISaUFwT8EwaXjvnjyKN1 l/sBpcZEjB+XUrjJmrFaQcfzT1I+6OKSgknn2R/qxDhX+xhjFiqVcieGqcfFSk+JZoFs41 Xy+HdgO960NUWu8m9bZV6B8XgHfS0CU= Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RBRSbeDr; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3HOIIYwYKCCMFKHCDQFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--glider.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3HOIIYwYKCCMFKHCDQFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--glider.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hnxb6ycgpbq1pgietkea19a6fu66wibh X-Rspamd-Queue-Id: A9B82C0015 X-HE-Tag: 1661526557-799243 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 4620e9d79dde8..a9f06ec5b3c27 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 <linux/spinlock.h> #include <xen/xen.h> @@ -352,8 +353,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