lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <60ce403c-12e6-4677-9503-a7cf3411fae6@kernel.dk>
Date: Tue, 10 Jun 2025 13:15:12 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Keith Busch <kbusch@...nel.org>
Cc: Penglei Jiang <superman.xpt@...il.com>, io-uring@...r.kernel.org,
 linux-kernel@...r.kernel.org,
 syzbot+531502bbbe51d2f769f4@...kaller.appspotmail.com
Subject: Re: [PATCH v2] io_uring: fix use-after-free of sq->thread in
 __io_uring_show_fdinfo()

On 6/10/25 1:12 PM, Keith Busch wrote:
> On Tue, Jun 10, 2025 at 12:56:31PM -0600, Jens Axboe wrote:
>> On 6/10/25 12:44 PM, Keith Busch wrote:
>>> On Tue, Jun 10, 2025 at 10:18:01AM -0700, Penglei Jiang wrote:
>>>> @@ -379,7 +380,8 @@ static int io_sq_thread(void *data)
>>>>  		io_sq_tw(&retry_list, UINT_MAX);
>>>>  
>>>>  	io_uring_cancel_generic(true, sqd);
>>>> -	sqd->thread = NULL;
>>>> +	rcu_assign_pointer(sqd->thread, NULL);
>>>
>>> I believe this will fail a sparse check without adding the "__rcu" type
>>> annotation on the struct's "thread" member.
>>
>> I think that only happens the other way around, eg accessing them directly
>> when marked with __rcu. I could be entirely wrong, though...
> 
> I was just looking at rcu_assign_pointer():
> 
>   #define rcu_assign_pointer(p, v)                                              \
>   do {                                                                          \
>           uintptr_t _r_a_p__v = (uintptr_t)(v);                                 \
>           rcu_check_sparse(p, __rcu);                                           \
> 
> And rcu_check_sparse expands to this when __CHECKER__ is enabled:
> 
>   #define rcu_check_sparse(p, space) \
>           ((void)(((typeof(*p) space *)p) == p))
> 
> So whatever "p" is, rcu_assign_pointer's checker appears to want it to
> be of a type annotated with "__rcu".
> 
> But I don't know for sure, so let's just try it and see!
> 
>   # make C=1 io_uring/sqpoll.o
>   io_uring/sqpoll.c:273:17: error: incompatible types in comparison expression (different address spaces):
>   io_uring/sqpoll.c:273:17:    struct task_struct [noderef] __rcu *
>   io_uring/sqpoll.c:273:17:    struct task_struct *
>   io_uring/sqpoll.c:383:9: error: incompatible types in comparison expression (different address spaces):
>   io_uring/sqpoll.c:383:9:    struct task_struct [noderef] __rcu *
>   io_uring/sqpoll.c:383:9:    struct task_struct *

Proof's in the pudding! Want to send a patch?

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ