On Tue, Jan 13, 2026 at 07:07:01PM +0000, Al Viro wrote: > FWIW, an unpleasant surprise is that LTP apparently doesn't test that > case anywhere - the effect of that braino is to lower the cutoff for > name length by 48 characters and there's not a single test in there > that would test that ;-/ > > chdir04 does check that name component is not too long, but that's > a different codepath - it's individual filesystem's ->lookup() rejecting > a component. > > Oh, well - not hard to add (to the same chdir04, for example)...
Crude variant on top of https://github.com/linux-test-project/ltp #master: diff --git a/testcases/kernel/syscalls/chdir/chdir04.c b/testcases/kernel/syscalls/chdir/chdir04.c index 6e53b7fef..7e959e090 100644 --- a/testcases/kernel/syscalls/chdir/chdir04.c +++ b/testcases/kernel/syscalls/chdir/chdir04.c @@ -11,6 +11,8 @@ #include "tst_test.h" static char long_dir[] = "abcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; +static char long_path_4096[4096+1]; +static char long_path_4094[4094+1]; static char noexist_dir[] = "noexistdir"; static struct tcase { @@ -20,16 +22,26 @@ static struct tcase { {long_dir, ENAMETOOLONG}, {noexist_dir, ENOENT}, {0, EFAULT}, // bad_addr + {long_path_4096, ENAMETOOLONG}, + {long_path_4094, 0}, }; static void verify_chdir(unsigned int i) { - TST_EXP_FAIL(chdir(tcases[i].dir), tcases[i].exp_errno, "chdir()"); + if (tcases[i].exp_errno) + TST_EXP_FAIL(chdir(tcases[i].dir), tcases[i].exp_errno, "chdir()"); + else + TST_EXP_PASS(chdir(tcases[i].dir), "chdir()"); } static void setup(void) { tcases[2].dir = tst_get_bad_addr(NULL); + for (int i = 0; i < 4096; ) { + long_path_4096[i++] = '.'; + long_path_4096[i++] = '/'; + } + memcpy(long_path_4094, long_path_4096, 4094); } static struct tst_test test = {
