From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA971C433E0 for ; Fri, 22 Jan 2021 10:47:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 57A4C223C8 for ; Fri, 22 Jan 2021 10:47:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57A4C223C8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=i-love.sakura.ne.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C7C976B0007; Fri, 22 Jan 2021 05:47:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2CC36B000A; Fri, 22 Jan 2021 05:47:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF3D36B000C; Fri, 22 Jan 2021 05:47:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 951596B0007 for ; Fri, 22 Jan 2021 05:47:51 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5C5548249980 for ; Fri, 22 Jan 2021 10:47:51 +0000 (UTC) X-FDA: 77733085542.20.trees54_1500cf12756b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 3A4A2180C07AF for ; Fri, 22 Jan 2021 10:47:51 +0000 (UTC) X-HE-Tag: trees54_1500cf12756b X-Filterd-Recvd-Size: 3680 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Jan 2021 10:47:50 +0000 (UTC) Received: from fsav107.sakura.ne.jp (fsav107.sakura.ne.jp [27.133.134.234]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 10MAlh5A024453; Fri, 22 Jan 2021 19:47:43 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav107.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav107.sakura.ne.jp); Fri, 22 Jan 2021 19:47:43 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav107.sakura.ne.jp) Received: from [192.168.1.9] (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 10MAlhoG024444 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Jan 2021 19:47:43 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH v2] mm: memdup_user*() should use same gfp flags To: Andrew Morton , Michal Hocko , Alexander Viro Cc: linux-mm@kvack.org References: <20210120041843.5090-1-penguin-kernel@I-love.SAKURA.ne.jp> <20210120103436.11830-1-penguin-kernel@I-love.SAKURA.ne.jp> <20210121173538.166e8b27408d4525360fbb70@linux-foundation.org> From: Tetsuo Handa Message-ID: <5346de21-a404-8476-f2a3-c98c191a2ef9@i-love.sakura.ne.jp> Date: Fri, 22 Jan 2021 19:47:42 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210121173538.166e8b27408d4525360fbb70@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 2021/01/22 10:35, Andrew Morton wrote: > On Wed, 20 Jan 2021 19:34:36 +0900 Tetsuo Handa wrote: > >> syzbot is reporting that memdup_user_nul() which receives user-controlled >> size (which can be up to (INT_MAX & PAGE_MASK)) via vfs_write() will hit >> order >= MAX_ORDER path [1]. >> >> Let's add __GFP_NOWARN to memdup_user_nul() as with commit 6c8fcc096be9d02f >> ("mm: don't let userspace spam allocations warnings"). Also use GFP_USER as >> with commit 6c2c97a24f096e32 ("memdup_user(): switch to GFP_USER"). > > That commit failed to explain why a switch to GFP_USER was performed, > so that commit isn't a good substitute for an explanation of this > change. For example, commit 2f77d107050abc14 ("Fix incorrect user space access locking in mincore()") silently converted GFP_KERNEL to GFP_USER. #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL) * %GFP_KERNEL is typical for kernel-internal allocations. The caller requires * %ZONE_NORMAL or a lower zone for direct access but can direct reclaim. * %GFP_USER is for userspace allocations that also need to be directly * accessibly by the kernel or hardware. It is typically used by hardware * for buffers that are mapped to userspace (e.g. graphics) that hardware * still must DMA to. cpuset limits are enforced for these allocations. * %__GFP_HARDWALL enforces the cpuset memory allocation policy. > > So... please fully describe the reason for this change right here in > this patch's changelog. I guess that GFP_USER is chosen by cautious developers when memory is allocated by userspace request. Is there a guideline for when to use GFP_USER ?