From mboxrd@z Thu Jan 1 00:00:00 1970 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 1B4ECC77B7F for ; Sat, 20 May 2023 08:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjETISt (ORCPT ); Sat, 20 May 2023 04:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjETISq (ORCPT ); Sat, 20 May 2023 04:18:46 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3F21B7; Sat, 20 May 2023 01:18:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AEF561FE47; Sat, 20 May 2023 08:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684570723; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ja15y8XMTe42QTsiGosmU8QGb3JXxs+EBDUNM6FHOus=; b=TrRlVig2P+LX9WwFPVh7icY/Wjb3PYnBq8yJOu4s5z8i+2b09EYtrP6rNEyJxT6L7Af6Ks K46gFc7lkZzsDoyTaxiCI6TNLsKp+7AfrgEPz4L1IyOTV4v47VcICB3P3M3XdjI6PPXryR plh+qafQISx0ezHiij7RFsHvwy/a/10= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684570723; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ja15y8XMTe42QTsiGosmU8QGb3JXxs+EBDUNM6FHOus=; b=E9GLa6sD7W9VyAK5hwendacXi4tzYAhcD2j3Q/nreKGVwYfTP7RDzPJs0dUVbkIPcPXEph WQKc5w4YIJ5zUYBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 86A2F1358F; Sat, 20 May 2023 08:18:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pDYCIGOCaGRfOAAAMHmgww (envelope-from ); Sat, 20 May 2023 08:18:43 +0000 Date: Sat, 20 May 2023 10:18:43 +0200 Message-ID: <87h6s7za8s.wl-tiwai@suse.de> From: Takashi Iwai To: "Gustavo A. R. Silva" Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2][next] ALSA: mixart: Replace one-element arrays with simple object declarations In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Fri, 19 May 2023 22:54:46 +0200, Gustavo A. R. Silva wrote: > > One-element arrays are deprecated, and we are replacing them with flexible > array members instead. However, in this case it seems those one-element > arrays have never actually been used as fake flexible arrays. > > See this code that dates from Linux-2.6.12-rc2 initial git repository build > (commit 1da177e4c3f4 ("Linux-2.6.12-rc2")): > > sound/pci/mixart/mixart_core.h: > 215 struct mixart_stream_state_req > 216 { > 217 u32 delayed; > 218 u64 scheduler; > 219 u32 reserved4np[3]; > 220 u32 stream_count; /* set to 1 for instance */ > 221 struct mixart_flow_info stream_info; /* could be an array[stream_count] */ > 222 } __attribute__((packed)); > > sound/pci/mixart/mixart.c: > 388 > 389 memset(&stream_state_req, 0, sizeof(stream_state_req)); > 390 stream_state_req.stream_count = 1; > 391 stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid; > 392 stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number; > 393 > > So, taking the code above as example, replace multiple one-element > arrays with simple object declarations, and refactor the rest of the > code, accordingly. > > 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 [1]. > > This results in no differences in binary output. > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/296 > Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] > Signed-off-by: Gustavo A. R. Silva Thanks, applied. Takashi