[RFC 1/2] x86/mm/cpa: always fail when user address is passed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently CPA is not used for user mappings (only pgd of init_mm
or and efi_mm is used). For simplicity, always fail when user address
is passed.

Note that efi_mm uses 1:1 mapping so its address should not be
considered as user address.

Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
---
 arch/x86/mm/pat/set_memory.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 1abd5438f126..67cf969fed0d 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -20,6 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/cc_platform.h>
 #include <linux/set_memory.h>
+#include <linux/efi.h>
 
 #include <asm/e820/api.h>
 #include <asm/processor.h>
@@ -1514,6 +1515,11 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
 	pte_t *kpte, old_pte;
 
 	address = __cpa_addr(cpa, cpa->curpage);
+
+	if (WARN((IS_ENABLED(CONFIG_EFI) ? cpa->pgd != efi_mm.pgd : true)
+		  && address <= TASK_SIZE_MAX,
+		 KERN_WARNING "CPA: Got a user address"))
+		return -EINVAL;
 repeat:
 	kpte = _lookup_address_cpa(cpa, address, &level);
 	if (!kpte)
-- 
2.32.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux