All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+f987ceaddc6bcc334cde@syzkaller.appspotmail.com
Cc: almaz.alexandrovich@paragon-software.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	ntfs3@lists.linux.dev, syzkaller-bugs@googlegroups.com
Subject: [PATCH] fs/ntfs3: fix warning in ntfs_load_attr_list
Date: Sat, 23 Dec 2023 12:05:27 +0800	[thread overview]
Message-ID: <tencent_C789B86EF5AED70CAF27CF06EF52C1C66106@qq.com> (raw)
In-Reply-To: <0000000000006ee8fe060d16e2a5@google.com>

kvmalloc needs to check __GFP_NOWARN, so this flag should be passed before
applying for memory.

Fixes: fc471e39e38f ("fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN)")
Reported-and-tested-by: syzbot+f987ceaddc6bcc334cde@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/ntfs3/attrlist.c | 4 ++--
 fs/ntfs3/bitmap.c   | 2 +-
 fs/ntfs3/super.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
index 7c01735d1219..e631ecc1b9df 100644
--- a/fs/ntfs3/attrlist.c
+++ b/fs/ntfs3/attrlist.c
@@ -53,7 +53,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);
 		/* attr is resident: lsize < record_size (1K or 4K) */
-		le = kvmalloc(al_aligned(lsize), GFP_KERNEL);
+		le = kvmalloc(al_aligned(lsize), GFP_KERNEL | __GFP_NOWARN);
 		if (!le) {
 			err = -ENOMEM;
 			goto out;
@@ -91,7 +91,7 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr)
 		 * the result is 16M bytes per attribute list.
 		 * Use kvmalloc to allocate in range [several Kbytes - dozen Mbytes]
 		 */
-		le = kvmalloc(al_aligned(lsize), GFP_KERNEL);
+		le = kvmalloc(al_aligned(lsize), GFP_KERNEL | __GFP_NOWARN);
 		if (!le) {
 			err = -ENOMEM;
 			goto out;
diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
index 63f14a0232f6..49e660be9a0f 100644
--- a/fs/ntfs3/bitmap.c
+++ b/fs/ntfs3/bitmap.c
@@ -660,7 +660,7 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block *sb, size_t nbits)
 		wnd->bits_last = wbits;
 
 	wnd->free_bits =
-		kvmalloc_array(wnd->nwnd, sizeof(u16), GFP_KERNEL | __GFP_ZERO);
+		kvmalloc_array(wnd->nwnd, sizeof(u16), GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
 
 	if (!wnd->free_bits)
 		return -ENOMEM;
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 9153dffde950..87778834aa9c 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1413,7 +1413,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	}
 
 	bytes = inode->i_size;
-	sbi->def_table = t = kvmalloc(bytes, GFP_KERNEL);
+	sbi->def_table = t = kvmalloc(bytes, GFP_KERNEL | __GFP_NOWARN);
 	if (!t) {
 		err = -ENOMEM;
 		goto put_inode_out;
-- 
2.43.0


  parent reply	other threads:[~2023-12-23  4:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 10:43 [syzbot] [ntfs3?] WARNING: kmalloc bug in ntfs_load_attr_list syzbot
2023-12-23  3:47 ` Edward Adam Davis
2023-12-23  4:05   ` syzbot
2023-12-23  4:05 ` Edward Adam Davis [this message]
2023-12-23 13:38   ` [PATCH] fs/ntfs3: fix warning " Tetsuo Handa

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=tencent_C789B86EF5AED70CAF27CF06EF52C1C66106@qq.com \
    --to=eadavis@qq.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=syzbot+f987ceaddc6bcc334cde@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 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.