From patchwork Tue Jul 6 09:24:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12360097 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0F391C07E9B for ; Tue, 6 Jul 2021 09:25:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F565613C8 for ; Tue, 6 Jul 2021 09:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F565613C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vivo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 47E456B0011; Tue, 6 Jul 2021 05:25:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42DDD6B0036; Tue, 6 Jul 2021 05:25:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6AD6B005D; Tue, 6 Jul 2021 05:25:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 0BE636B0011 for ; Tue, 6 Jul 2021 05:25:20 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 68F14181FA8AA for ; Tue, 6 Jul 2021 09:25:19 +0000 (UTC) X-FDA: 78331629558.09.F8156F9 Received: from mail-m17639.qiye.163.com (mail-m17639.qiye.163.com [59.111.176.39]) by imf10.hostedemail.com (Postfix) with SMTP id 290606001AAE for ; Tue, 6 Jul 2021 09:25:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; b=fsB1TXyBUOJ/Qaqv5mSIpYKgYP1FhlOkIsPrAn/yCH53IKhgeTAvjgVjHCgbNIgAPmA/BmNbf92Jn7LQXmoummyEH4utQxFDwcK9dw21mlmh+jNLuJZgxzcQC+0y0EMjQ+vK0HIEFjy6TwWZnhOTGxd4NMRsN8iCHm0tX5czu5E=; s=default; c=relaxed/relaxed; d=vivo.com; v=1; bh=bOc4pvtcNfvNmA+UO/ZMqZD/nzwNN8K7zpJtMiW/zWY=; h=date:mime-version:subject:message-id:from; Received: from vivo-HP-ProDesk-680-G4-PCI-MT.vivo.xyz (unknown [58.251.74.232]) by mail-m17639.qiye.163.com (Hmail) with ESMTPA id 7E28D38018B; Tue, 6 Jul 2021 17:25:15 +0800 (CST) From: Wang Qing To: Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), linux-kernel@vger.kernel.org (open list) Cc: mgorman@techsingularity.net, Qiang.Zhang@windriver.com, Wang Qing Subject: [PATCH V2] mm: add GFP_ATOMIC flag after local_lock_irqsave Date: Tue, 6 Jul 2021 17:24:31 +0800 Message-Id: <1625563471-3873-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQxlPSFZOQx9NSx9KHUMaH05VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKQ1VLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6KzY6LBw4Aj9PLh8rE0oBDhIw PxoKCRFVSlVKTUlOTk1ITkpNS05KVTMWGhIXVQwaFRwKEhUcOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5KVUxPVUlISVlXWQgBWUFJSkxINwY+ X-HM-Tid: 0a7a7b22cb46d994kuws7e28d38018b Authentication-Results: imf10.hostedemail.com; dkim=none ("invalid DKIM record") header.d=vivo.com header.s=default header.b=fsB1TXyB; dmarc=pass (policy=none) header.from=vivo.com; spf=pass (imf10.hostedemail.com: domain of wangqing@vivo.com designates 59.111.176.39 as permitted sender) smtp.mailfrom=wangqing@vivo.com X-Stat-Signature: kg4j46fsoyjinczhneehh3wb39yhxwju X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 290606001AAE X-HE-Tag: 1625563517-855191 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: prep_new_page() will allocate memory in some scenarios. Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:96 ___might_sleep.cold+0x1f1/0x237 kernel/sched/core.c:9153 prepare_alloc_pages+0x3da/0x580 mm/page_alloc.c:5179 __alloc_pages+0x12f/0x500 mm/page_alloc.c:5375 alloc_pages+0x18c/0x2a0 mm/mempolicy.c:2272 stack_depot_save+0x39d/0x4e0 lib/stackdepot.c:303 save_stack+0x15e/0x1e0 mm/page_owner.c:120 __set_page_owner+0x50/0x290 mm/page_owner.c:181 prep_new_page mm/page_alloc.c:2445 [inline] __alloc_pages_bulk+0x8b9/0x1870 mm/page_alloc.c:5313 So we add GFP_ATOMIC and remove GFP_KERNEL flag. Reported-and-tested-by: syzbot+b07d8440edb5f8988eea@syzkaller.appspotmail.com Signed-off-by: Wang Qing --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d6e94cc..3016ba5 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5309,7 +5309,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, } nr_account++; - prep_new_page(page, 0, gfp, 0); + prep_new_page(page, 0, gfp | GFP_ATOMIC & ~GFP_KERNEL, 0); if (page_list) list_add(&page->lru, page_list); else