All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: songxiebing <songxiebing@kylinos.cn>
Cc: tiwai@suse.com, perex@perex.cz, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: info: Fix maxsize underflow in snd_info_entry_write()
Date: Wed, 04 Nov 2026 08:09:09 +0100	[thread overview]
Message-ID: <87zevpul7u.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261104061311.1345791-1-songxiebing@kylinos.cn>

On Wed, 04 Nov 2026 07:13:11 +0100,
songxiebing wrote:
> 
> From: Bob Song <songxiebing@kylinos.cn>
> 
> snd_info_entry_write() computes maxsize as entry->size - pos without
> first checking whether pos has already reached entry->size.  If a write
> is issued with an offset beyond the entry size, the subtraction
> underflows and count is left unclamped, so the write callback is called
> with an out-of-range offset and the original count.
> 
> The read path already handles this case by returning 0 when
> pos >= entry->size.  Add the same check to the write path.
> 
> Fixes: d97e1b78239c ("ALSA: info - Check file position validity in common layer")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Bob Song <songxiebing@kylinos.cn>

This was already addressed in Christian's recent patchset.
https://lore.kernel.org/20261102-work-procfs-bugfixes-v1-9-59422ed3e465@kernel.org

(... and he mentioned that return 0 would lead to endless stdio
retry, too.)


thanks,

Takashi

> ---
>  sound/core/info.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/core/info.c b/sound/core/info.c
> index 3b8ccda04e1a..676b06e0d463 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -171,6 +171,8 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer
>  	pos = *offset;
>  	if (!valid_pos(pos, count))
>  		return -EIO;
> +	if (pos >= entry->size)
> +		return 0;
>  	if (count > 0) {
>  		size_t maxsize = entry->size - pos;
>  		count = min(count, maxsize);
> -- 
> 2.25.1
> 

  reply	other threads:[~2026-11-04  7:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  6:13 [PATCH] ALSA: info: Fix maxsize underflow in snd_info_entry_write() songxiebing
2026-11-04  7:09 ` Takashi Iwai [this message]
2026-11-04  8:46 ` songxiebing

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=87zevpul7u.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=songxiebing@kylinos.cn \
    --cc=stable@vger.kernel.org \
    --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 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.