From patchwork Fri Dec 20 18:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11306161 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 690C56C1 for ; Fri, 20 Dec 2019 18:50:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34A9A20866 for ; Fri, 20 Dec 2019 18:50:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WoW2NBt5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34A9A20866 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 E8A0C8E01B1; Fri, 20 Dec 2019 13:50:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E61398E019D; Fri, 20 Dec 2019 13:50:47 -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 DA0438E01B1; Fri, 20 Dec 2019 13:50:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id C2BD98E019D for ; Fri, 20 Dec 2019 13:50:47 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 8AAEC8249980 for ; Fri, 20 Dec 2019 18:50:47 +0000 (UTC) X-FDA: 76286411334.29.boats69_7b446a0a49b4b X-Spam-Summary: 2,0,0,454ae407a775eed4,d41d8cd98f00b204,3brj9xqykccache9anckkcha.8kihejqt-iigr68g.knc@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: boats69_7b446a0a49b4b X-Filterd-Recvd-Size: 5616 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Dec 2019 18:50:46 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id g26so2205116wmk.6 for ; Fri, 20 Dec 2019 10:50:46 -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=RwnlpOY4tCkNTmMYsU2o+2AeZF4El5Kix01F9MyqOmI=; b=WoW2NBt5uKITKc1NlGOm/BtN2Mkrv9yZPp74Cey5RD8AFatyy+Oc56w+l78qrmAHsQ PyNaQ8PCMLyFHb2jwHDNNIa5/4JzB9Z/YyrB/6lFbuGvWgoiYXa946fT3sFcNyH4KbiA AQn6KVTv7BXKe6Np6XR059COpcY+piM1gNWzZpgrT+ROuMtqMYYwEJDZyTdwSWG92HYe /La8u8o+F/ZRymQX7EibA3Kj6PxEGv1tQYCMdRIwzbVxFSMuUskaYVzA1LgiPWjievqd ttJqnlZuPQhE4fuBoRsWLlwVKF9FiY2ety5nxWxTZBM1KW0BYDcVGQc+vmt2tJBDiae+ Wpsw== 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=RwnlpOY4tCkNTmMYsU2o+2AeZF4El5Kix01F9MyqOmI=; b=B10+xDeqrKl/tZMOfNwV9oDh85Gihaz7IBU/AWo6aOW60dvjLLxxxWTR6hJo3gaPWx ulERmzpeqCXwqblHl6USc5AWLSX95+eNuM0TGSuvA8tSKcvq3J1z4ATbeQfqY08VEt7b isI96saYPq8aWS55+TxKgNbCdHYneWf83Dn4n1Am++XRWdRPK+sX43HXJNI81W5OykCr VZqL3Hvh3+jxxSmC0eLCb19VFUwncSYJmAe+1WafsO9BGUVSUdyqUzqc4VCUFcQoTKJy qSw1kqF+7v533VeJ4GFQKlDTLoGclaXQzYOq2lVjv2pcRLxwoPVL7wjQSPBmFuIb1VCR yLdg== X-Gm-Message-State: APjAAAXLdfvhB9kEK+bVPOp+fhKfJNOtJuSIFfQg2UaqvRSAX4oLfQ6G HrdXMLdwD1uUKSvgdPCKIgttwbQGlkA= X-Google-Smtp-Source: APXvYqw7JQ14Tsb+4TXClYlu4q7wvaIK772QF6cXH3ug1yUtYVh9mQJHhTV5ibhVvujRECssjlmFNWA/MQQ= X-Received: by 2002:adf:ed83:: with SMTP id c3mr16264390wro.51.1576867845598; Fri, 20 Dec 2019 10:50:45 -0800 (PST) Date: Fri, 20 Dec 2019 19:49:27 +0100 In-Reply-To: <20191220184955.223741-1-glider@google.com> Message-Id: <20191220184955.223741-15-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 14/42] kmsan: make READ_ONCE_TASK_STACK() return initialized values From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , 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 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: Marco Elver Cc: Andrey Konovalov Cc: linux-mm@kvack.org Acked-by: Marco Elver --- v4: - added an #include as requested by Marco Elver Change-Id: Ie73e5a41fdc8195699928e65f5cbe0d3d3c9e2fa --- arch/x86/include/asm/unwind.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 499578f7e6d7..82c3bceb9999 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -100,9 +101,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 +113,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)