* [LTP] [PATCH] syscalls/rename10: Test long file name too
@ 2023-10-25 15:33 Kevin Brodsky
2023-10-25 21:05 ` Petr Vorel
2023-10-26 8:49 ` Cyril Hrubis
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Brodsky @ 2023-10-25 15:33 UTC (permalink / raw)
To: ltp; +Cc: Kevin Brodsky
Commit 5b706c4ee104 ("Provide a PATH_MAX-long buffer when expecting
ENAMETOOLONG") modified rename10 in order to prevent out-of-bound
uaccess. However, in so doing, it changed the failure mode of the
rename() syscall: instead of the path being rejected by the
filesystem, due to the file name being too long, it is now rejected
directly by the syscall handler as the path itself is too long.
This patch adds a new long_name string that triggers the "file name
too long" failure mode, while preserving the "path too long" failure
mode for long_path. Unlike the original buffer (before commit
5b706c4ee104), no out-of-bound uaccess occurs when passing long_name
to rename(), as long_name is a null-terminated string that is short
enough to be interpreted as a valid path.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
---
CI run: https://github.com/kevin-brodsky-arm/ltp/actions/runs/6642693217
See also: https://lore.kernel.org/ltp/20231023135647.2157030-1-kevin.brodsky@arm.com/T/#m3d1649d695faa4426f141bb1beeb3b4762ca5876
testcases/kernel/syscalls/rename/rename10.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/testcases/kernel/syscalls/rename/rename10.c b/testcases/kernel/syscalls/rename/rename10.c
index 3eab4be0f913..5b5f79073e6b 100644
--- a/testcases/kernel/syscalls/rename/rename10.c
+++ b/testcases/kernel/syscalls/rename/rename10.c
@@ -18,7 +18,13 @@
#define MNT_POINT "mntpoint"
#define TEMP_FILE "tmpfile"
+/* Path longer than PATH_MAX: fails the syscall right away (getname() fails) */
static char long_path[PATH_MAX + 1] = {[0 ... PATH_MAX] = 'a'};
+/*
+ * Path fitting in PATH_MAX, but with an excessively long file name: rejected
+ * by the underlying filesystem
+ */
+static char long_name[PATH_MAX] = {[0 ... PATH_MAX - 2] = 'a', [PATH_MAX - 1] = '\0'};
static void setup(void)
{
@@ -30,6 +36,8 @@ static void run(void)
{
TST_EXP_FAIL(rename(TEMP_FILE, long_path),
ENAMETOOLONG);
+ TST_EXP_FAIL(rename(TEMP_FILE, long_name),
+ ENAMETOOLONG);
}
static struct tst_test test = {
--
2.38.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/rename10: Test long file name too
2023-10-25 15:33 [LTP] [PATCH] syscalls/rename10: Test long file name too Kevin Brodsky
@ 2023-10-25 21:05 ` Petr Vorel
2023-10-26 8:49 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2023-10-25 21:05 UTC (permalink / raw)
To: Kevin Brodsky; +Cc: ltp
Hi Kevin,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/rename10: Test long file name too
2023-10-25 15:33 [LTP] [PATCH] syscalls/rename10: Test long file name too Kevin Brodsky
2023-10-25 21:05 ` Petr Vorel
@ 2023-10-26 8:49 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2023-10-26 8:49 UTC (permalink / raw)
To: Kevin Brodsky; +Cc: ltp
Hi!
Applied, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-26 8:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 15:33 [LTP] [PATCH] syscalls/rename10: Test long file name too Kevin Brodsky
2023-10-25 21:05 ` Petr Vorel
2023-10-26 8:49 ` Cyril Hrubis
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.