Message ID | 20191220184955.223741-30-glider@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=GDT+=2K=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 25FD8139A for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 20 Dec 2019 18:51:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7098206D8 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 20 Dec 2019 18:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PRhxAuZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7098206D8 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 C68F58E01C0; Fri, 20 Dec 2019 13:51:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C18118E019D; Fri, 20 Dec 2019 13:51:35 -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 B07D58E01C0; Fri, 20 Dec 2019 13:51:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 994CD8E019D for <linux-mm@kvack.org>; Fri, 20 Dec 2019 13:51:35 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 5CF548249980 for <linux-mm@kvack.org>; Fri, 20 Dec 2019 18:51:35 +0000 (UTC) X-FDA: 76286413350.11.sort85_8238750166663 X-Spam-Summary: 2,0,0,3d23dd608de44263,d41d8cd98f00b204,3nrj9xqykcfay30vw9y66y3w.u64305cf-442dsu2.69y@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com:elver@google.com:andreyknvl@google.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org: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:jasowang@redhat.com:axboe@kernel.dk:m.szyprowski@samsung.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:mhocko@suse.com: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.c om:tytso X-HE-Tag: sort85_8238750166663 X-Filterd-Recvd-Size: 5578 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf16.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Fri, 20 Dec 2019 18:51:34 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id y125so4352495wmg.1 for <linux-mm@kvack.org>; Fri, 20 Dec 2019 10:51:34 -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=sBPvokdmOb4+jixnZRxRT84LYKy2EwXQk4bdSICtBpU=; b=PRhxAuZphNCbMSSUwPBLm+fKGURQduz3lGtixwo/N2j7baCKsGVwIuEHv4AmL+ZYvB a+AG8XM+qqnU2Ml66kd7ErgySgOKun0mKVAD796zqwa2nif5p0Llr1ZtKJ47DA+nzQY0 2i0LRsY1/rkxIoEll94maN7lNmAwfUh/lhBIR56Z+IRLdPXfl9jxwtYN8IvZ5OqvLr3b FnD9VP6ne00KtHGn5Y93wDrWRt9jvmUg2oNrngXhqpZQluzTR4wb7QzxGW+vKij6VmH6 aMqEEkbfttTfOLgBo/CPrBM0eANtKfCOOtMhOCFrcTDzg7fuaQ3xtH8830kCgmKD6T1A i1rQ== 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=sBPvokdmOb4+jixnZRxRT84LYKy2EwXQk4bdSICtBpU=; b=S8UTJchUmhcgjb0kfTkzX+Lo2GRwuDtzXAhKuJFms+ZZA18by0569hOm+5coG59rqS sEfC7knXRtRM9SlMqn2Q3aafaaoS7u5PpjvHth6iXTMU8GPZISYRAw+OnREvvTA1CA8c iVX7c2z060VmLHNgCbSRu+twp/He5y3kMoeM4Pzg2I7qWiL2itq12Q4D9cx5oiKI9yF8 EIJiSeKWoD4CZQecA+qKFhk8ctRYE1mglT7wYf4oYIqAMXrgdFdqbb0mhFblaX8/FtgF B242jfdQk4C0RU2MX4SGje/FL58giXIWmhs8eDiyNiS94qnX/aK8m1DnEUcvKUBD0J4f NZ3g== X-Gm-Message-State: APjAAAWHccS5nTNdw9STgHGq5fmU3zKNGlxcBRcJQqwQHQCL07/y6dBS OOiXk2fS4g3tDTS9SiC9oSCPooBxSDE= X-Google-Smtp-Source: APXvYqxiX8kRW1mpVOkCm3BVAvrPMlGlUwlg38j7FjBepEaysqcM37Q2fqAvCn39vKxPfHAUjW/Am1ZiGb4= X-Received: by 2002:adf:f606:: with SMTP id t6mr16176185wrp.85.1576867893283; Fri, 20 Dec 2019 10:51:33 -0800 (PST) Date: Fri, 20 Dec 2019 19:49:42 +0100 In-Reply-To: <20191220184955.223741-1-glider@google.com> Message-Id: <20191220184955.223741-30-glider@google.com> Mime-Version: 1.0 References: <20191220184955.223741-1-glider@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH RFC v4 29/42] kmsan: unpoison |tlb| in arch_tlb_gather_mmu() From: glider@google.com To: Vegard Nossum <vegard.nossum@oracle.com>, Dmitry Vyukov <dvyukov@google.com>, Marco Elver <elver@google.com>, Andrey Konovalov <andreyknvl@google.com>, linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, 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, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.com, 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/mm/mmu_gather.c b/mm/mmu_gather.c index 7d70e5c78f97..28105c267268 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/pagemap.h> @@ -206,6 +207,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb) void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) { + /* + * 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_shadow(tlb, sizeof(*tlb)); tlb->mm = mm; /* Is it from 0 to ~0? */
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> To: Alexander Potapenko <glider@google.com> Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Marco Elver <elver@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: linux-mm@kvack.org --- v4: - removed a TODO, updated patch description Change-Id: I22a201e7e4f67ed74f8129072f12e5351b26103a --- mm/mmu_gather.c | 10 ++++++++++ 1 file changed, 10 insertions(+)