Skip to content

Commit cd4126d

Browse files
btw616jmberg-intel
authored andcommitted
um: Fix pte_read() and pte_exec() for kernel mappings
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 102331b commit cd4126d

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

arch/um/include/asm/pgtable.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ static inline int pte_none(pte_t pte)
121121
*/
122122
static inline int pte_read(pte_t pte)
123123
{
124-
return((pte_get_bits(pte, _PAGE_USER)) &&
125-
!(pte_get_bits(pte, _PAGE_PROTNONE)));
124+
return !pte_get_bits(pte, _PAGE_PROTNONE);
126125
}
127126

128-
static inline int pte_exec(pte_t pte){
129-
return((pte_get_bits(pte, _PAGE_USER)) &&
130-
!(pte_get_bits(pte, _PAGE_PROTNONE)));
127+
static inline int pte_exec(pte_t pte)
128+
{
129+
return !pte_get_bits(pte, _PAGE_PROTNONE);
131130
}
132131

133132
static inline int pte_write(pte_t pte)

arch/um/kernel/tlb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ static int kern_map(struct mm_id *mm_idp,
2929
unsigned long virt, unsigned long len, int prot,
3030
int phys_fd, unsigned long long offset)
3131
{
32-
/* TODO: Why is executable needed to be always set in the kernel? */
3332
return os_map_memory((void *)virt, phys_fd, offset, len,
3433
prot & UM_PROT_READ, prot & UM_PROT_WRITE,
35-
1);
34+
prot & UM_PROT_EXEC);
3635
}
3736

3837
static int kern_unmap(struct mm_id *mm_idp,

0 commit comments

Comments
 (0)