From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Matthew Bobrowski <repnop@google.com>,
Christian Brauner <brauner@kernel.org>,
Lennart Poettering <lennart@poettering.net>,
linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org
Subject: Re: [RFC][PATCH] fanotify: support watching filesystems and mounts inside userns
Date: Thu, 20 Apr 2023 15:12:07 +0200 [thread overview]
Message-ID: <20230420131207.dligsga5spbiptje@quack3> (raw)
In-Reply-To: <20230416060722.1912831-1-amir73il@gmail.com>
On Sun 16-04-23 09:07:22, Amir Goldstein wrote:
> An unprivileged user is allowed to create an fanotify group and add
> inode marks, but not filesystem and mount marks.
>
> Add limited support for setting up filesystem and mount marks by an
> unprivileged user under the following conditions:
>
> 1. User has CAP_SYS_ADMIN in the user ns where the group was created
> 2.a. User has CAP_SYS_ADMIN in the user ns where the filesystem was
> mounted (implies FS_USERNS_MOUNT)
> OR (in case setting up a mark mount)
> 2.b. User has CAP_SYS_ADMIN in the user ns attached to an idmapped mount
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
The patch looks good to me. Just two comments below.
> Christian,
>
> You can find this patch, along with FAN_UNMOUNT patches on my github [3].
> Please confirm that this meets your needs for watching container mounts.
>
> [3] https://github.com/amir73il/linux/commits/fan_unmount
Yeah, it would be good to get ack from Christian that the model you propose
works for him.
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index db3b79b8e901..2c3e123aee14 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -1238,6 +1238,7 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
> * A group with FAN_UNLIMITED_MARKS does not contribute to mark count
> * in the limited groups account.
> */
> + BUILD_BUG_ON(!(FANOTIFY_ADMIN_INIT_FLAGS & FAN_UNLIMITED_MARKS));
> if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS) &&
> !inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_FANOTIFY_MARKS))
> return ERR_PTR(-ENOSPC);
...
> @@ -1557,21 +1559,13 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
> goto out_destroy_group;
> }
>
> + BUILD_BUG_ON(!(FANOTIFY_ADMIN_INIT_FLAGS & FAN_UNLIMITED_QUEUE));
> if (flags & FAN_UNLIMITED_QUEUE) {
> - fd = -EPERM;
> - if (!capable(CAP_SYS_ADMIN))
> - goto out_destroy_group;
> group->max_events = UINT_MAX;
> } else {
> group->max_events = fanotify_max_queued_events;
> }
>
> - if (flags & FAN_UNLIMITED_MARKS) {
> - fd = -EPERM;
> - if (!capable(CAP_SYS_ADMIN))
> - goto out_destroy_group;
> - }
> -
Perhaps this hunk (plus the BUILD_BUG_ON hunk above) should go into a
separate patch with a proper changelog? I was scratching my head over it
for a while until I've realized it's unrelated cleanup of dead code.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-04-20 13:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-16 6:07 [RFC][PATCH] fanotify: support watching filesystems and mounts inside userns Amir Goldstein
2023-04-20 13:12 ` Jan Kara [this message]
2023-04-20 14:15 ` Amir Goldstein
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=20230420131207.dligsga5spbiptje@quack3 \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=lennart@poettering.net \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=repnop@google.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;
as well as URLs for NNTP newsgroup(s).