]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/kasan: avoid report in get_wchan
authorVasily Gorbik <gor@linux.ibm.com>
Tue, 13 Aug 2019 17:23:51 +0000 (19:23 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Wed, 21 Aug 2019 10:58:53 +0000 (12:58 +0200)
Reading other running task's stack can be a dangerous endeavor. Kasan
stack memory access instrumentation includes special prologue and epilogue
to mark/remove red zones in shadow memory between stack variables. For
that reason there is always a race between a task reading value in other
task's stack and that other task returning from a function and entering
another one generating different red zones pattern.

To avoid kasan reports simply perform uninstrumented memory reads.

Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/process.c

index 9f2727bf3cbebadea09c8cca710dc7d1bed9bdc5..b0afec673f77844986bc68262bae4ddae88eb839 100644 (file)
@@ -196,12 +196,12 @@ unsigned long get_wchan(struct task_struct *p)
                goto out;
        }
        for (count = 0; count < 16; count++) {
-               sf = (struct stack_frame *) sf->back_chain;
+               sf = (struct stack_frame *)READ_ONCE_NOCHECK(sf->back_chain);
                if (sf <= low || sf > high) {
                        return_address = 0;
                        goto out;
                }
-               return_address = sf->gprs[8];
+               return_address = READ_ONCE_NOCHECK(sf->gprs[8]);
                if (!in_sched_functions(return_address))
                        goto out;
        }