lkml.org 
[lkml]   [2021]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: 回复: [PATCH] io-wq: Fix UAF when wa keup wqe in hash waitqueue
Date
On 5/24/21 10:19 AM, Zhang, Qiang wrote:
[...]
>> Scratch scalp one inch off to work out how this is a cure given a) uaf makes
>> no sense without free and b) how io workers could survive
>> wait_for_completion(&wq->worker_done).
>>
>> If they could OTOH then this is not the pill for the leak in worker_refs.
>
> Hello Pavel Begunkov, Hillf Danton
>
> Sorry there is a problem with the calltrace described in my message. Please ignore this modification

Haven't looked at the trace and description, but I do think
there is a problem it solves.

1) io_wait_on_hash() -> __add_wait_queue(&hash->wait, &wqe->wait);
2) (note: wqe is a worker) wqe's workers exit dropping refs
3) refs are zero, free io-wq
4) @hash is shared, so other task/wq does wake_up(&wq->hash->wait);
5) it wakes freed wqe

step 4) is a bit more trickier than that, tl;dr;
wq3:worker1 | locks bit1
wq1:worker2 | waits bit1
wq2:worker1 | waits bit1
wq1:worker3 | waits bit1

wq3:worker1 | drop bit1
wq1:worker2 | locks bit1
wq1:worker2 | completes all wq1 bit1 work items
wq1:worker2 | drop bit1, exit and free io-wq

wq2:worker1 | locks bit1
wq1 | free complete
wq2:worker1 | drops bit1
wq1:worker3 | waked up, even though freed

Can be simplified, don't want to waste time on that

--
Pavel Begunkov

\
 
 \ /
  Last update: 2021-05-24 12:17    [W:0.061 / U:1.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site