lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250217140809.1702789-14-ryan.roberts@arm.com>
Date: Mon, 17 Feb 2025 14:08:05 +0000
From: Ryan Roberts <ryan.roberts@....com>
To: Catalin Marinas <catalin.marinas@....com>,
	Will Deacon <will@...nel.org>,
	Pasha Tatashin <pasha.tatashin@...een.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Uladzislau Rezki <urezki@...il.com>,
	Christoph Hellwig <hch@...radead.org>,
	David Hildenbrand <david@...hat.com>,
	"Matthew Wilcox (Oracle)" <willy@...radead.org>,
	Mark Rutland <mark.rutland@....com>,
	Anshuman Khandual <anshuman.khandual@....com>,
	Alexandre Ghiti <alexghiti@...osinc.com>,
	Kevin Brodsky <kevin.brodsky@....com>
Cc: Ryan Roberts <ryan.roberts@....com>,
	linux-arm-kernel@...ts.infradead.org,
	linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH v2 13/14] mm: Only call arch_update_kernel_mappings_[begin|end]() for kernel mappings

arch_update_kernel_mappings_[begin|end]() is called from
__apply_to_page_range(), which operates both on kernel and user
mappings. Previously arch_update_kernel_mappings_[begin|end]() was
called unconditionally for both user and kernel mappings.

The existing arch implementations of arch_sync_kernel_mappings() (which
is called by the default implementation of
arch_update_kernel_mappings_end()) filter on kernel address ranges so
this change is still correct for those users. But given
"kernel_mappings" is in the function name, we really shouldn't be
calling it for user mappings. This change will also make the upcoming
arm64 implementation simpler.

Signed-off-by: Ryan Roberts <ryan.roberts@....com>
---
 mm/memory.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index f80930bc19f6..4e299d254a11 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3035,7 +3035,8 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 	if (WARN_ON(addr >= end))
 		return -EINVAL;
 
-	arch_update_kernel_mappings_begin(start, end);
+	if (mm == &init_mm)
+		arch_update_kernel_mappings_begin(start, end);
 
 	pgd = pgd_offset(mm, addr);
 	do {
@@ -3057,7 +3058,8 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 			break;
 	} while (pgd++, addr = next, addr != end);
 
-	arch_update_kernel_mappings_end(start, end, mask);
+	if (mm == &init_mm)
+		arch_update_kernel_mappings_end(start, end, mask);
 
 	return err;
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ