Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lin Tzu Yang" <rongh7426@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH] leds: trigger: tty: fix overflow in ttyname show
Date: Tue, 01 Dec 2026 06:26:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-242696@kernel.org> (raw)
In-Reply-To: <20261201062037.880601-1-rongh7426@gmail.com>

> ttyname_store() keeps whatever the user writes, without a length
> limit. sysfs passes up to PAGE_SIZE bytes to a store callback, so the
> stored name can be 4096 characters long.
> 
> ttyname_show() prints it back with sprintf(buf, "%s\n", ...). With a
> 4095-byte name that is 4097 bytes, with 4096 bytes it is 4098, both
> past the PAGE_SIZE sysfs buffer. Reading the attribute after writing
> a 4095-byte name gives:
> 
>   BUG: KASAN: slab-out-of-bounds in vsnprintf+0xdd8/0xdfc
>   Write of size 1 at addr ffff00001281f000 by task cat/114
>   ...
>    sprintf+0xb0/0xec
>    ttyname_show+0xec/0x140
>    dev_attr_show+0x48/0xbc
>    sysfs_kf_seq_show+0x160/0x314
> 
> followed by the "OOB write or bad count" warning
> from sysfs_kf_seq_show().
> 
> Use sysfs_emit(), which never writes past PAGE_SIZE. The other show
> callbacks in this file already use it.
> 
> Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lin Tzu Yang <rongh7426@gmail.com>

Sashiko has reviewed this patch and found no issues.

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

      reply	other threads:[~2026-12-01  6:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  6:20 [PATCH] leds: trigger: tty: fix overflow in ttyname show Lin Tzu Yang
2026-12-01  6:26 ` sashiko-bot [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=sashiko-outbox-242696@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rongh7426@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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