From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: Maxwell Doose <m32285159@gmail.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Dan Carpenter <error27@gmail.com>, Nuno Sa <nuno.sa@analog.com>,
Olivier Moysan <olivier.moysan@foss.st.com>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: backend: fix uninitialized data in debugfs
Date: Tue, 9 Jun 2026 14:09:50 +0100 [thread overview]
Message-ID: <20260609140950.70cd6810@jic23-huawei> (raw)
In-Reply-To: <aifJtgLkM2m3KciV@nsa>
On Tue, 9 Jun 2026 09:10:14 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, Jun 08, 2026 at 04:51:38PM -0500, Maxwell Doose wrote:
> > On Mon, 08 Jun 2026 21:31:14 +0100
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >
> > > On Fri, 2026-06-05 at 11:28 +0300, Andy Shevchenko wrote:
> > > > On Fri, Jun 05, 2026 at 09:12:38AM +0300, Dan Carpenter wrote:
> > > > > On Thu, Jun 04, 2026 at 05:55:08PM +0300, Andy Shevchenko wrote:
> > > > > > On Thu, Jun 04, 2026 at 01:42:11PM +0300, Dan Carpenter wrote:
> > > > > > > On Thu, Jun 04, 2026 at 01:38:50PM +0300, Dan Carpenter wrote:
> > > > > > > > 168 ret = sscanf(buf, "%i %i", &back->cached_reg_addr, &val);
> > > > > > > > ^^^
> > > > > > > > Uninitialized variable.
> > > > > > >
> > > > > > > s/variable/data/.
> > > > > >
> > > > > > With what I asked in the previous reply and what you explained there
> > > > > > (thanks, btw!) I still think your patches are not fully correct. They
> > > > > > will require to atomically write all or nothing. If we want support
> > > > > > partial writes we need to go with that differently (reset ppos when
> > > > > > we got enough or more than enough data).
> > > > >
> > > > > Requiring writes to syfs and debugfs be atomic is pretty normal and
> > > > > works well in practice. These are very small writes.
> > > >
> > > > Perhaps. In any case your patch will break existing partial writes, right?
> > > > I'm still considering that resetting ppos is the right thing to do. Just
> > > > need to find where the best place is to do that.
> > >
> > > I think anyone doing partial writes on a debugfs interface like this one is very
> > > unlikely but it is a fair point, yes. But can't we be more relaxed on debugfs? No
> > > userspace app should be relying on debugfs in order to work (though I know that
> > > actually happens).
> > >
> > > Anyways, this is one of those interesting edge cases and easy enough to get wrong. I
> > > guess we should either:
> > >
> > > 1. Improve simple_write_to_buffer() docs;
> > > 2. Or come up with a new simple_write_once_to_buffer() helper?
> > >
> >
> > When you say "simple_write_once_to_buffer()" do you mean a wrapper
> > around simple_write_to_buffer() that also checks if *ppos is 0 and
> > returns -EINVAL if *ppos isn't 0? If so I can start writing that
> > function. Though I guess we probably want to ask Jonathan about it
> > first since obviously he'll have his own opinions.
>
> Yeah basically not allowing partial writes. Partial writes are also very
> tricky to handle in terms of concurrency (assuming userspace can do
> whatever they want). But I would not rush into writing the helper
> without understanding how people feel about it (at least the ones in
> this thread). Might not be super beneficial.
I'd be fine with such a helper. No huge rush though as I don't plan
to back out the patch that kicked off this long discussion.
Hence it would be an improvement on top of that. Dan probably is
the right person to offer a considered view on whether it is worth yet
another helper.
Jonathan
>
> - Nuno Sá
>
> >
> > --
> > best regards,
> > max
next prev parent reply other threads:[~2026-06-09 13:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 7:16 Dan Carpenter
2026-05-25 13:20 ` Maxwell Doose
2026-05-26 18:19 ` Jonathan Cameron
2026-06-04 7:30 ` Andy Shevchenko
2026-06-04 7:38 ` Andy Shevchenko
2026-06-04 7:45 ` Dan Carpenter
2026-06-04 8:03 ` Andy Shevchenko
2026-06-04 8:28 ` Andy Shevchenko
2026-06-04 10:38 ` Dan Carpenter
2026-06-04 10:42 ` Dan Carpenter
2026-06-04 14:55 ` Andy Shevchenko
2026-06-05 6:12 ` Dan Carpenter
2026-06-05 8:28 ` Andy Shevchenko
2026-06-05 14:38 ` Maxwell Doose
2026-06-08 20:31 ` Nuno Sá
2026-06-08 21:51 ` Maxwell Doose
2026-06-09 8:10 ` Nuno Sá
2026-06-09 12:16 ` Andy Shevchenko
2026-06-09 13:09 ` Jonathan Cameron [this message]
2026-06-09 6:21 ` Dan Carpenter
2026-06-09 6:19 ` Dan Carpenter
2026-06-10 10:41 ` Andy Shevchenko
2026-06-10 12:19 ` Dan Carpenter
2026-06-10 13:44 ` Andy Shevchenko
2026-06-04 14:52 ` Andy Shevchenko
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=20260609140950.70cd6810@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=error27@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m32285159@gmail.com \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.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®