Thread (33 messages) 33 messages, 6 authors, 5h ago

[PATCH v4 10/11] nvdimm: ndtest: Return the string length from flags_show()

flat view
HOTtoday SUPERSEDED: 23 (23M)

From: Kees Cook <kees@kernel.org>
Date: 2026-10-03 03:59:25
Also in: bpf, linux-doc, linux-hardening, linux-security-module, linuxppc-dev, lkml, nvdimm
Subsystem: libnvdimm: non-volatile memory device subsystem, the rest · Maintainers: Dan Williams, Vishal Verma, Dave Jiang, Alison Schofield, Linus Torvalds

Revision v4 of 3 in this series; 3 review trailers (2 from subsystem maintainers).

Revisions (3)
  1. v3 [diff vs current]
  2. v4 current
  3. v5 [diff vs current]
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>
Reviewed-by: Alison Schofield <alison.schofield@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.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help