From: Petr Vorel <pvorel@suse.cz>
To: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v3 0/2] mount03: Convert to new API
Date: Tue, 16 Aug 2022 08:57:34 +0200 [thread overview]
Message-ID: <Yvs/3gBnn/FGyAyq@pevik> (raw)
In-Reply-To: <09a4ff13-eaf1-6a97-f868-893c56ac6b4c@fujitsu.com>
Hi Xu,
> >> Why here is nobody_gid?
> >>> + SAFE_SETGID(nobody_gid);
> >>> + SAFE_SETREUID(-1, nobody_uid);
> >> What problem do you meet?
> > Using original code SAFE_SETREUID(nobody_uid, nobody_gid);
> > causes mount03_setuid_test to fail (exit 1).
> > The same code is in creat08.c, creat09.c, open10.c.
> > Did I answer your question?
> I look mount03_setuid_test code today, nosuid mount option should
> expect setuid failed when using a non-privileged user even this program
> has set-user-id bit.
> Old api also think PASS when mount03_setuid_test exit 1
Ah, thanks for catching my error!
> So I think you should use SAFE_SETREUID(nobody_uid, nobody_uid);
> and then use code as below:
> if (WIFEXITED(status)) {
> switch (WEXITSTATUS(status)) {
> case EXIT_FAILURE:
> tst_res(TPASS, "%s passed", TESTBIN);
> return;
> case EXIT_SUCCESS:
> tst_res(TFAIL, "%s failed", TESTBIN);
> return;
> default:
> case TBROK:
> break;
> }
I guess we can drop the default and TBROK part, right?
It's caught later by tst_brk(TBROK, ...)
> }
https://github.com/pevik/ltp/blob/22652d668a5ccbf3c7aa835c2dab6d0eb6058ba2/testcases/kernel/syscalls/mount/mount03.c#L74-L105
static void test_nosuid(void)
{
pid_t pid;
int status;
struct stat st;
SAFE_CP(TESTBIN, BIN_PATH);
SAFE_STAT(BIN_PATH, &st);
if (st.st_mode != SUID_MODE)
SAFE_CHMOD(BIN_PATH, SUID_MODE);
pid = SAFE_FORK();
if (!pid) {
SAFE_SETREUID(nobody_uid, nobody_uid);
SAFE_EXECL(BIN_PATH, TESTBIN, NULL);
}
SAFE_WAITPID(pid, &status, 0);
if (WIFEXITED(status)) {
switch (WEXITSTATUS(status)) {
case EXIT_FAILURE:
tst_res(TPASS, "%s passed", TESTBIN);
return;
case EXIT_SUCCESS:
tst_res(TFAIL, "%s failed", TESTBIN);
return;
}
}
tst_brk(TBROK, "Child %s", tst_strstatus(status));
}
Kind regards,
Petr
> Best Regards
> Yang Xu
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-08-16 6:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 13:57 [LTP] [PATCH v3 0/2] mount03: Convert to new API Petr Vorel
2022-08-11 13:57 ` [LTP] [PATCH v3 1/2] tst_test_macros.h: Add TST_EXP_EQ_STR Petr Vorel
2022-08-15 3:17 ` xuyang2018.jy
2022-08-11 13:57 ` [LTP] [PATCH v3 2/2] mount03: Convert to new API Petr Vorel
2022-08-16 9:07 ` Cyril Hrubis
2022-08-16 9:18 ` Petr Vorel
2022-08-16 9:31 ` Cyril Hrubis
2022-08-15 5:15 ` [LTP] [PATCH v3 0/2] " xuyang2018.jy
2022-08-15 6:40 ` Petr Vorel
2022-08-15 6:58 ` xuyang2018.jy
2022-08-15 8:28 ` Petr Vorel
2022-08-15 9:57 ` xuyang2018.jy
2022-08-15 14:19 ` Petr Vorel
2022-08-16 3:40 ` xuyang2018.jy
2022-08-16 11:49 ` Petr Vorel
2022-08-16 13:01 ` Petr Vorel
2022-08-17 2:23 ` xuyang2018.jy
2022-08-22 13:28 ` Petr Vorel
2022-08-22 13:35 ` Petr Vorel
2022-08-16 4:37 ` xuyang2018.jy
2022-08-16 6:57 ` Petr Vorel [this message]
2022-08-16 7:28 ` xuyang2018.jy
2022-08-16 9:00 ` Cyril Hrubis
2022-08-16 9:06 ` Petr Vorel
2022-08-16 9:57 ` xuyang2018.jy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yvs/3gBnn/FGyAyq@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox