* [LTP] [PATCH v2] waitid10: Set the core dump file location to temporary directory
@ 2024-04-03 5:18 Hui Min Mina Chou via ltp
2024-04-03 10:59 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Hui Min Mina Chou via ltp @ 2024-04-03 5:18 UTC (permalink / raw)
To: ltp; +Cc: Hui Min Mina Chou, tim609, cynthia, az70021
When testing via NFS mount LTP folder on the board, with the NFS server
configured using 'anonuid' and 'anongid' options to set specific
uid/gid, waitid10 fails. This is due to a uid mismatch during core dump
file creation, leading to an aborted dump, resulting in the child
process receiving the signal CLD_KILLED instead of CLD_DUMPED.
# ./waitid10
tst_buffers.c:56: TINFO: Test is using guarded buffers
tst_test.c:1732: TINFO: LTP version: 20240129
tst_test.c:1616: TINFO: Timeout per run is 0h 05m 00s
waitid10.c:64: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
[ 296.482665] mnt_uid= 1036, curr_uid= 0
[ 296.483041] Core dump to core aborted: cannot preserve file owner
waitid10.c:36: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
waitid10.c:37: TPASS: infop->si_pid == pidchild (149)
waitid10.c:38: TPASS: infop->si_status == SIGFPE (8)
waitid10.c:39: TPASS: infop->si_signo == SIGCHLD (17)
waitid10.c:42: TFAIL: infop->si_code (2) != CLD_DUMPED (3)
Therefore, referring to madvise08, during testing, set the core dump file
to the temporary directory instead of the current working directory. After
testing, restore the contents of /proc/sys/kernel/core_pattern and clear
all test temporary file.
# ./waitid10
tst_buffers.c:56: TINFO: Test is using guarded buffers
tst_test.c:1709: TINFO: LTP version: 20240129-45-g69537563d16a
tst_test.c:1593: TINFO: Timeout per run is 0h 05m 00s
waitid10.c:60: TINFO: Temporary core pattern is '/tmp/LTP_waiSzyEv2/core'
waitid10.c:73: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
[68549.534126] mnt_uid= 0, curr_uid= 0
waitid10.c:38: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
waitid10.c:39: TPASS: infop->si_pid == pidchild (163)
waitid10.c:40: TPASS: infop->si_status == SIGFPE (8)
waitid10.c:41: TPASS: infop->si_signo == SIGCHLD (17)
waitid10.c:44: TPASS: infop->si_code == CLD_DUMPED (3)
Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
---
testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
index e55e88c2325e..3e48f52d0ea8 100644
--- a/testcases/kernel/syscalls/waitid/waitid10.c
+++ b/testcases/kernel/syscalls/waitid/waitid10.c
@@ -16,6 +16,8 @@
#include <sys/prctl.h>
#include "tst_test.h"
+#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
+
static siginfo_t *infop;
static int core_dumps = 1;
@@ -48,9 +50,16 @@ static void setup(void)
{
struct rlimit rlim;
char c;
+ char cwd[1024];
+ char tmpcpattern[1048];
SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
- SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
+
+ SAFE_GETCWD(cwd, sizeof(cwd));
+ snprintf(tmpcpattern, sizeof(tmpcpattern), "%s/core", cwd);
+ tst_res(TINFO, "Temporary core pattern is '%s'", tmpcpattern);
+ SAFE_FILE_PRINTF(CORE_PATTERN, "%s", tmpcpattern);
+ SAFE_FILE_SCANF(CORE_PATTERN, "%c", &c);
if (rlim.rlim_cur)
return;
@@ -76,4 +85,9 @@ static struct tst_test test = {
{&infop, .size = sizeof(*infop)},
{},
},
+ .needs_tmpdir = 1,
+ .save_restore = (const struct tst_path_val[]) {
+ {CORE_PATTERN, NULL, TST_SR_TCONF},
+ {}
+ },
};
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] waitid10: Set the core dump file location to temporary directory
2024-04-03 5:18 [LTP] [PATCH v2] waitid10: Set the core dump file location to temporary directory Hui Min Mina Chou via ltp
@ 2024-04-03 10:59 ` Cyril Hrubis
2024-04-08 3:15 ` Mina Chou via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-04-03 10:59 UTC (permalink / raw)
To: Hui Min Mina Chou; +Cc: tim609, cynthia, az70021, ltp
Hi!
> When testing via NFS mount LTP folder on the board, with the NFS server
> configured using 'anonuid' and 'anongid' options to set specific
> uid/gid, waitid10 fails. This is due to a uid mismatch during core dump
> file creation, leading to an aborted dump, resulting in the child
> process receiving the signal CLD_KILLED instead of CLD_DUMPED.
>
> # ./waitid10
> tst_buffers.c:56: TINFO: Test is using guarded buffers
> tst_test.c:1732: TINFO: LTP version: 20240129
> tst_test.c:1616: TINFO: Timeout per run is 0h 05m 00s
> waitid10.c:64: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
> [ 296.482665] mnt_uid= 1036, curr_uid= 0
> [ 296.483041] Core dump to core aborted: cannot preserve file owner
> waitid10.c:36: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
> waitid10.c:37: TPASS: infop->si_pid == pidchild (149)
> waitid10.c:38: TPASS: infop->si_status == SIGFPE (8)
> waitid10.c:39: TPASS: infop->si_signo == SIGCHLD (17)
> waitid10.c:42: TFAIL: infop->si_code (2) != CLD_DUMPED (3)
>
> Therefore, referring to madvise08, during testing, set the core dump file
> to the temporary directory instead of the current working directory. After
> testing, restore the contents of /proc/sys/kernel/core_pattern and clear
> all test temporary file.
Thanks for the detailed description, now it's clear what happens on your
system.
> # ./waitid10
> tst_buffers.c:56: TINFO: Test is using guarded buffers
> tst_test.c:1709: TINFO: LTP version: 20240129-45-g69537563d16a
> tst_test.c:1593: TINFO: Timeout per run is 0h 05m 00s
> waitid10.c:60: TINFO: Temporary core pattern is '/tmp/LTP_waiSzyEv2/core'
> waitid10.c:73: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
> [68549.534126] mnt_uid= 0, curr_uid= 0
> waitid10.c:38: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
> waitid10.c:39: TPASS: infop->si_pid == pidchild (163)
> waitid10.c:40: TPASS: infop->si_status == SIGFPE (8)
> waitid10.c:41: TPASS: infop->si_signo == SIGCHLD (17)
> waitid10.c:44: TPASS: infop->si_code == CLD_DUMPED (3)
>
> Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
> ---
> testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
> index e55e88c2325e..3e48f52d0ea8 100644
> --- a/testcases/kernel/syscalls/waitid/waitid10.c
> +++ b/testcases/kernel/syscalls/waitid/waitid10.c
> @@ -16,6 +16,8 @@
> #include <sys/prctl.h>
> #include "tst_test.h"
>
> +#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
> +
> static siginfo_t *infop;
> static int core_dumps = 1;
>
> @@ -48,9 +50,16 @@ static void setup(void)
> {
> struct rlimit rlim;
> char c;
> + char cwd[1024];
> + char tmpcpattern[1048];
>
> SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
> - SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
> +
> + SAFE_GETCWD(cwd, sizeof(cwd));
> + snprintf(tmpcpattern, sizeof(tmpcpattern), "%s/core", cwd);
> + tst_res(TINFO, "Temporary core pattern is '%s'", tmpcpattern);
> + SAFE_FILE_PRINTF(CORE_PATTERN, "%s", tmpcpattern);
> + SAFE_FILE_SCANF(CORE_PATTERN, "%c", &c);
Given the description do we really need to change the core pattern?
I guess that just adding .needs_tmpdir = 1 would fix the test since the
test $CWD would point to the test temporary directory.
> if (rlim.rlim_cur)
> return;
> @@ -76,4 +85,9 @@ static struct tst_test test = {
> {&infop, .size = sizeof(*infop)},
> {},
> },
> + .needs_tmpdir = 1,
> + .save_restore = (const struct tst_path_val[]) {
> + {CORE_PATTERN, NULL, TST_SR_TCONF},
> + {}
> + },
> };
> --
> 2.34.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
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 v2] waitid10: Set the core dump file location to temporary directory
2024-04-03 10:59 ` Cyril Hrubis
@ 2024-04-08 3:15 ` Mina Chou via ltp
0 siblings, 0 replies; 3+ messages in thread
From: Mina Chou via ltp @ 2024-04-08 3:15 UTC (permalink / raw)
To: ltp
On Wed, Apr 03, 2024 at 12:59:37PM +0200, Cyril Hrubis wrote:
> [EXTERNAL MAIL]
>
> Hi!
> > When testing via NFS mount LTP folder on the board, with the NFS server
> > configured using 'anonuid' and 'anongid' options to set specific
> > uid/gid, waitid10 fails. This is due to a uid mismatch during core dump
> > file creation, leading to an aborted dump, resulting in the child
> > process receiving the signal CLD_KILLED instead of CLD_DUMPED.
> >
> > # ./waitid10
> > tst_buffers.c:56: TINFO: Test is using guarded buffers
> > tst_test.c:1732: TINFO: LTP version: 20240129
> > tst_test.c:1616: TINFO: Timeout per run is 0h 05m 00s
> > waitid10.c:64: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
> > [ 296.482665] mnt_uid= 1036, curr_uid= 0
> > [ 296.483041] Core dump to core aborted: cannot preserve file owner
> > waitid10.c:36: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
> > waitid10.c:37: TPASS: infop->si_pid == pidchild (149)
> > waitid10.c:38: TPASS: infop->si_status == SIGFPE (8)
> > waitid10.c:39: TPASS: infop->si_signo == SIGCHLD (17)
> > waitid10.c:42: TFAIL: infop->si_code (2) != CLD_DUMPED (3)
> >
> > Therefore, referring to madvise08, during testing, set the core dump file
> > to the temporary directory instead of the current working directory. After
> > testing, restore the contents of /proc/sys/kernel/core_pattern and clear
> > all test temporary file.
>
> Thanks for the detailed description, now it's clear what happens on your
> system.
>
> > # ./waitid10
> > tst_buffers.c:56: TINFO: Test is using guarded buffers
> > tst_test.c:1709: TINFO: LTP version: 20240129-45-g69537563d16a
> > tst_test.c:1593: TINFO: Timeout per run is 0h 05m 00s
> > waitid10.c:60: TINFO: Temporary core pattern is '/tmp/LTP_waiSzyEv2/core'
> > waitid10.c:73: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
> > [68549.534126] mnt_uid= 0, curr_uid= 0
> > waitid10.c:38: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
> > waitid10.c:39: TPASS: infop->si_pid == pidchild (163)
> > waitid10.c:40: TPASS: infop->si_status == SIGFPE (8)
> > waitid10.c:41: TPASS: infop->si_signo == SIGCHLD (17)
> > waitid10.c:44: TPASS: infop->si_code == CLD_DUMPED (3)
> >
> > Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
> > ---
> > testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
> > 1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
> > index e55e88c2325e..3e48f52d0ea8 100644
> > --- a/testcases/kernel/syscalls/waitid/waitid10.c
> > +++ b/testcases/kernel/syscalls/waitid/waitid10.c
> > @@ -16,6 +16,8 @@
> > #include <sys/prctl.h>
> > #include "tst_test.h"
> >
> > +#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
> > +
> > static siginfo_t *infop;
> > static int core_dumps = 1;
> >
> > @@ -48,9 +50,16 @@ static void setup(void)
> > {
> > struct rlimit rlim;
> > char c;
> > + char cwd[1024];
> > + char tmpcpattern[1048];
> >
> > SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
> > - SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
> > +
> > + SAFE_GETCWD(cwd, sizeof(cwd));
> > + snprintf(tmpcpattern, sizeof(tmpcpattern), "%s/core", cwd);
> > + tst_res(TINFO, "Temporary core pattern is '%s'", tmpcpattern);
> > + SAFE_FILE_PRINTF(CORE_PATTERN, "%s", tmpcpattern);
> > + SAFE_FILE_SCANF(CORE_PATTERN, "%c", &c);
>
> Given the description do we really need to change the core pattern?
>
> I guess that just adding .needs_tmpdir = 1 would fix the test since the
> test $CWD would point to the test temporary directory.
>
Yes, you're right! Simply adding .needs_tmpdir = 1 can solve the issue.
Thanks, I'll revise another version.
> > if (rlim.rlim_cur)
> > return;
> > @@ -76,4 +85,9 @@ static struct tst_test test = {
> > {&infop, .size = sizeof(*infop)},
> > {},
> > },
> > + .needs_tmpdir = 1,
> > + .save_restore = (const struct tst_path_val[]) {
> > + {CORE_PATTERN, NULL, TST_SR_TCONF},
> > + {}
> > + },
> > };
> > --
> > 2.34.1
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
Thanks,
Mina
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-08 3:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03 5:18 [LTP] [PATCH v2] waitid10: Set the core dump file location to temporary directory Hui Min Mina Chou via ltp
2024-04-03 10:59 ` Cyril Hrubis
2024-04-08 3:15 ` Mina Chou via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox