Skip to contentSkip to conversation

getdents: account for d_name size in tst_dirp_size

PATCH In review Andreas Schwab 2 participants 2 messages Sep 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 getdents: account for d_name size in tst_dirp_size

The linux_dirent and linux_dirent64 structs do not contain space for the d_name member. Add NAME_MAX to the size in tst_dirp_size so that the getdents syscalls do not spuriously fail with EINVAL instead of EFAULT.

---
 testcases/kernel/syscalls/getdents/getdents.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/getdents/getdents.h +2 -2
index 560df4126..02c3bc509 100644
@@ -64,9 +64,9 @@ tst_dirp_size(void)
 {
 	switch (tst_variant) {
 	case 0:
-		return sizeof(struct linux_dirent);
+		return sizeof(struct linux_dirent) + NAME_MAX;
 	case 1:
-		return sizeof(struct linux_dirent64);
+		return sizeof(struct linux_dirent64) + NAME_MAX;
 #if HAVE_GETDENTS
 	case 2:
 		return sizeof(struct dirent);
Signature · 10 lines
2.46.1


-- 
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andreas Schwab

The linux_dirent and linux_dirent64 structs do not contain space for the d_name member. Add NAME_MAX to the size in tst_dirp_size so that the getdents syscalls do not spuriously fail with EINVAL instead of EFAULT.

Signed-off-by seems missing.

Quoted 32 lines
---
 testcases/kernel/syscalls/getdents/getdents.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/getdents/getdents.h +2 -3
index 560df4126..02c3bc509 100644
@@ -64,9 +64,9 @@ tst_dirp_size(void)
 {
        switch (tst_variant) {
        case 0:
-               return sizeof(struct linux_dirent);
+               return sizeof(struct linux_dirent) + NAME_MAX;
        case 1:
-               return sizeof(struct linux_dirent64);
+               return sizeof(struct linux_dirent64) + NAME_MAX;
 #if HAVE_GETDENTS
        case 2:
                return sizeof(struct dirent);
--

2.46.1

--
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."

--
Mailing list info: https://lists.linux.it/listinfo/ltp

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