From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
To: Simon Chopin <simon.chopin@canonical.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
Xi Ruoyao <xry111@xry111.site>
Subject: Re: [PATCH v2] tests: gracefully handle AppArmor userns containment
Date: Tue, 13 Feb 2024 11:36:34 +0400 [thread overview]
Message-ID: <CB9608D8-73AF-4A6F-B07D-B604378E8B5C@linaro.org> (raw)
In-Reply-To: <20240206105932.127820-1-simon.chopin@canonical.com>
> On Feb 6, 2024, at 14:59, Simon Chopin <simon.chopin@canonical.com> wrote:
>
> Recent AppArmor containment allows restricting unprivileged user
> namespaces, which is enabled by default on recent Ubuntu systems.
>
> When that happens, the affected tests will now be considered unsupported
> rather than simply failing.
>
> Further information:
>
> * https://gitlab.com/apparmor/apparmor/-/wikis/unprivileged_userns_restriction
> * https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
>
> V2:
> * Fix duplicated line in check_unshare_hints
> * Also handle similar failure in tst-pidfd_getpid
Looks good, with below comments addressed.
Please CC reviewers of the previous versions of the patch -- Xi Ruoyao in this case.
>
> Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
> ---
> support/test-container.c | 7 +++++--
> sysdeps/unix/sysv/linux/tst-pidfd_getpid.c | 3 ++-
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/support/test-container.c b/support/test-container.c
> index adf2b30215..af66cece51 100644
> --- a/support/test-container.c
> +++ b/support/test-container.c
> @@ -682,6 +682,8 @@ check_for_unshare_hints (int require_pidns)
> { "/proc/sys/kernel/unprivileged_userns_clone", 0, 1, 0 },
> /* ALT Linux has an alternate way of doing the same. */
> { "/proc/sys/kernel/userns_restrict", 1, 0, 0 },
> + /* AppArmor can also disable unprivileged user namespaces */
GNU coding style is to finish comment sentences with a dot, followed by two spaces. E.g.,
/* My new comment. */
> + { "/proc/sys/kernel/apparmor_restrict_unprivileged_userns", 1, 0, 0 },
> /* Linux kernel >= 4.9 has a configurable limit on the number of
> each namespace. Some distros set the limit to zero to disable the
> corresponding namespace as a "security policy". */
> @@ -1108,10 +1110,11 @@ main (int argc, char **argv)
> {
> /* Older kernels may not support all the options, or security
> policy may block this call. */
> - if (errno == EINVAL || errno == EPERM || errno == ENOSPC)
> + if (errno == EINVAL || errno == EPERM
> + || errno == ENOSPC || errno == EACCES)
Where is EACCES coming from? I could not find documentation mentioning EACCES as a possible error condition for unshare().
> {
> int saved_errno = errno;
> - if (errno == EPERM || errno == ENOSPC)
> + if (errno == EPERM || errno == ENOSPC || errno == EACCES)
> check_for_unshare_hints (require_pidns);
> FAIL_UNSUPPORTED ("unable to unshare user/fs: %s", strerror (saved_errno));
> }
> diff --git a/sysdeps/unix/sysv/linux/tst-pidfd_getpid.c b/sysdeps/unix/sysv/linux/tst-pidfd_getpid.c
> index 0354da5abb..ef62fbe941 100644
> --- a/sysdeps/unix/sysv/linux/tst-pidfd_getpid.c
> +++ b/sysdeps/unix/sysv/linux/tst-pidfd_getpid.c
> @@ -61,7 +61,8 @@ do_test (void)
> {
> /* Older kernels may not support all the options, or security
> policy may block this call. */
> - if (errno == EINVAL || errno == EPERM || errno == ENOSPC)
> + if (errno == EINVAL || errno == EPERM
> + || errno == ENOSPC || errno == EACCES)
> exit (EXIT_UNSUPPORTED);
> FAIL_EXIT1 ("unshare user/fs/pid failed: %m");
> }
>
> base-commit: fa3eb7d5e7d32ca1ad48b48a7eb6d15b8382c3a7
> --
> 2.40.1
>
Thanks,
--
Maxim Kuvyrkov
https://www.linaro.org
next prev parent reply other threads:[~2024-02-13 7:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 12:01 [PATCH] test-container: gracefully handle AppArmor containment Simon Chopin
2024-02-01 12:20 ` Xi Ruoyao
2024-02-06 11:01 ` Simon Chopin
2024-02-06 10:59 ` [PATCH v2] tests: gracefully handle AppArmor userns containment Simon Chopin
2024-02-13 7:36 ` Maxim Kuvyrkov [this message]
2024-02-14 7:53 ` Florian Weimer
2024-02-16 15:57 ` Simon Chopin
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=CB9608D8-73AF-4A6F-B07D-B604378E8B5C@linaro.org \
--to=maxim.kuvyrkov@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=simon.chopin@canonical.com \
--cc=xry111@xry111.site \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).