Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2281450ybt; Tue, 16 Jun 2020 01:46:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/q65FV1zNjxZO4Pp9KkVxrAJ6vrDLR+ydWHClPwOEDaIARZ0zb6nPOZE1fQ7+S0cOAHCe X-Received: by 2002:a17:906:90b:: with SMTP id i11mr1690852ejd.343.1592297179821; Tue, 16 Jun 2020 01:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592297179; cv=none; d=google.com; s=arc-20160816; b=qSrQl3IvLXiDBZ8CPtAaPwuN9mJRBZtDc9VADFOqx5NgFuxIi20y5TpViMWGRG69SL 3fQVos8vn9l0aSLj0oSeu/Vou9H+XjovgXfI1sBY/6Lf1AsegJ1RQVDOJqZN94RSE0fW B95M+uCwEPmWu9B2esvxRdjpOtTGLmvee2ehuJ/dMv+FXmseq+XAQd14RFM/VcTd9zv4 TmWGg7V9hvf1BYVlmm4CtJ9e2t9IS3KricFG7VsRHzX1ckOCwMwQGHIojlfY7wGYsgMr y2GM6PvJ8/vxOhl8XHsyEXBcQHPdPgnTk84+vt9CRCMqUwpdsj/CQsPFVOVkQrHnDPN9 7KTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=C9Ht3rje4vjIOp9lVzmW76JWjSSJxPkhpI6gvlvB4wA=; b=cwizkkCSnyKYOgufZQMr7cmDmfeN4SM9ZFW1oZTEiYfVVx76Kb3xV7Dn0mFS71fxpM uBp4cKaExen0sNIW92uPrwbQRoWyqJ1H9QzNrwxvSI6IbKqs26Dd0KjbhSttRFCkcGsp THOyZG3A3vvqF5+L5kNDXSBkupYhYr3cZKFGqNeiaEDCXMcfqQDo6aUjXbCDRYFB9q3h cOdO32ugIp7whCLpxjy9W82ARZkoSzpOC5q29ocPIqDdMUiBO6CmVXVgtA0SQX5+P4vx TRtBqgW+rbekavTLFjvhDd5p4+XGqOSSMjWKnBdgmnQF4BUbk4gpc04JGEB9DYw6KXGk Z0Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qaoLYrfY; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck16si7275324ejb.416.2020.06.16.01.45.57; Tue, 16 Jun 2020 01:46:19 -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=@google.com header.s=20161025 header.b=qaoLYrfY; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727792AbgFPIlq (ORCPT + 99 others); Tue, 16 Jun 2020 04:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgFPIlp (ORCPT ); Tue, 16 Jun 2020 04:41:45 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E74BC05BD43 for ; Tue, 16 Jun 2020 01:41:44 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id t8so1607818ilm.7 for ; Tue, 16 Jun 2020 01:41:44 -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:content-transfer-encoding; bh=C9Ht3rje4vjIOp9lVzmW76JWjSSJxPkhpI6gvlvB4wA=; b=qaoLYrfYUXl7c6aIemIuQ99M8rRpyqaO/kUHXwJEBvIZyq/VBYHcareqmotJAH9lLc 56pEn63BOGWwVz9KjHbf5jzJqdRpTOe9LPHQ6o8/VXocyVbRE8BcUkk9XWJAsk+XTYX0 d4ZJMMkZChDt4CLKSkfnNvfDjAh7GbHJFfUdxrP2RRBdgQweOldjR14hEGuHry6x+oQR 8jVKTb6ddwN118FUhUknxC9EjaLPKMTwRgPty/uB2VEGaqiWxjZOtPHy+CXmL6AvLn8Q DRfSnQsBPg61EM2Qi8JUb/2xLl3JS1LXqrUZ57SSUpgjPsAAcyQZl7lSM71JQHBzdT/p 72LA== 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:content-transfer-encoding; bh=C9Ht3rje4vjIOp9lVzmW76JWjSSJxPkhpI6gvlvB4wA=; b=uVUUH284M807k6H/NY+d4jaTAmy8TegYFCVgngtq3dvX4FhjiR91pt/zvi/XUbn45p gbq8mcUBa3YJLhhHRo+Q+AfNnf4RzDw7rq3SO6puteGDjUvA2YR21Y6IN4JyN7X2buhB vQmERJwojxcVIipHkcpq5Z0mcMi+YeEU7RHXKZ3R6t11xZHCoZHU/bQmp9D+BAQxjtu/ BSrFJNoeYjfDiElpeeMVFRmeahuraQDGiIcHBkmHozrZcjO4FAUtMwz7Bt6LGIpzhWme qQRMxJ/bHepVhTqzCTz0hPDQ505W2e+HMP+HPt/byybPejQhpn+jU96IZPhuH+r53ycU LgcQ== X-Gm-Message-State: AOAM531SkaPbajX9gOJmnGLLBpGqTVvrhNptbL8/7IK3vcNhasc9NcYH 7uCLVZHhBdDI9/sDPUL/5VDXJbKJudNNU48S5h/ljQ== X-Received: by 2002:a92:af44:: with SMTP id n65mr1905398ili.61.1592296903309; Tue, 16 Jun 2020 01:41:43 -0700 (PDT) MIME-Version: 1.0 References: <20200616083435.223038-1-glider@google.com> In-Reply-To: <20200616083435.223038-1-glider@google.com> From: =?UTF-8?Q?Maciej_=C5=BBenczykowski?= Date: Tue, 16 Jun 2020 01:41:31 -0700 Message-ID: Subject: Re: [PATCH v2] [RFC] security: allow using Clang's zero initialization for stack variables To: Alexander Potapenko Cc: yamada.masahiro@socionext.com, Kees Cook , jmorris@namei.org, Nick Desaulniers , Greg Kroah-Hartman , linux-security-module@vger.kernel.org, Kernel hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > In addition to -ftrivial-auto-var-init=3Dpattern (used by > CONFIG_INIT_STACK_ALL now) Clang also supports zero initialization for > locals enabled by -ftrivial-auto-var-init=3Dzero. > The future of this flag is still being debated, see > https://bugs.llvm.org/show_bug.cgi?id=3D45497 > 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=3Dzero 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. I'm a great fan of zero initialization as opposed to pattern. I don't understand why clang is refusing to make this a supported option. Anyway: Reviewed-by: Maciej =C5=BBenczykowski