From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
linux-iio@vger.kernel.org, "Jinseob Kim" <kimjinseob88@gmail.com>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
"Sanjay Chitroda" <sanjayembeddedse@gmail.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
sashiko-bot@kernel.org
Subject: Re: [PATCH v2] iio: buffer: Ensure bounce buffer used for unaligned case is zeroed.
Date: Sun, 14 Jun 2026 20:52:36 +0100 [thread overview]
Message-ID: <20260614205236.117b669a@jic23-huawei> (raw)
In-Reply-To: <f1d569e66abbe0c065f0f4f889f82f8e9343a2c5.camel@gmail.com>
On Mon, 08 Jun 2026 21:00:30 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Fri, 2026-06-05 at 22:18 +0300, Andy Shevchenko wrote:
> > On Fri, Jun 05, 2026 at 02:50:00PM +0100, Jonathan Cameron wrote:
> > > On Thu, 4 Jun 2026 12:10:42 +0300
> > > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > > On Thu, Jun 04, 2026 at 09:43:07AM +0100, Jonathan Cameron wrote:
> >
> > ...
> >
> > > > > indio_dev->scan_bytes, GFP_KERNEL);
> > > > > if (!bb)
> > > > > return -ENOMEM;
> > > > > + memset(bb, 0, indio_dev->scan_bytes);
> > > >
> > > > May I suggest different approach, id est use __GFP_ZERO instead of hunting
> > > > correct pointers?
> > >
> > > That's a weird beast when combined with a krealloc so I was a bit
> > > nervous about readability (and less so whether it was correct).
> > > It should be fine in that we will either get stale data or zeros
> > > because we always use this path to allocate the buffer so if you
> > > think it is obviously fine then I don't mind.
> > >
> > > The oddities are that if an object grows within a slab but doesn't need
> > > a new one we are relying on those bits happening to be zero based on the
> > > original allocation doing __GFP_ZERO as well (as it's the same call)
> > >
> > > I'm nervous though as that region off the end is sometimes used for
> > > debug objects and I really don't understand that bit of slab well enough.
> > > If it actually does this, then seems like we'd end up with a lot of
> > > nasty corner cases so I assume it doesn't.
> >
> > Such a bug will be a serious issue in mm. I don't think it exists.
> > But, of course, chances are not completely 0.
> >
> > Current users (not a comprehensive list)
> >
> > arch/arm64/kvm/nested.c:92
> > drivers/firmware/efi/capsule-loader.c:61
> > drivers/gpio/gpiolib.c:5198
> > drivers/media/platform/amphion/vdec.c:329
> > drivers/net/ethernet/intel/ice/ice_lib.c:3044
> > drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c:785
> > drivers/net/wireless/ti/wl18xx/main.c:1582
> > drivers/nvme/target/pci-epf.c:708
> > drivers/spi/spi.c:1411
> > drivers/usb/gadget/function/uvc_configfs.c:880
> > fs/ceph/mdsmap.c:322
> > fs/smb/server/ksmbd_work.c:123
> > lib/tests/slub_kunit.c:273
> > sound/soc/meson/meson-card-utils.c:49
> >
> > Also note the kernel-doc for krealloc_array(). It has some note WRT __GFP_ZERO
> > and it means the flag must be supported. Also there is a note in mm/slub.c.
> >
> > > However, I couldn't convince myself enough not to just force a memset of the
> > > whole thing.
> >
> > I personally would go with __GFP_ZERO.
>
> If I'm not missing anything, this should also be proof that the flag should be fine:
>
> https://elixir.bootlin.com/linux/v7.1-rc7/source/lib/tests/slub_kunit.c#L275
>
Perfect! Thanks. I'll hopefully spin an updated version in next few days
Jonathan
> - Nuno Sá
next prev parent reply other threads:[~2026-06-14 19:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 8:43 [PATCH v2] iio: buffer: Ensure bounce buffer used for unaligned case is zeroed Jonathan Cameron
2026-06-04 9:10 ` Andy Shevchenko
2026-06-05 13:50 ` Jonathan Cameron
2026-06-05 19:18 ` Andy Shevchenko
2026-06-08 20:00 ` Nuno Sá
2026-06-14 19:52 ` Jonathan Cameron [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-08-03 1:22 Jonathan Cameron
2026-08-03 9:05 ` Nuno Sá
2026-08-03 9:26 ` Joshua Crofts
2026-08-04 23:54 ` Jonathan Cameron
2026-08-11 10:32 ` 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=20260614205236.117b669a@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=joshua.crofts1@gmail.com \
--cc=kimjinseob88@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@analog.com \
--cc=sanjayembeddedse@gmail.com \
--cc=sashiko-bot@kernel.org \
/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.