From patchwork Wed Mar 25 16:12:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458253 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 CC92414B4 for ; Wed, 25 Mar 2020 16:13:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A0F320409 for ; Wed, 25 Mar 2020 16:13:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Xc70D+cV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A0F320409 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 50D266B0071; Wed, 25 Mar 2020 12:13:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E44D6B0072; Wed, 25 Mar 2020 12:13:33 -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 3D26D6B0073; Wed, 25 Mar 2020 12:13:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 24FDD6B0071 for ; Wed, 25 Mar 2020 12:13:33 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7E48181F24BF for ; Wed, 25 Mar 2020 16:13:32 +0000 (UTC) X-FDA: 76634379864.15.game06_764058ed0504d X-Spam-Summary: 2,0,0,d2bd54bb4022dba1,d41d8cd98f00b204,3k4n7xgykcbo6b834h6ee6b4.2ecb8dkn-ccal02a.eh6@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3867:3868:3870:3874:4250:4321:5007:6261:6653:6742:6743:7875:7903:9969:10004:10400:11026:11473:11657:11658:11914:12043:12048:12114:12296:12297:12438:12555:12895:12986:13846:14181:14394:14659:14721:21080:21365:21444:21451:21627:21990:30054:30064:30070,0,RBL:209.85.128.74:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: game06_764058ed0504d X-Filterd-Recvd-Size: 5611 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:13:32 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id g9so2664298wmh.1 for ; Wed, 25 Mar 2020 09:13:32 -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=r7vWvtvdqE3Z9xHwFz+7JS8RRlA0WqNLTVNjzNGYEtc=; b=Xc70D+cVw9n/9kGBj03TExsdP7n1vAT60jT2bQrjyEMrqGpVaqiPpvXRdU098bdZol Tl7PM5BfAs1dMGyISLjyrExGZJsYBBL7hs4W0ztfn4KsuBkU5W9FzDyzdHIrXQzUKuZO h+pGyMcXdl7xhZY8+JYbxkvEnv3d3mJgCvCUFT0TZ7dyTmKsS+OdR/GZwBYhNomNRxsT jiqtyvkFTKpBfc7TG68NGASpkpNZtM1ZZQJ9EkCkuAiXIBeKW9Z/Y2czXM5XpLTGVw+7 RBg5/i1Q805JTaUtZw/ixaXmSuXxGQlbCapMNyeAGIUrJWNmtt0phwDbaE8MeLxoJ3ar sh2w== 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=r7vWvtvdqE3Z9xHwFz+7JS8RRlA0WqNLTVNjzNGYEtc=; b=f8Sl/9Fb7xXwZUdbykbkMzGs+yzQzK+XNZxpeigHPhPrpzgORP3kQzZjLfb7Eqjg4F 8HDHbVun3iP1I2g0HN95slJ/Euh47ID9Jtl58HqtwqbQ+U1Nf9TZeAqLeFDvA+7F8Dkp PiY/PAeUlzwOat+W+6KBClstAYGh15e+sfqPPnGgM6Ft/9MrXh2WeORuhVyiHKXQJxSq 8c9pe6Z7Ksk2SZK2LY9Jrz44cHn9KHOFCtwBjahMiqPdAv8uMLXOXnDqBX8PERGxEPfL QBZBmv5cG6qF74DwJAzSeaWdoS7SlzprM81aav2KVjVI4kaz1I+Q/82Tu9aaf7nj48QT jg+w== X-Gm-Message-State: ANhLgQ0BEqo6DzzuOMDhMZu5EIA0zRe/1p20+xKEE/Gc4t9RYsHJIx0Z VzHHQoH1C3zidauKsHn+MtPO/QjEILs= X-Google-Smtp-Source: ADFU+vugn8qR3xrks8fjiGYMa9i61dKIOQ3sIYJl83DGAdYPEXhNknnLjQk84Ek4sj0eyNmBiXdxY7g2nOs= X-Received: by 2002:adf:b3d4:: with SMTP id x20mr3905146wrd.269.1585152811036; Wed, 25 Mar 2020 09:13:31 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:22 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-12-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 11/38] 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 Reviewed-by: Andrey Konovalov --- 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 499578f7e6d7b..82c3bceb9999c 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)