Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp516865rwd; Sat, 20 May 2023 01:45:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kAUxGNIr3INCMgdnciyE0MFBI2sZ2N9AVzRNVcIXx3oKmfXaCkNudURQcN0RAbDzpZmnA X-Received: by 2002:a05:6a21:2d8d:b0:104:ffd0:2338 with SMTP id ty13-20020a056a212d8d00b00104ffd02338mr4698203pzb.26.1684572306775; Sat, 20 May 2023 01:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684572306; cv=none; d=google.com; s=arc-20160816; b=mmnN7re05xkVGVuXWM5ntD7zQrzo09Q94okWVbS+XgEnjcLQ0yFD2aWtBUOz2ehE44 cbcJB8wp9AmdMMxhQ2wCWbIVx6qijz8HStpEgs32aW2X4hk2xKYeCZK5ttb21AGz+w5v XeldQmyiNoCbVcwPWts77DNX9CPoBh94FPd/ro/dyMjvDeEhj+sjHWEEA8WA0x1dPu+h H4GNIkqu1F31RCPCl6xD55deQYkvDXgQ11Z4gxzd9kPba/jotO6NGF+zYCJRFCpP6VoE 7FsDaTruvPUo5GY/K6r068nyNnXaukC//Tll2lyVdWBG8qRGXNmdE26CSUyhgJLHLz8n aa+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=Ja15y8XMTe42QTsiGosmU8QGb3JXxs+EBDUNM6FHOus=; b=SDixvoqc2NbYpTFPJbZbkHPAwZXQf0f8G3EV/CdVh0JS989UTH9Ujcup3C8muwZ8ZE CoeMDhfh7Ba2FqW5aoO2Aar2SZT/pohflWRO2P8SJsQUWOpndAsUo8i0hHbNXYi+DC5t t0E20t91czkEe5Hv5XgQ2+Wf940MGSVLxzFSjAkKn4Je6DT8nTGKPI4UZU0jUvvpR0kn tXNHRNL0lZltOAS18wPGDY2CwXsiYfzWNB22mxr78yxQdNJNzPYBcPwgztqzdZR0tM/N tCIoVf8swmC0k87kuCpoauBrZZCGqS9cyI0t6loCPjKOQYsaAI+B4L++KFFUOIJDOwNj zCWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TrRlVig2; dkim=neutral (no key) header.i=@suse.de header.b=E9GLa6sD; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v26-20020a637a1a000000b0051b5de41857si1230546pgc.101.2023.05.20.01.44.44; Sat, 20 May 2023 01:45:06 -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=@suse.de header.s=susede2_rsa header.b=TrRlVig2; dkim=neutral (no key) header.i=@suse.de header.b=E9GLa6sD; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbjETISu (ORCPT + 99 others); Sat, 20 May 2023 04:18:50 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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