From: "Darrick J. Wong" <djwong@kernel.org>
To: bernd@bsbernd.com
Cc: fuse-devel@lists.linux.dev
Subject: Re: [PATCH 03/10] test: assert ro/rw, nosuid/suid, nodev/dev round-trip via fsmount
Date: Fri, 8 May 2026 17:04:02 -0700 [thread overview]
Message-ID: <20260509000402.GI2241589@frogsfrogsfrogs> (raw)
In-Reply-To: <20260508-new-mount-fixes-and-tests-v1-3-c67a0893ddbc@bsbernd.com>
On Fri, May 08, 2026 at 06:39:06PM +0200, Bernd Schubert via B4 Relay wrote:
> From: Bernd Schubert <bernd@bsbernd.com>
>
> Assisted by ClaudeOpus 4.7
> Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
> ---
> test/test_mount_state.py | 70 ++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 62 insertions(+), 8 deletions(-)
>
> diff --git a/test/test_mount_state.py b/test/test_mount_state.py
> index eacb7326..a7949ec3 100644
> --- a/test/test_mount_state.py
> +++ b/test/test_mount_state.py
> @@ -105,12 +105,66 @@ def test_mountinfo_subtype_fsname(tmpdir, output_checker, name):
> 'unexpected source: %r' % info['source']
>
>
> -@pytest.mark.parametrize('name', ('hello', 'hello_ll'))
> -def test_mountinfo_unprivileged_attrs(tmpdir, output_checker, name):
> - if os.getuid() == 0:
> - pytest.skip('only meaningful for unprivileged mounts via fusermount3')
> - with hello_mount(tmpdir, output_checker, name) as mnt:
> - info = parse_mountinfo(mnt)
> +# (label, options, must-be-in mount_options, must-NOT-be-in mount_options)
> +#
> +# Library defaults are MS_NOSUID|MS_NODEV (lib/mount.c:771,
> +# util/fusermount.c:988), so a no-options mount is expected to land
> +# with both attrs set. The negation forms (suid/dev) clear the default
> +# flags via lib/mount.c:set_mount_flag(), which on the new mount API
> +# path means MOUNT_ATTR_NOSUID/MOUNT_ATTR_NODEV are not set in the
> +# fsmount() call. Asserting their absence catches a routing bug where
> +# the negation wasn't honored.
> +ATTR_CASES = [
> + ('default', (), ('rw', 'nosuid', 'nodev'), ('ro',)),
> + ('ro', ('ro',), ('ro',), ('rw',)),
> + ('nosuid', ('nosuid',), ('nosuid',), ()),
> + ('nodev', ('nodev',), ('nodev',), ()),
> +]
> +
> +# suid/dev are root-only: the kernel rejects MS_NOSUID/MS_NODEV being
> +# cleared for unprivileged mounts, and fusermount3 hard-codes them on
> +# anyway (util/fusermount.c:988).
> +ATTR_CASES_ROOT = [
> + ('suid', ('suid',), (), ('nosuid',)),
> + ('dev', ('dev',), (), ('nodev',)),
> +]
> +
> +
> +def _check_attrs(info, must_have, must_not_have):
> assert info is not None
> - assert 'nosuid' in info['mount_options']
> - assert 'nodev' in info['mount_options']
> + for opt in must_have:
> + assert opt in info['mount_options'], \
> + '%r missing from mount_options=%r' % (opt, info['mount_options'])
> + for opt in must_not_have:
> + assert opt not in info['mount_options'], \
> + 'unexpected %r in mount_options=%r' % (opt, info['mount_options'])
> +
> +
> +@pytest.mark.parametrize('name', ('hello', 'hello_ll'))
> +@pytest.mark.parametrize('label,opts,must_have,must_not_have', ATTR_CASES,
> + ids=[c[0] for c in ATTR_CASES])
> +def test_mountinfo_attrs(tmpdir, output_checker, name,
> + label, opts, must_have, must_not_have):
> + with hello_mount(tmpdir, output_checker, name, opts) as mnt:
> + info = parse_mountinfo(mnt)
> + _check_attrs(info, must_have, must_not_have)
> + # ro/rw also surface in super_options; if we asked for ro the
> + # superblock must agree. Catches a path that sets MOUNT_ATTR_RDONLY
> + # but forgets the FSCONFIG-side MS_RDONLY (or vice versa).
Ehhh we're probably going to have to fix this again to handle the new
"ro=vfs"/"ro=fs" behaviors that util-linux 2.41 added.
/me is sad that this wasn't all that well publicized on fsdevel:
https://lore.kernel.org/linux-fsdevel/?q=%22ro%3Dvfs%22
The rest of the new tests look ok to me.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> + if 'ro' in must_have:
> + assert 'ro' in info['super_options'], \
> + 'ro on mount but rw on superblock: super_options=%r' % \
> + info['super_options']
> +
> +
> +@pytest.mark.parametrize('name', ('hello', 'hello_ll'))
> +@pytest.mark.parametrize('label,opts,must_have,must_not_have',
> + ATTR_CASES_ROOT,
> + ids=[c[0] for c in ATTR_CASES_ROOT])
> +def test_mountinfo_attrs_root(tmpdir, output_checker, name,
> + label, opts, must_have, must_not_have):
> + if os.getuid() != 0:
> + pytest.skip('clearing nosuid/nodev requires root')
> + with hello_mount(tmpdir, output_checker, name, opts) as mnt:
> + info = parse_mountinfo(mnt)
> + _check_attrs(info, must_have, must_not_have)
>
> --
> 2.53.0
>
>
next prev parent reply other threads:[~2026-05-09 0:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 16:39 [PATCH 00/10] libfuse: new mount API and SYNC_INIT fixes and tests Bernd Schubert via B4 Relay
2026-05-08 16:39 ` [PATCH 01/10] test: register pytest run as a meson test Bernd Schubert via B4 Relay
2026-05-08 23:53 ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 02/10] Add tests to verify that mountinfo matches requested options Bernd Schubert via B4 Relay
2026-05-08 23:59 ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 03/10] test: assert ro/rw, nosuid/suid, nodev/dev round-trip via fsmount Bernd Schubert via B4 Relay
2026-05-09 0:04 ` Darrick J. Wong [this message]
2026-05-08 16:39 ` [PATCH 04/10] New mount API: read-only option is for fsmount() and fsconfig() Bernd Schubert via B4 Relay
2026-05-09 0:17 ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 05/10] libfuse: don't use SYNC_INIT unless asked for Bernd Schubert via B4 Relay
2026-05-08 16:39 ` [PATCH 06/10] example: silence add_languages warning by setting 'native: false' Bernd Schubert via B4 Relay
2026-05-09 0:23 ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 07/10] mount: clarify kernel_opts vs mnt_opts vs flags in fuse_kern_fsmount Bernd Schubert via B4 Relay
2026-05-09 0:27 ` Darrick J. Wong
2026-05-10 17:21 ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 08/10] fuse_daemonize_early_start: Disallow daemonization when already active Bernd Schubert via B4 Relay
2026-05-09 0:30 ` Darrick J. Wong
2026-05-10 16:53 ` Bernd Schubert
2026-05-10 17:01 ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 09/10] fuse mount: Do not set sync_init when sync_init was not used Bernd Schubert via B4 Relay
2026-05-09 0:35 ` Darrick J. Wong
2026-05-10 17:04 ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 10/10] highlevel: Switch fuse_main_real_versioned() to fuse_daemonize_early() Bernd Schubert via B4 Relay
2026-05-09 0:38 ` Darrick J. Wong
2026-05-10 17:19 ` Bernd Schubert
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=20260509000402.GI2241589@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bernd@bsbernd.com \
--cc=fuse-devel@lists.linux.dev \
/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