Merge tag 'selinux-pr-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / kernel / debug / kdb / kdb_support.c
index 91bb666d7c03966be2a5283c3e84f6204290bc43..9f50d22d68e630a68e571bad5de2c73fbff7b01c 100644 (file)
@@ -609,23 +609,25 @@ unsigned long kdb_task_state_string(const char *s)
  */
 char kdb_task_state_char (const struct task_struct *p)
 {
-       int cpu;
-       char state;
+       unsigned int p_state;
        unsigned long tmp;
+       char state;
+       int cpu;
 
        if (!p ||
            copy_from_kernel_nofault(&tmp, (char *)p, sizeof(unsigned long)))
                return 'E';
 
        cpu = kdb_process_cpu(p);
-       state = (p->state == 0) ? 'R' :
-               (p->state < 0) ? 'U' :
-               (p->state & TASK_UNINTERRUPTIBLE) ? 'D' :
-               (p->state & TASK_STOPPED) ? 'T' :
-               (p->state & TASK_TRACED) ? 'C' :
+       p_state = READ_ONCE(p->__state);
+       state = (p_state == 0) ? 'R' :
+               (p_state < 0) ? 'U' :
+               (p_state & TASK_UNINTERRUPTIBLE) ? 'D' :
+               (p_state & TASK_STOPPED) ? 'T' :
+               (p_state & TASK_TRACED) ? 'C' :
                (p->exit_state & EXIT_ZOMBIE) ? 'Z' :
                (p->exit_state & EXIT_DEAD) ? 'E' :
-               (p->state & TASK_INTERRUPTIBLE) ? 'S' : '?';
+               (p_state & TASK_INTERRUPTIBLE) ? 'S' : '?';
        if (is_idle_task(p)) {
                /* Idle task.  Is it really idle, apart from the kdb
                 * interrupt? */