]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
um: Fix pte_read() and pte_exec() for kernel mappings
authorTiwei Bie <tiwei.btw@antgroup.com>
Mon, 2 Mar 2026 23:52:24 +0000 (07:52 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Sat, 21 Mar 2026 09:42:24 +0000 (10:42 +0100)
The pte_read() and pte_exec() helpers are only used during the TLB
sync to determine the read/exec permissions for mmap. However, for
kernel mappings, they will always return 0. This leads to kern_map()
having to unconditionally set the exec flag to 1 and the read flag
unexpectedly always being 0. Remove the unnecessary check for the
_PAGE_USER bit in these helpers to ensure that the kernel mapping
permissions can be correctly determined.

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20260302235224.1915380-3-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/include/asm/pgtable.h
arch/um/kernel/tlb.c

index 3b42b0f45bf6cdf5807659bd5bd8b31ccdf45884..e156ef6f4fdb697e0f1f4ce9dff32f80ad583df2 100644 (file)
@@ -121,13 +121,12 @@ static inline int pte_none(pte_t pte)
  */
 static inline int pte_read(pte_t pte)
 {
-       return((pte_get_bits(pte, _PAGE_USER)) &&
-              !(pte_get_bits(pte, _PAGE_PROTNONE)));
+       return !pte_get_bits(pte, _PAGE_PROTNONE);
 }
 
-static inline int pte_exec(pte_t pte){
-       return((pte_get_bits(pte, _PAGE_USER)) &&
-              !(pte_get_bits(pte, _PAGE_PROTNONE)));
+static inline int pte_exec(pte_t pte)
+{
+       return !pte_get_bits(pte, _PAGE_PROTNONE);
 }
 
 static inline int pte_write(pte_t pte)
index 5386ab2d0da50561e7c42712d1783c838e27265f..1f175716b47478454e14758905b222bbeadb05e6 100644 (file)
@@ -29,10 +29,9 @@ static int kern_map(struct mm_id *mm_idp,
                    unsigned long virt, unsigned long len, int prot,
                    int phys_fd, unsigned long long offset)
 {
-       /* TODO: Why is executable needed to be always set in the kernel? */
        return os_map_memory((void *)virt, phys_fd, offset, len,
                             prot & UM_PROT_READ, prot & UM_PROT_WRITE,
-                            1);
+                            prot & UM_PROT_EXEC);
 }
 
 static int kern_unmap(struct mm_id *mm_idp,