Received: by 10.223.185.116 with SMTP id b49csp1075777wrg; Sat, 3 Mar 2018 14:53:16 -0800 (PST) X-Google-Smtp-Source: AG47ELu5mIMZuI2dUKXJIZJEjxf1jR1ZKLmNhoZ0nW4Z2QJePqXcgMkM5cMLypLOjOvDwfx50k3E X-Received: by 2002:a17:902:7282:: with SMTP id d2-v6mr9079566pll.303.1520117596644; Sat, 03 Mar 2018 14:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520117596; cv=none; d=google.com; s=arc-20160816; b=H2p0tKAaQ0ZjB7VxwqcG9z3MM5Hq5V87f2lhKcphLXQ9Y4DuK4SXGtk1sw+WsX1Mb+ 7usCGBCDu9HW9IaRfACMNlU8wfmv5+rI28tknMzPY+v5vVIXIENS8VNIBSvvxaq+0Zs0 Ysr2wiYoE9sg41mz/IVRIN44pgLLt7p/NSrnjH4biaM5SjmDP/7r1fR8Vem0oya9Xd3a XLbGQQZEhTp56ifgCyDmdipgJayPJZTYJEN1qFKKXefaPBh1kUN4PiDkuTilroVjNKs/ yXzEzyGf5eCTo5hmQPwWKjPJJ1gTGlCe5PZMHVG6GbLbPIlNPtVzRn4RQQcyrYC6fRNj TiMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=cLJWgXwSqhxdAWUBJjg2Pd5zUm46OrpIYsj793d0kxc=; b=uX7JqQv5p1HwFv7S7EfoH1tgN+OBoB0pX2TzHoDB1foKyIgfCA77pLl/jVq/UIZpXd 5Xt0GOt4cMvgwLmiimAjxxeq5c5np+qKZQWjCZOfy5qPi6f6NU/qQmm3PFyqm6cUpGAI SPN+LnTv3EJysoIKUEWlYC3Yn9+T0LcYzsbjnpxhv4+El7sdBiQL5BJFd4FOJgVzpjPW tWO1/XC8049pQmPtKaj5a66gboIFP4/9b+wsefKFbr+v+XqHKrz/OqS67HsKs/00siOC cf+X6OvnG7q+u7t4rB9qZc4GJVzjj9ivt8U4v9z8IrpsqjL7P98XB3zTstsiwaHb6jRS ub4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=CdTCrfTP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6-v6si467526plm.448.2018.03.03.14.53.02; Sat, 03 Mar 2018 14:53:16 -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=@microsoft.com header.s=selector1 header.b=CdTCrfTP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934513AbeCCWwF (ORCPT + 99 others); Sat, 3 Mar 2018 17:52:05 -0500 Received: from mail-by2nam01on0095.outbound.protection.outlook.com ([104.47.34.95]:48488 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935435AbeCCWlK (ORCPT ); Sat, 3 Mar 2018 17:41:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cLJWgXwSqhxdAWUBJjg2Pd5zUm46OrpIYsj793d0kxc=; b=CdTCrfTPBBua1mleD/JwfUFCb2CCSFHuaDhkF7o9k8byP/AFEzldYCeUlaeBnkdRPzCQy57vU+u43xKxok6zSpNgC9cByJiotQEJ+iPD9V2ia3ptHcCuzsyteNuzRzunKWbiRl9Iaj7l5vIDD+sRMV+8Bv2vnmIwfKaEKo/dU6E= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0940.namprd21.prod.outlook.com (52.132.146.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.5; Sat, 3 Mar 2018 22:41:06 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:41:06 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Kirill A. Shutemov" , Andrew Morton , "Aneesh Kumar K . V" , "Kirill A . Shutemov" , LKP , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , "linux-mm@kvack.org" , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 22/63] mm: Fix false-positive VM_BUG_ON() in page_cache_{get,add}_speculative() Thread-Topic: [PATCH AUTOSEL for 3.18 22/63] mm: Fix false-positive VM_BUG_ON() in page_cache_{get,add}_speculative() Thread-Index: AQHTsz+j0Ej9J09mk0mlWiJBppzPDA== Date: Sat, 3 Mar 2018 22:33:22 +0000 Message-ID: <20180303223228.27323-22-alexander.levin@microsoft.com> References: <20180303223228.27323-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223228.27323-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0940;7:sOMwNWptvPyDzQ+Ic5HDMdmm8fiijl/xLhXDeG5vrRqwMcARD35TBtQg/LHAvwRvK70ZOBNxdmA5XHE989UC2fuVCU+tB8+GdBax1N8bGv43zw1qOBRXOvclVCBkrzUlQYl3Lm/oUw7OHog7SVWM3YIur2eqhTkkkVhq3D8EZrPE81g251MHwsh31mgvSHHjZsqP9C9yktA+v6iUTxyQ8tn4U9a1M1ekfZXj0ohK6a9nKvCMunCode+a3WCOK8x5 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b5e64083-a0c8-4f49-038f-08d58157da73 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0940; x-ms-traffictypediagnostic: MW2PR2101MB0940: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301)(104084551191319)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0940;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0940; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(39380400002)(346002)(366004)(39860400002)(396003)(199004)(189003)(106356001)(68736007)(6486002)(25786009)(22452003)(6436002)(186003)(2906002)(81156014)(81166006)(10090500001)(66066001)(8676002)(36756003)(6512007)(2900100001)(316002)(97736004)(59450400001)(102836004)(53936002)(6506007)(3280700002)(26005)(6306002)(4326008)(966005)(5250100002)(305945005)(2501003)(76176011)(7416002)(2950100002)(86362001)(99286004)(3846002)(72206003)(14454004)(3660700001)(478600001)(1076002)(5660300001)(10290500003)(6666003)(6116002)(7736002)(86612001)(107886003)(110136005)(54906003)(105586002)(8936002)(22906009)(142933001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0940;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: R/D7YtSZq0sYheZd2AVT9guIfrmhqVxyCXWSKUYEEgyMkdY7T0/hj56gYPHAn5xoZnZmkyygZ1QH5IKLh50z1WCG82N9hGoBLHU0Tu5w6pawHQ5ArpW4eGWDbzaZzsFQLMCzWXXciHHrQAHoU6yfi9BhQBzx8GFpRfaIMV66IJc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5e64083-a0c8-4f49-038f-08d58157da73 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:33:22.9973 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0940 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Kirill A. Shutemov" [ Upstream commit 591a3d7c09fa08baff48ad86c2347dbd28a52753 ] 0day testing by Fengguang Wu triggered this crash while running Trinity: kernel BUG at include/linux/pagemap.h:151! ... CPU: 0 PID: 458 Comm: trinity-c0 Not tainted 4.11.0-rc2-00251-g2947ba0 #1 ... Call Trace: __get_user_pages_fast() get_user_pages_fast() get_futex_key() futex_requeue() do_futex() SyS_futex() do_syscall_64() entry_SYSCALL64_slow_path() It' VM_BUG_ON() due to false-negative in_atomic(). We call page_cache_get_speculative() with disabled local interrupts. It should be atomic enough. So let's check for disabled interrupts in the VM_BUG_ON() condition too, to resolve this. ( This got triggered by the conversion of the x86 GUP code to the generic GUP code. ) Reported-by: Fengguang Wu Signed-off-by: Kirill A. Shutemov Cc: Andrew Morton Cc: Aneesh Kumar K.V Cc: Kirill A. Shutemov Cc: LKP Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20170324114709.pcytvyb3d6ajux33@black.fi.int= el.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- include/linux/pagemap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 30a8f531236c..2629fc3e24e0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -146,7 +146,7 @@ static inline int page_cache_get_speculative(struct pag= e *page) =20 #ifdef CONFIG_TINY_RCU # ifdef CONFIG_PREEMPT_COUNT - VM_BUG_ON(!in_atomic()); + VM_BUG_ON(!in_atomic() && !irqs_disabled()); # endif /* * Preempt must be disabled here - we rely on rcu_read_lock doing @@ -184,7 +184,7 @@ static inline int page_cache_add_speculative(struct pag= e *page, int count) =20 #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU) # ifdef CONFIG_PREEMPT_COUNT - VM_BUG_ON(!in_atomic()); + VM_BUG_ON(!in_atomic() && !irqs_disabled()); # endif VM_BUG_ON_PAGE(page_count(page) =3D=3D 0, page); atomic_add(count, &page->_count); --=20 2.14.1