Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2323858ybt; Tue, 16 Jun 2020 03:05:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFJAM1LeRwuXZzT9ATq2o8MfRExGN6Hp0iRVLc1rj7BNpWSLkKf0IQsjY3fUiHfa+w3yIW X-Received: by 2002:a17:906:97cd:: with SMTP id ef13mr1861955ejb.165.1592301959253; Tue, 16 Jun 2020 03:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592301959; cv=none; d=google.com; s=arc-20160816; b=Q+GHTV1GI+/qxJbielmsg7DK0exZdBgxrBIooXsm3RiCWIxb6tR6rYqRTQ4E+M+YdI 66BGmhc4aDVBGlN7Z00RsGBEYOJ1N+h8dqpO2gSwW7IAIlQeAvHaWJha7rJqDKFxTQRP QMffko5wlYgyglKTyglyq85JwgqpchOGs0F9uF7PHW8v+FG60zOi3vdrUU2oN6mNzdPN DGYDixy1lFmjwH7K6WItWiVbiWBHThgg2MyCgWr3u77ZQnhIiRJteJhsKnVTY/l3eoEn bHFk5hXZFuXL/Co1+eh24wgCFtSDI2qMAnmcqpf+jwGxpm0fz8IoQBMSZjNUfH9XzP53 1Xyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YXZ4iGrDAwO4GWyPKQVblaJqDiHLhomUB7pbZU+tIhc=; b=nj1Yr0Elq17BiNPn4fEzg5pUQTEkyBVr4WjPsq+7hVZDk7MpDhGSp8hxju1j6AroCO uAd/cnyJcCmfjhEk2jpzWF2wKCdIp9RFEs4jLtD708sjM1mwD3ru/4xdnRW+VQZtxCvX JWATDHBmbyOmAQ751ki/+zRMdZrGdS4dwGUCR+p/SNsy+fmF3Tcld8/eBrlh1BYDQJ7u idFkG/9iCEnVgBoLMR0i4ANeLLw+ML6f1M6a3/MurNShtC8jgkiS+OSVxgK5QMMR7wW+ jnS1oDugPVPhEL63RA2Fz7eiJrfmkPo6/jbl9UaFjytiOcDNBDZ5bkCV2oAuhM5KUWtM tSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bcet8w7K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si10365363edt.498.2020.06.16.03.05.36; Tue, 16 Jun 2020 03:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bcet8w7K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726805AbgFPKDT (ORCPT + 99 others); Tue, 16 Jun 2020 06:03:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:34836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbgFPKDQ (ORCPT ); Tue, 16 Jun 2020 06:03:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 121BA20767; Tue, 16 Jun 2020 10:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592301794; bh=X84sKt5PQLBc6tu+9pZlqv+58ESwXd+4uih/06fLewg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bcet8w7K5NFpfHYfjfkLwL1qs9ZtjQohV31jXzphpq9OJxrIfz+L3oKah5JqyJwBm Ll3/YYZjEJNs6kCySvEebEtGdmH1rR97oUQ5Pdv7wwPAPNtyStJHZ/Dzye5j87MfmC m5/TnAyj/7cZ4dTvD0O1tjANuBK8ZYpuZu2zEdJ4= Date: Tue, 16 Jun 2020 12:03:09 +0200 From: Greg KH To: glider@google.com Cc: yamada.masahiro@socionext.com, keescook@chromium.org, jmorris@namei.org, maze@google.com, ndesaulniers@google.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] [RFC] security: allow using Clang's zero initialization for stack variables Message-ID: <20200616100309.GA2614426@kroah.com> References: <20200616083435.223038-1-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200616083435.223038-1-glider@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 16, 2020 at 10:34:35AM +0200, glider@google.com wrote: > In addition to -ftrivial-auto-var-init=pattern (used by > CONFIG_INIT_STACK_ALL now) Clang also supports zero initialization for > locals enabled by -ftrivial-auto-var-init=zero. > The future of this flag is still being debated, see > https://bugs.llvm.org/show_bug.cgi?id=45497 > Right now it is guarded by another flag, > -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang, > which means it may not be supported by future Clang releases. > Another possible resolution is that -ftrivial-auto-var-init=zero will > persist (as certain users have already started depending on it), but the > name of the guard flag will change. > > In the meantime, zero initialization has proven itself as a good > production mitigation measure against uninitialized locals. Unlike > pattern initialization, which has a higher chance of triggering existing > bugs, zero initialization provides safe defaults for strings, pointers, > indexes, and sizes. On the other hand, pattern initialization remains > safer for return values. > Performance-wise, the difference between pattern and zero initialization > is usually negligible, although the generated code for zero > initialization is more compact. > > This patch renames CONFIG_INIT_STACK_ALL to > CONFIG_INIT_STACK_ALL_PATTERN and introduces another config option, > CONFIG_INIT_STACK_ALL_ZERO, that enables zero initialization for locals > if the corresponding flags are supported by Clang. > > Cc: Kees Cook > Cc: Nick Desaulniers > Cc: Greg Kroah-Hartman > Signed-off-by: Alexander Potapenko Nit, your From: line of your email does not match your signed-off-by: line :( In the future, you should fix that up so that maintainers don't have to do it for you... > +# Initialize all stack variables with a zero pattern. > +ifdef CONFIG_INIT_STACK_ALL_ZERO > +# Future support for zero initialization is still being debated, see > +# https://bugs.llvm.org/show_bug.cgi?id=45497. These flags are subject to being > +# renamed or dropped. > +KBUILD_CFLAGS += -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang > +endif Gotta love the name... Anyway, if this is enabled, and clang changes the flag or drops it, does the build suddenly break? And does gcc have something like this as well, or does that have to come in a compiler plugin? thanks, greg k-h