Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp61534pxy; Tue, 4 May 2021 18:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUsVDms4xB+/8u13r3J83LeYytWWC+Q3SjaT+PR8Ug+j8CcYmjylRcD1KC148pJG5fdUz+ X-Received: by 2002:aa7:908c:0:b029:209:aacd:d8b with SMTP id i12-20020aa7908c0000b0290209aacd0d8bmr26582783pfa.74.1620178455451; Tue, 04 May 2021 18:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620178455; cv=none; d=google.com; s=arc-20160816; b=q7I1cfdgUy4adby5q2PxnBSsZJLC5O66ZxtUGSIbvd8NyoQVTBSomXqVUhZTRO/S/i DhRQKbu3bojQLSkyYPxqc9SNYvTWlNLA2m6MRAbVJ654gvbRqldriM4HeKEI5aeL98ux m3d3qJC7Mxvn9mP0RvZCJ3StW0W8TmKskruycuPCIZxdjEtS+SbMb1CJdj6f9BpzUGsN 8EkAvxBYtJdC3gYfoOH5XmpWiJuzoBvxlwO/RU9QWRAXsQop8QOImqZaGcXL3b1THFuY 4YaDeXwVI4aWuy6f2pZ6mqne4/6HflOXQTg3XtQeYt8aXdQuZrRz3+fxC6XbWfUyYENW oxjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=dxBqgTIAlD9AOqIHVyc3HqYnnABYZ3bEvyGKPX83fas=; b=0KKK1Emj045r4xlAyOx1vu+NcovpS5/QSTZdhBrNkzNjM3ZfCvZTriswoQ5XIumtsh nmhAo05ZjT/+U4mcaGnsCkdSsF+ocSLndqzsh8CfddVJx+9sr4vC5MEUbvZKUiAbjONY AKvtVjHTVnHCiSCJpW8qxSuSQwViJm1puJT+TCNxfCuuPyED4RkL1dwx1TeZ+se64U+y qvpzNkCGeQ4/8zdHy0p/E2qAOZlOvzoLXAzomsZ4AVsMxng/dLgsI0LJl4Og6PGw9Khv NXTjV2vlHcnFrHhue4rHIKCnmObirswLHnVCmJkkXU2ayNsMrgBIJQCMQ/r7Cvu3pww3 Vigw== 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 h3si5551083plo.77.2021.05.04.18.34.03; Tue, 04 May 2021 18:34:15 -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 S231602AbhEEAda (ORCPT + 99 others); Tue, 4 May 2021 20:33:30 -0400 Received: from mga04.intel.com ([192.55.52.120]:19820 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231368AbhEEAdX (ORCPT ); Tue, 4 May 2021 20:33:23 -0400 IronPort-SDR: LDaNp2MLP1T+aTmViAThbvBbg8azv0brTRbLKvM+MrBHlECk4Di4AtG2MnogqjbFm4314xkPlg kcR+a4DvCYiQ== X-IronPort-AV: E=McAfee;i="6200,9189,9974"; a="196058593" X-IronPort-AV: E=Sophos;i="5.82,273,1613462400"; d="scan'208";a="196058593" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 17:32:27 -0700 IronPort-SDR: ip0J5D3qBZcnDAFgdM7HQHdxWI8/FjbpAGZI0G2d4bIwRZLNN6s4O1irKqEf+BRPr25p+FQq1v G9Ah1barEj0Q== X-IronPort-AV: E=Sophos;i="5.82,273,1613462400"; d="scan'208";a="429490787" Received: from rpedgeco-mobl3.amr.corp.intel.com (HELO localhost.intel.com) ([10.209.26.68]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 17:32:27 -0700 From: Rick Edgecombe To: dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, linux-hardening@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: ira.weiny@intel.com, rppt@kernel.org, dan.j.williams@intel.com, linux-kernel@vger.kernel.org, Rick Edgecombe Subject: [PATCH RFC 4/9] mm: Explicitly zero page table lock ptr Date: Tue, 4 May 2021 17:30:27 -0700 Message-Id: <20210505003032.489164-5-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210505003032.489164-1-rick.p.edgecombe@intel.com> References: <20210505003032.489164-1-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 5efa07fb6cdc..130f8c1e380a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5225,5 +5225,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.30.2