Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1058935rwd; Thu, 1 Jun 2023 09:55:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5plRbtgenHFPcuAjxQvaD3ITE81PTa/WlUN0Sg1zA25nsJcijlszfhEuqVJjq1x8pnckDL X-Received: by 2002:a05:6a00:b84:b0:64d:6db8:f191 with SMTP id g4-20020a056a000b8400b0064d6db8f191mr11999193pfj.27.1685638525465; Thu, 01 Jun 2023 09:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685638525; cv=none; d=google.com; s=arc-20160816; b=hhGio76UZwm6pf2oWgIpgFOrIkAeMFXcx2uXp0SEQqV9pLakXf0/r3SN5DeqhTR/Xu Sp0Rc4MHek+nvr7xuHFHxpPQuZkegspXEeZOsEvbZ1ds1fJKTLFL8Seg5GL8I2xAB14d GdcmstxvxiJiIcafnByKZcPVfqH6jmV6qm5S/2gWzbBPl8TmJ72brpBfUMMFwp34oHUv 1Uee3PvfSP/p+s+E1hXzcOY/FuCF3Xys5wBor55Ly7ne4EOZ6tZ1lu/NfPiukLY9h9yK gE59DHDNJIthRiKn2tUzVONcKaYSChkMJjoTXHFGCqPYfuhp2dUZWPaP4O8e52RxTQ5s 1CnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=NyNKSVwYfX6bmYj1vDnG0L6FuWW1nhZ+DOcSY6uZJpQ=; b=gc1u+Ngl5SQ+hZNd2FzD1khTn0yn7/41UdN2zbbrvwt4hwQ3F4pwGeVd5L4I7JhPNU AF5eTTd8tq6Ns94EvpNT3w+qqM4w6sl1hWraYXUhpz1mb/bIo3o7Y2dVy2VatQJ6bYiS b1eRef7FYw2yXasLki3hFoyDDf/AwJQWmraK0mbfgsDkk+vf/XxzXM+Phympd6yul3Q2 mrn8pSTNL4wHHkaTLXi/t56dnSwE8ovw4BUT9Kf2X+paLagBwhwA/qIPf9oWTtYEoNAC 0pjTz6G4JY2q9CP1XgwxKJGYnQ2AV9C8iWczLisfxv5MtTXz2c9SYmHHuu02SSHRSxZn lHXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nJlhZ5IH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c28-20020a056a00009c00b0064d2484f08esi5667799pfj.361.2023.06.01.09.55.12; Thu, 01 Jun 2023 09:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nJlhZ5IH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231178AbjFAQqD (ORCPT + 99 others); Thu, 1 Jun 2023 12:46:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbjFAQqB (ORCPT ); Thu, 1 Jun 2023 12:46:01 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3CA195; Thu, 1 Jun 2023 09:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685637959; x=1717173959; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=iDL6LVNWKZBuZvvnqj/X3vGXzRQAR73q49VVn7ziVp0=; b=nJlhZ5IHgjL8o8J/ql3asMRn+gNDZsIDjLRnNE1WFYx9nA78dGprQKOo HeHUd5O2vOLjkkVWiUZCdECHGymdryRwMwMxJHoDNCA4Xh8qTo9Rvlxep lsZ3E2C2/0kxYxHOOyDF4p1Lk7lfmR7pzys2km0gp5MTBG0Nec+HtNiIO vUuKXZxRa3Gf2tPs4hGJscvhPaGvP1V7tQUkzacC3mG7h2X8E7B7IATLb UAb6Oir14dJ81KWZthRY1xzfwJZ1Ht2VxKYgkSUqJ09HvnqQ8hCIdyXw/ Lp105XooDWw6vGlFIJsa/S54yES8vaLMvmiB8F5Hitf/63iUv1CmxvxVh A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358037897" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="358037897" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 09:45:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="701621225" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="701621225" Received: from jdboswor-mobl.amr.corp.intel.com (HELO [10.212.227.45]) ([10.212.227.45]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 09:45:57 -0700 Message-ID: <3c67fdd6-bce9-f695-a6c5-0fe9209bd3e4@intel.com> Date: Thu, 1 Jun 2023 09:45:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] x86/purgatory: Do not use fortified string functions Content-Language: en-US To: Kees Cook , Thomas Gleixner Cc: Thorsten Leemhuis , =?UTF-8?Q?Joan_Bruguera_Mic=c3=b3?= , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nick Desaulniers , Masahiro Yamada , "Peter Zijlstra (Intel)" , Alyssa Ross , Sami Tolvanen , Alexander Potapenko , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230531003345.never.325-kees@kernel.org> From: Dave Hansen In-Reply-To: <20230531003345.never.325-kees@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 5/30/23 17:33, Kees Cook wrote: > With the addition of -fstrict-flex-arrays=3, struct sha256_state's > trailing array is no longer ignored by CONFIG_FORTIFY_SOURCE: > > struct sha256_state { > u32 state[SHA256_DIGEST_SIZE / 4]; > u64 count; > u8 buf[SHA256_BLOCK_SIZE]; > }; > > This means that the memcpy() calls with "buf" as a destination in > sha256.c's code will attempt to perform run-time bounds checking, which > could lead to calling missing functions, specifically a potential > WARN_ONCE, which isn't callable from purgatory. > > Reported-by: Thorsten Leemhuis > Closes: https://lore.kernel.org/lkml/175578ec-9dec-7a9c-8d3a-43f24ff86b92@leemhuis.info/ > Bisected-by: "Joan Bruguera Micó" > Fixes: df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") > Cc: Thomas Gleixner > Cc: Ingo Molnar Hi Folks, The -fstrict-flex-arrays=3 commit isn't upstream yet, right? That makes it a _bit_ wonky for us to carry this on the x86 side since among other things, the Fixes commit doesn't exist. I'd be fine if this goes up along with the -fstrict-flex-arrays=3 code, so: Acked-by: Dave Hansen We could also pick it up from the x86 side, but I think that would need a _bit_ of a different commit message to allude to it being to prepare for the _future_ setting of -fstrict-flex-arrays=3 and having no practical benefits now. Let me know if you don't want to send this up with the -fstrict-flex-arrays=3 set.