diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2024-12-21 08:47:29 +0100 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-12-31 02:59:11 +0100 |
commit | dd2a5b5514ab0e690f018595e34dd1fcb981d345 (patch) | |
tree | a2bf0a1933cb15addb2618c6d5ce738304484ec9 /mm | |
parent | mm, madvise: fix potential workingset node list_lru leaks (diff) | |
download | linux-dd2a5b5514ab0e690f018595e34dd1fcb981d345.tar.xz linux-dd2a5b5514ab0e690f018595e34dd1fcb981d345.zip |
mm/util: make memdup_user_nul() similar to memdup_user()
Since the string data to copy from userspace is likely less than PAGE_SIZE
bytes, replace GFP_KERNEL with GFP_USER like commit 6c2c97a24f09
("memdup_user(): switch to GFP_USER") does and add __GFP_NOWARN like
commit 6c8fcc096be9 ("mm: don't let userspace spam allocations warnings")
does. Also, use dedicated slab buckets like commit d73778e4b867
("mm/util: Use dedicated slab buckets for memdup_user()") does.
Link: https://lkml.kernel.org/r/014cd694-cc27-4a07-a34a-2ae95d744515@I-love.SAKURA.ne.jp
Reported-by: syzbot+7e12e97b36154c54414b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7e12e97b36154c54414b
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/util.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/mm/util.c b/mm/util.c index c1c3b06ab4f9..60aa40f612b8 100644 --- a/mm/util.c +++ b/mm/util.c @@ -297,12 +297,7 @@ void *memdup_user_nul(const void __user *src, size_t len) { char *p; - /* - * Always use GFP_KERNEL, since copy_from_user() can sleep and - * cause pagefault, which makes it pointless to use GFP_NOFS - * or GFP_ATOMIC. - */ - p = kmalloc_track_caller(len + 1, GFP_KERNEL); + p = kmem_buckets_alloc_track_caller(user_buckets, len + 1, GFP_USER | __GFP_NOWARN); if (!p) return ERR_PTR(-ENOMEM); |