From patchwork Fri Nov 22 11:25:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257877 Return-Path: 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 591F814DB for ; Fri, 22 Nov 2019 11:26:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1984A20674 for ; Fri, 22 Nov 2019 11:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jx2fnSSm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1984A20674 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 C357A6B04D2; Fri, 22 Nov 2019 06:26:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BE6D66B04D3; Fri, 22 Nov 2019 06:26:56 -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 A62E36B04D4; Fri, 22 Nov 2019 06:26:56 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 8E7FC6B04D2 for ; Fri, 22 Nov 2019 06:26:56 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 3D46F180AD81C for ; Fri, 22 Nov 2019 11:26:56 +0000 (UTC) X-FDA: 76183686432.12.honey97_24ba7f51b807 X-Spam-Summary: 2,0,0,c36d82f5fdca2a12,d41d8cd98f00b204,3_sxxxqykcn0fkhcdqfnnfkd.bnlkhmtw-llju9bj.nqf@flex--glider.bounces.google.com,:axboe@kernel.dk:luto@kernel.org:vegard.nossum@oracle.com:dvyukov@google.com:hch@lst.de::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com:aryabinin@virtuozzo.com:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org: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:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.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@li X-HE-Tag: honey97_24ba7f51b807 X-Filterd-Recvd-Size: 5559 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:26:55 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id e3so3712349wrs.17 for ; Fri, 22 Nov 2019 03:26:55 -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=HxY/e5efS8deUXBIIbyEg4j3CHlTRT+PZQjM32fChqc=; b=Jx2fnSSmSDb0jaHzNUf6QdqWuUA0scsCDUGUqeGHjgtulgYY6nWVkxL3co/TBcM5/E NUQZcoRlRDkCXXPMlAWHpdWK2qZBeHh29oCMkqUxe7BrEhXfyuY63OuzpzqaeB5T6ipi JupOkL1KJTIlwPM0kXF/apVMpVDoK0A3fsYL7WJqPCDMFaFdU/iB3we+Bc/zP0/TsCn2 oz22i+sWnD2r1JHeCzjXl1q06tV02OQ6wT2Ki1JhNM0i1YPT2QEPw0ssJ+TDcXRXRaKw JuRvScdb0C4F9J9GjZHkbO4EJdeirVUt7ONuwXJ8hrTOVRD+GRvbzn5UdvmidaPYAAzh MW1Q== 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=HxY/e5efS8deUXBIIbyEg4j3CHlTRT+PZQjM32fChqc=; b=Hdxd4DA2iDIt/d/NaeonxN75cUTc+es5WGLXYvROgWugufTkyymFu0XjecdGMRIrfk J2V7SmK1PEkg56ClhNqHho236Y9iJw5OS0oxO3m4hBqylpem7vBvLhURVPQ3KArXr+4U 4ztYYMNcCRB+dlq3OVSJLlfWBC4iMeQeb2KjPkdwwZZ4G2O2bYV3XbX6USTZNMwBT/vj PkguiuQZUtGJXcXpIwkhgq+l2PHi04lWPrNQdOP4wtpyYrOs2ifxsiNZsTtjIpw+GqaX aNZy4RwobGZ4SXe8lm/flH0dnCJ1ePtNcjumT5iFcr0EjgrE5kp8WulYM45sd6ZYbAks D6Nw== X-Gm-Message-State: APjAAAWxUJBs/b47T8Ja7Es1NeECdw1TUsIKK19Qi8a2eaiqJQXqUDal c7ayZIfz8LmDuUrAw7i89k8jKvCj0tY= X-Google-Smtp-Source: APXvYqx/+I53WIV+DxLj/ituEPWvhZjIzNL/U+lgeAeiCz7ii3eDaAaXa3/ZcArWEaG+FUExPBtrql4i5P8= X-Received: by 2002:a5d:66cf:: with SMTP id k15mr16967137wrw.38.1574422014307; Fri, 22 Nov 2019 03:26:54 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:54 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-10-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 09/36] kmsan: add KMSAN bits to struct page and struct task_struct From: glider@google.com To: Jens Axboe , Andy Lutomirski , Vegard Nossum , Dmitry Vyukov , Christoph Hellwig , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, andreyknvl@google.com, aryabinin@virtuozzo.com, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, 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, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.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 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: Each struct page now contains pointers to two struct pages holding KMSAN metadata (shadow and origins) for the original struct page. Each task_struct contains a struct kmsan_task_state used to track the metadata of function parameters and return values for that task. Signed-off-by: Alexander Potapenko Cc: Jens Axboe Cc: Andy Lutomirski Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Christoph Hellwig Cc: linux-mm@kvack.org --- Change-Id: Ie329527e558dd60307fb88b2da151f7f4db951ac --- include/linux/mm_types.h | 9 +++++++++ include/linux/sched.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 2222fa795284..c87c5416a802 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -216,6 +216,15 @@ struct page { not kmapped, ie. highmem) */ #endif /* WANT_PAGE_VIRTUAL */ +#ifdef CONFIG_KMSAN + /* + * Bits in struct page are scarce, so the LSB in *shadow is used to + * indicate whether the page should be ignored by KMSAN or not. + */ + struct page *shadow; + struct page *origin; +#endif + #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid; #endif diff --git a/include/linux/sched.h b/include/linux/sched.h index 72b20f33c56e..ba705f66f78c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1173,6 +1174,10 @@ struct task_struct { unsigned int kasan_depth; #endif +#ifdef CONFIG_KMSAN + struct kmsan_task_state kmsan; +#endif + #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* Index of current stored address in ret_stack: */ int curr_ret_stack;