From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Babanpreet Singh <bbnpreetsingh@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Angelo Dureghello" <adureghello@baylibre.com>,
linux@analog.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: dac: ad3552r-hs: use sysfs_emit_at() in data source avail show
Date: Sat, 18 Jul 2026 11:34:29 +0300 [thread overview]
Message-ID: <als6lRi-H4DM7ra6@ashevche-desk.local> (raw)
In-Reply-To: <20260718044244.7-1-bbnpreetsingh@gmail.com>
On Sat, Jul 18, 2026 at 04:42:44AM +0000, Babanpreet Singh wrote:
> ad3552r_hs_show_data_source_avail() formats the available data source
> names into a 128-byte stack buffer, but bounds each scnprintf() with
> PAGE_SIZE instead of the buffer size, so the bound does not protect
> the destination at all.
>
> This cannot overflow today - dbgfs_attr_source[] has two entries,
> "normal" and "ramp-16bit", 18 bytes formatted - but the bound stops
> protecting the stack the day the table grows.
>
> Found by smatch:
>
> drivers/iio/dac/ad3552r-hs.c:593 ad3552r_hs_show_data_source_avail()
> error: scnprintf() 'buf[len]' too small (128 vs 4096)
> Fixes: b1c5d68ea66e ("iio: dac: ad3552r-hs: add support for internal ramp")
> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
This whole thing is not what I suggested, I only had an idea of using
sysfs_emit_at(). BUT...
...
> static ssize_t ad3552r_hs_show_data_source_avail(struct file *f,
> char __user *userbuf,
...I haven't paid attention that this is not sysfs attribute handling
in the default way, this is customized one and the passed buffer is
in user space.
> size_t count, loff_t *ppos)
Hence the correct fix is just replace PAGE_SIZE with sizeof(buf) as it was
I suppose in v1. Sorry for my mistake.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-07-18 8:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 4:42 Babanpreet Singh
2026-07-18 8:34 ` Andy Shevchenko [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=als6lRi-H4DM7ra6@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=adureghello@baylibre.com \
--cc=andy@kernel.org \
--cc=bbnpreetsingh@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®