Skip to content

Commit db7a347

Browse files
sjp38torvalds
authored andcommitted
mm/damon/dbgfs: use '__GFP_NOWARN' for user-specified size buffer allocation
Patch series "DAMON fixes". This patch (of 2): DAMON users can trigger below warning in '__alloc_pages()' by invoking write() to some DAMON debugfs files with arbitrarily high count argument, because DAMON debugfs interface allocates some buffers based on the user-specified 'count'. if (unlikely(order >= MAX_ORDER)) { WARN_ON_ONCE(!(gfp & __GFP_NOWARN)); return NULL; } Because the DAMON debugfs interface code checks failure of the 'kmalloc()', this commit simply suppresses the warnings by adding '__GFP_NOWARN' flag. Link: https://lkml.kernel.org/r/20211110145758.16558-1-sj@kernel.org Link: https://lkml.kernel.org/r/20211110145758.16558-2-sj@kernel.org Fixes: 4bc0595 ("mm/damon: implement a debugfs-based user space interface") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cab71f7 commit db7a347

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/damon/dbgfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static char *user_input_str(const char __user *buf, size_t count, loff_t *ppos)
3232
if (*ppos)
3333
return ERR_PTR(-EINVAL);
3434

35-
kbuf = kmalloc(count + 1, GFP_KERNEL);
35+
kbuf = kmalloc(count + 1, GFP_KERNEL | __GFP_NOWARN);
3636
if (!kbuf)
3737
return ERR_PTR(-ENOMEM);
3838

@@ -133,7 +133,7 @@ static ssize_t dbgfs_schemes_read(struct file *file, char __user *buf,
133133
char *kbuf;
134134
ssize_t len;
135135

136-
kbuf = kmalloc(count, GFP_KERNEL);
136+
kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
137137
if (!kbuf)
138138
return -ENOMEM;
139139

@@ -452,7 +452,7 @@ static ssize_t dbgfs_init_regions_read(struct file *file, char __user *buf,
452452
char *kbuf;
453453
ssize_t len;
454454

455-
kbuf = kmalloc(count, GFP_KERNEL);
455+
kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
456456
if (!kbuf)
457457
return -ENOMEM;
458458

@@ -578,7 +578,7 @@ static ssize_t dbgfs_kdamond_pid_read(struct file *file,
578578
char *kbuf;
579579
ssize_t len;
580580

581-
kbuf = kmalloc(count, GFP_KERNEL);
581+
kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
582582
if (!kbuf)
583583
return -ENOMEM;
584584

0 commit comments

Comments
 (0)