kernel: Clean up process flags

* Move PF_WAKE_UP_IDLE to 0x00000002 to make room for PF_SUSPEND_TASK
* Drop PF_SU in favor of a bit 'task_is_su' in the task_struct bitfield
  which has still lots of room without changing the struct size.

Change-Id: I2af053ebcbb3c41b7407560008da8150a73c8c05
Signed-off-by: Corinna Vinschen <xda@vinschen.de>
This commit is contained in:
Corinna Vinschen 2019-04-10 20:36:23 +02:00 committed by syphyr
parent 3cccbf08e3
commit e84e872bc4
4 changed files with 7 additions and 6 deletions

View File

@ -1726,7 +1726,7 @@ static int do_execve_common(const char *filename,
goto out;
if (is_su && capable(CAP_SYS_ADMIN)) {
current->flags |= PF_SU;
current->task_is_su = true;
su_exec();
}

View File

@ -1321,6 +1321,9 @@ struct task_struct {
unsigned sched_reset_on_fork:1;
unsigned sched_contributes_to_load:1;
/* task is su (lineage-only, LVT-2017-000[1-3]) */
unsigned task_is_su:1;
unsigned long atomic_flags; /* Flags needing atomic access. */
pid_t pid;
@ -1846,6 +1849,7 @@ static inline void sched_set_io_is_busy(int val) {};
/*
* Per process flags
*/
#define PF_WAKE_UP_IDLE 0x00000002 /* try to wake up on an idle CPU */
#define PF_EXITING 0x00000004 /* getting shut down */
#define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */
#define PF_VCPU 0x00000010 /* I'm a virtual CPU */
@ -1873,9 +1877,6 @@ static inline void sched_set_io_is_busy(int val) {};
#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
#define PF_WAKE_UP_IDLE 0x80000000 /* try to wake up on an idle CPU */
#define PF_SU 0x00000002 /* task is su */
/*
* Only the _current_ task can read/write to tsk->flags, but other

View File

@ -777,7 +777,7 @@ void do_exit(long code)
sched_exit(tsk);
if (tsk->flags & PF_SU) {
if (tsk->task_is_su) {
su_exit();
}

View File

@ -328,7 +328,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
if (err)
goto free_ti;
tsk->flags &= ~PF_SU;
tsk->task_is_su = false;
tsk->stack = ti;
#ifdef CONFIG_SECCOMP