From patchwork Wed Oct 30 14:22:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219631 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 35542112B for ; Wed, 30 Oct 2019 14:23:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0171B2087E for ; Wed, 30 Oct 2019 14:23:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J9iWz8o1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0171B2087E 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 51FF66B026E; Wed, 30 Oct 2019 10:23:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A61E6B026F; Wed, 30 Oct 2019 10:23:27 -0400 (EDT) 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 3710C6B0270; Wed, 30 Oct 2019 10:23:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 121D16B026E for ; Wed, 30 Oct 2019 10:23:27 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id A8F21180AD822 for ; Wed, 30 Oct 2019 14:23:26 +0000 (UTC) X-FDA: 76100668812.04.spark76_3b05309ae8319 X-Spam-Summary: 2,0,0,85d0922c67f83d17,d41d8cd98f00b204,325y5xqykco4wbytuhweewbu.secbydkn-ccalqsa.ehw@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com::viro@zeniv.linux.org.uk:akpm@linux-foundation.org:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:rdunlap@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1541:1593:1594:1711:1730:1747 :1777:17 X-HE-Tag: spark76_3b05309ae8319 X-Filterd-Recvd-Size: 5041 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:23:25 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id z5so679785wma.5 for ; Wed, 30 Oct 2019 07:23:25 -0700 (PDT) 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=r1rimWPSVZnlscUh2KjkHO3RzEDqzDMgK4H1V1YaUMg=; b=J9iWz8o1jeNdl2+zd6zF5q8TbNep85mHubqBUtf3WoIbxeqFJmXUKTTL3oEwTXe2y9 8GajzIDy0wCtHuDus67jkdgDgpq4wWPVeBcdZYOPEjvOZshejxE5kzeoNKrILQmR5aX8 IaRmrpJ6gz3rKG2Ukbc5kEdnOTNU2YQz24Blr5UclSmLu33xFHLxbP0uvuXqzpyvTXwo aTnCBd5gvdT8hSpB73FySxQcEoCz5tdjD/Yn/u+ukv2ULYbIsW0KXNNCUgVMU4xRPAAP 9plJ70P+caOZLFVXK/dVIIQ5JtxC1eWOQrozoEWjWeGHtNT73srdEQ46qGNq8PpFb2c3 +FKg== 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=r1rimWPSVZnlscUh2KjkHO3RzEDqzDMgK4H1V1YaUMg=; b=eCwyaOyd2IlD4ttCD5JOBhILMkRekBKO26ojuvAiO0n8hmCv8bD82R1o04cvGm/abx cskt8xgsp3nDg/UCmAzVJByHbDEsg/L/BeBcEDfICipzUoqo4qxDxd4SHxk4eMW73we4 EPXNzu0dYitK3i6WupmE3eLaWnSS9ug2oN0GET4BHQzE1QWmGF23LqzDeomawmKKZtJq IlZ2mYL2VLbdZAttxnEl9hBNNBbGK3d75/gToqltjA2p08UnHG6o8nWUNSxi/xR0HmKY fhVKbKqX/eAT2/sAjC8dNj8pJIBVoNy98eseWAY3wuWc6bGq5NlxoLZFcDbLjrGbXg8i lLkA== X-Gm-Message-State: APjAAAUJR+2lW6GSSa8VDuNIpXFbWag4FKDXxKgts8h2jI5YJfME9pBF G3JxsxVXUgEBKz/RpAyBCjJfhk3EadY= X-Google-Smtp-Source: APXvYqw4oTuQi8o6uJ4O3XSt/8G4qv52mS+ZInpBFLCgSkxJaM92QnVojPia+CtT2ixPtB0UafE27JuNbAk= X-Received: by 2002:adf:dd10:: with SMTP id a16mr103618wrm.213.1572445403925; Wed, 30 Oct 2019 07:23:23 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:25 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-14-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 13/25] kmsan: make READ_ONCE_TASK_STACK() return initialized values From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, rdunlap@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko 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 --- 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)