Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4423793ioa; Wed, 27 Apr 2022 03:39:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfJNm5LEbROMqOlpa7xRaoTr1vntqOwFjR6e9+X6Hn3ZAKGs4K8IE/B8qHLBw4MNW6Ct2X X-Received: by 2002:a62:1b91:0:b0:50a:64d0:58a2 with SMTP id b139-20020a621b91000000b0050a64d058a2mr29109728pfb.38.1651055976662; Wed, 27 Apr 2022 03:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055976; cv=none; d=google.com; s=arc-20160816; b=sZA07uxXM1f8SuupPA3rSlg5d9ccqVt4LoZLBNdt+4NSx75KSJLAUtbjdyAu3WcmWd AY16qDwGtJ6MGhwQYivCKTya3DQttsXTF4hUzz1DU0UNKp0PWmMXZIiOmefgbr/rwCp7 LnWjyD0yUPIClu6tFADGTo68WSPMye26T20HbdZCyu/D1RqZb+YHyBs5hPvjY3EIIpKc jyOtYE964JJaqumjkFbHhGYGAFqQsx1XVm1tHQmKj7eIwLhQRfN93znjXFhWEMGmWJfT 6robZOhv7qkh3MlcE1+g0u1OwlF/OYMrbHX/5qO/aRbs0x0dZY3jgoP6eP2O06QL0TUs 0JpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=Fx98fFr6n4NVKGBzav2AZaWX3VRzhlrRB+7m3pCHiSE=; b=eJBtvnu/vJOVLMhvvKNPlAR+rNr8kMxISQ5O0Lgn8mPyZWeFr0tRT7PsJpiAEjZMjR AhK5H9LSEWPu/19ML97q8bZYtccq2Obj5ryqh4gAo1rx08SDsE8bVKPaJifsxTj9fPPP 0WrJ7dmMgMEBrEjrHNLg2ixw4VvLs+qFsf6d7v4/pRNxKkbbCCPifAx6x58VEiQHOYFm 0EibXteQVjUDRDzBh3wsMNRH1b9yJKjm5fP2XaL9H5ScSqqSvCP2GDLoqIYs4NXrQaki W0LMJnMPPJlcam2BWlQhXgyKaAredgNAVKAlFXNgbOfaNXlE4Dz1HmiUrTUOz15QxtZ3 GINA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XHfBp7Cl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m10-20020a170902db0a00b00158dd22994dsi1417854plx.93.2022.04.27.03.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XHfBp7Cl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00D0E3DD32D; Wed, 27 Apr 2022 02:50:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353379AbiDZQvp (ORCPT + 99 others); Tue, 26 Apr 2022 12:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353354AbiDZQu7 (ORCPT ); Tue, 26 Apr 2022 12:50:59 -0400 Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B11C34833B for ; Tue, 26 Apr 2022 09:45:57 -0700 (PDT) Received: by mail-ed1-x549.google.com with SMTP id dn26-20020a05640222fa00b00425e4b8efa9so3782638edb.1 for ; Tue, 26 Apr 2022 09:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Fx98fFr6n4NVKGBzav2AZaWX3VRzhlrRB+7m3pCHiSE=; b=XHfBp7Cl9xVO2N8a97yhZbWVDGYXssOGKoCjey19oDLs3NuPvKFqJlX77OVyMj94Gt 2jjyaOrHBMMVqPlV8iHx1esMbi+0FDIhnzF7Cykz5C7cq/uxOyLSo3F2oQbehHxHtWWq J0Gr9w+xpCyeNSmgjOjL6MaF2r1Jb+P68Kxo24lt3IECVMYNwPiYSWt8f1OWxVrhhtpd NO15cOsJnLjPuQEWdNOcUO0Xa9QVwX7bjyI3Sb7JSEshKJQJE+Pg0L1D80PFDwJ2uTlH nrRZFhYPzn8Skr3KSaxneh2u7R3qXEV++ExcIhKQSHekMMa2AQX+GQFmuIwyxjASi21j HPqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Fx98fFr6n4NVKGBzav2AZaWX3VRzhlrRB+7m3pCHiSE=; b=CP1RoppJKCsVGHZz1UW9wZff7LQD6AsJW41JGTZ2fXUsJ2vAIY5EKJHK1XnkRQYwZS DWEoTSVL3wk2a0LH32tAGx6tJgNA/V+7KBeU+PhrO0stolESH8yWrEZOxSnTpo5EX4cA LvsyDAxtWiupy0+r4fg1qXVN55XhEZOoYL0PJ2okTj++NHgEA1KDMIFgX+qlpbc44dYY jPbSsHeP5WWNojTRCrtrf7j/AHoJ2RaAT9KN88d2yCThhYo19KPt4dSLNpBRK51MWuSJ 9trFFkzrVQV8QftcYZEe5oDNzIXPjOUisSKqy/Op2xI283H6UTgSCrRLPFlA+5jMJjwU wY7w== X-Gm-Message-State: AOAM533t8dpP10I+a1DjE3bJbzp0j3MSQ8LYxAAMEz5+X7IJhATV1y0V WYCDdNEMD9cs7ALsrP0pSs8l5kXMnqo= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:a05:6402:34d2:b0:423:e6c4:3e9 with SMTP id w18-20020a05640234d200b00423e6c403e9mr26328332edc.372.1650991556120; Tue, 26 Apr 2022 09:45:56 -0700 (PDT) Date: Tue, 26 Apr 2022 18:43:06 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-38-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 37/46] x86: kmsan: make READ_ONCE_TASK_STACK() return initialized values From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To avoid false positives, assume that reading from the task stack always produces initialized values. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/I9e2350bf3e88688dd83537e12a23456480141997 --- arch/x86/include/asm/unwind.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 7cede4dc21f00..87acc90875b74 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -128,18 +128,19 @@ unsigned long unwind_recover_ret_addr(struct unwind_state *state, } /* - * 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) \ -({ \ - unsigned long val; \ - if (task == current) \ - val = READ_ONCE(x); \ - else \ - val = READ_ONCE_NOCHECK(x); \ - val; \ +#define READ_ONCE_TASK_STACK(task, x) \ +({ \ + unsigned long val; \ + if (task == current && !IS_ENABLED(CONFIG_KMSAN)) \ + val = READ_ONCE(x); \ + else \ + val = READ_ONCE_NOCHECK(x); \ + val; \ }) static inline bool task_on_another_cpu(struct task_struct *task) -- 2.36.0.rc2.479.g8af0fa9b8e-goog