linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: inotify_init1() syscall creates memcg-uncharged objects
       [not found] <39472b9e.5a92d.178d5843523.Coremail.ytyang@zju.edu.cn>
@ 2021-04-15 12:48 ` Jan Kara
  0 siblings, 0 replies; only message in thread
From: Jan Kara @ 2021-04-15 12:48 UTC (permalink / raw)
  To: Yutian Yang
  Cc: jack, mhocko, linux-fsdevel, amir73il, shenwenbo, vdavydov.dev, hannes

On Thu 15-04-21 20:31:54, Yutian Yang wrote:
> Hi, our team has found a bug in fsnotify_alloc_group() on Linux kernel
> v5.10.19, which leads to memcg accounting bypassing.
> 
> The bug is caused by the code snippets listed below:
> 
> /*--------------- fs/notify/group.c --------------------*/
> ...
> 119 struct fsnotify_group *group;
> 120 
> 121 group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL);
> ...
> 
> 
> /*------------------------ end --------------------------*/
> 
> The code can be triggered by syscall inotify_init1() and causes uncharged
> fsnotify_group objects. A user could repeatedly make the syscall and
> trigger the bug to occupy more and more memory. In fact, fsnotify_group
> objects could be allocated by users and are also controllable by users.
> As a result, they need to be charged and we suggest the following patch:
> 
> /*--------------- fs/notify/group.c --------------------*/
> ...
> 119 struct fsnotify_group *group;
> 120 
> 121 group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL_ACCOUNT);
> ...
> 
> /*------------------------ end --------------------------*/

This was mostly by design since number of inotify groups is limited to
relatively low number anyway. But what you ask for has already happened in
commit ac7b79fd190b0 merged to 5.12-rc1 anyway.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-15 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <39472b9e.5a92d.178d5843523.Coremail.ytyang@zju.edu.cn>
2021-04-15 12:48 ` inotify_init1() syscall creates memcg-uncharged objects Jan Kara

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).