Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6021764ybc; Wed, 27 Nov 2019 13:33:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzNuDkAhHQwXKmnjH0xINKw5/b4KWiS/naybTGSv2EowxiXEQmWcacbVzcHU9saol2rrvhn X-Received: by 2002:a50:f292:: with SMTP id f18mr8799965edm.169.1574890391625; Wed, 27 Nov 2019 13:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890391; cv=none; d=google.com; s=arc-20160816; b=Sc5AhVrgv//+d95iJIEoS8HYfNyE6saNLShg3T3rUgP8jgXFWGyKcy5VQKRkHkc2LX jBDZYVoFjC+2MboB+vB9/1jBVCxLLkpCvl/1XQt1gzkOUQoyXPaukrQnUjgoygAKaL+a 8EV5kYwfplgkBIaflV82O/uxwsgaX6bTcsWwi77BN6PT3fANfGmU3hEBNwovzXV6hl9M 6mFrWZgSGZm+JPtL0eeukdxVWC8s520FWJNtu8zFpd/SVpzls/nq5ZE4x9OU9/ghFS23 cE3GCt9+3iSB4iF9Xd+3m/PkeAVoOexPVBJRuioOA+qkC0UY7132tSTktkWrQnT+Jc45 XLjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qhBJg+wdiqDEu0Sf3CFYBJelV1H4J/ljIAQ1izxmpVg=; b=WnYpZ13rpOjAmtymv0SlDlNiLroREAIfuSzMe4FMB4MQ/c/wAqfJUhHIcXAPhdO+MC auT0W1gw90IK7E1o0uU1b4WRvGoDkBOQH7OSXoEDxl6qcuUHeSQyZm6Tch1OMpYfUOzK sSYZauNXRb09yYeYfyvD60jOJMiHeIe0GxH2JZY15W4C7RwsLcFQhA5TiRZwJJkigqlY TeOWXt0k+q6lAubV0u85nHHNUF26H3WeQI+EaYaX0Okjz/bdB/c8c+xkJJkMrkxRwTL0 v8zhyzEzvNlYWleQ43xzFLnVpx/wLkH/O/cIfhcDfjFfxmL5h+pQRJmK+15lgXzm+dzL iOGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LIN3u2tp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23si3637876edr.447.2019.11.27.13.32.47; Wed, 27 Nov 2019 13:33:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LIN3u2tp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730670AbfK0Uzj (ORCPT + 99 others); Wed, 27 Nov 2019 15:55:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:46058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730965AbfK0Uzc (ORCPT ); Wed, 27 Nov 2019 15:55:32 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5167E21582; Wed, 27 Nov 2019 20:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888131; bh=MTXxrypDEJvyoxSioOfbN3iV+2WTuL9ZZHwwufuetbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIN3u2tpU3UrqZN01O5YzV0vie1tf0x9UFcaYzIi3Y7mNx4ndeJM0f74cJVLN2tmB CXY0Pf0u/dgzqhyapkgsogkcR+gpAnVx0HVH4WlTZHky9Ol2rgLILKfr8piWVIx9aU AexofUUC9lVLcF5cGpmrnwNYWmr4f1v3Rkg0SvCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Ryabinin , Hugh Dickins , Andrea Arcangeli , Andrew Morton , Linus Torvalds Subject: [PATCH 4.19 017/306] mm/ksm.c: dont WARN if page is still mapped in remove_stable_node() Date: Wed, 27 Nov 2019 21:27:47 +0100 Message-Id: <20191127203115.954898981@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Ryabinin commit 9a63236f1ad82d71a98aa80320b6cb618fb32f44 upstream. It's possible to hit the WARN_ON_ONCE(page_mapped(page)) in remove_stable_node() when it races with __mmput() and squeezes in between ksm_exit() and exit_mmap(). WARNING: CPU: 0 PID: 3295 at mm/ksm.c:888 remove_stable_node+0x10c/0x150 Call Trace: remove_all_stable_nodes+0x12b/0x330 run_store+0x4ef/0x7b0 kernfs_fop_write+0x200/0x420 vfs_write+0x154/0x450 ksys_write+0xf9/0x1d0 do_syscall_64+0x99/0x510 entry_SYSCALL_64_after_hwframe+0x49/0xbe Remove the warning as there is nothing scary going on. Link: http://lkml.kernel.org/r/20191119131850.5675-1-aryabinin@virtuozzo.com Fixes: cbf86cfe04a6 ("ksm: remove old stable nodes more thoroughly") Signed-off-by: Andrey Ryabinin Acked-by: Hugh Dickins Cc: Andrea Arcangeli Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/ksm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/mm/ksm.c +++ b/mm/ksm.c @@ -870,13 +870,13 @@ static int remove_stable_node(struct sta return 0; } - if (WARN_ON_ONCE(page_mapped(page))) { - /* - * This should not happen: but if it does, just refuse to let - * merge_across_nodes be switched - there is no need to panic. - */ - err = -EBUSY; - } else { + /* + * Page could be still mapped if this races with __mmput() running in + * between ksm_exit() and exit_mmap(). Just refuse to let + * merge_across_nodes/max_page_sharing be switched. + */ + err = -EBUSY; + if (!page_mapped(page)) { /* * The stable node did not yet appear stale to get_ksm_page(), * since that allows for an unmapped ksm page to be recognized