From patchwork Fri Jun 30 01:32:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13297482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7419FEB64D9 for ; Fri, 30 Jun 2023 01:32:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDADC8D0002; Thu, 29 Jun 2023 21:32:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB2758D0001; Thu, 29 Jun 2023 21:32:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D530D8D0002; Thu, 29 Jun 2023 21:32:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C59438D0001 for ; Thu, 29 Jun 2023 21:32:23 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A378C140459 for ; Fri, 30 Jun 2023 01:32:23 +0000 (UTC) X-FDA: 80957688966.12.CA9D7F5 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2045.outbound.protection.outlook.com [40.107.237.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 7ECDB1C0006 for ; Fri, 30 Jun 2023 01:32:20 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=BZ9V+3qH; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.237.45 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688088740; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=C2czduMdPMPW74eoadqc75//pR696cUAJih3JlUHpmU=; b=p9DgnaZeuUh/94jhPEAZIeB+OMaQjTzcOj3zvGPFIotvVCz27qlE7DFJewMLRXNKKlmWso CIK1Zl78C90AihXiQjvFpQ8jcJUwgAIppqdQGTTuuE701vfFfcM7wCJ7noTZE8XK2j+HuQ eY0IsYKrGudTqGkitAX3o1kWrmrKDr8= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=BZ9V+3qH; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.237.45 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1688088740; a=rsa-sha256; cv=pass; b=FbpTDckfv01p1CKN3AKUGFnNIYx4C2TcjjbhyeEdeiuEiABn0VYn/y1UfLu8j0bATNG9q3 fixgC5LSHUJwiVE5zDQ/baaPF6a4SodMyeyUlvH/uWGnZLUjvogqlrh2en3CvhhORMO0jH wC7Lmp0adsBqqXyt5itqKPiiyZQue1c= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cn5nAxcUNnld5oDMF/qxe6603EHAgNfnjxPGWX2r88y5YXnQ4J6Sy+7k5FImfiVYtJCI306nOdWnoLExlKNZZKD25R6DoLqHYH+o07JS7kKD1/YYLCRuClSMxxQsf93J4MkMPMQO+/SoKQf1m2ViG4DxQJAHQB/0kXVeGXf7hr0tQPhsNZZVqVUtkjVRu/r4UkvXoXBTZLnr023tJ8m84t1ZAzsNxVfIC0IJtdiDVgGXI7oIhySMK07dZwMW+zaVtnSbW+kb9iyret6KPJuNY/pTTZMsifYzSo69uZiucQ3FUS0r6wi1AoTkJ+nBB+vMcacqJ2jGLfhVyYax+AATOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C2czduMdPMPW74eoadqc75//pR696cUAJih3JlUHpmU=; b=DZNRIBb+q3mNSZPz/mGqVAGU7OTCXbKeE59t0Sbl7ll8LN1lShf1Kogp8ttzAElX7mG4FcHiGto8heIEQ1mk63hm6wtdUTa3XEN9ZwzAdbjrHCHATanRgtmIix4JpfNtMFb36rT3bCdmB4VR3aO0XE3qogprxR0Fs7OHWdOyahi5uDeeMMD8WySbk7YrrIQTcDoULFZbn7INgWc6pgduzLo+VEWDDch7iNswfgcEVDfggVof1sKx1nr+vTp0eBPMyxa1+8+P7bry7Wu/LQu/YmRgBlpOLiPLXqf9Di9cEuXPUPA4gMVTAWvQUUY10JM4MTBJKHA8hK4tYJknXowIGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C2czduMdPMPW74eoadqc75//pR696cUAJih3JlUHpmU=; b=BZ9V+3qH+jEXb9/7j/CHIx3dz+lNIB4mW729pc+HJ8XwQyBpS5Uxo/5K4Uv3xMTY7umKV4MKeS40EJS5BiU9ovfskZhrlN/fG6e4vPoROOkwjTjhjX0riQ/+kKaoRZ2UOYI/a54r1wpA/bHar2Y2Kj0qeifpvWX2KsvkEsFrAb5y5+KYAut6d7ISlpYaTBcTfuVrV9Vjn47gutuYPmgbWQ6lx3vgjN2yB9ju/35qq8Fsys01vkZqUsjDemLnXtZfJXfyLlVC70GaMZh3aTg+03c1PsTM5K0w57B9Gh5xpZQBBT1we6ZK6MRgQXqnC+zqGvoFUgLHqNTnBNsJLMu4+g== Received: from BN9PR03CA0756.namprd03.prod.outlook.com (2603:10b6:408:13a::11) by SJ1PR12MB6171.namprd12.prod.outlook.com (2603:10b6:a03:45a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 01:32:16 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::eb) by BN9PR03CA0756.outlook.office365.com (2603:10b6:408:13a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 01:32:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.49 via Frontend Transport; Fri, 30 Jun 2023 01:32:16 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 29 Jun 2023 18:32:07 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 29 Jun 2023 18:32:07 -0700 Received: from blueforge.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 29 Jun 2023 18:32:07 -0700 From: John Hubbard To: Andrew Morton CC: LKML , , John Hubbard , Adrian Hunter , Al Viro , Alex Williamson , Alexander Potapenko , Alexander Shishkin , Andrey Konovalov , Andrey Ryabinin , "Christian Brauner" , Christoph Hellwig , "Daniel Vetter" , Dave Airlie , Dimitri Sivanich , Dmitry Vyukov , Ian Rogers , Jason Gunthorpe , Jiri Olsa , Johannes Weiner , "Kirill A . Shutemov" , Lorenzo Stoakes , Mark Rutland , Matthew Wilcox , Miaohe Lin , Michal Hocko , Mike Kravetz , Mike Rapoport , Muchun Song , Namhyung Kim , Naoya Horiguchi , "Oleksandr Tyshchenko" , Pavel Tatashin , Roman Gushchin , "Ryan Roberts" , SeongJae Park , Shakeel Butt , Uladzislau Rezki , Vincenzo Frascino , Yu Zhao Subject: [PATCH] mm/hugetlb.c: fix a bug within a BUG(): inconsistent pte comparison Date: Thu, 29 Jun 2023 18:32:03 -0700 Message-ID: <20230630013203.1955064-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT040:EE_|SJ1PR12MB6171:EE_ X-MS-Office365-Filtering-Correlation-Id: bdb23fa6-fdd0-4073-718a-08db7909d6bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3D5x6w8n1ppm+s3zpLP/9s2GLV6tfFG0Syur83pdkQdQIuSj2sR8DxP3hDRPM3QwFCQxKGC+1X/sktWmAyRbzelOGYEaFC+BpEvTJptsgWJsBuSb3cHcOw0e/dghtZ9YJOQPdDC0Rup7/qX0gz3Kke9rqwzojXCIShk9SIqVEC2WLnWZqC5a85GLtXAAWfWhgDbnA94Nr64HszmR5N9IGpcEGR+4OgjolhEBYR9oAXOaTKTuyj3bD3zlLDCrPH8wNMxsID3GHSK1ThXqq/S0MUsoD6y/zs9tYurqOD2XUN6kUE/rh8eBEYf+IvV6YXHYs/6F7d/eTaBLzIt8DelF5nkVkBCG52N6+FD5HozpBgWDGA+IerCc6KQyCp3h73DngVl6/iHXPAgN/JDFEnVOpvthJvsIoVler8i7xhH7eL0MPnO0fbiEmWMsHTluxZdAW7luDDeyNjGnFnjiipuQmMIFU140GajR4OyOuhMFkR5NGt5xP7Th58fTKqYC7mbiXRpcqD2z3ltkwVXFug+p0dEp1cWGk7NXFhW4DtxP6kCcvxv/8J9+3nFiefnLx61VNYd40EzjYN186mcq0bUkj6PFXxvkiXllsMbQBIrnVOD92Lv7KNj43w8Gb1OIXz6aO6Gs0HTmJgQTG/oGs/2twGJaXbH0lw0u5hZ9jdBQn6YHd2WBy3Tgs6Ovhi5EA8iZjuaXkdAtahnJ9ILZksJjVTPo+5FGSBvE57xh27tgwPnIO2Ye7nWmMkP5yS7LYYzU X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(36840700001)(40470700004)(46966006)(336012)(426003)(47076005)(40460700003)(83380400001)(2616005)(2906002)(7636003)(356005)(82740400003)(36860700001)(40480700001)(36756003)(8936002)(8676002)(82310400005)(5660300002)(86362001)(54906003)(41300700001)(70586007)(6916009)(4326008)(70206006)(6666004)(316002)(7696005)(478600001)(186003)(1076003)(7406005)(7416002)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 01:32:16.4963 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdb23fa6-fdd0-4073-718a-08db7909d6bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6171 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7ECDB1C0006 X-Stat-Signature: ohnzbxuaebeqp3pbwnk55auyt4s55ef4 X-Rspam-User: X-HE-Tag: 1688088740-751956 X-HE-Meta: U2FsdGVkX19/e1w1ia/lBMOxHJySvwy6swVXGWNZWW0LHRgjCDm6IX/8CIL4mUOb+p8fA+qu9bCywW8t5Epcr/BQCcNuimXtX4Kng3kEgnBhpDv1nPX/8RpRs8h3xl+jDEz5lCYhlY9apDbPWXbdXqN1osDtUz7FQIDBkAce07AihfnP0swhtKLkjbzipYnVft+X8ZMU8GJCe/doADgjzBZg8uxFSltXpuI6GvtFRJ85Us5FDMJ29GxkOrhhtHBxROa2MeqnId40I0t2cm2GN6iwhpsiEACgly5M4e2nWVeqHFnlztafHnfKDKetEo/jTpmp2U0+Vssl0dTd8dOuRoLZz+pVCPlriIqFdHbk49PMDqYuQRqcOPIfMjff0e1ZX8O6s6mmCl0va1Lf3GH6Ho704tU0scvP36mfghqvnQw2fQ571jRHCwkQIKHOLFAZPBZ7vTuQBplRhmqyNe6A7QNDsn6vBA/CyZaiDcw8KGH+RbKBdcj3QNPGVvdTAiR0UAqB4i38aIM+D/LFb+3gLnALUX015tS138O4w0J5mvbgQVR+IzmMm1/We0S+dg3u21HUhtSraU7Capky65jaEPgDNXDt02D+b1XatDPHclRTx7FctqMWcKt/Prh0GxLiXZwuuVjANBCrh9ypT1vQ1lMKsU/24D3Lzpy+3VectNag/o0HLdmaZP+F0HEtMurAMtcMs2R9EXBJijyc2ZpYVsX26uMN/PKG+uXg8N6h2LMbZvRF9F5YGSWZrsg3bDKfMmp8j5VHwH2gyACkJS9etPS/VABb+lB7y+Zohgv48YsAafeUShqLkFYGCrdvA9qgzUg8GPAVxzNN+oIfyGyv9GeowrkFlNmXHSzk+D+adDD4slv5+b0EnJ8Vrj8nsxL8uIJBxDe0DE15cwOQxoaOK0ffgcZgXCwS+NHt9pozEjMLgXVIFldFu+IZ56+fxM+oGk9yBK7sZ/STXI/4nl7 7LXe7A4M 6RYC0WsCE1epChnwGmll4Sly+7qcmHHIuP2EWTIZnh2RZ29C/Kfjh8TcWaQ46n9uJ+GNjuDGqBNgCbWpZ6ZhTHP+oOz6PcTJht8pOqw+TReg5X2AfAzsCDmPmXUR6K3HEfsuNFPOoa5gyRQoFTb+ScEvI7kC4zD7eonPYtVNQpkby1LBO7jCLzo+AlLJj6HkULTCyOK+mTjkEHjLHYhpijtw+cv7W+Iki/uB+6F87w6EUhzDegorBFw13Gh5n5u6v9qQYjjg0Gh+S8ooAR2YQ0RZzO2Rp+dT1BJBhklDToiUgr+AlXYl8iMEik5cvyZNepDUOpTVvDEDKWsFJL7G9mbosaZzK+6aPg08ZUNIgdMvH9Ha+hb4UWLsMgm7jk9egO0MfPysWT19w6GwnFfo+GRAjTU764NIrTfmshl5C69t193D9drTrxJn13Oi14xz6tMYIUvKgJHWnBZQpGhtSJm6xyTBwH/4Yjq8fac+g4QZoMloz6D5nH2+r7RfUx6+xJW15Slcz7QciT1jEw1dlAG3eG7FvG145l1LScu5Dw3O6N5adE8229LTzKFgFhpNyjp4M9/or9Vw8UAfJ8fPDCuRNUnJoMiwCHkiOmL6SrKtSZe6Snih7fs5uctp6DZA4AYURz9gggFnS46mxK+34sVZ04uhD5IFE4sRdZ+CHQOQwgSy/wqYR8VB2LM5OZdeb2Q6kNvAe48rM7xZvTM1qs3oI+0DZFH2CFXNZu5I0mPBMRZeYnOHHkR2DfK10AbU4HEHaZLQy5Tt3jZBd3AVedqswLRN+35lP/U7GqjzemWtopm6lbHq0QRy7ARCNdoZWca7WcH4IaF9cCpJvo0ygFp6AlgEvm//ih/6aYWjsXDIX36GtsdxyLIzqBBTE13C4V9FSiJIkABd/UfOhMsXl84ku5QdmqY0Kz2LvZoOe0RURBlXwGv61Bud2ucwqkCOOhanwwT7MW5kZ8a5XXmKwPO/Xk9oS DoTmJhAi cC/FldB5bAlJ7o64sXvD6R2U4mmH9SMTE6T2batt+xyEqcJswG4gkA== 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: The following crash happens for me when running the -mm selftests (below). Specifically, it happens while running the uffd-stress subtests: kernel BUG at mm/hugetlb.c:7249! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 3238 Comm: uffd-stress Not tainted 6.4.0-hubbard-github+ #109 Hardware name: ASUS X299-A/PRIME X299-A, BIOS 1503 08/03/2018 RIP: 0010:huge_pte_alloc+0x12c/0x1a0 ... Call Trace: ? __die_body+0x63/0xb0 ? die+0x9f/0xc0 ? do_trap+0xab/0x180 ? huge_pte_alloc+0x12c/0x1a0 ? do_error_trap+0xc6/0x110 ? huge_pte_alloc+0x12c/0x1a0 ? handle_invalid_op+0x2c/0x40 ? huge_pte_alloc+0x12c/0x1a0 ? exc_invalid_op+0x33/0x50 ? asm_exc_invalid_op+0x16/0x20 ? __pfx_put_prev_task_idle+0x10/0x10 ? huge_pte_alloc+0x12c/0x1a0 hugetlb_fault+0x1a3/0x1120 ? finish_task_switch+0xb3/0x2a0 ? lock_is_held_type+0xdb/0x150 handle_mm_fault+0xb8a/0xd40 ? find_vma+0x5d/0xa0 do_user_addr_fault+0x257/0x5d0 exc_page_fault+0x7b/0x1f0 asm_exc_page_fault+0x22/0x30 That happens because a BUG() statement in huge_pte_alloc() attempts to check that a pte, if present, is a hugetlb pte, but it does so in a non-lockless-safe manner that leads to a false BUG() report. We got here due to a couple of bugs, each of which by itself was not quite enough to cause a problem: First of all, before commit c33c794828f2("mm: ptep_get() conversion"), the BUG() statement in huge_pte_alloc() was itself fragile: it relied upon compiler behavior to only read the pte once, despite using it twice in the same conditional. Next, commit c33c794828f2 ("mm: ptep_get() conversion") broke that delicate situation, by causing all direct pte reads to be done via READ_ONCE(). And so READ_ONCE() got called twice within the same BUG() conditional, leading to comparing (potentially, occasionally) different versions of the pte, and thus to false BUG() reports. Fix this by taking a single snapshot of the pte before using it in the BUG conditional. Now, that commit is only partially to blame here but, people doing bisections will invariably land there, so this will help them find a fix for a real crash. And also, the previous behavior was unlikely to ever expose this bug--it was fragile, yet not actually broken. So that's why I chose this commit for the Fixes tag, rather than the commit that created the original BUG() statement. Fixes: c33c794828f2 ("mm: ptep_get() conversion") Cc: Adrian Hunter Cc: Al Viro Cc: Alex Williamson Cc: Alexander Potapenko Cc: Alexander Shishkin Cc: Andrew Morton Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Christian Brauner Cc: Christoph Hellwig Cc: Daniel Vetter Cc: Dave Airlie Cc: Dimitri Sivanich Cc: Dmitry Vyukov Cc: Ian Rogers Cc: Jason Gunthorpe Cc: Jiri Olsa Cc: Johannes Weiner Cc: Kirill A. Shutemov Cc: Lorenzo Stoakes Cc: Mark Rutland Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Michal Hocko Cc: Mike Kravetz Cc: Mike Rapoport (IBM) Cc: Muchun Song Cc: Namhyung Kim Cc: Naoya Horiguchi Cc: Oleksandr Tyshchenko Cc: Pavel Tatashin Cc: Roman Gushchin Cc: Ryan Roberts Cc: SeongJae Park Cc: Shakeel Butt Cc: Uladzislau Rezki (Sony) Cc: Vincenzo Frascino Cc: Yu Zhao Signed-off-by: John Hubbard Acked-by: James Houghton Acked-by: Muchun Song Acked-by: Mike Kravetz --- mm/hugetlb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) base-commit: bf1fa6f15553df04f2bdd06190ccd5f388ab0777 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bce28cca73a1..73fbeb8f979f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7246,7 +7246,12 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, pte = (pte_t *)pmd_alloc(mm, pud, addr); } } - BUG_ON(pte && pte_present(ptep_get(pte)) && !pte_huge(ptep_get(pte))); + + if (pte) { + pte_t pteval = ptep_get(pte); + + BUG_ON(pte_present(pteval) && !pte_huge(pteval)); + } return pte; }