-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
powerpc: Add a framework for user access tracking
Backported from commit de78a9c ("powerpc: Add a framework for Kernel Userspace Access Protection"). Here we don't try to add the KUAP framework, we just want the helper functions because we want to put uaccess flush helpers in them. In terms of fixes, we don't need commit 1d8f739 ("powerpc/kuap: Fix set direction in allow/prevent_user_access()") as we don't have real KUAP. Likewise as all our allows are noops and all our prevents are just flushes, we don't need commit 9dc086f ("powerpc/futex: Fix incorrect user access blocking") The other 2 fixes we do need. The original description is: This patch implements a framework for Kernel Userspace Access Protection. Then subarches will have the possibility to provide their own implementation by providing setup_kuap() and allow/prevent_user_access(). Some platforms will need to know the area accessed and whether it is accessed from read, write or both. Therefore source, destination and size and handed over to the two functions. mpe: Rename to allow/prevent rather than unlock/lock, and add read/write wrappers. Drop the 32-bit code for now until we have an implementation for it. Add kuap to pt_regs for 64-bit as well as 32-bit. Don't split strings, use pr_crit_ratelimited(). Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Daniel Axtens <dja@axtens.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Christophe Leroy
authored and
Greg Kroah-Hartman
committed
Nov 22, 2020
1 parent
f69bb4e
commit 357a5e6
Showing
4 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_POWERPC_KUP_H_ | ||
#define _ASM_POWERPC_KUP_H_ | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#include <asm/pgtable.h> | ||
|
||
static inline void allow_user_access(void __user *to, const void __user *from, | ||
unsigned long size) { } | ||
static inline void prevent_user_access(void __user *to, const void __user *from, | ||
unsigned long size) { } | ||
|
||
static inline void allow_read_from_user(const void __user *from, unsigned long size) | ||
{ | ||
allow_user_access(NULL, from, size); | ||
} | ||
|
||
static inline void allow_write_to_user(void __user *to, unsigned long size) | ||
{ | ||
allow_user_access(to, NULL, size); | ||
} | ||
|
||
static inline void prevent_read_from_user(const void __user *from, unsigned long size) | ||
{ | ||
prevent_user_access(NULL, from, size); | ||
} | ||
|
||
static inline void prevent_write_to_user(void __user *to, unsigned long size) | ||
{ | ||
prevent_user_access(to, NULL, size); | ||
} | ||
|
||
#endif /* !__ASSEMBLY__ */ | ||
|
||
#endif /* _ASM_POWERPC_KUP_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters