• Pavel Begunkov's avatar
    io_uring: fix missing ->mm on exit · 8eb06d7e
    Pavel Begunkov authored
    There is a fancy bug, where exiting user task may not have ->mm,
    that makes task_works to try to do kthread_use_mm(ctx->sqo_mm).
    
    Don't do that if sqo_mm is NULL.
    
    [  290.460558] WARNING: CPU: 6 PID: 150933 at kernel/kthread.c:1238
    	kthread_use_mm+0xf3/0x110
    [  290.460579] CPU: 6 PID: 150933 Comm: read-write2 Tainted: G
    	I E     5.8.0-rc2-00066-g9b21720607cf #531
    [  290.460580] RIP: 0010:kthread_use_mm+0xf3/0x110
    ...
    [  290.460584] Call Trace:
    [  290.460584]  __io_sq_thread_acquire_mm.isra.0.part.0+0x25/0x30
    [  290.460584]  __io_req_task_submit+0x64/0x80
    [  290.460584]  io_req_task_submit+0x15/0x20
    [  290.460585]  task_work_run+0x67/0xa0
    [  290.460585]  do_exit+0x35d/0xb70
    [  290.460585]  do_group_exit+0x43/0xa0
    [  290.460585]  get_signal+0x140/0x900
    [  290.460586]  do_signal+0x37/0x780
    [  290.460586]  __prepare_exit_to_usermode+0x126/0x1c0
    [  290.460586]  __syscall_return_slowpath+0x3b/0x1c0
    [  290.460587]  do_syscall_64+0x5f/0xa0
    [  290.460587]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    following with faults.
    Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    8eb06d7e
io_uring.c 202 KB