[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200525192143.GG317569@hirez.programming.kicks-ass.net>
Date: Mon, 25 May 2020 21:21:43 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Stefano Garzarella <sgarzare@...hat.com>, io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Ingo Molnar <mingo@...hat.com>
Subject: Re: io_uring: BUG: kernel NULL pointer dereference
On Mon, May 25, 2020 at 08:10:27AM -0600, Jens Axboe wrote:
> I think the odd part here is that task_tick_numa() checks for a
> valid mm, and queues work if the task has it. But for the sqpoll
> kthread, the mm can come and go. By the time the task work is run,
> the mm is gone and we oops on current->mm == NULL.
>
> I think the below should fix it:
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 538ba5d94e99..24a8557f001f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2908,7 +2908,8 @@ static void task_tick_numa(struct rq *rq, struct task_struct *curr)
> /*
> * We don't care about NUMA placement if we don't have memory.
> */
> - if (!curr->mm || (curr->flags & PF_EXITING) || work->next != work)
> + if (!curr->mm || (curr->flags & (PF_EXITING | PF_KTHREAD)) ||
> + work->next != work)
> return;
Ah, I think that's one more instance of '!p->mm' != is_kthread(). A
while ago someone went and cleaned a bunch of them up. Clearly this one
was missed.
I'm thinking just:
if ((curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)
should be enough.
Powered by blists - more mailing lists