From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 07/11] Add landlock03 test
Date: Tue, 16 Jul 2024 19:15:20 +0200 [thread overview]
Message-ID: <20240716171520.GB549165@pevik> (raw)
In-Reply-To: <20240711-landlock-v3-7-c7b0e9edf9b0@suse.com>
Hi Andrea, Li,
...
> +static struct tcase {
> + int *fd;
> + uint32_t flags;
> + int exp_errno;
> + char *msg;
> +} tcases[] = {
> + {&ruleset_fd, -1, EINVAL, "Invalid flags"},
> + {&ruleset_invalid, 0, EBADF, "Invalid file descriptor"},
> + {&file_fd, 0, EBADFD, "Not a ruleset file descriptor"},
> + {&ruleset_fd, 0, EPERM, "File descriptor doesn't have CAP_SYS_ADMIN"},
> + {&ruleset_fd, 0, E2BIG, "Maximum number of stacked rulesets is reached"},
I was going to merge this, but the last E2BIG does not work with -i2:
# ./landlock03 -i2
tst_kconfig.c:88: TINFO: Parsing kernel config '/boot/config-6.6.15-amd64'
tst_buffers.c:57: TINFO: Test is using guarded buffers
tst_test.c:1806: TINFO: LTP version: 20240524-99-gf651e2dd5
tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
landlock_common.h:30: TINFO: Landlock ABI v3
landlock03.c:70: TPASS: Invalid flags : EINVAL (22)
landlock03.c:70: TPASS: Invalid file descriptor : EBADF (9)
landlock03.c:70: TPASS: Not a ruleset file descriptor : EBADFD (77)
tst_capability.c:29: TINFO: Dropping CAP_SYS_ADMIN(21)
landlock03.c:70: TPASS: File descriptor doesn't have CAP_SYS_ADMIN : EPERM (1)
tst_capability.c:41: TINFO: Permitting CAP_SYS_ADMIN(21)
landlock03.c:70: TPASS: Maximum number of stacked rulesets is reached : E2BIG (7)
landlock03.c:70: TPASS: Invalid flags : EINVAL (22)
landlock03.c:70: TPASS: Invalid file descriptor : EBADF (9)
landlock03.c:70: TPASS: Not a ruleset file descriptor : EBADFD (77)
tst_capability.c:29: TINFO: Dropping CAP_SYS_ADMIN(21)
landlock03.c:70: TPASS: File descriptor doesn't have CAP_SYS_ADMIN : EPERM (1)
tst_capability.c:41: TINFO: Permitting CAP_SYS_ADMIN(21)
landlock03.c:63: TFAIL: tst_syscall(__NR_landlock_restrict_self, *tc->fd, tc->flags) failed: E2BIG (7)
> +};
> +
> +static void run(unsigned int n)
> +{
> + struct tcase *tc = &tcases[n];
> +
> + if (tc->exp_errno == EPERM)
> + tst_cap_action(&dropadmin);
> +
> + if (tc->exp_errno == E2BIG) {
> + for (int i = 0; i < MAX_STACKED_RULESETS; i++) {
> + TST_EXP_PASS_SILENT(tst_syscall(__NR_landlock_restrict_self,
> + *tc->fd, tc->flags));
I suppose any later call for E2BIG will fail, because we reached maximum of the
rulests, right? (That's why there is below TST_EXP_FAIL). Can we somehow undo
landlock rulestes?
It looks to me it's not possible:
https://docs.kernel.org/userspace-api/landlock.html#ruleset-layers
man page does not mention it either:
https://man7.org/linux/man-pages/man2/landlock_restrict_self.2.html
https://man7.org/linux/man-pages/man2/landlock_create_ruleset.2.html
Tomorrow I'll try to have look into the sources, but I guess we will need to
skip this last test for other iterations, right?
> + if (TST_RET == -1)
> + return;
> + }
> + }
> +
> + TST_EXP_FAIL(tst_syscall(__NR_landlock_restrict_self, *tc->fd, tc->flags),
> + tc->exp_errno,
> + "%s", tc->msg);
Kind regards,
Petr
> +
> + if (tc->exp_errno == EPERM)
> + tst_cap_action(&needadmin);
> +}
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-07-16 17:15 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 11:18 [LTP] [PATCH v3 00/11] landlock testing suite Andrea Cervesato
2024-07-11 11:18 ` [LTP] [PATCH v3 01/11] Add landlock syscalls definitions Andrea Cervesato
2024-07-11 11:18 ` [LTP] [PATCH v3 02/11] Add lapi/landlock.h fallback Andrea Cervesato
2024-07-11 11:18 ` [LTP] [PATCH v3 03/11] Added three more SAFE_* macros for landlock sandbox: Andrea Cervesato
2024-07-11 11:18 ` [LTP] [PATCH v3 04/11] Add SAFE_PRCTL macro Andrea Cervesato
2024-07-11 20:06 ` Petr Vorel
2024-07-11 11:18 ` [LTP] [PATCH v3 05/11] Add landlock01 test Andrea Cervesato
2024-07-11 20:40 ` Petr Vorel
2024-07-12 2:11 ` Li Wang
2024-07-12 3:03 ` Li Wang
2024-07-12 7:57 ` Petr Vorel
2024-07-12 8:28 ` Li Wang
2024-07-12 9:22 ` Petr Vorel
2024-07-12 7:07 ` Petr Vorel
2024-07-11 11:18 ` [LTP] [PATCH v3 06/11] Add landlock02 test Andrea Cervesato
2024-07-11 20:32 ` Petr Vorel
2024-07-16 16:59 ` Petr Vorel
2024-07-11 11:18 ` [LTP] [PATCH v3 07/11] Add landlock03 test Andrea Cervesato
2024-07-16 17:15 ` Petr Vorel [this message]
2024-07-11 11:18 ` [LTP] [PATCH v3 08/11] Add CAP_MKNOD fallback in lapi/capability.h Andrea Cervesato
2024-07-12 7:49 ` Li Wang
2024-07-11 11:18 ` [LTP] [PATCH v3 09/11] Add landlock04 test Andrea Cervesato
2024-07-12 7:50 ` Li Wang
2024-07-16 17:27 ` Petr Vorel
2024-07-24 10:41 ` Andrea Cervesato via ltp
2024-07-24 12:12 ` Li Wang
2024-07-24 13:30 ` Petr Vorel
2024-07-24 13:37 ` Li Wang
2024-07-24 13:41 ` Petr Vorel
2024-07-24 13:41 ` Li Wang
2024-07-24 13:47 ` Andrea Cervesato via ltp
2024-07-25 7:12 ` Andrea Cervesato via ltp
[not found] ` <54317d90-ec53-49ff-bbff-15200f09c8d2@suse.com>
2024-07-25 9:06 ` [LTP] LTP landlock test is failing for all kernels <= 6.6 Mickaël Salaün
2024-07-25 9:17 ` Andrea Cervesato via ltp
2024-07-11 11:18 ` [LTP] [PATCH v3 10/11] Add landlock05 test Andrea Cervesato
2024-07-11 11:18 ` [LTP] [PATCH v3 11/11] Add landlock06 test Andrea Cervesato
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=20240716171520.GB549165@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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