mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <mtk.manpages@googlemail.com>
To: "Evgeniy Polyakov" <zbr@ioremap.net>
Cc: "Robert Love" <rlove@rlove.org>,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Christoph Hellwig" <hch@lst.de>
Subject: Re: [take 3] Use pid in inotify events.
Date: Mon, 17 Nov 2008 11:59:11 -0500	[thread overview]
Message-ID: <cfd18e0f0811170859w1d3f903ej1d5626f2d2bf4496@mail.gmail.com> (raw)
In-Reply-To: <20081116232450.GA13547@ioremap.net>

Hi Evgeniy,

On Sun, Nov 16, 2008 at 6:24 PM, Evgeniy Polyakov <zbr@ioremap.net> wrote:
> Hi.
>
> This patch allows to send IO origin PID in inotify events (using cookie
> fields for all events except moving, where it is already used to track
> move from and move to parts) when its uid matches inotify owner uid or
> when inotify owner has admin (CAP_SYS_ADMIN) capabilities (Jeff
> Schroeder's idea).
>
> This is a resend of the previous patch, which was not commented by
> anyone. Does it mean no one objects? If so, please apply.

NAK.  If we are going to do this -- and I leave the security
discussions to others more knowlegeable on that score than me -- then
the API design should be better than this.  The current design is a
hack.  Why exclude rename events?  Why re-use the cookie field?  The
only answers I can guess at are that the current patch is less work to
write.  IMO, there are (much) better design possibilities, using
inotify1(), as I suggested earlier in this thread.

Thanks,

Michael

> Also removed John McCutchan's email, which bounces.
>
> Signed-off-by: Evgeniy Polyakov <zbr@ioremap.net>
>
> diff --git a/fs/inotify.c b/fs/inotify.c
> index 690e725..835259d 100644
> --- a/fs/inotify.c
> +++ b/fs/inotify.c
> @@ -69,6 +69,9 @@ static atomic_t inotify_cookie;
>  * inotify_add_watch() to the final put_inotify_watch().
>  */
>
> +#define IH_FLAGS_ADMIN         (0x00000001)
> +/* handler owner has admin capabilities */
> +
>  /*
>  * struct inotify_handle - represents an inotify instance
>  *
> @@ -80,6 +83,8 @@ struct inotify_handle {
>        struct list_head        watches;        /* list of watches */
>        atomic_t                count;          /* reference count */
>        u32                     last_wd;        /* the last wd allocated */
> +       uid_t                   uid;            /* owner's uid */
> +       u32                     flags;          /* operation flags */
>        const struct inotify_operations *in_ops; /* inotify caller operations */
>  };
>
> @@ -292,6 +297,11 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
>                        mutex_lock(&ih->mutex);
>                        if (watch_mask & IN_ONESHOT)
>                                remove_watch_no_event(watch, ih);
> +
> +                       if (!cookie && ((ih->flags & IH_FLAGS_ADMIN) ||
> +                                       (current->uid == ih->uid)))
> +                               cookie = task_tgid_vnr(current);
> +
>                        ih->in_ops->handle_event(watch, watch->wd, mask, cookie,
>                                                 name, n_inode);
>                        mutex_unlock(&ih->mutex);
> @@ -459,6 +469,10 @@ struct inotify_handle *inotify_init(const struct inotify_operations *ops)
>        mutex_init(&ih->mutex);
>        ih->last_wd = 0;
>        ih->in_ops = ops;
> +       ih->uid = current->user->uid;
> +       ih->flags = 0;
> +       if (capable(CAP_SYS_ADMIN))
> +               ih->flags |= IH_FLAGS_ADMIN;
>        atomic_set(&ih->count, 0);
>        get_inotify_handle(ih);
>
> --
>        Evgeniy Polyakov
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

  reply	other threads:[~2008-11-17 16:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <acdcfe7e0811081035l56eedf05x8b3b7ee2fc01eee6@mail.gmail.com>
2008-11-08 18:40 ` [1/1] " Evgeniy Polyakov
2008-11-08 22:03   ` Evgeniy Polyakov
2008-11-10 15:13 ` [take 2] " Evgeniy Polyakov
2008-11-16 23:24 ` [take 3] " Evgeniy Polyakov
2008-11-17 16:59   ` Michael Kerrisk [this message]
2008-11-17 17:15     ` Evgeniy Polyakov
2008-11-17 17:23       ` Michael Kerrisk
2008-11-17 17:52         ` Evgeniy Polyakov
2008-11-20 13:09           ` Pavel Machek
2008-11-21 14:03             ` Evgeniy Polyakov
2008-11-21 14:20               ` Michael Kerrisk
2008-11-21 14:37                 ` Evgeniy Polyakov
2008-11-21 14:30               ` Robert Love
2008-11-21 14:53                 ` Evgeniy Polyakov
2008-11-21 14:57                 ` Pavel Machek
2008-11-21 15:08                   ` Evgeniy Polyakov
2008-11-18 13:19     ` Christoph Hellwig
2008-11-19 14:05       ` Evgeniy Polyakov
     [not found]         ` <cfd18e0f0811190634g276b4a2dm5b3d5de25a5c9222@mail.gmail.com>
2008-11-19 14:43           ` Michael Kerrisk
2008-11-20 19:17             ` Ville Syrjälä
2008-11-19 14:53           ` Evgeniy Polyakov
2008-11-20 22:34             ` John McCutchan
2008-11-20 23:06               ` Evgeniy Polyakov
2008-11-21 18:39                 ` Arnd Bergmann
2008-11-22  7:12                   ` David Newall
2008-11-22  9:41                     ` Evgeniy Polyakov
2008-11-22 11:41                       ` David Newall
2008-11-22  9:37                   ` Evgeniy Polyakov
2008-11-24  5:08                     ` John McCutchan
2008-11-24  7:30                       ` Evgeniy Polyakov

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=cfd18e0f0811170859w1d3f903ej1d5626f2d2bf4496@mail.gmail.com \
    --to=mtk.manpages@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=rlove@rlove.org \
    --cc=zbr@ioremap.net \
    /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

all inboxes | Powered by JetHome®