linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Yutian Yang <ytyang@zju.edu.cn>
Cc: jack@suse.cz, mhocko@kernel.org, linux-fsdevel@vger.kernel.org,
	amir73il@gmail.com, "shenwenbo@zju.edu.cn" <shenwenbo@zju.edu.cn>,
	vdavydov.dev@gmail.com, hannes@cmpxchg.org
Subject: Re: inotify_init1() syscall creates memcg-uncharged objects
Date: Thu, 15 Apr 2021 14:48:48 +0200	[thread overview]
Message-ID: <20210415124848.GD25217@quack2.suse.cz> (raw)
In-Reply-To: <39472b9e.5a92d.178d5843523.Coremail.ytyang@zju.edu.cn>

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

           reply	other threads:[~2021-04-15 12:49 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <39472b9e.5a92d.178d5843523.Coremail.ytyang@zju.edu.cn>]

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=20210415124848.GD25217@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mhocko@kernel.org \
    --cc=shenwenbo@zju.edu.cn \
    --cc=vdavydov.dev@gmail.com \
    --cc=ytyang@zju.edu.cn \
    /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).