All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: Nikolay Borisov <n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	avagin-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
	serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCHv3] inotify: Convert to using per-namespace limits
Date: Thu, 15 Dec 2016 13:37:56 +1300	[thread overview]
Message-ID: <87wpf2t4bf.fsf@xmission.com> (raw)
In-Reply-To: <1481723793-6756-1-git-send-email-n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> (Nikolay Borisov's message of "Wed, 14 Dec 2016 15:56:33 +0200")

Nikolay Borisov <n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> This patchset converts inotify to using the newly introduced
> per-userns sysctl infrastructure.
>
> Currently the inotify instances/watches are being accounted in the
> user_struct structure. This means that in setups where multiple
> users in unprivileged containers map to the same underlying
> real user (i.e. pointing to the same user_struct) the inotify limits
> are going to be shared as well, allowing one user(or application) to exhaust
> all others limits.
>
> Fix this by switching the inotify sysctls to using the
> per-namespace/per-user limits. This will allow the server admin to
> set sensible global limits, which can further be tuned inside every
> individual user namespace. Additionally, in order to preserve the
> sysctl ABI make the existing inotify instances/watches sysctls
> modify the values of the initial user namespace.
>
> Signed-off-by: Nikolay Borisov <n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Acked-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
> Acked-by: Serge Hallyn <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>
> ---
>
> Okay, so here is another version, which should 
> hopefully be free of slab corruptions. There was an issue
> where in ucount.c the ifdef was checking the CONFIG_INOTIFY_USER_
> (pay attention to the trailing _, this was clearly a mistake). This 
> led to the user_table (and all duplicated from it tables) to not 
> contain the inotify-related members. In my local testing I got 
> kasan splats even during kernel boot, due to out-of-bound writes. 
> Let's see how this version fares.

So there is one more thing that needs to be addressed with your patch.

In inotify.h the functions need to be marked static inline
rather than just static or else there a number of new compiler warnings.

I have addressed this for now, but if anything else comes up or if you
resend this patch I would appreciate it if you add the static inline
notations in your internal copy of the patch.

Thank you,
Eric Biederman


> diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
> index ed855ef6f077..b5536f8ad3e0 100644
> --- a/fs/notify/inotify/inotify.h
> +++ b/fs/notify/inotify/inotify.h
> @@ -30,3 +30,20 @@ extern int inotify_handle_event(struct fsnotify_group *group,
>  				const unsigned char *file_name, u32 cookie);
>  
>  extern const struct fsnotify_ops inotify_fsnotify_ops;
> +
> +#ifdef CONFIG_INOTIFY_USER
> +static void dec_inotify_instances(struct ucounts *ucounts)
> +{
> +	dec_ucount(ucounts, UCOUNT_INOTIFY_INSTANCES);
> +}
> +
> +static struct ucounts *inc_inotify_watches(struct ucounts *ucounts)
> +{
> +	return inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_INOTIFY_WATCHES);
> +}
> +
> +static void dec_inotify_watches(struct ucounts *ucounts)
> +{
> +	dec_ucount(ucounts, UCOUNT_INOTIFY_WATCHES);
> +}
> +#endif

  parent reply	other threads:[~2016-12-15  0:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13  3:22 [inotify] fee1df54b6: BUG_kmalloc-#(Not_tainted):Freepointer_corrupt kernel test robot
2016-12-13  3:22 ` kernel test robot
     [not found] ` <87inqo4ip1.fsf-5/hDr2MS57EDqwDYnZuMFFaTQe2KTcn/@public.gmane.org>
2016-12-13 16:56   ` Nikolay Borisov
2016-12-13 16:56     ` Nikolay Borisov
     [not found]     ` <db529280-24ec-9957-93bc-b42998e1d692-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-13 18:51       ` Eric W. Biederman
2016-12-13 18:51         ` Eric W. Biederman
     [not found]         ` <87oa0fpsqs.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-12-13 19:34           ` Nikolay Borisov
2016-12-13 19:34             ` Nikolay Borisov
     [not found]             ` <dd3fa59d-a8e0-95cb-d05d-631918608a70-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-13 22:18               ` Andrey Vagin
2016-12-13 22:18                 ` Andrey Vagin
2016-12-14 13:56           ` [PATCHv3] inotify: Convert to using per-namespace limits Nikolay Borisov
     [not found]             ` <1481723793-6756-1-git-send-email-n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-14 22:29               ` Eric W. Biederman
2016-12-15  0:37               ` Eric W. Biederman [this message]
     [not found]                 ` <87wpf2t4bf.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-12-15  7:26                   ` Nikolay Borisov

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=87wpf2t4bf.fsf@xmission.com \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=avagin-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.