From patchwork Fri Nov 22 11:25:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257885 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 074F91593 for ; Fri, 22 Nov 2019 11:27:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C86A120672 for ; Fri, 22 Nov 2019 11:27:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OZb0FAr7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C86A120672 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 4BC4D6B04D8; Fri, 22 Nov 2019 06:27:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 493C06B04DA; Fri, 22 Nov 2019 06:27:09 -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 3A9B86B04DB; Fri, 22 Nov 2019 06:27:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id 1DAC66B04D8 for ; Fri, 22 Nov 2019 06:27:09 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D81113A9B for ; Fri, 22 Nov 2019 11:27:08 +0000 (UTC) X-FDA: 76183686936.17.quill79_42382b40374f X-Spam-Summary: 2,0,0,c4c86e7e246e74bd,d41d8cd98f00b204,3csbxxqykcokrwtopcrzzrwp.nzxwtyfi-xxvglnv.zcr@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com: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: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: quill79_42382b40374f X-Filterd-Recvd-Size: 5215 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:27:08 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id f191so3297342wme.1 for ; Fri, 22 Nov 2019 03:27:08 -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=Gp4KYo9RUuZ5+hrUebYWIeNuLUp9JL+k3mENfZ2WLUk=; b=OZb0FAr7eTVAlgRmOSHb89LwlK2LvNcZ8/+0A1cCZ6DyESVExA3ZsdihDWlV3QsJ/p Z43o256JWMZqnCgAcYIZqSZ1Cm9T94iVoWwvcRQm4oyGmkeAusbcx2EP86bfWixbzctW hAYBPWIw2tMSMZegMVrDrHOdudBQnl9/tpBFBGybXn488cl8m604qrfxzX0DOkDGaiCs uH0YQbOul1K89WjhBUgYtdd4Lv1u98Ta/cUvEXXYQOE6C2hJUg56urjCB9eDVGB9Yoml WY/6ZPNRSWftXT9/NxDICQcXMZR/4DMJBqTsd1dP+hy5vCN7FYCNI4erTBapkDKkjBT9 Zpew== 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=Gp4KYo9RUuZ5+hrUebYWIeNuLUp9JL+k3mENfZ2WLUk=; b=ZWSpsAGn22AbMzlvucJhw5yhUT6/5QZCsqo28jaawLnqhPsHrMf5i1vSBi2nZUt0fg CBqibeWj60DSHwqGSrMzdJy3+Q0EZbTpEpv5lJLHNAEh5ZDk0ZCS1M8xmoBciRQripVz 3iItXOnagSW+vwrQdkJ4aYl+tkdPCzUoOeiKXk9VTidUmP9pkKZ/E82wR2cvv7t567yh To+NySfq2Uqe+RneHqGO3MIas9gkLrTmx8b1nvCJXhN1hhvfVHNBtyAqlbzuqhsBGQX7 0MWXT/2ihk+0K9t04HjoAu/phQXZ+KDGxfASpl+K8y7OoZmI5Z861stLLzPr3RHnpI9S LmuQ== X-Gm-Message-State: APjAAAUE1m/hgHc1Ynk7t++mTRk/2kZwSIezeg5AOX8CHkuf45g49Mq9 cUKjwZ4Yq/L68Z1z4q+0VCY0xhvGlQo= X-Google-Smtp-Source: APXvYqwmtuS1mWPQt9J6bwXo126QmuGnDArQtwTSRstKHhPmNL6Qy/LsYvyrXIfbljMmFQZB7+E+ZLIcdpU= X-Received: by 2002:adf:f18e:: with SMTP id h14mr17873964wro.348.1574422026834; Fri, 22 Nov 2019 03:27:06 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:58 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-14-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 13/36] kmsan: make READ_ONCE_TASK_STACK() return initialized values From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , 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, 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, 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: To avoid false positives, assume that reading from the task stack always produces initialized values. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org Acked-by: Marco Elver --- Change-Id: Ie73e5a41fdc8195699928e65f5cbe0d3d3c9e2fa --- arch/x86/include/asm/unwind.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 499578f7e6d7..f60c2bd1ddf2 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -100,9 +100,10 @@ void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size, #endif /* - * This disables KASAN checking when reading a value from another task's stack, - * since the other task could be running on another CPU and could have poisoned - * the stack in the meantime. + * This disables KASAN/KMSAN checking when reading a value from another task's + * stack, since the other task could be running on another CPU and could have + * poisoned the stack in the meantime. Frame pointers are uninitialized by + * default, so for KMSAN we mark the return value initialized unconditionally. */ #define READ_ONCE_TASK_STACK(task, x) \ ({ \ @@ -111,7 +112,7 @@ void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size, val = READ_ONCE(x); \ else \ val = READ_ONCE_NOCHECK(x); \ - val; \ + KMSAN_INIT_VALUE(val); \ }) static inline bool task_on_another_cpu(struct task_struct *task)