read_all: Fix buffer too small for long paths
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.
--- 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
@@ -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
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 pathstestcases/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
Hi Michael,
testcases/kernel/fs/read_all/read_all.c line 54
Quoted 3 lines
#define
QUEUE_SIZE16384testcases/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