kernel: migrate barriers to spec barriers and code style thing
overkill, but yeah, might as well move on to the real deal. [ rsuntk: Rename original variable name ] Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com> Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
This commit is contained in:
@@ -313,21 +313,17 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
if (current_uid_val != manager_uid &&
|
if (current_uid_val != manager_uid &&
|
||||||
current_uid_val % 100000 == manager_uid) {
|
current_uid_val % 100000 == manager_uid) {
|
||||||
ksu_set_manager_uid(current_uid_val);
|
ksu_set_manager_uid(current_uid_val);
|
||||||
// make sure all cpus sees this change, next line will check
|
|
||||||
smp_mb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_check:
|
skip_check:
|
||||||
// yes this causes delay, but this keeps the delay consistent, which is what we want
|
// yes this causes delay, but this keeps the delay consistent, which is what we want
|
||||||
barrier();
|
// with a proper barrier for safety as the compiler and cpu might try to do something smart.
|
||||||
|
KCOMPAT_BARRIER();
|
||||||
if (!is_allow_su())
|
if (!is_allow_su())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// we move it after uid check here so they cannot
|
// we move it after uid check here so they cannot
|
||||||
// compare 0xdeadbeef call to a non-0xdeadbeef call
|
// compare 0xdeadbeef call to a non-0xdeadbeef call
|
||||||
// with barriers around for safety as the compiler
|
|
||||||
// might try to do something smart.
|
|
||||||
barrier();
|
|
||||||
if (KERNEL_SU_OPTION != option)
|
if (KERNEL_SU_OPTION != option)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,14 @@
|
|||||||
#include "ss/policydb.h"
|
#include "ss/policydb.h"
|
||||||
#include "linux/key.h"
|
#include "linux/key.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_X86)
|
||||||
|
#define KCOMPAT_BARRIER() barrier_nospec()
|
||||||
|
#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
|
||||||
|
#define KCOMPAT_BARRIER() isb() // arch/arm64/include/asm/barrier.h
|
||||||
|
#else
|
||||||
|
#define KCOMPAT_BARRIER() barrier() // well, compiler atleast.
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list_count_nodes - count the number of nodes in a list
|
* list_count_nodes - count the number of nodes in a list
|
||||||
* @head: the head of the list
|
* @head: the head of the list
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ int __ksu_handle_devpts(struct inode *inode)
|
|||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) || defined(KSU_OPTIONAL_SELINUX_INODE)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) || defined(KSU_OPTIONAL_SELINUX_INODE)
|
||||||
struct inode_security_struct *sec = selinux_inode(inode);
|
struct inode_security_struct *sec = selinux_inode(inode);
|
||||||
#else
|
#else
|
||||||
struct inode_security_struct *sec =
|
struct inode_security_struct *sec = (struct inode_security_struct *)inode->i_security;
|
||||||
(struct inode_security_struct *)inode->i_security;
|
|
||||||
#endif
|
#endif
|
||||||
if (ksu_devpts_sid && sec)
|
if (ksu_devpts_sid && sec)
|
||||||
sec->sid = ksu_devpts_sid;
|
sec->sid = ksu_devpts_sid;
|
||||||
|
|||||||
Reference in New Issue
Block a user