All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Brahmajit Das <listout@listout.xyz>
Cc: linux-sound@vger.kernel.org, linux-next@vger.kernel.org,
	cezary.rojewski@intel.com, liam.r.girdwood@linux.intel.com,
	peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
	broonie@kernel.org
Subject: Re: [RFC PATCH] ASoC: Intel: avs: Fix reading 1 or more bytes from a region of size 0
Date: Tue, 02 Sep 2025 10:15:23 +0200	[thread overview]
Message-ID: <87qzwp9so4.wl-tiwai@suse.de> (raw)
In-Reply-To: <20250902080812.684149-1-listout@listout.xyz>

On Tue, 02 Sep 2025 10:08:12 +0200,
Brahmajit Das wrote:
> 
> Building the next tree with GCC 16, results in the following error:
> 
> sound/soc/intel/avs/path.c:137:38: error: ‘strcmp’ reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
>   137 |         return id->id == id2->id && !strcmp(id->tplg_name, id2->tplg_name);
>       |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from sound/soc/intel/avs/path.h:14,
>                  from sound/soc/intel/avs/path.c:15:
> sound/soc/intel/avs/topology.h: In function ‘avs_condpaths_walk’:
> sound/soc/intel/avs/topology.h:150:13: note: at offset 4 into source object ‘id’ of size 4
>   150 |         u32 id;
>       |             ^~
> sound/soc/intel/avs/topology.h:150:13: note: at offset 4 into source object ‘id’ of size 4
> 
> I'm not quite sure if this is a GCC bug or a problem with the source
> code.
> As an workaround, instead of using strcmp, strncmp helps. But would
> really appriciate comments from developers as I'm sure there might be a
> better way to fix this.
> 
> Introduced by commit 595b7f155b926 ("ASoC: Intel: avs: Conditional-path
> support")
> 
> Signed-off-by: Brahmajit Das <listout@listout.xyz>
> ---
>  sound/soc/intel/avs/path.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
> index 7aa20fcf1a33..8c3df2002b58 100644
> --- a/sound/soc/intel/avs/path.c
> +++ b/sound/soc/intel/avs/path.c
> @@ -134,7 +134,8 @@ static struct avs_tplg_path *avs_condpath_find_variant(struct avs_dev *adev,
>  static bool avs_tplg_path_template_id_equal(struct avs_tplg_path_template_id *id,
>  					    struct avs_tplg_path_template_id *id2)
>  {
> -	return id->id == id2->id && !strcmp(id->tplg_name, id2->tplg_name);
> +	return id->id == id2->id &&
> +	       !strncmp(id->tplg_name, id2->tplg_name, strlen(id->tplg_name));

Please use sizeof()-1 instead of strlen(), as it's a fixed size array.

Practically seen, it's likely a false-positive from the new compiler.
But it's still safer to add the boundary check in the code itself.


thanks,

Takashi

  reply	other threads:[~2025-09-02  8:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  8:08 [RFC PATCH] ASoC: Intel: avs: Fix reading 1 or more bytes from a region of size 0 Brahmajit Das
2025-09-02  8:15 ` Takashi Iwai [this message]
2025-09-02 10:13   ` [RFC PATCH v2] " Brahmajit Das
2025-09-04  8:40   ` [RFC PATCH] " Brahmajit Das
2025-09-04  9:14     ` Takashi Iwai

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=87qzwp9so4.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=listout@listout.xyz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=yung-chuan.liao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.