From: Linus Torvalds <torvalds@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Casey Schaufler <casey@schaufler-ca.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Ian Kent <raven@themaw.net>,
Christian Brauner <christian@brauner.io>,
Jeff Layton <jlayton@redhat.com>, Karel Zak <kzak@redhat.com>,
Miklos Szeredi <mszeredi@redhat.com>,
Linux API <linux-api@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
LSM List <linux-security-module@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] watch_queue: Implement mount topology and attribute change notifications
Date: Fri, 24 Jul 2020 12:14:18 -0700 [thread overview]
Message-ID: <CAHk-=wjnQArU_BewVKQgYHy2mQD6LNKC5kkKXOm7GpNkJCapQg@mail.gmail.com> (raw)
In-Reply-To: <159559630912.2141315.16186899692832741137.stgit@warthog.procyon.org.uk>
This just can't be right.
On Fri, Jul 24, 2020 at 6:12 AM David Howells <dhowells@redhat.com> wrote:
>
> +
> +/**
> + * sys_watch_mount - Watch for mount topology/attribute changes
> + * @dfd: Base directory to pathwalk from or fd referring to mount.
> + * @filename: Path to mount to place the watch upon
> + * @at_flags: Pathwalk control flags
> + * @watch_fd: The watch queue to send notifications to.
> + * @watch_id: The watch ID to be placed in the notification (-1 to remove watch)
> + */
> +SYSCALL_DEFINE5(watch_mount, [...]
> + int, watch_id)
...
> + if (watch_id < -1 || watch_id > 0xff)
> + return -EINVAL;
...
> + ret = inode_permission(path.dentry->d_inode, MAY_EXEC);
> + if (ret)
> + goto err_path;
...
> + if (watch_id >= 0) {
...
> + watch = kzalloc(sizeof(*watch), GFP_KERNEL);
> + if (!watch)
> + goto err_wlist;
So now you can basically allocate as much kernel memory as you want as
a regular user, as long as you have a mounted directory you can walk
(ie everybody).
Is there any limiting of watches anywhere? I don't see it.
I notice we already have this pattern elsewhere. I think we need to
fix this before we add more watch types.
Watch allocation shouldn't just be a kzalloc(). I think you should
have a "watch_allocate()" that does the initialization of id etc, but
also does some basic per-user watch resource tracking or something.
Linus
next prev parent reply other threads:[~2020-07-24 19:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 13:11 [PATCH 0/4] Mount notifications David Howells
2020-07-24 13:11 ` [PATCH 1/4] watch_queue: Make watch_sizeof() check record size David Howells
2020-07-24 13:11 ` [PATCH 2/4] watch_queue: Add security hooks to rule on setting mount watches David Howells
2020-07-24 13:11 ` [PATCH 3/4] watch_queue: Implement mount topology and attribute change notifications David Howells
2020-07-24 19:14 ` Linus Torvalds [this message]
2020-07-24 19:59 ` David Howells
2020-07-24 20:25 ` Linus Torvalds
2020-07-24 20:45 ` David Howells
2020-07-24 13:11 ` [PATCH 4/4] watch_queue: sample: Display mount tree " David Howells
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='CAHk-=wjnQArU_BewVKQgYHy2mQD6LNKC5kkKXOm7GpNkJCapQg@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=casey@schaufler-ca.com \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=jlayton@redhat.com \
--cc=kzak@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=nicolas.dichtel@6wind.com \
--cc=raven@themaw.net \
--cc=sds@tycho.nsa.gov \
--cc=viro@zeniv.linux.org.uk \
/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).