Message ID | 20220426164315.625149-22-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 F1FCAC433EF for <linux-mm@archiver.kernel.org>; Tue, 26 Apr 2022 16:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F71F6B009B; Tue, 26 Apr 2022 12:45:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77FC86B009C; Tue, 26 Apr 2022 12:45:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66EDC8D0001; Tue, 26 Apr 2022 12:45:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 5999E6B009B for <linux-mm@kvack.org>; Tue, 26 Apr 2022 12:45:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3032020CFB for <linux-mm@kvack.org>; Tue, 26 Apr 2022 16:45:17 +0000 (UTC) X-FDA: 79399605474.15.BA0E6AC Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf09.hostedemail.com (Postfix) with ESMTP id 80CDE140048 for <linux-mm@kvack.org>; Tue, 26 Apr 2022 16:45:13 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id sh14-20020a1709076e8e00b006f3b7adb9ffso1014271ejc.16 for <linux-mm@kvack.org>; Tue, 26 Apr 2022 09:45:16 -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=vFqZ9iNZJAVQIjd7MnY5jhYV4PJ/+WpYoNR2VRSWpiM=; b=eaD4tCJ/YLTDe4ajl2gQ/TiaUeEA4djHXSqlMDmsulc+qbwyzuVd2W9yINHg7fHnga 3Y+nBojMivWb/vlWu7aJjqdQ3YqnLBqv0yN1IxxX322BLlHzj3IM9ELCwxkKAp16qOhv LyADFdDfCUsE+lxz9NxlRdyYnWL3NGagYS8JkeULjygmzHGrjysJLw6McGcbkSgOELQg 1Rc7TqbJxh506aPuLFlQCeuB/YWI3RUvsBYyts3m6+c10BC++lIyRNin1VxoT8iWyPi+ 5eWh+n4wLJVVQzkWe/7aM9SIO+vr3tXqfKqj3v7+4FSCDACZ5wNHzbimfz+M1Qn6e6s2 Njyw== 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=vFqZ9iNZJAVQIjd7MnY5jhYV4PJ/+WpYoNR2VRSWpiM=; b=YTihtTE5kWadIvhictlFEJa1GAEb0xMeKb4NXFL2AOa6NWrrsrkmtzRBWEptgAMYcF /GZbZGh+EwTSseKUFgSos4k9NJ7KN+SWz5Okrz1ramIksjxvO4jMWqsgyLROgda7jcIK W11RLOKjvmQ7Bgn2elZVKAktv8kZoDnDUU9XuwOFJ84INXfa2IP/+GkOJ27CwdDJlddD lVi8SzcsuOVQXryJ7mS3xgJj+DP8btSiDxgjrsWG62SJ/0fdbORHQqqGptGRnL9c9cBO bNdm/jUw9wq1aVX4ehFpebWusJQZurfZiqMjYZaIvp1O9hdtE8a+uDm9yy2rrtDRRr/X 6byQ== X-Gm-Message-State: AOAM533qdbLTULKec2AizysftM4MfWURbo2evIQ6LzcZQHksli0R4f/X UP9xmlciaiK/yFenni3PMC4q2OInlXY= X-Google-Smtp-Source: ABdhPJxSGoEtwF4OOq0yTBsFRqUEi4ydvzEhY/S3s2+/j9D6/negQ9CVvZDUHjNLSrRATTf6/ojzjnCmZdU= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:a17:906:3e05:b0:6f3:a14a:fd3f with SMTP id k5-20020a1709063e0500b006f3a14afd3fmr7558438eji.640.1650991515225; Tue, 26 Apr 2022 09:45:15 -0700 (PDT) Date: Tue, 26 Apr 2022 18:42:50 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-22-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 21/46] kmsan: unpoison @tlb in arch_tlb_gather_mmu() 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>, 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" X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 80CDE140048 X-Stat-Signature: 37jj7pctnagcupu8enxobn6refiyisk1 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="eaD4tCJ/"; spf=pass (imf09.hostedemail.com: domain of 3myFoYgYKCJg8DA56J8GG8D6.4GEDAFMP-EECN24C.GJ8@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3myFoYgYKCJg8DA56J8GG8D6.4GEDAFMP-EECN24C.GJ8@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1650991513-883791 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/mm/mmu_gather.c b/mm/mmu_gather.c index afb7185ffdc45..2f3821268b311 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -1,6 +1,7 @@ #include <linux/gfp.h> #include <linux/highmem.h> #include <linux/kernel.h> +#include <linux/kmsan-checks.h> #include <linux/mmdebug.h> #include <linux/mm_types.h> #include <linux/mm_inline.h> @@ -253,6 +254,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb) static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm) { + /* + * struct mmu_gather contains 7 1-bit fields packed into a 32-bit + * unsigned int value. The remaining 25 bits remain uninitialized + * and are never used, but KMSAN updates the origin for them in + * zap_pXX_range() in mm/memory.c, thus creating very long origin + * chains. This is technically correct, but consumes too much memory. + * Unpoisoning the whole structure will prevent creating such chains. + */ + kmsan_unpoison_memory(tlb, sizeof(*tlb)); tlb->mm = mm; tlb->fullmm = fullmm;
This is a hack to reduce stackdepot pressure. struct mmu_gather contains 7 1-bit fields packed into a 32-bit unsigned int value. The remaining 25 bits remain uninitialized and are never used, but KMSAN updates the origin for them in zap_pXX_range() in mm/memory.c, thus creating very long origin chains. This is technically correct, but consumes too much memory. Unpoisoning the whole structure will prevent creating such chains. Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/I76abee411b8323acfdbc29bc3a60dca8cff2de77 --- mm/mmu_gather.c | 10 ++++++++++ 1 file changed, 10 insertions(+)