Message ID | 20220329124017.737571-7-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 AF9AAC433F5 for <linux-mm@archiver.kernel.org>; Tue, 29 Mar 2022 12:40:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E38E8D000E; Tue, 29 Mar 2022 08:40:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 393398D000D; Tue, 29 Mar 2022 08:40:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20C958D000E; Tue, 29 Mar 2022 08:40:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 0F7238D000D for <linux-mm@kvack.org>; Tue, 29 Mar 2022 08:40:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6B591828A7F9 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:40:45 +0000 (UTC) X-FDA: 79297382850.25.717828C Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf23.hostedemail.com (Postfix) with ESMTP id 72524140003 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:40:45 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id f2-20020a50d542000000b00418ed3d95d8so10959508edj.11 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 05:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=f/cngww90lUXjaM8lQFtWcyKhuwI9PqnftLYJV81Lhc=; b=ZhkI15SJzz773ZYscrUiWSWJETsRZFPteEYHqIHePZDMxUIF+3PQF+2Fw76owrqA6c UPmlNmwXK1Z6638+mZDSIi3ZaYImXqe+Uh0pSLh1rhQp3Xoe7jl74OrGzrvEG7z0eTSq o8MSM+eKeJVRDYa5y/OP8y60rroWEDJ8vzz/DDepligD6r9qfkOI3I92z4rW1hHLRtic cm0rD0pMAAL/xX1aSmAtPrmorukG9QpyLNGeNh6R44fL+JlPunKHnHJWEF85pS921n3e lbvxIMwP6/gs5F0Sdc52ZKShD71Ts7NFaxuC1noz1+PVJK55QErm2j6Lz/PX6SBoULEe K4FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=f/cngww90lUXjaM8lQFtWcyKhuwI9PqnftLYJV81Lhc=; b=ScTIuCgnrd4xMZ7DUYZopVsI9wlFHlQmIED3mIxFrtmDk7tLJXNal4Fmqji0uJdjvB 8XEZxP/aw4wRkyY+LYv1eTW0Uve1XSp8P47IgzLEVmt8RvTxRoCWHazTADWgBke8CalT cGpp3hqb5oL/DLOAPeyeS1ni8+WyeTgqoO235ovLeZRRfwvSduUFRoYTQDbyjoimngHi girXCsRTK2A4y5/dAExplw4RCW7nnmXIJAiGpAcde8pq+H6+lLy7CGxup5M82o6OSvfN Z4D5fJSvpip5aEa5BCl4wNx/CtJcodbigg4zwVisoPaaaih4z+t+TF0mEsOxDOEdXViq oF4w== X-Gm-Message-State: AOAM5319Zu6hgN9VPZNpkLIjisvfsPsOlLwId85jFqxssIuivU57lQWx 1t6v4iIMrdwO6EcC7xgrhWRDSbs81nw= X-Google-Smtp-Source: ABdhPJx0Sl5gQKr3lXwaLxCri9MHvRT0DK5gtdgM1us4GPzvAAhQsz1qiosUClgYfwn1c4jOcnHsaUZStL0= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:478e:b0:6db:7c67:c7e0 with SMTP id cw14-20020a170906478e00b006db7c67c7e0mr34151057ejc.335.1648557643821; Tue, 29 Mar 2022 05:40:43 -0700 (PDT) Date: Tue, 29 Mar 2022 14:39:35 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-7-glider@google.com> Mime-Version: 1.0 References: <20220329124017.737571-1-glider@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2 06/48] asm-generic: instrument usercopy in cacheflush.h From: Alexander Potapenko <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, 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>, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: z6jrcxxwmmqpntfsmqcs5k3bsnk7sts9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 72524140003 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ZhkI15SJ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 3S_5CYgYKCGwQVSNObQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3S_5CYgYKCGwQVSNObQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--glider.bounces.google.com X-Rspam-User: X-HE-Tag: 1648557645-75694 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/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h index 4f07afacbc239..0f63eb325025f 100644 --- a/include/asm-generic/cacheflush.h +++ b/include/asm-generic/cacheflush.h @@ -2,6 +2,8 @@ #ifndef _ASM_GENERIC_CACHEFLUSH_H #define _ASM_GENERIC_CACHEFLUSH_H +#include <linux/instrumented.h> + struct mm_struct; struct vm_area_struct; struct page; @@ -105,6 +107,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) #ifndef copy_to_user_page #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ do { \ + instrument_copy_to_user(dst, src, len); \ memcpy(dst, src, len); \ flush_icache_user_page(vma, page, vaddr, len); \ } while (0) @@ -112,7 +115,11 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) #ifndef copy_from_user_page #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) + do { \ + instrument_copy_from_user_before(dst, src, len); \ + memcpy(dst, src, len); \ + instrument_copy_from_user_after(dst, src, len, 0); \ + } while (0) #endif #endif /* _ASM_GENERIC_CACHEFLUSH_H */
Notify memory tools about usercopy events in copy_to_user_page() and copy_from_user_page(). Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/Ic1ee8da1886325f46ad67f52176f48c2c836c48f --- include/asm-generic/cacheflush.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)