* [LTP] [PATCH] syscalls/getdents02: reserve big enough buffer
@ 2024-09-16 8:30 Jan Stancek
2024-09-16 10:09 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2024-09-16 8:30 UTC (permalink / raw)
To: ltp
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(-)
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);
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/getdents02: reserve big enough buffer
2024-09-16 8:30 [LTP] [PATCH] syscalls/getdents02: reserve big enough buffer Jan Stancek
@ 2024-09-16 10:09 ` Cyril Hrubis
2024-09-16 10:32 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-09-16 10:09 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp
Hi!
What about the slightly different version from Andreas? Looks a bit better to me.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/getdents02: reserve big enough buffer
2024-09-16 10:09 ` Cyril Hrubis
@ 2024-09-16 10:32 ` Jan Stancek
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2024-09-16 10:32 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
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.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-16 10:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 8:30 [LTP] [PATCH] syscalls/getdents02: reserve big enough buffer Jan Stancek
2024-09-16 10:09 ` Cyril Hrubis
2024-09-16 10:32 ` Jan Stancek
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.