From patchwork Sat Dec 21 07:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 13917699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F040E77184 for ; Sat, 21 Dec 2024 07:47:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E2996B0083; Sat, 21 Dec 2024 02:47:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 590C66B0088; Sat, 21 Dec 2024 02:47:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 458306B0089; Sat, 21 Dec 2024 02:47:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 26B906B0083 for ; Sat, 21 Dec 2024 02:47:39 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C44EB12082A for ; Sat, 21 Dec 2024 07:47:38 +0000 (UTC) X-FDA: 82918186218.28.F523241 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf04.hostedemail.com (Postfix) with ESMTP id 27EE64000D for ; Sat, 21 Dec 2024 07:46:58 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734767230; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=y8RqQGtD0qvYS0QB5NQiEs/daFvb2CHpTPt39Q4L+Us=; b=T2rfu+kRexVul1jO4pg0GbZmyJvkepruyp7T1WeGPHrpyNX42+qK6iDb8YWaryDCp/GkIF LXhgJt07PunBbllLiSb6Q3wDXv+9e1yIKWnGONbhrj4haHjUIMxIm+/4Nw25gHXL0Q5Tyh m3LZCndjpZzjysokeNkQHFprDtuWEO8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734767230; a=rsa-sha256; cv=none; b=Hp4cz7mJMytPbzRKljD+xHmeABHFXgjKasRSTmcez3nNdZC39CR4mh8rrIB6x1GxkHMRUQ dTud926c56onv6y4x39f5rwX3MQcj2vlsecnCr/I9eCqsQf1ykMGrWbuM56fKWzAbs8n9Y 46TMnW4F9Kqudwr43KN5/ZJOPDy3Py4= Received: from www262.sakura.ne.jp (localhost [127.0.0.1]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 4BL7lVk3085310; Sat, 21 Dec 2024 16:47:31 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 4BL7lVQ3085304 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Sat, 21 Dec 2024 16:47:31 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <014cd694-cc27-4a07-a34a-2ae95d744515@I-love.SAKURA.ne.jp> Date: Sat, 21 Dec 2024 16:47:29 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Andrew Morton , linux-mm Cc: LKML From: Tetsuo Handa Subject: [PATCH] mm/util: make memdup_user_nul() similar to memdup_user() X-Anti-Virus-Server: fsav201.rs.sakura.ne.jp X-Virus-Status: clean X-Rspamd-Queue-Id: 27EE64000D X-Rspamd-Server: rspam12 X-Stat-Signature: ddnqazfx5fanbkbqr954c39iabf6oa38 X-Rspam-User: X-HE-Tag: 1734767218-351859 X-HE-Meta: U2FsdGVkX189XTJVBxJXwy5vMdIi7KehRSIN3CYbTX6eHi8Kro6AAg92fidptq1cGbCCtKzuEEPZJbQL31bZPEuDgw3N9ARWv+sAuKw8EsaaYIj7Nk8hCBjZz35JVyT0pTJvMSKtiGmnorCcnGDTTApyv6U9ljhRqtLHn052ealvL8nEy/r6en3cJJgj1AxYsyil8RYJKa6L8kBgxYpou7jRIuwspfYy53POyImUFbQFvzucQxjLIK3Y2uzectSfBZarPNPNz/G27T8D2J4hk/Yk9noAaSBZyrOYoYjr5ObkfFURL+I2c8e3o1ISfZqcbM55HdPp7DHY6K3C4TgZfn70/3h5T8GUAzvsfN91Z4sEvcBS8CaDQFJ4XTUYQt4NV8eH8YV2sHZcG7Eaj1Ji1BNXxiHEWZkVyxj/dMMIXlP46ajgSjcq1kUs7/FFVKv1Zg33Lv0xrlzU0I4Hkbt39zoAohyvx7R7XWYjP467a5AuEtYHTjmHxn81VjsHUKw7TTiGxClAvy93XmWv4MwnahYgPO/2MTPTIeR46KyqJKroptyRW6Sp19pIG214YxSZcufo5JPswSFKaBk35m8+v8izSoqvNr7hhWiVPE7r9HLbvcJc1yeZ0k+j3N48Ku/Sxz1bN34PI0eP0dehhbJeMmlRDTnkXIdY3j3tTA7tcxuY07RbF+r2OwEJ66RYWDL3igtJJyCjYbAQNb/Pl5i8UJkMEZEDsDZb6vDpKtjLYHVYh+NRr/FIiXpUxrAk1jd/qUiqFVxd/CluW6QiKFmEQpyYj5tfctmEisrvZ6HFfTP2iwVJDiWPyY7TH+fvOkNG4ov8lhDCig4iJgjDUffgrr4GtzfKDDnpsy9Tr+7ZpHgjB3bsKO7EoG48tMbLLyOx60Ijp2Ikqi1MVupMWWoFreJn6yeZpfURqJCG1DuvunTVMD2ih/+1yK0kxqz70kd6aDAytfYx5irB/4WU2Ev yjlBd9Hu F1pzFe7PwQw8srFxV/L60ehe+Gp3tcj1Z62MMln4FemnhreJ8QDf8ONoexgvtEWjp75Lyn05+5XFfDKnATuaNHDODL8FXM4WyO379hiEK2TR1Q4Il0rpI35rzyJrZClmSWsJTD+uNAN28st5aYB43gsx84Ycguj7+X5Qg2k5Bi1VpeNl+cMFPDIwNehpULmnrTt1UKdqNBvQQ84Fq7r+4NgcwT9AdGM2DtUfoZKqmgQ3FngbkPlD1PdsB6UvXmTLmesI60ArM1BNPKCjea/2G7REn3F8XUja5idqZGjKYsfUDhB03jnRnlth+V9uRwNGghiMFNcF3EJ1xBiZPygvKcJnpboq2L38UHoDAPL6z9+t7CRivOb6oiCeVY4xi2oWS1+I+3D/cn7DZNYc9waPw9sVg2dPnBVIHc1S0zO0sCm+ZCE/cK4eHYi3ZEG8LP+B4RKUp9xgIiJW5Rh5Qe8nZF2nQ0+MqqxhIxqNjtt0QeH8zM8E= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. Reported-by: syzbot+7e12e97b36154c54414b@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=7e12e97b36154c54414b Signed-off-by: Tetsuo Handa --- mm/util.c | 7 +------ 1 file changed, 1 insertion(+), 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);