kernel: Add the ability to manually elevate privileges for programs using prctl by specifying UID or PID.

This commit is contained in:
ShirkNeko
2025-09-28 19:33:08 +08:00
parent e552163d9e
commit 65d5d6a494
5 changed files with 172 additions and 0 deletions

22
kernel/manual_su.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef __KSU_MANUAL_SU_H
#define __KSU_MANUAL_SU_H
#include <linux/types.h>
#include <linux/sched.h>
#define KSU_SU_VERIFIED_BIT (1UL << 0)
static inline bool ksu_is_current_verified(void)
{
return ((unsigned long)(current->security) & KSU_SU_VERIFIED_BIT) != 0;
}
static inline void ksu_mark_current_verified(void)
{
current->security = (void *)((unsigned long)(current->security) | KSU_SU_VERIFIED_BIT);
}
int ksu_manual_su_escalate(uid_t target_uid, pid_t target_pid,
const char __user *user_password);
#endif