From patchwork Fri Aug 14 22:13:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11715221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06DD6109B for ; Fri, 14 Aug 2020 22:13:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B8F9C20771 for ; Fri, 14 Aug 2020 22:13:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nYChkY22" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8F9C20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D248B6B0002; Fri, 14 Aug 2020 18:13:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD48D6B0005; Fri, 14 Aug 2020 18:13:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEAA16B0006; Fri, 14 Aug 2020 18:13:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0036.hostedemail.com [216.40.44.36]) by kanga.kvack.org (Postfix) with ESMTP id AB4E56B0002 for ; Fri, 14 Aug 2020 18:13:35 -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 71FF4180AD817 for ; Fri, 14 Aug 2020 22:13:35 +0000 (UTC) X-FDA: 77150576790.09.town51_5e047c627000 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 4DBA4180AD815 for ; Fri, 14 Aug 2020 22:13:35 +0000 (UTC) X-Spam-Summary: 1,0,0,1d2d2b4cd10c13cd,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:3872:4321:4385:5007:6261:6653:9108:10004:10400:11026:11232:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13221:13229:13311:13357:13439:14096:14097:14181:14394:14659:14721:21080:21324:21444:21451:21627:21990:30054:30070,0,RBL:209.85.167.193:@google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrw5ggwas6ijkccpid3pbbn4tj5ypdzxfmq9hx3bid1aits94da5x6e8u6wt8.1g61j5uhd7b788zcz84xtborp5eaafpzz18wdj8y55d1eizx64qfcbka6d1izum.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: town51_5e047c627000 X-Filterd-Recvd-Size: 4566 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Aug 2020 22:13:34 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id o21so9406704oie.12 for ; Fri, 14 Aug 2020 15:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=YU5kgUEDzxyOMT9rzgRH7KQsCrrC/AMgf4MvEBjYqSc=; b=nYChkY22lU50rLV7b9nv0rXxQPMAplE8whIy4wX+YDdfkpl5bkJdoownt03q6o3oJH 5PKRmzqjAA4Wm7kStjerqBL2FQ7Lp+uOYg+d+zOcdbBQmJa7PYkByPcpiXvATsMOlcU/ SNCQbDoaRdcivLYrdXpUUZHBGj9RniVch9cGXACewSF8kk9WQou9qJip8nSriIj8WZk/ 2TjUl94ia3EyVnjELzeXTMKkCjftGcH4/K8w+//rrTFeVB/sA0qi/0dG8sW1AkpX5Vno jly2O2hkMl0hdYkA1Ya3KXWWka0cXRMgOvMQwUTlyGwDNqd3zWBwLW2f1TaAy25w64Iq XJ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=YU5kgUEDzxyOMT9rzgRH7KQsCrrC/AMgf4MvEBjYqSc=; b=NDZdAhoBa6HUSHa3ujWIZwgYaa8chquct5Sfzkmc5MoOHAtGw5ThV4Mk5U9/jccXt2 LSEVn+m3RhvcbtFMLYKrtcVZylWq+kjvGkBh9tnMw38mz91W8Pngj8JO84SN/h9pRngV d2CN1bdcjhucj/1BoHA8H+9KII2b0gOLfGJQB6r6/M7w+olB987sID0vWue0uaWU4qmD ZoT6OgiDPyDnB/4Jfyn0mIZMmHeARkNlUK3bz6ccGqIHi61pP8s5oXfHnCvQNZjtBnSV +PR0a44uDUF1k02CWS6dwMu/6jhUKxnpTGNn7STFcCbciXTCpKS5PuhzuWn/TK16atA/ eEwQ== X-Gm-Message-State: AOAM531amyi7ullSdOtvN43rviR/ptq+ua72DIS4yG2TBmQ0haAsE2Q1 /HDi4YQsiuR12SukjsZ7EEFb3A== X-Google-Smtp-Source: ABdhPJwi07+q4De1leK1kwaoeRMb3m/eApDhDsZ6VRKOOd0v1IPUfrLquHEUtRL8j2SBF/BnIMK0LA== X-Received: by 2002:aca:5642:: with SMTP id k63mr2771385oib.42.1597443213626; Fri, 14 Aug 2020 15:13:33 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id w30sm1948549oow.36.2020.08.14.15.13.31 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 14 Aug 2020 15:13:32 -0700 (PDT) Date: Fri, 14 Aug 2020 15:13:18 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Hugh Dickins cc: Andrew Morton , "Kirill A. Shutemov" , Andrea Arcangeli , Song Liu , Mike Kravetz , Eric Dumazet , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter() In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: 4DBA4180AD815 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: syzbot crashes on the VM_BUG_ON_MM(khugepaged_test_exit(mm), mm) in __khugepaged_enter(): yes, when one thread is about to dump core, has set core_state, and is waiting for others, another might do something calling __khugepaged_enter(), which now crashes because I lumped the core_state test (known as "mmget_still_valid") into khugepaged_test_exit(). I still think it's best to lump them together, so just in this exceptional case, check mm->mm_users directly instead of khugepaged_test_exit(). Reported-by: syzbot Fixes: bbe98f9cadff ("khugepaged: khugepaged_test_exit() check mmget_still_valid()") Signed-off-by: Hugh Dickins Cc: stable@vger.kernel.org # v4.8+ Acked-by: Yang Shi --- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- v5.9-rc/mm/khugepaged.c 2020-08-12 19:46:50.867196579 -0700 +++ linux/mm/khugepaged.c 2020-08-14 14:24:32.739457309 -0700 @@ -466,7 +466,7 @@ int __khugepaged_enter(struct mm_struct return -ENOMEM; /* __khugepaged_exit() must not run from under us */ - VM_BUG_ON_MM(khugepaged_test_exit(mm), mm); + VM_BUG_ON_MM(atomic_read(&mm->mm_users) == 0, mm); if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) { free_mm_slot(mm_slot); return 0;