Message ID | 20220826150807.723137-36-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 E44A5ECAAD4 for <linux-mm@archiver.kernel.org>; Fri, 26 Aug 2022 15:09:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E788940010; Fri, 26 Aug 2022 11:09:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77028940007; Fri, 26 Aug 2022 11:09:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EA0F940010; Fri, 26 Aug 2022 11:09:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4CE33940007 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 11:09:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E6FB80E5A for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:52 +0000 (UTC) X-FDA: 79842078624.09.1A7DB53 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) by imf28.hostedemail.com (Postfix) with ESMTP id E0892C0031 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:51 +0000 (UTC) Received: by mail-ed1-f73.google.com with SMTP id b12-20020a056402278c00b00447f2029741so1135568ede.23 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 08:09:51 -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=+OT6SjVSfWjyqzxbCZyABchDUcmsVpvJACt5vGUex24=; b=Z6njr41sW+TrPWrMaWFwC05L0RlOcYNPG3bg02BhPFfdHpKhjWZb3JQSd3EE7bQR4t BLm0gQ80M2u3Pdlj1pDIh1/qXUSrg7ZtmpWtyd9GiSzXUcv17N5l1NutHYYducPw8Nm1 53fip5LebyiAQRD1QGNbSqOqemN8I8dcjPld+gmWIt0k8q85y5Jr57b99LSEVn0lBt+H zdJQxrYdMQVOvNNpr1+RziHtXPGmKyGhGOD17LJ7bJ7AAVD99iIBY1+G52ypCLREDV+F yPwT4hR+BLBGY/xYmzyBjGu/5to6IUIp+jowlZqMWLLM1SmRm2HCrOTVeGnkhu8gk10k xggQ== 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=+OT6SjVSfWjyqzxbCZyABchDUcmsVpvJACt5vGUex24=; b=DsJ8/2f7Hn17IjcRwW/xRqsC5qw6kGIiD1ZcmLQJOW7EPAm7T1o2kgc2rdiiik5+cq zuGTc4DZher/Gd33hyP86F/uSm/7hS2yS+cYHF6O2rwXnW5cq0BOr7UDxxCfroJthZHG 7EnEvHX7e88jixkSjU6C1xAwCWaFmIVDXFHFgaLN/cCwNqzoz2eijkqapfet8BJLT1s3 UHCsNF8y8dcQ3Zxem/UXch+CEDiNcZAV6fj+VlMb4zf3Ix1dAAo/Pd9jod4Nasg2/qoZ SD9CAIJGhJ7pFK7NpJMMuQp9E8+EoMuTmMY1HphRm2PQU8NrErT68IwZiUVGiCbmp8by vcEA== X-Gm-Message-State: ACgBeo0NxeJTV+L1m/uyh+lSxwWuHJfo19GrPpf6sQvT15uWnQwEp9PA 5Hyb+HBYaUyT1ext91rLyd3ZyxMGQIc= X-Google-Smtp-Source: AA6agR4t0eef92ReeAZR+Mrv7r8ag8b4BdV1NIADifSFVxHgYfyFuws8EoWxRalcgwj85FhAMYNvlh2MVzI= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a05:6402:43c6:b0:43d:79a6:4e32 with SMTP id p6-20020a05640243c600b0043d79a64e32mr6871771edc.281.1661526590665; Fri, 26 Aug 2022 08:09:50 -0700 (PDT) Date: Fri, 26 Aug 2022 17:07:58 +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-36-glider@google.com> Subject: [PATCH v5 35/44] x86: kmsan: handle open-coded assembly in lib/iomem.c 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-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Z6njr41s; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3PuIIYwYKCEUnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3PuIIYwYKCEUnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661526591; a=rsa-sha256; cv=none; b=ky3W86vD7ZmzAUSK8+zP8olCaAuO+Zw1nx2PGm62qxho/wS3rW8860DvqKUm2DiO8VAJdW w7GZ9SN5LgbNGrgS+ZBxN5j6AnzxdxxI6iaXwsTpIw5vhBAv2N0ra+H8K0fFBGX1/Mu0i1 RKvgy01jAZJZ+paEkwCYnwK4073PfEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661526591; 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=+OT6SjVSfWjyqzxbCZyABchDUcmsVpvJACt5vGUex24=; b=jVMOsMS+0lSIpC6V8aVJ+jJCTUISbNYqryO9BHC+tHibBt0bqv4xbhTWfAK+Atv49A08YA t3kcfhgzdKYawmcjr+4fCVlkQKgjUEN+c/kJEmuID0RZM4dq7E39rk4pNMR9L6y2jdwjpp Nyr4TZm6eAtpZbJAJzipnDAVIpBdN4A= X-Rspam-User: X-Rspamd-Queue-Id: E0892C0031 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Z6njr41s; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3PuIIYwYKCEUnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3PuIIYwYKCEUnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com X-Stat-Signature: yy3jmpjhuaz8r7cpoytsh8wdft18yofh X-Rspamd-Server: rspam03 X-HE-Tag: 1661526591-654583 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/arch/x86/lib/iomem.c b/arch/x86/lib/iomem.c index 3e2f33fc33de2..e0411a3774d49 100644 --- a/arch/x86/lib/iomem.c +++ b/arch/x86/lib/iomem.c @@ -1,6 +1,7 @@ #include <linux/string.h> #include <linux/module.h> #include <linux/io.h> +#include <linux/kmsan-checks.h> #define movs(type,to,from) \ asm volatile("movs" type:"=&D" (to), "=&S" (from):"0" (to), "1" (from):"memory") @@ -37,6 +38,8 @@ static void string_memcpy_fromio(void *to, const volatile void __iomem *from, si n-=2; } rep_movs(to, (const void *)from, n); + /* KMSAN must treat values read from devices as initialized. */ + kmsan_unpoison_memory(to, n); } static void string_memcpy_toio(volatile void __iomem *to, const void *from, size_t n) @@ -44,6 +47,8 @@ static void string_memcpy_toio(volatile void __iomem *to, const void *from, size if (unlikely(!n)) return; + /* Make sure uninitialized memory isn't copied to devices. */ + kmsan_check_memory(from, n); /* Align any unaligned destination IO */ if (unlikely(1 & (unsigned long)to)) { movs("b", to, from);
KMSAN cannot intercept memory accesses within asm() statements. That's why we add kmsan_unpoison_memory() and kmsan_check_memory() to hint it how to handle memory copied from/to I/O memory. Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/Icb16bf17269087e475debf07a7fe7d4bebc3df23 --- arch/x86/lib/iomem.c | 5 +++++ 1 file changed, 5 insertions(+)