Skip to contentSkip to conversation

readdir: delete readdir02

PATCH New Li Wang 2 participants 2 messages Feb 26, 2019

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH v3 1/1 readdir: delete readdir02

Issue:
On ppc64le and aarch64, when testing in NFS mountpoint, test process receives SIGSEGV when calling readdir on a DIR which has just been closed by closedir().

Unfortunately, ltp/readdir02.c handles SIGSEGV. This makes it hits SIGSEGV again in its cleanup function. So readdir02 hangs there hitting SEGV endlessly.

That's because a DIR * is NOT a file descriptor. It's memory allocated by opendir() that contains libc internal information about the directory. closedir(test_dir) frees any memory associated with the open directory pointer test_dir.

To then pass the freed dir pointer to readdir() is a use-after-free. It probably won't return EBADF, it will dereference freed memory and whatever happens after that is undefined.

And, considering LTP does cover the EBADF for getents() syscalls getdents02 test already, here let's remove this readdir02 directly.

Cc Dave Chinner <[email protected]>
Cc Scott Mayhew <[email protected]>
Cc Cyril Hrubis <[email protected]>
---
 runtest/syscalls                              |   1 -
 testcases/kernel/syscalls/readdir/.gitignore  |   1 -
 testcases/kernel/syscalls/readdir/readdir02.c | 142 ------------------
 3 files changed, 144 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/readdir/readdir02.c
runtest/syscalls +0 -1
index 668c87cd1..343e78fc7 100644
@@ -920,7 +920,6 @@ readahead01 readahead01
 readahead02 readahead02
 
 readdir01 readdir01
-readdir02 readdir02
 readdir21 readdir21
 
 readlink01A symlink01 -T readlink01
testcases/kernel/syscalls/readdir/.gitignore +0 -1
index b0b30ff9b..8a67a9c0c 100644
@@ -1,3 +1,2 @@
 /readdir01
-/readdir02
 /readdir21
testcases/kernel/syscalls/readdir/readdir02.c deleted +0 -142

142 lines not on this page · raw message

Signature · 1 line
2.20.1