Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4029752pxb; Mon, 30 Aug 2021 17:01:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjpOfELIe+fF4El8rE7rvZZdnGJOEXe4SwgWxhF4qrjacwWzgknU5fKg3W6Sq6y8hJJ57J X-Received: by 2002:a5e:9819:: with SMTP id s25mr20509148ioj.63.1630368084901; Mon, 30 Aug 2021 17:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630368084; cv=none; d=google.com; s=arc-20160816; b=o3vlmOETWUX+IFjOGJqFe+LykYhJKJOMa90n8+fS/eg5GErnAzilmLRfTccIoKMzxy rS11Xc+cromZszQFuT7mAtqmxsQh1cbscqml1OE2DnZaoi8mRmdPM5UQDkE7vd4360ol houJJC4AUZQ7HB83JVmGP6QTlTwVWnSc3dVpbBS6Wh/7+xqShpjI1ZdR5Kr+d3H6eIiZ rWrHmrhIbvkjLjKMyM/MThyxOHt1xmJjRBVHtIxZiELMQv3TafdtNTKpsAd+uP5S7KCe kZOybxj8zd4Cvf0h2M0Jc+9JGA4sNjFX7Jg4rTa4Q6bCuv/88rEEBQ4+UdWou4XjrPLE 54Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=BVu6jMy3fMQ5JQx5uvGn8hDEziUJKKbLsaQr9puVH7E=; b=MUtPQhB1Vvk963YinDzQ8rWpe0OG03+zwrlSKbF4tbl3pW3cHbpIbAaQdJgVyevcRV 9q68CDi7Lly/OF4zcqsTQPPFf0UXru93uGwUriV2//5mvdy6uGQfQtxa3kuKr9o5Ad+E dfKc9mP5MPVG6FHGPrb3d0Rg5MPbG4ht22DFJYCDGcnfSPemSNHFYkh+Zp7sR4Zf8g3t Lb7f3kIOwc8yhD6gV1y6ua8cYZbMbFyu4TGwA1gz4SjNsH159vb0MO8Unt4vFeSs0Fu3 Xs1GHG6YbqHTolRAHijn9SWIZfyc8/SjcagzPxgf0W3mIpu4wg3zdkMdtwI+uT4jtspR irCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si15184569jas.84.2021.08.30.17.00.48; Mon, 30 Aug 2021 17:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239244AbhHaABD (ORCPT + 99 others); Mon, 30 Aug 2021 20:01:03 -0400 Received: from mga09.intel.com ([134.134.136.24]:50152 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239163AbhHaAAy (ORCPT ); Mon, 30 Aug 2021 20:00:54 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="218381517" X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="218381517" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 17:00:00 -0700 X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="530712816" Received: from ajinkyak-mobl2.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.212.240.95]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 16:59:59 -0700 From: Rick Edgecombe To: dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, x86@kernel.org, akpm@linux-foundation.org, keescook@chromium.org, shakeelb@google.com, vbabka@suse.cz, rppt@kernel.org Cc: Rick Edgecombe , linux-mm@kvack.org, linux-hardening@vger.kernel.org, kernel-hardening@lists.openwall.com, ira.weiny@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 04/19] mm: Explicitly zero page table lock ptr Date: Mon, 30 Aug 2021 16:59:12 -0700 Message-Id: <20210830235927.6443-5-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210830235927.6443-1-rick.p.edgecombe@intel.com> References: <20210830235927.6443-1-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ptlock_init() there is a VM_BUG_ON_PAGE() check on the page table lock pointer. Explicitly zero the lock in ptlock_free() so a page table lock can be re-initialized without triggering the BUG_ON(). It appears this doesn't normally trigger because the private field shares the same space in struct page as ptl and page tables always return to the buddy allocator before being re-initialized as new page tables. When the page returns to the buddy allocator, private gets used to store the page order, so it inadvertently clears ptl as well. In future patches, pages will get re-initialized as page tables without returning to the buddy allocator so this is needed. Signed-off-by: Rick Edgecombe --- mm/memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory.c b/mm/memory.c index 25fc46e87214..e6d630463c7f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5465,5 +5465,6 @@ bool ptlock_alloc(struct page *page) void ptlock_free(struct page *page) { kmem_cache_free(page_ptl_cachep, page->ptl); + page->ptl = 0; } #endif -- 2.17.1