From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C7AEC55191 for ; Thu, 23 Apr 2020 19:18:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 28A9220767 for ; Thu, 23 Apr 2020 19:18:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ET/5gPkT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28A9220767 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 A55BF8E0007; Thu, 23 Apr 2020 15:18:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A06308E0003; Thu, 23 Apr 2020 15:18:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CDDB8E0007; Thu, 23 Apr 2020 15:18:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 763B78E0003 for ; Thu, 23 Apr 2020 15:18:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2D39A180AD822 for ; Thu, 23 Apr 2020 19:18:56 +0000 (UTC) X-FDA: 76740082272.06.bun17_4df4d62356615 X-HE-Tag: bun17_4df4d62356615 X-Filterd-Recvd-Size: 7330 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Apr 2020 19:18:55 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id g6so3355871pgs.9 for ; Thu, 23 Apr 2020 12:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O/wq0aKUhLAxR2QCp5D0esonrZnIqRh7+pniz7v7jnY=; b=ET/5gPkTtqi/FS70IgGfrtiTiJ6BlIRjBVoW5MGvtZbiZwcVGDEh26wKYSdto9vl/M ng0b3byWicp0FX4T/gKnRlzU0JMT8njR+7u/8z2coHrs0K0afP/PQhZ28rPjlqJClbQY XsaaXR6Uy+/6paEoAGAXsBtLdL4+xhE59BuLklb8StVdkuKO+y+dS/3vWuZsdVHGtMFz O+GHo9NTRWT7UUSfH6X1JyW+f2n0hsezHwlkaLz4rhl6aBg0/pQtOkTxWaZEMxMvI5H5 3zj6FkbSq2N1GmXKjpy471vXfeCZR0xfu8ULUqwB3ZI+DPUCJaEx0YE/SET8vlTzQnk2 EUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O/wq0aKUhLAxR2QCp5D0esonrZnIqRh7+pniz7v7jnY=; b=qk3oJPO6ZUdI4rQYkUoJYwrBDEfXjFZHny46mNRkCMrB4h2MGnnNMHGjmrK5tKikvU 3aJIlcw0rqA8p/b6Hu+uPoUvBIvzQZHCXoXEtkV/eCdt8cBdWwAFz8ZpGBVTzKfB+V2i 9qgHG3NnJ4joANZ0BRwyo5XPy2Tc69ROReEpFeKcf0tR4W/mNrBLmdGPVm8qzslmPwvw kvwImCv7+ry26f1rOQMIl/Ht4c0BjiBLPq2weiqo7AVh7V82R8EfrhlAYHDnV0jIdf1J edG2mrQCM/FMltPmHfPaboSf27gTYb63NXOP79T2W+qyeGy8wuVXRwSgti7NXRbyYv4E KfZw== X-Gm-Message-State: AGi0PuazMxZJzNCNuOfQTF4LcZc3JxzDJRr728a6bBAkhutYM2PmhmRf C8CTk8OyfEV9dMBLWurzmvqyEPjJJd34EMe2nXedbQ== X-Google-Smtp-Source: APiQypJe9VD9vaPFwr5a4Fq0Hlk/oIl/FL6CyMf37DLId+PnoQ/Vvfhg4FfEx7/iSPIoMMLvww6UUXlafgPU57i9fFs= X-Received: by 2002:a63:fc45:: with SMTP id r5mr5303205pgk.440.1587669534602; Thu, 23 Apr 2020 12:18:54 -0700 (PDT) MIME-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> <20200325161249.55095-12-glider@google.com> In-Reply-To: From: Andrey Konovalov Date: Thu, 23 Apr 2020 21:18:43 +0200 Message-ID: Subject: Re: [PATCH v5 11/38] kmsan: make READ_ONCE_TASK_STACK() return initialized values To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , Marco Elver , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrew Morton , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , Eric Van Hensbergen , Greg Kroah-Hartman , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Hocko , Michal Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik , Wolfram Sang Content-Type: text/plain; charset="UTF-8" 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: On Thu, Apr 23, 2020 at 9:15 PM Andrey Konovalov wrote: > > On Wed, Mar 25, 2020 at 5:13 PM wrote: > > > > 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 On the second though, nack. > > > > > --- > > 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); \ If the task != current, we use READ_ONCE_TASK_STACK(), which already does KMSAN_INIT_VALUE(), so no need for it here? > > }) > > > > static inline bool task_on_another_cpu(struct task_struct *task) > > -- > > 2.25.1.696.g5e7596f4ac-goog > >