linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	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
Date: Sat, 20 May 2023 10:18:43 +0200	[thread overview]
Message-ID: <87h6s7za8s.wl-tiwai@suse.de> (raw)
In-Reply-To: <ZGfiFjcL8+r3mayq@work>

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 <gustavoars@kernel.org>

Thanks, applied.


Takashi

      reply	other threads:[~2023-05-20  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 20:54 [PATCH v2][next] ALSA: mixart: Replace one-element arrays with simple object declarations Gustavo A. R. Silva
2023-05-20  8:18 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6s7za8s.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).