kernel: Only expose su when daemon is running
It has been claimed that the PG implementation of 'su' has security vulnerabilities even when disabled. Unfortunately, the people that find these vulnerabilities often like to keep them private so they can profit from exploits while leaving users exposed to malicious hackers. In order to reduce the attack surface for vulnerabilites, it is therefore necessary to make 'su' completely inaccessible when it is not in use (except by the root and system users). Change-Id: I79716c72f74d0b7af34ec3a8054896c6559a181d
This commit is contained in:
@@ -778,6 +778,11 @@ void do_exit(long code)
|
||||
}
|
||||
|
||||
exit_signals(tsk); /* sets PF_EXITING */
|
||||
|
||||
if (tsk->flags & PF_SU) {
|
||||
su_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* tsk->flags are checked in the futex code to protect against
|
||||
* an exiting task cleaning up the robust pi futexes.
|
||||
|
||||
@@ -334,6 +334,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
|
||||
printk("[%d:%s] fork fail at arch_dup_task_struct, err:%d \n", current->pid, current->comm, err);
|
||||
goto free_ti;
|
||||
}
|
||||
|
||||
tsk->flags &= ~PF_SU;
|
||||
|
||||
tsk->stack = ti;
|
||||
#ifdef CONFIG_SECCOMP
|
||||
/*
|
||||
|
||||
@@ -102,6 +102,38 @@
|
||||
# include <linux/prio_tracer.h>
|
||||
#endif
|
||||
|
||||
static atomic_t __su_instances;
|
||||
|
||||
int su_instances(void)
|
||||
{
|
||||
return atomic_read(&__su_instances);
|
||||
}
|
||||
|
||||
bool su_running(void)
|
||||
{
|
||||
return su_instances() > 0;
|
||||
}
|
||||
|
||||
bool su_visible(void)
|
||||
{
|
||||
kuid_t uid = current_uid();
|
||||
if (su_running())
|
||||
return true;
|
||||
if (uid_eq(uid, GLOBAL_ROOT_UID) || uid_eq(uid, GLOBAL_SYSTEM_UID))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void su_exec(void)
|
||||
{
|
||||
atomic_inc(&__su_instances);
|
||||
}
|
||||
|
||||
void su_exit(void)
|
||||
{
|
||||
atomic_dec(&__su_instances);
|
||||
}
|
||||
|
||||
void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period)
|
||||
{
|
||||
unsigned long delta;
|
||||
|
||||
Reference in New Issue
Block a user