wait: swap EXIT_ZOMBIE and EXIT_DEAD to hide EXIT_TRACE from user-space
authorOleg Nesterov <oleg@redhat.com>
Mon, 7 Apr 2014 22:38:46 +0000 (15:38 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 7 Apr 2014 23:36:06 +0000 (16:36 -0700)
get_task_state() uses the most significant bit to report the state to
user-space, this means that EXIT_ZOMBIE->EXIT_TRACE->EXIT_DEAD transition
can be noticed via /proc as Z -> X -> Z change.  Note that this was
possible even before EXIT_TRACE was introduced.

This is not really bad but imho it make sense to hide EXIT_TRACE from
user-space completely.  So the patch simply swaps EXIT_ZOMBIE and
EXIT_DEAD, this way EXIT_TRACE will be seen as EXIT_ZOMBIE by user-space.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Michal Schmidt <mschmidt@redhat.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Lennart Poettering <lpoetter@redhat.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/array.c
include/linux/sched.h

index 656e401794de5f8e2b03e975130cd3546ed5ed27..64db2bceac59e7634976235bcddeada98e592b1c 100644 (file)
@@ -138,8 +138,8 @@ static const char * const task_state_array[] = {
        "D (disk sleep)",       /*   2 */
        "T (stopped)",          /*   4 */
        "t (tracing stop)",     /*   8 */
-       "Z (zombie)",           /*  16 */
-       "X (dead)",             /*  32 */
+       "X (dead)",             /*  16 */
+       "Z (zombie)",           /*  32 */
 };
 
 static inline const char *get_task_state(struct task_struct *tsk)
index 7781de5e5e7bd39ff961d6aeea587d9ff69b53a8..075b3056c0c00692e6f23cf17d45349323a9d5ec 100644 (file)
@@ -210,8 +210,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
 #define __TASK_STOPPED         4
 #define __TASK_TRACED          8
 /* in tsk->exit_state */
-#define EXIT_ZOMBIE            16
-#define EXIT_DEAD              32
+#define EXIT_DEAD              16
+#define EXIT_ZOMBIE            32
 #define EXIT_TRACE             (EXIT_ZOMBIE | EXIT_DEAD)
 /* in tsk->state again */
 #define TASK_DEAD              64