Skip to content

Commit dcc0b49

Browse files
committed
Merge tag 'powerpc-5.11-8' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fix from Michael Ellerman: "One fix for a regression seen in io_uring, introduced by our support for KUAP (Kernel User Access Prevention) with the Hash MMU. Thanks to Aneesh Kumar K.V, and Zorro Lang" * tag 'powerpc-5.11-8' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/kuap: Allow kernel thread to access userspace after kthread_use_mm
2 parents c05263d + 8c511ef commit dcc0b49

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

arch/powerpc/include/asm/book3s/64/kup.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,31 @@ DECLARE_STATIC_KEY_FALSE(uaccess_flush_key);
199199

200200
#ifdef CONFIG_PPC_PKEY
201201

202+
extern u64 __ro_after_init default_uamor;
203+
extern u64 __ro_after_init default_amr;
204+
extern u64 __ro_after_init default_iamr;
205+
202206
#include <asm/mmu.h>
203207
#include <asm/ptrace.h>
204208

205-
/*
206-
* For kernel thread that doesn't have thread.regs return
207-
* default AMR/IAMR values.
209+
/* usage of kthread_use_mm() should inherit the
210+
* AMR value of the operating address space. But, the AMR value is
211+
* thread-specific and we inherit the address space and not thread
212+
* access restrictions. Because of this ignore AMR value when accessing
213+
* userspace via kernel thread.
208214
*/
209215
static inline u64 current_thread_amr(void)
210216
{
211217
if (current->thread.regs)
212218
return current->thread.regs->amr;
213-
return AMR_KUAP_BLOCKED;
219+
return default_amr;
214220
}
215221

216222
static inline u64 current_thread_iamr(void)
217223
{
218224
if (current->thread.regs)
219225
return current->thread.regs->iamr;
220-
return AMR_KUEP_BLOCKED;
226+
return default_iamr;
221227
}
222228
#endif /* CONFIG_PPC_PKEY */
223229

arch/powerpc/include/asm/book3s/64/pkeys.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
#include <asm/book3s/64/hash-pkey.h>
77

8-
extern u64 __ro_after_init default_uamor;
9-
extern u64 __ro_after_init default_amr;
10-
extern u64 __ro_after_init default_iamr;
11-
128
static inline u64 vmflag_to_pte_pkey_bits(u64 vm_flags)
139
{
1410
if (!mmu_has_feature(MMU_FTR_PKEY))

arch/powerpc/mm/book3s64/pkeys.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static u32 initial_allocation_mask __ro_after_init;
3131
u64 default_amr __ro_after_init = ~0x0UL;
3232
u64 default_iamr __ro_after_init = 0x5555555555555555UL;
3333
u64 default_uamor __ro_after_init;
34+
EXPORT_SYMBOL(default_amr);
3435
/*
3536
* Key used to implement PROT_EXEC mmap. Denies READ/WRITE
3637
* We pick key 2 because 0 is special key and 1 is reserved as per ISA.

0 commit comments

Comments
 (0)