Skip to contentSkip to conversation

read_all: Fix buffer too small for long paths

PATCH Superseded Michael Menasherov via ltp 2 participants 3 messages Sep 6 – Sep 7

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 to 4096 to match MAX_PATH. QUEUE_SIZE (16384) still holds a full-length path.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/fs/read_all/read_all.c +1 -1
index 5720ffb99..d67fe5712 100644
@@ -51,7 +51,7 @@
 #include "tst_timer.h"
 
 #define QUEUE_SIZE 16384
-#define BUFFER_SIZE 1024
+#define BUFFER_SIZE 4096
 #define MAX_PATH 4096
 #define MAX_DISPLAY 40
 
Signature · 5 lines
2.55.0


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

Hi Michael,

testcases/kernel/fs/read_all/read_all.c line 54

Quoted 4 lines · Michael Menasherov

read_all: Fix buffer too small for long paths

testcases/kernel/fs/read_all/read_all.c +1 -1
-#define BUFFER_SIZE 1024
+#define BUFFER_SIZE 4096

queue_pop() still aborts for a 4095-byte pathname: after copying its final byte, ++j is 4095, which satisfies BUFFER_SIZE - 1. Use PATH_MAX for popped and compare j against PATH_MAX so every pathname that fits dent_path also fits the queue buffer.

Verdict - Needs revision

Pre-existing issue:

read_all.c:218 has an unnecessary blank line before a closing brace, as reported by make check.

---
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
#2 lore raw
In reply to Michael Menasherov via ltp

Hi Michael,

testcases/kernel/fs/read_all/read_all.c line 54

Quoted 3 lines

#define QUEUE_SIZE 16384

testcases/kernel/fs/read_all/read_all.c +1 -1
-#define BUFFER_SIZE 1024
+#define BUFFER_SIZE 4096

better to use PATH_MAX here and make sure that when we create a path, PATH_MAX is always preserved as the maximum size of the strings.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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