public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: almaz.alexandrovich@paragon-software.com, ntfs3@lists.linux.dev,
	syzbot <syzbot+89dbb3a789a5b9711793@syzkaller.appspotmail.com>,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] fs/ntfs3: Use __GFP_NOWARN allocation at ntfs_load_attr_list()
Date: Mon, 2 Jan 2023 21:19:59 +0100	[thread overview]
Message-ID: <Y7M8bwYAzyuYbmP3@dhcp22.suse.cz> (raw)
In-Reply-To: <7b10c1aa-0b3a-da0d-ea0e-b135cffc3491@I-love.SAKURA.ne.jp>

[this has just hit my filters, I am not really familiar with the code
 itself]

On Mon 02-01-23 23:53:40, Tetsuo Handa wrote:
> syzbot is reporting too large allocation at ntfs_load_attr_list() [1], for
> a crafted filesystem can have huge data_size.
> 
> Link: https://syzkaller.appspot.com/bug?extid=89dbb3a789a5b9711793 [1]
> Reported-by: syzbot <syzbot+89dbb3a789a5b9711793@syzkaller.appspotmail.com>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
>  fs/ntfs3/attrlist.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
> index c0c6bcbc8c05..81c22df27c72 100644
> --- a/fs/ntfs3/attrlist.c
> +++ b/fs/ntfs3/attrlist.c
> @@ -52,7 +52,7 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr)
>  
>  	if (!attr->non_res) {
>  		lsize = le32_to_cpu(attr->res.data_size);
> -		le = kmalloc(al_aligned(lsize), GFP_NOFS);
> +		le = kmalloc(al_aligned(lsize), GFP_NOFS | __GFP_NOWARN);

This looks like a bad idea in general. The allocator merely says that
something is wrong and you are silencing that. The calling code should
check the size for reasonable range and if larger size. Moreover, if
lsize can be really more than PAGE_SIZE this should be kvmalloc instead.
Ditto for the the other case.

>  		if (!le) {
>  			err = -ENOMEM;
>  			goto out;
> @@ -80,7 +80,7 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr)
>  		if (err < 0)
>  			goto out;
>  
> -		le = kmalloc(al_aligned(lsize), GFP_NOFS);
> +		le = kmalloc(al_aligned(lsize), GFP_NOFS | __GFP_NOWARN);
>  		if (!le) {
>  			err = -ENOMEM;
>  			goto out;
> -- 
> 2.34.1
> 

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2023-01-02 20:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 10:11 [syzbot] [ntfs3?] WARNING in ntfs_load_attr_list syzbot
2023-01-02 14:53 ` [PATCH] fs/ntfs3: Use __GFP_NOWARN allocation at ntfs_load_attr_list() Tetsuo Handa
2023-01-02 20:19   ` Michal Hocko [this message]
2023-01-03  0:49     ` Tetsuo Handa
2023-01-03  8:01       ` Michal Hocko
2023-01-03  8:13         ` Michal Hocko
2023-01-17 11:11           ` Tetsuo Handa
2023-05-08 12:48   ` Konstantin Komarov

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=Y7M8bwYAzyuYbmP3@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=ntfs3@lists.linux.dev \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=syzbot+89dbb3a789a5b9711793@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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