From patchwork Tue Jan 10 01:40:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13094572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF54BC54EBD for ; Tue, 10 Jan 2023 01:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233656AbjAJBko (ORCPT ); Mon, 9 Jan 2023 20:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233142AbjAJBke (ORCPT ); Mon, 9 Jan 2023 20:40:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4C62200E; Mon, 9 Jan 2023 17:40:33 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 8EA02B810C3; Tue, 10 Jan 2023 01:40:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38BFAC433D2; Tue, 10 Jan 2023 01:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673314831; bh=ABYz4ZvvBdMvRbwp1IznTPG8KGEBT7V9tcgJKTQXuro=; h=Date:From:To:Cc:Subject:From; b=W3mYbBp9vkdjbVHF2zITSzwHSTgb2Sl9K6C43HXVbbn33c8I19QHvpySmLuybdyQC PNYA4wIpQ3paQHUK5SVTtZTcPRiN7mPxo8QRHVLHftxmpjeEF3XHbCGmtn9tjK1uMe v9kKOf+H1cuM6SUVkQFaffdHBut/81KhMo4Z2vuoxgXi7qrCwBQ9NkBDE1wbkszM3I AND/wO7BTJ7/7LnehbHLx6kZy3gbJHdIc2+u28Qs1Ka8q0oqiHOFUg82JFBdeOOJwG hSwz7Wu6vgUB4CCeMIQnUJwWqXkTr9XJPJs3dxbInq330EaCMRCfqd48gK/5OkcLqI kMcMY3rXesqPA== Date: Mon, 9 Jan 2023 19:40:38 -0600 From: "Gustavo A. R. Silva" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] x86/fpu: Replace zero-length array with flexible-array member Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct xregs_state with flex-array member. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2]. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2] Link: https://github.com/KSPP/linux/issues/78 Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- arch/x86/include/asm/fpu/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h index eb7cd1139d97..7f6d858ff47a 100644 --- a/arch/x86/include/asm/fpu/types.h +++ b/arch/x86/include/asm/fpu/types.h @@ -321,7 +321,7 @@ struct xstate_header { struct xregs_state { struct fxregs_state i387; struct xstate_header header; - u8 extended_state_area[0]; + u8 extended_state_area[]; } __attribute__ ((packed, aligned (64))); /*