* [LTP] [PATCH 0/3] Fix bugs in LTP core library
@ 2026-07-17 12:33 Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow Andrea Cervesato
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-07-17 12:33 UTC (permalink / raw)
To: Linux Test Project
These bugs were found by LLM long time ago, after asking to check for
errors in memory management and general usage. An in-depth analysis was
not done, because these were mostly cases where LTP might produce false
positives or crash the application. Keep it simple.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Andrea Cervesato (3):
lib: Avoid loop_info.lo_name buffer overflow
lib: Close directory fd on ENOSPC in tst_fill_fs
lib: Fix wrong field in tst_iovec_alloc
lib/tst_buffers.c | 2 +-
lib/tst_device.c | 2 +-
lib/tst_fill_fs.c | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
---
base-commit: a67fe5f7b20492ff6ee7f4b1776a7579d4b3859b
change-id: 20260717-fix_core_library-c9fef66bd8df
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread* [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow
2026-07-17 12:33 [LTP] [PATCH 0/3] Fix bugs in LTP core library Andrea Cervesato
@ 2026-07-17 12:33 ` Andrea Cervesato
2026-07-17 13:33 ` [LTP] " linuxtestproject.agent
2026-07-17 12:33 ` [LTP] [PATCH 2/3] lib: Close directory fd on ENOSPC in tst_fill_fs Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 3/3] lib: Fix wrong field in tst_iovec_alloc Andrea Cervesato
2 siblings, 1 reply; 5+ messages in thread
From: Andrea Cervesato @ 2026-07-17 12:33 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
The backing file path may be longer than the fixed-size lo_name field,
so an unbounded strcpy() can overflow the loop_info structure. Copy at
most the field size and rely on the preceding memset() for termination.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
lib/tst_device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_device.c b/lib/tst_device.c
index d3c53a1a18d2e4948ebff21d6d66c0ccd1590c6f..b5c3ccdb7be52ce600fbd7d7a83f6081df65d616 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -182,7 +182,7 @@ int tst_attach_device(const char *dev, const char *file)
* LOOP_SET_FD and LOOP_SET_STATUS.
*/
memset(&loopinfo, 0, sizeof(loopinfo));
- strcpy(loopinfo.lo_name, file);
+ strncpy(loopinfo.lo_name, file, sizeof(loopinfo.lo_name) - 1);
if (ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo)) {
close(dev_fd);
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH 2/3] lib: Close directory fd on ENOSPC in tst_fill_fs
2026-07-17 12:33 [LTP] [PATCH 0/3] Fix bugs in LTP core library Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow Andrea Cervesato
@ 2026-07-17 12:33 ` Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 3/3] lib: Fix wrong field in tst_iovec_alloc Andrea Cervesato
2 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-07-17 12:33 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
The directory descriptor opened at the top of the function was leaked
when openat() failed with ENOSPC and the function returned early. Close
it before returning.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
lib/tst_fill_fs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/tst_fill_fs.c b/lib/tst_fill_fs.c
index c62d48e289965d59ef6c877870c6047bbecb33da..b1e48fdeea6ab00848aab482fd3899fc6f6ce23c 100644
--- a/lib/tst_fill_fs.c
+++ b/lib/tst_fill_fs.c
@@ -91,6 +91,7 @@ static void fill_flat_vec(const char *path, int verbose)
if (fd == -1) {
if (errno == ENOSPC) {
tst_res(TINFO | TERRNO, "openat()");
+ SAFE_CLOSE(dir);
return;
}
tst_brk(TBROK | TERRNO, "openat(%d, %d, 0600) failed for path %s",
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH 3/3] lib: Fix wrong field in tst_iovec_alloc
2026-07-17 12:33 [LTP] [PATCH 0/3] Fix bugs in LTP core library Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 2/3] lib: Close directory fd on ENOSPC in tst_fill_fs Andrea Cervesato
@ 2026-07-17 12:33 ` Andrea Cervesato
2 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-07-17 12:33 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
The zero-size branch assigned iov_base twice and left iov_len unset,
clearly a copy-paste typo. Set iov_len to 0 as intended.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
lib/tst_buffers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_buffers.c b/lib/tst_buffers.c
index ac76a784bb7060ad46815310b56b2a4229bfd395..048b322457c3173df61e0617ad0bc190581c78a7 100644
--- a/lib/tst_buffers.c
+++ b/lib/tst_buffers.c
@@ -123,7 +123,7 @@ struct iovec *tst_iovec_alloc(int sizes[])
iovec[i].iov_len = sizes[i];
} else {
iovec[i].iov_base = NULL;
- iovec[i].iov_base = 0;
+ iovec[i].iov_len = 0;
}
}
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-17 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 12:33 [LTP] [PATCH 0/3] Fix bugs in LTP core library Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow Andrea Cervesato
2026-07-17 13:33 ` [LTP] " linuxtestproject.agent
2026-07-17 12:33 ` [LTP] [PATCH 2/3] lib: Close directory fd on ENOSPC in tst_fill_fs Andrea Cervesato
2026-07-17 12:33 ` [LTP] [PATCH 3/3] lib: Fix wrong field in tst_iovec_alloc Andrea Cervesato
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.