* [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() [not found] <20260930235231.out.387-kees@kernel.org> @ 2026-09-30 23:52 ` Kees Cook 2026-10-01 5:40 ` Alison Schofield 0 siblings, 1 reply; 4+ messages in thread From: Kees Cook @ 2026-09-30 23:52 UTC (permalink / raw) To: Bill Wendling Cc: Kees Cook, nvdimm, Alison Schofield, Dave Jiang, Greg Kroah-Hartman, Guangshuo Li, Ira Weiny, Uwe Kleine-König, Vishal Verma, Andy Shevchenko, Steven Rostedt, nikitash.mariiaw, linux-kernel, linux-hardening flags_show() build their output with a seq_buf and return seq_buf_used(), which may include the trailing NUL byte when the seq_buf has overflowed. Use seq_buf_strlen() instead. The flag names are far shorter than the PAGE_SIZE buffer sysfs provides, so this cannot overflow today. Build tested ARCH=x86_64 with GCC 16.2.0, built out of tree with make M=tools/testing/nvdimm: tools/testing/nvdimm/test/ndtest.o Assisted-by: LLM Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Kees Cook <kees@kernel.org> --- tools/testing/nvdimm/test/ndtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c index 2051ad5d4882..f097f2992966 100644 --- a/tools/testing/nvdimm/test/ndtest.c +++ b/tools/testing/nvdimm/test/ndtest.c @@ -693,7 +693,7 @@ static ssize_t flags_show(struct device *dev, if (seq_buf_used(&s)) seq_buf_printf(&s, "\n"); - return seq_buf_used(&s); + return seq_buf_strlen(&s); } static DEVICE_ATTR_RO(flags); -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() 2026-09-30 23:52 ` [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() Kees Cook @ 2026-10-01 5:40 ` Alison Schofield 2026-10-01 23:39 ` Alison Schofield 0 siblings, 1 reply; 4+ messages in thread From: Alison Schofield @ 2026-10-01 5:40 UTC (permalink / raw) To: Kees Cook Cc: Bill Wendling, nvdimm, Dave Jiang, Greg Kroah-Hartman, Guangshuo Li, Ira Weiny, Uwe Kleine-König, Vishal Verma, Andy Shevchenko, Steven Rostedt, nikitash.mariiaw, linux-kernel, linux-hardening On Wed, Sep 30, 2026 at 04:52:38PM -0700, Kees Cook wrote: > flags_show() build their output with a seq_buf and return seq_buf_used(), > which may include the trailing NUL byte when the seq_buf has > overflowed. Use seq_buf_strlen() instead. > > The flag names are far shorter than the PAGE_SIZE buffer sysfs > provides, so this cannot overflow today. > > Build tested ARCH=x86_64 with GCC 16.2.0, built out of tree with > make M=tools/testing/nvdimm: > tools/testing/nvdimm/test/ndtest.o > > Assisted-by: LLM > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Reviewed-by: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Kees Cook <kees@kernel.org> Hi Kees, Should I include this one in a 7.4 PR for nvdimm or is someone else merging the entire series? -- Alison > --- > tools/testing/nvdimm/test/ndtest.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c > index 2051ad5d4882..f097f2992966 100644 > --- a/tools/testing/nvdimm/test/ndtest.c > +++ b/tools/testing/nvdimm/test/ndtest.c > @@ -693,7 +693,7 @@ static ssize_t flags_show(struct device *dev, > if (seq_buf_used(&s)) > seq_buf_printf(&s, "\n"); > > - return seq_buf_used(&s); > + return seq_buf_strlen(&s); > } > static DEVICE_ATTR_RO(flags); > > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() 2026-10-01 5:40 ` Alison Schofield @ 2026-10-01 23:39 ` Alison Schofield 2026-10-03 2:17 ` Kees Cook 0 siblings, 1 reply; 4+ messages in thread From: Alison Schofield @ 2026-10-01 23:39 UTC (permalink / raw) To: Kees Cook Cc: Bill Wendling, nvdimm, Dave Jiang, Greg Kroah-Hartman, Guangshuo Li, Ira Weiny, Uwe Kleine-König, Vishal Verma, Andy Shevchenko, Steven Rostedt, nikitash.mariiaw, linux-kernel, linux-hardening On Wed, Sep 30, 2026 at 10:40:47PM -0700, Alison Schofield wrote: > On Wed, Sep 30, 2026 at 04:52:38PM -0700, Kees Cook wrote: > > flags_show() build their output with a seq_buf and return seq_buf_used(), > > which may include the trailing NUL byte when the seq_buf has > > overflowed. Use seq_buf_strlen() instead. > > > > The flag names are far shorter than the PAGE_SIZE buffer sysfs > > provides, so this cannot overflow today. > > > > Build tested ARCH=x86_64 with GCC 16.2.0, built out of tree with > > make M=tools/testing/nvdimm: > > tools/testing/nvdimm/test/ndtest.o > > > > Assisted-by: LLM > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Reviewed-by: Dave Jiang <dave.jiang@intel.com> > > Signed-off-by: Kees Cook <kees@kernel.org> > > > Hi Kees, > > Should I include this one in a 7.4 PR for nvdimm or is someone else > merging the entire series? NVM, found my answer when trying to build without the entire series. Tagging but won't try to merge - Reviewed-by: Alison Schofield <alison.schofield@intel.com> > > -- Alison > > > > > --- > > tools/testing/nvdimm/test/ndtest.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c > > index 2051ad5d4882..f097f2992966 100644 > > --- a/tools/testing/nvdimm/test/ndtest.c > > +++ b/tools/testing/nvdimm/test/ndtest.c > > @@ -693,7 +693,7 @@ static ssize_t flags_show(struct device *dev, > > if (seq_buf_used(&s)) > > seq_buf_printf(&s, "\n"); > > > > - return seq_buf_used(&s); > > + return seq_buf_strlen(&s); > > } > > static DEVICE_ATTR_RO(flags); > > > > -- > > 2.34.1 > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() 2026-10-01 23:39 ` Alison Schofield @ 2026-10-03 2:17 ` Kees Cook 0 siblings, 0 replies; 4+ messages in thread From: Kees Cook @ 2026-10-03 2:17 UTC (permalink / raw) To: Alison Schofield Cc: Bill Wendling, nvdimm, Dave Jiang, Greg Kroah-Hartman, Guangshuo Li, Ira Weiny, Uwe Kleine-König, Vishal Verma, Andy Shevchenko, Steven Rostedt, nikitash.mariiaw, linux-kernel, linux-hardening On Thu, Oct 01, 2026 at 04:39:57PM -0700, Alison Schofield wrote: > > Should I include this one in a 7.4 PR for nvdimm or is someone else > > merging the entire series? > > NVM, found my answer when trying to build without the entire series. > Tagging but won't try to merge - Right, it needs seq_buf_strlen() from earlier in the series, so I'll take the whole series through my tree. Thanks for the review! -Kees -- Kees Cook ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-03 2:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260930235231.out.387-kees@kernel.org>
2026-09-30 23:52 ` [PATCH v3 10/11] nvdimm: ndtest: Return the string length from flags_show() Kees Cook
2026-10-01 5:40 ` Alison Schofield
2026-10-01 23:39 ` Alison Schofield
2026-10-03 2:17 ` Kees Cook
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox