Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2249189ybf; Mon, 2 Mar 2020 05:05:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwHyVT7ws1mqOFjUV+NBIVe6IFOnq9rscPXyhNRfBslrEnCxeXgScFBhdg7HgUeMQPSxsAo X-Received: by 2002:a54:450f:: with SMTP id l15mr11826118oil.126.1583154301367; Mon, 02 Mar 2020 05:05:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583154301; cv=none; d=google.com; s=arc-20160816; b=Cp2Q+1vF6192KZLdzibSWeMtloahbS49ykm3hmlpZjD49RuvLIR6gMtT2rb1h89YVv ixDi/AYBn9q8ZU1FScO8fQ7gryoUbkvrGlPrqnGIOXtNLrjpT5E5YC8bFvp4v/PP7SqZ mzsaczsm1xnJpIft0MR9IJ0rWN7TLEYbwpOQ8/xUN4JRTt/Ih07Z585GkBubOhZCxXoI yrXYbM2ZSwMmTBz1LcZ0P290Jv9HVlcTXHeQgyci73n+1SmDnoqiBMXYb/Wuow7Gd/p/ z2CcBYBp5kQs8f1vvdqq0o3gzbMMmoAhyTDuPodTbRE+nfDypTsiHpwb7TTKAuIlQ8gQ 60NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=Wr2Qj05MN+2+uObWO7o5CaCL9JBE9M/aEcqw3hihs/Y=; b=GeOfEVqo0O8krPOtMoCtxR2LuoA2a365Cfst2D1+WhsOc4y3AvyFMR7oCWHkId1lU0 RMndND1ZArEOftSLKNSqdeE5QTqFSKoGcsMaa6TfFrzmtD/pRjbUdHkFZPGziIiUagv6 WpkxyYj4jul04Qcc1QoF8lRmRU3K5NvSkfgRItAMOKjWBnN6F0emxVkGG3+G8sgSCZzb Qk49yBilMBaLu1e04lXrhSnuDryku5dbHGfdWPMYAaQ9H9aC/zW4WDTP5mRuEVH8iArl /KOVXSJQBA+D7vChGZZmPJXuLULiZDCiLhHRzYY6IMdtf8cCEq8mBuSX4ztZ+FzTBO3h m0ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JsMLy1Lw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si6574951oti.226.2020.03.02.05.04.48; Mon, 02 Mar 2020 05:05:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JsMLy1Lw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbgCBNEi (ORCPT + 99 others); Mon, 2 Mar 2020 08:04:38 -0500 Received: from mail-wm1-f74.google.com ([209.85.128.74]:41013 "EHLO mail-wm1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgCBNEh (ORCPT ); Mon, 2 Mar 2020 08:04:37 -0500 Received: by mail-wm1-f74.google.com with SMTP id f207so2871528wme.6 for ; Mon, 02 Mar 2020 05:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=Wr2Qj05MN+2+uObWO7o5CaCL9JBE9M/aEcqw3hihs/Y=; b=JsMLy1LwqBPNhCZ8C0SkN0ibFV2jvFW7MLh2FiV+2/se6TT5NzZZoAm/skX7PxHnTP QDLYP+vYyGE+Z79s0Eycc7aeC7/ucskvy5rO4qJFgiHSEBeClC68CULVEOj/7z90Ugxi 1CMfCA6Dk+tP+GESoBVRt/nEtS/b2zkiUWErzLsqm3cO18Jq7wjCxWmkXivrEWcv5BkT RBqWZOvPZIgt/B3+mTn1xdgIMAS9q+Ke5m3Lp4iLhMhTtHf/Gt91xDyQf0u6Iyy0gMrq 9vcuL5GXPGvsuNHVWmrSGcFOhUkouHWb/CFhz/WwWJrhIap3S/1lDf9bsY+I2sfB1/7T 96EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Wr2Qj05MN+2+uObWO7o5CaCL9JBE9M/aEcqw3hihs/Y=; b=SnGjbXSr9fWaNxFoysHfskNFwfFm7ZEAvVg8Eq0dS+6BxKjxRzzj9mFFopcCyMunKt 0pTVbLLiLmV5VnzSTAUHglbaVy4RUhZDlK+vrwoSo85PDg+nc9Wc7kYYSGRUCne1jxa+ 2zx9zIe3p8imuPbO3vPVqL/weHgaG7REhz8w0Nrs0Ij9DptyELInDietIsHGzrWynaEA Av1vNCbRSCR7f5z4E8n7RtrLjsd8rYZo+YVbtpz45FdUi8uDVyms98tYppSaW4nGZpOp EgosIwnu4eJUqU65M2k37E4SU/T4PeUfHtlOyPcKgIvPl3gKHeQiLGLPoxTkRUzPG8bR xUxg== X-Gm-Message-State: APjAAAXUWPMotZGx9fj/o+P0dRMZPJibrx15ii+jzn1OwYWBaaIriHlf 2PS/AVQtoLaJDHH4G3KGu0kItUipU9E= X-Received: by 2002:a5d:4807:: with SMTP id l7mr22350075wrq.250.1583154275704; Mon, 02 Mar 2020 05:04:35 -0800 (PST) Date: Mon, 2 Mar 2020 14:04:28 +0100 Message-Id: <20200302130430.201037-1-glider@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH v2 1/3] compiler.h: define __no_initialize From: glider@google.com To: tkjos@google.com, keescook@chromium.org, gregkh@linuxfoundation.org, arve@android.com, mingo@redhat.com Cc: dvyukov@google.com, jannh@google.com, devel@driverdev.osuosl.org, peterz@infradead.org, linux-kernel@vger.kernel.org, Alexander Potapenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For CONFIG_INIT_STACK_ALL it's sometimes handy to disable force-initialization for a local variable, if it is known to be initialized later on before the first use. This can be done by using the __no_initialize macro. __no_initialize should be applied carefully, as future changes to the code around the local variable may introduce paths on which the variable remains uninitialized before the use. Signed-off-by: Alexander Potapenko --- v2: - changed __do_not_initialize to __no_initialize as requested by Kees Cook --- include/linux/compiler-clang.h | 10 ++++++++++ include/linux/compiler_types.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 333a6695a918c..27f774b27b061 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -24,6 +24,16 @@ #define __no_sanitize_address #endif +/* + * Disable initialization of a local variable when building with + * CONFIG_INIT_STACK_ALL. + */ +#ifdef CONFIG_INIT_STACK_ALL +#define __no_initialize __attribute__((uninitialized)) +#else +#define __no_initialize +#endif + /* * Not all versions of clang implement the the type-generic versions * of the builtin overflow checkers. Fortunately, clang implements diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 72393a8c1a6c5..0208699c855af 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -216,6 +216,10 @@ struct ftrace_likely_data { # define __no_fgcse #endif +#ifndef __no_initialize +#define __no_initialize +#endif + /* Are two types/vars the same type (ignoring qualifiers)? */ #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -- 2.25.0.265.gbab2e86ba0-goog