Skip to contentSkip to conversation

read_all: Fix buffer too small for long paths

PATCH Superseded Michael Menasherov via ltp 2 participants 2 messages Sep 7

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 read_all: Fix buffer too small for long paths

queue_pop() copies each path into popped[BUFFER_SIZE], but BUFFER_SIZE was 1024 while visit_dir() builds paths up to MAX_PATH (4096). Any path longer than 1023 bytes aborted the test with TBROK "Buffer is too small for path".

Set BUFFER_SIZE and MAX_PATH to PATH_MAX so all path buffers and size limits use the standard constant consistently.

Tested on smaller boards and then on local machines with deeply nested directories under /sys; read_all_sys now passes instead of aborting.

Fixes 67c95fbbfc3a ("Add read_all file systems test")
---
 testcases/kernel/fs/read_all/read_all.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/fs/read_all/read_all.c +2 -2
index 5720ffb99..bf5f613a3 100644
@@ -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 {
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Michael,

Quoted 3 lines · Michael Menasherov

read_all: Fix buffer too small for long paths

+#define BUFFER_SIZE PATH_MAX

With the existing if (++j >= BUFFER_SIZE - 1) check, this still rejects a valid PATH_MAX - 1-character pathname and reports TBROK before writing its terminating NUL. A 4095-byte pathname reproduces this on PATH_MAX=4096; change the queue_pop() bound so PATH_MAX - 1 characters fit.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp