Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] read_all: Fix buffer too small for long paths
@ 2026-09-08  9:22 Michael Menasherov via ltp
  2026-09-08 10:42 ` [LTP] " linuxtestproject.agent
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Menasherov via ltp @ 2026-09-08  9:22 UTC (permalink / raw)
  To: ltp

queue_pop() copies each path into popped[BUFFER_SIZE], but BUFFER_SIZE
was 1024 while visit_dir() builds paths up to PATH_MAX. Any path longer
than 1023 bytes aborted the test with TBROK.

Use PATH_MAX for BUFFER_SIZE and MAX_PATH, and drop the extra -1 from
the queue_pop() bound so a PATH_MAX - 1 character path fits.

Tested on smaller boards and then on local machines with deeply nested
directories under /sys.

Fixes: 67c95fbbfc3a ("Add read_all file systems test")
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
 testcases/kernel/fs/read_all/read_all.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c
index 5720ffb99..ec9454fc9 100644
--- a/testcases/kernel/fs/read_all/read_all.c
+++ b/testcases/kernel/fs/read_all/read_all.c
@@ -51,8 +51,8 @@
 #include "tst_timer.h"
 
 #define QUEUE_SIZE 16384
-#define BUFFER_SIZE 1024
-#define MAX_PATH 4096
+#define BUFFER_SIZE PATH_MAX
+#define MAX_PATH PATH_MAX
 #define MAX_DISPLAY 40
 
 struct queue {
@@ -131,7 +131,7 @@ static int queue_pop(struct queue *q)
 	while (q->data[i]) {
 		q->popped[j] = q->data[i];
 
-		if (++j >= BUFFER_SIZE - 1)
+		if (++j >= BUFFER_SIZE)
 			tst_brk(TBROK, "Buffer is too small for path");
 
 		 i = (i + 1) % QUEUE_SIZE;
-- 
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-15 14:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08  9:22 [LTP] [PATCH v3] read_all: Fix buffer too small for long paths Michael Menasherov via ltp
2026-09-08 10:42 ` [LTP] " linuxtestproject.agent
2026-09-11  7:17 ` [LTP] [PATCH v3] " Andrea Cervesato via ltp
2026-09-15 12:57 ` Cyril Hrubis
2026-09-15 14:00   ` Michael Menasherov via ltp
2026-09-15 14:44     ` Cyril Hrubis
2026-09-15 14:52       ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox