Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1136366rwd; Thu, 1 Jun 2023 10:57:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5pPUgeJpWPanbK5iYmxcWb+QL4NB7JB5hoHQduRzbf9nnTrafE1RA74uXYhUNrjj6NR/I6 X-Received: by 2002:a17:903:22cc:b0:1af:e295:ad56 with SMTP id y12-20020a17090322cc00b001afe295ad56mr101072plg.49.1685642235249; Thu, 01 Jun 2023 10:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685642235; cv=none; d=google.com; s=arc-20160816; b=Qef0TWBJjJYnEEKDZT0DhREd7xh7iBfU34yTbrGTSGcfSW772lHI2EI1BLL9DKFKU9 XocElPx3S7qnxoiD4hiLdDBMzuZK3X7W+ELOu+fw7u2sEORIXjninymmiJ1HlLYIkn2S zJ+zG9vNBrQXH4NKH/kBQyKdiAw1g8NzgASME9zNyYqJYCp0k9qTbgxV1qN09kKgnt8R +mV0wMZWMFjznuROsxziJ7xQk49Zo+OpBCG0NglSseAm3YgKypXgu2I7vDbvEUBL4Fq5 LyT0XrjSljgOb+5j7kmLUgdKbpevZWktbqSSLza3dwk/iL35gZDFJ1ZlqXD35/MFyD55 AfSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Nfyb+CCBE6uLYsQ+X0LyjWzbXVsfe1KNGV0HPV0UxvI=; b=EB0VpSsTvkyvhyyBIsKhwdKSIhvuvfCuwRP0U+mCPy4VRX02uHcZToAXXe+FDr2Ld2 LguIn/iFb9dOpD8YRwHPWnFIZDUcg5iPvYvoryEeZy4HKcer8pGs4ROzTr0kZPcij7oT n4kHP0XWMaBrFzvfQNE3Kd6NLvjiE2OvqVrUlVeYDp74zUx9SOG9S6v7/EJbhhiEkFfS PJi9No1bVASSYeynEt2S7DWBSzXVqHO7susxXnuzQw+zZUcNm+K5NJKPEZdUv592jSLM i6/u/rQwZfqkWCmm4rPuw5RMFDztW9GH/jRRhuKTd+9kly99HZPyz6XVeK5BHXqQn7d5 URgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nFNBX6d5; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x21-20020a17090300d500b001b186709e78si2648047plc.39.2023.06.01.10.57.00; Thu, 01 Jun 2023 10:57:15 -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=@kernel.org header.s=k20201202 header.b=nFNBX6d5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232877AbjFARe3 (ORCPT + 99 others); Thu, 1 Jun 2023 13:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232852AbjFARe2 (ORCPT ); Thu, 1 Jun 2023 13:34:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A520134; Thu, 1 Jun 2023 10:34:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D975464859; Thu, 1 Jun 2023 17:34:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29F8DC433EF; Thu, 1 Jun 2023 17:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685640866; bh=NLd5rE4WJi/QMXLKsa2Ce3607NEbnjCF2lgw/E4Ilrg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nFNBX6d5uMMdF/EJtBaNz9XDKPIY4Hwf+NtRvr23KUZW0AdM3dBhxs2js0P6gFgTr vKXeLsDOhpOGQFEYDpC7pO0IEFblRaIQDP4dbvtf6sfeohyVa4pbAetThmI+nHtm4z Ghim2VhR6ACJeiPRPhvq9oapSHjPY2wOdhWFdkWqAXsyAABO/aKLIRvdAsI+htOO9K sRQG4DD0WUoXEpTDnNDKUJdhurHWQ4jBkqKV/4usG4gM9QYseaDetzDGKGcegNtLa1 4R2l6IvsTu1IiRgYHMJ49HvsAbMmWq3PvTngIZ4rjvg7MvPLYKGGw/BHyB/OnbMP4P lgxohBw8vW3kA== Date: Thu, 1 Jun 2023 18:34:20 +0100 From: Conor Dooley To: Kees Cook Cc: Paul Walmsley , Thorsten Leemhuis , Joan Bruguera =?iso-8859-1?Q?Mic=F3?= , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Conor Dooley , Nick Desaulniers , Alyssa Ross , Heiko Stuebner , "Gustavo A. R. Silva" , linux-riscv@lists.infradead.org, Andrew Jones , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] riscv/purgatory: Do not use fortified string functions Message-ID: <20230601-connected-unbolted-cf708c6da4a1@spud> References: <20230601160025.gonna.868-kees@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gTf3B7hbVc2YnwMI" Content-Disposition: inline In-Reply-To: <20230601160025.gonna.868-kees@kernel.org> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,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 --gTf3B7hbVc2YnwMI Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 01, 2023 at 09:00:28AM -0700, Kees Cook wrote: > With the addition of -fstrict-flex-arrays=3D3, struct sha256_state's > trailing array is no longer ignored by CONFIG_FORTIFY_SOURCE: >=20 > struct sha256_state { > u32 state[SHA256_DIGEST_SIZE / 4]; > u64 count; > u8 buf[SHA256_BLOCK_SIZE]; > }; >=20 > 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. >=20 > Reported-by: Thorsten Leemhuis > Closes: https://lore.kernel.org/lkml/175578ec-9dec-7a9c-8d3a-43f24ff86b92= @leemhuis.info/ > Bisected-by: "Joan Bruguera Mic=F3" > Fixes: df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3D3") > Cc: Paul Walmsley > Cc: Palmer Dabbelt > Cc: Albert Ou > Cc: Masahiro Yamada > Cc: Conor Dooley Reviewed-by: Conor Dooley Thanks for the quick update Kees, Conor. --gTf3B7hbVc2YnwMI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZHjWiwAKCRB4tDGHoIJi 0kIWAP4veZuc8tWugVZu2IOiEMZz7rzMOFo6ZJkp3tl6YRkuVAEA632MtlL3l8y6 KzIVgnx4OmDbCYnaIi/5WDzQtqJwOQ8= =YraL -----END PGP SIGNATURE----- --gTf3B7hbVc2YnwMI--