Message ID | b35bcb5fb9a87e218ddccd3944b961568a831aa4.1726475265.git.jstancek@redhat.com |
---|---|
State | Rejected |
Headers | show |
Series | syscalls/getdents02: reserve big enough buffer | expand |
Hi! What about the slightly different version from Andreas? Looks a bit better to me.
On Mon, Sep 16, 2024 at 12:10 PM Cyril Hrubis <chrubis@suse.cz> wrote: > > Hi! > What about the slightly different version from Andreas? Looks a bit better to me. That works too, test still allocates only single dirp entry, but given what we can expect to find in MNTPOINT that should be enough even if kernel decides to change EINVAL check. I'll ACK his patch.
diff --git a/testcases/kernel/syscalls/getdents/getdents02.c b/testcases/kernel/syscalls/getdents/getdents02.c index 805a8bc481e6..d17410c52afc 100644 --- a/testcases/kernel/syscalls/getdents/getdents02.c +++ b/testcases/kernel/syscalls/getdents/getdents02.c @@ -60,7 +60,8 @@ static void setup(void) { getdents_info(); - size = tst_dirp_size(); + /* reserve big enough buffer for all entries we might find */ + size = 4096; dirp = tst_alloc(size); fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
The test sporadically fails EFAULT testcase because kernel can iterate over directory entries in different order. In most runs the first entry it finds is '.', but in others it can be 'lost+found' or directory/file created by test. Test currently only reserves space for buffer via tst_dirp_size(), which uses sizeof() and doesn't take into account number of entries or the size of d_name. Since sizeof returns the aligned size, in some runs there's just enough space for '.' entry, and test fails as expected on EFAULT. But if there's entry with larger d_name we hit EINVAL check first and test fails. Reserve large enough buffer. Signed-off-by: Jan Stancek <jstancek@redhat.com> --- testcases/kernel/syscalls/getdents/getdents02.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)