lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri,  1 Jan 2016 23:03:01 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:	Ingo Molnar <mingo@...hat.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	"Serge E . Hallyn" <serge.hallyn@...ntu.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Richard Guy Briggs <rgb@...hat.com>,
	"Eric W . Biederman" <ebiederm@...ssion.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	stable@...r.kernel.org, linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: [PATCH] sched: check tgid in is_global_init

Global init can have sub-threads, so ->pid check is not reliable enough
for is_global_init(), we need to check tgid instead. This has been spotted
by Oleg and a fix was proposed by Richard a long time ago (see the link
below).

Oleg wrote:
:Because is_global_init() is only true for the main thread of /sbin/init.
:
:Just look at oom_unkillable_task(). It tries to not kill init. But, say,
:select_bad_process() can happily find a sub-thread of is_global_init()
:and still kill it.

I recently hit the problem in question; re-sending the patch (to the
best of my knowledge it has never been submitted) with updated function
comment. Credit goes to Oleg and Richard.

Link: https://www.redhat.com/archives/linux-audit/2013-December/msg00086.html
Reported-by: Oleg Nesterov <oleg@...hat.com>
Suggested-by: Richard Guy Briggs <rgb@...hat.com>
Acked-by: Serge Hallyn <serge.hallyn@...onical.com>
Cc: <stable@...r.kernel.org>
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
---
 include/linux/sched.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index daf600e..d33de52 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2013,7 +2013,8 @@ static inline int pid_alive(const struct task_struct *p)
 }
 
 /**
- * is_global_init - check if a task structure is init
+ * is_global_init - check if a task structure is init. Since init
+ * is free to have sub-threads we need to check tgid.
  * @tsk: Task structure to be checked.
  *
  * Check if a task structure is the first user space task the kernel created.
@@ -2022,7 +2023,7 @@ static inline int pid_alive(const struct task_struct *p)
  */
 static inline int is_global_init(struct task_struct *tsk)
 {
-	return tsk->pid == 1;
+	return task_tgid_nr(tsk) == 1;
 }
 
 extern struct pid *cad_pid;
-- 
2.7.0.rc0.20.g4b9ab0e

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ