All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ștefan Ghețu" <stefanghetu9@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] ASoC: SOF: Bound the panic filename print to its array size
Date: Wed, 09 Sep 2026 20:49:53 +0000	[thread overview]
Message-ID: <20260909204953.8669D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260909204042.46656-1-stefanghetu9@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uninitialized kernel stack memory (infoleak) is printed to the kernel log due to early returns in DSP get_registers functions on malformed firmware data.
--

commit 912b1c487de64ea505751942c78c4e99b655cbf5
Author: Ștefan Ghețu <stefanghetu9@gmail.com>

ASoC: SOF: Bound the panic filename print to its array size

This commit limits the printk format specifier for the panic filename
to SOF_TRACE_FILENAME_SIZE to avoid over-reading a non-null-terminated
string array.

> diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
> index 2d394389c945b..9b0850e87bf60 100644
> --- a/sound/soc/sof/core.c
> +++ b/sound/soc/sof/core.c
> @@ -152,7 +152,8 @@ void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
>  	dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code);
>  
>  out:
> -	dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename,
> +	dev_printk(level, sdev->dev, "panic at %.*s:%d\n",
> +		   SOF_TRACE_FILENAME_SIZE, panic_info->filename,

[Severity: High]
This isn't a bug introduced by this patch, but does this function leak
uninitialized kernel stack memory if the DSP firmware sends a malformed oops
header?

Looking at caller sequences like hda_dsp_dump(), the panic_info and stack
variables are allocated on the stack without zero-initialization:

sound/soc/sof/intel/hda-dsp.c:hda_dsp_dump() {
	struct sof_ipc_panic_info panic_info;
	u32 stack[HDA_DSP_STACK_DUMP_SIZE];
	...
	hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, ...);
	sof_print_oops_and_stack(..., &panic_info, stack, ...);
}

However, architecture-specific register getters like hda_dsp_get_registers()
and atom_get_registers() can return early without initializing this memory
if the header size is invalid:

sound/soc/sof/intel/hda-dsp.c:hda_dsp_get_registers() {
	if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) {
		dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n", ...);
		return;
	}
	...
}

Because these getter functions return void rather than an error code, the
callers continue unconditionally and pass the uninitialized variables to
sof_print_oops_and_stack().

This function then logs panic_info->filename, panic_info->linenum, and
loops through the uninitialized stack array via sof_stack(). Could this
allow a buggy or compromised firmware to trigger a dump of uninitialized
kernel stack memory into the kernel log?

>  		   panic_info->linenum);
>  	sof_oops(sdev, level, oops);
>  	sof_stack(sdev, level, oops, stack, stack_words);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909204042.46656-1-stefanghetu9@gmail.com?part=1

  parent reply	other threads:[~2026-09-09 20:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 20:40 [PATCH] ASoC: SOF: Bound the panic filename print to its array size Ștefan Ghețu
2026-09-09 20:40 ` [PATCH] ASoC: SOF: imx: Prevent stack OOB read in DSP panic dump Ștefan Ghețu
2026-09-09 20:49   ` sashiko-bot
2026-09-10 13:17   ` Mark Brown
2026-09-10 13:26     ` Péter Ujfalusi
2026-09-09 20:49 ` sashiko-bot [this message]
2026-09-10 12:15 ` [PATCH] ASoC: SOF: Bound the panic filename print to its array size Péter Ujfalusi

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=20260909204953.8669D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=stefanghetu9@gmail.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.