* [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
@ 2025-09-19 9:03 Yang Xiuwei
2025-09-19 11:18 ` Pavel Begunkov
2025-09-19 13:06 ` Jens Axboe
0 siblings, 2 replies; 8+ messages in thread
From: Yang Xiuwei @ 2025-09-19 9:03 UTC (permalink / raw)
To: axboe; +Cc: io-uring, Yang Xiuwei
From: Yang Xiuwei <yangxiuwei@kylinos.cn>
In io_link_skb function, there is a bug where prev_notif is incorrectly
assigned using 'nd' instead of 'prev_nd'. This causes the context
validation check to compare the current notification with itself instead
of comparing it with the previous notification.
Fix by using the correct prev_nd parameter when obtaining prev_notif.
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
diff --git a/io_uring/notif.c b/io_uring/notif.c
index 9a6f6e92d742..ea9c0116cec2 100644
--- a/io_uring/notif.c
+++ b/io_uring/notif.c
@@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
return -EEXIST;
prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
- prev_notif = cmd_to_io_kiocb(nd);
+ prev_notif = cmd_to_io_kiocb(prev_nd);
/* make sure all noifications can be finished in the same task_work */
if (unlikely(notif->ctx != prev_notif->ctx ||
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-19 9:03 [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb Yang Xiuwei
@ 2025-09-19 11:18 ` Pavel Begunkov
[not found] ` <CAAZOf24YaETroWiDjmTxu=2b2KVTxA1+rq_p5uxqtJqTVBfsJw@mail.gmail.com>
2025-09-19 13:06 ` Jens Axboe
1 sibling, 1 reply; 8+ messages in thread
From: Pavel Begunkov @ 2025-09-19 11:18 UTC (permalink / raw)
To: Yang Xiuwei, axboe; +Cc: io-uring, Yang Xiuwei
On 9/19/25 10:03, Yang Xiuwei wrote:
> From: Yang Xiuwei <yangxiuwei@kylinos.cn>
>
> In io_link_skb function, there is a bug where prev_notif is incorrectly
> assigned using 'nd' instead of 'prev_nd'. This causes the context
> validation check to compare the current notification with itself instead
> of comparing it with the previous notification.
>
> Fix by using the correct prev_nd parameter when obtaining prev_notif.
Good catch,
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Fixes: 6fe4220912d19 ("io_uring/notif: implement notification stacking")
Cc: stable@vger.kernel.org
> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
>
> diff --git a/io_uring/notif.c b/io_uring/notif.c
> index 9a6f6e92d742..ea9c0116cec2 100644
> --- a/io_uring/notif.c
> +++ b/io_uring/notif.c
> @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
> return -EEXIST;
>
> prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
> - prev_notif = cmd_to_io_kiocb(nd);
> + prev_notif = cmd_to_io_kiocb(prev_nd);
>
> /* make sure all noifications can be finished in the same task_work */
> if (unlikely(notif->ctx != prev_notif->ctx ||
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
[not found] ` <CAAZOf24YaETroWiDjmTxu=2b2KVTxA1+rq_p5uxqtJqTVBfsJw@mail.gmail.com>
@ 2025-09-19 11:25 ` David Kahurani
2025-09-19 14:16 ` Pavel Begunkov
0 siblings, 1 reply; 8+ messages in thread
From: David Kahurani @ 2025-09-19 11:25 UTC (permalink / raw)
To: Pavel Begunkov; +Cc: Yang Xiuwei, axboe, io-uring, Yang Xiuwei
On Fri, Sep 19, 2025 at 2:23 PM David Kahurani <k.kahurani@gmail.com> wrote:
>
> This is something unrelated but just bringing it up because it is in the same locality.
>
> It doesn't seem like the references(uarg->refcnt) are well accounted for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete' will gets its refcnt decremented but assuming there's a list of nodes, some of the nodes in the list will not get their reference count decremented and that will trigger the lockdep_assert in 'io_notif_tw_complete'
>
> It doesn't look that this will have any consequences beyond triggering the lockderp_assert, though.
>
> Maybe my analysis is wrong?
>
>
> On Fri, Sep 19, 2025 at 2:16 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>
>> On 9/19/25 10:03, Yang Xiuwei wrote:
>> > From: Yang Xiuwei <yangxiuwei@kylinos.cn>
>> >
>> > In io_link_skb function, there is a bug where prev_notif is incorrectly
>> > assigned using 'nd' instead of 'prev_nd'. This causes the context
>> > validation check to compare the current notification with itself instead
>> > of comparing it with the previous notification.
>> >
>> > Fix by using the correct prev_nd parameter when obtaining prev_notif.
>>
>> Good catch,
>>
>> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
>> Fixes: 6fe4220912d19 ("io_uring/notif: implement notification stacking")
>> Cc: stable@vger.kernel.org
>>
>>
>> > Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
>> >
>> > diff --git a/io_uring/notif.c b/io_uring/notif.c
>> > index 9a6f6e92d742..ea9c0116cec2 100644
>> > --- a/io_uring/notif.c
>> > +++ b/io_uring/notif.c
>> > @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
>> > return -EEXIST;
>> >
>> > prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
>> > - prev_notif = cmd_to_io_kiocb(nd);
>> > + prev_notif = cmd_to_io_kiocb(prev_nd);
>> >
>> > /* make sure all noifications can be finished in the same task_work */
>> > if (unlikely(notif->ctx != prev_notif->ctx ||
>>
>> --
>> Pavel Begunkov
>>
>>
This is something unrelated but just bringing it up because it is in
the same locality.
It doesn't seem like the references(uarg->refcnt) are well accounted
for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete'
will gets it's refcnt decremented but assuming there's a list of
nodes, some of the nodes in the list will not get their reference
count decremented and that will trigger the lockdep_assert in
'io_notif_tw_complete'
It doesn't look that this will have any consequences beyond triggering
the lockderp_assert, though.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-19 9:03 [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb Yang Xiuwei
2025-09-19 11:18 ` Pavel Begunkov
@ 2025-09-19 13:06 ` Jens Axboe
1 sibling, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2025-09-19 13:06 UTC (permalink / raw)
To: Yang Xiuwei; +Cc: io-uring, Yang Xiuwei
On Fri, 19 Sep 2025 17:03:52 +0800, Yang Xiuwei wrote:
> In io_link_skb function, there is a bug where prev_notif is incorrectly
> assigned using 'nd' instead of 'prev_nd'. This causes the context
> validation check to compare the current notification with itself instead
> of comparing it with the previous notification.
>
> Fix by using the correct prev_nd parameter when obtaining prev_notif.
>
> [...]
Applied, thanks!
[1/1] io_uring: fix incorrect io_kiocb reference in io_link_skb
commit: 2c139a47eff8de24e3350dadb4c9d5e3426db826
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-19 11:25 ` David Kahurani
@ 2025-09-19 14:16 ` Pavel Begunkov
2025-09-19 14:28 ` David Kahurani
0 siblings, 1 reply; 8+ messages in thread
From: Pavel Begunkov @ 2025-09-19 14:16 UTC (permalink / raw)
To: David Kahurani; +Cc: Yang Xiuwei, axboe, io-uring, Yang Xiuwei
On 9/19/25 12:25, David Kahurani wrote:
...>>>> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
>>>>
>>>> diff --git a/io_uring/notif.c b/io_uring/notif.c
>>>> index 9a6f6e92d742..ea9c0116cec2 100644
>>>> --- a/io_uring/notif.c
>>>> +++ b/io_uring/notif.c
>>>> @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
>>>> return -EEXIST;
>>>>
>>>> prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
>>>> - prev_notif = cmd_to_io_kiocb(nd);
>>>> + prev_notif = cmd_to_io_kiocb(prev_nd);
>>>>
>>>> /* make sure all noifications can be finished in the same task_work */
>>>> if (unlikely(notif->ctx != prev_notif->ctx ||
>>>
>>> --
>>> Pavel Begunkov
>>>
>>>
>
> This is something unrelated but just bringing it up because it is in
> the same locality.
>
> It doesn't seem like the references(uarg->refcnt) are well accounted
> for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete'
> will gets it's refcnt decremented but assuming there's a list of
> nodes, some of the nodes in the list will not get their reference
> count decremented and
And not supposed to. Children reference the head, and the head dies
last.
> that will trigger the lockdep_assert in
> 'io_notif_tw_complete'
Did you see it trigger? If so, please attach the warning splat.
> It doesn't look that this will have any consequences beyond triggering
> the lockderp_assert, though.
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-19 14:16 ` Pavel Begunkov
@ 2025-09-19 14:28 ` David Kahurani
2025-09-22 7:52 ` Pavel Begunkov
0 siblings, 1 reply; 8+ messages in thread
From: David Kahurani @ 2025-09-19 14:28 UTC (permalink / raw)
To: Pavel Begunkov; +Cc: Yang Xiuwei, axboe, io-uring, Yang Xiuwei
On Fri, Sep 19, 2025 at 5:14 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>
> On 9/19/25 12:25, David Kahurani wrote:
> ...>>>> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
> >>>>
> >>>> diff --git a/io_uring/notif.c b/io_uring/notif.c
> >>>> index 9a6f6e92d742..ea9c0116cec2 100644
> >>>> --- a/io_uring/notif.c
> >>>> +++ b/io_uring/notif.c
> >>>> @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
> >>>> return -EEXIST;
> >>>>
> >>>> prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
> >>>> - prev_notif = cmd_to_io_kiocb(nd);
> >>>> + prev_notif = cmd_to_io_kiocb(prev_nd);
> >>>>
> >>>> /* make sure all noifications can be finished in the same task_work */
> >>>> if (unlikely(notif->ctx != prev_notif->ctx ||
> >>>
> >>> --
> >>> Pavel Begunkov
> >>>
> >>>
> >
> > This is something unrelated but just bringing it up because it is in
> > the same locality.
> >
> > It doesn't seem like the references(uarg->refcnt) are well accounted
> > for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete'
> > will gets it's refcnt decremented but assuming there's a list of
> > nodes, some of the nodes in the list will not get their reference
> > count decremented and
>
> And not supposed to. Children reference the head, and the head dies
> last.
I am not sure about the mechanics of this. This is only based on
analysing the code but it seems, if a child node gets completed, it
will pull all the other nodes in that link by jumping to the head
node. But, I trust that you know better :-)
What do you mean it's not supposed to? All the nodes eventually go
through 'io_notif_tw_complete' to be queued back into request queues,
if any nodes whose reference was not handled(all nodes get a reference
of 1 at allocation) goes through the method, then the warning will
trigger.
>
> > that will trigger the lockdep_assert in
> > 'io_notif_tw_complete'
>
> Did you see it trigger? If so, please attach the warning splat.
>
> > It doesn't look that this will have any consequences beyond triggering
> > the lockderp_assert, though.
>
> --
> Pavel Begunkov
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-19 14:28 ` David Kahurani
@ 2025-09-22 7:52 ` Pavel Begunkov
2025-09-22 8:17 ` David Kahurani
0 siblings, 1 reply; 8+ messages in thread
From: Pavel Begunkov @ 2025-09-22 7:52 UTC (permalink / raw)
To: David Kahurani; +Cc: Yang Xiuwei, axboe, io-uring, Yang Xiuwei
On 9/19/25 15:28, David Kahurani wrote:
> On Fri, Sep 19, 2025 at 5:14 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>
>> On 9/19/25 12:25, David Kahurani wrote:
>> ...>>>> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
>>>>>>
>>>>>> diff --git a/io_uring/notif.c b/io_uring/notif.c
>>>>>> index 9a6f6e92d742..ea9c0116cec2 100644
>>>>>> --- a/io_uring/notif.c
>>>>>> +++ b/io_uring/notif.c
>>>>>> @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)
>>>>>> return -EEXIST;
>>>>>>
>>>>>> prev_nd = container_of(prev_uarg, struct io_notif_data, uarg);
>>>>>> - prev_notif = cmd_to_io_kiocb(nd);
>>>>>> + prev_notif = cmd_to_io_kiocb(prev_nd);
>>>>>>
>>>>>> /* make sure all noifications can be finished in the same task_work */
>>>>>> if (unlikely(notif->ctx != prev_notif->ctx ||
>>>>>
>>>>> --
>>>>> Pavel Begunkov
>>>>>
>>>>>
>>>
>>> This is something unrelated but just bringing it up because it is in
>>> the same locality.
>>>
>>> It doesn't seem like the references(uarg->refcnt) are well accounted
>>> for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete'
>>> will gets it's refcnt decremented but assuming there's a list of
>>> nodes, some of the nodes in the list will not get their reference
>>> count decremented and
>>
>> And not supposed to. Children reference the head, and the head dies
>> last.
>
> I am not sure about the mechanics of this. This is only based on
> analysing the code but it seems, if a child node gets completed, it
> will pull all the other nodes in that link by jumping to the head
It'll put its reference to the head, but nothing is going to
be destroyed until the head refs hit 0.
> node. But, I trust that you know better :-)
>
> What do you mean it's not supposed to? All the nodes eventually go
I was saying that the head isn't supposed to put the children's
references, it goes the other way around. Children have refs to
head, and everything is destroyed once the head is put down.
> through 'io_notif_tw_complete' to be queued back into request queues,
> if any nodes whose reference was not handled(all nodes get a reference
> of 1 at allocation) goes through the method, then the warning will
> trigger.
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb
2025-09-22 7:52 ` Pavel Begunkov
@ 2025-09-22 8:17 ` David Kahurani
0 siblings, 0 replies; 8+ messages in thread
From: David Kahurani @ 2025-09-22 8:17 UTC (permalink / raw)
To: Pavel Begunkov; +Cc: Yang Xiuwei, axboe, io-uring, Yang Xiuwei
On 9/22/25 10:52, Pavel Begunkov wrote:
> On 9/19/25 15:28, David Kahurani wrote:
>> On Fri, Sep 19, 2025 at 5:14 PM Pavel Begunkov
>> <asml.silence@gmail.com> wrote:
>>>
>>> On 9/19/25 12:25, David Kahurani wrote:
>>> ...>>>> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
>>>>>>>
>>>>>>> diff --git a/io_uring/notif.c b/io_uring/notif.c
>>>>>>> index 9a6f6e92d742..ea9c0116cec2 100644
>>>>>>> --- a/io_uring/notif.c
>>>>>>> +++ b/io_uring/notif.c
>>>>>>> @@ -85,7 +85,7 @@ static int io_link_skb(struct sk_buff *skb,
>>>>>>> struct ubuf_info *uarg)
>>>>>>> return -EEXIST;
>>>>>>>
>>>>>>> prev_nd = container_of(prev_uarg, struct io_notif_data,
>>>>>>> uarg);
>>>>>>> - prev_notif = cmd_to_io_kiocb(nd);
>>>>>>> + prev_notif = cmd_to_io_kiocb(prev_nd);
>>>>>>>
>>>>>>> /* make sure all noifications can be finished in the
>>>>>>> same task_work */
>>>>>>> if (unlikely(notif->ctx != prev_notif->ctx ||
>>>>>>
>>>>>> --
>>>>>> Pavel Begunkov
>>>>>>
>>>>>>
>>>>
>>>> This is something unrelated but just bringing it up because it is in
>>>> the same locality.
>>>>
>>>> It doesn't seem like the references(uarg->refcnt) are well accounted
>>>> for io_notif_data. Any node that gets passed to 'io_tx_ubuf_complete'
>>>> will gets it's refcnt decremented but assuming there's a list of
>>>> nodes, some of the nodes in the list will not get their reference
>>>> count decremented and
>>>
>>> And not supposed to. Children reference the head, and the head dies
>>> last.
>>
>> I am not sure about the mechanics of this. This is only based on
>> analysing the code but it seems, if a child node gets completed, it
>> will pull all the other nodes in that link by jumping to the head
>
> It'll put its reference to the head, but nothing is going to
> be destroyed until the head refs hit 0.
I take that to mean there's some code elsewhere that also interacts with
these references otherwise just based on this code, it seems like notifs
always have a reference of 1
Because I don't have a stacktrace, I will leave it that.
>
>> node. But, I trust that you know better :-)
>>
>> What do you mean it's not supposed to? All the nodes eventually go
>
> I was saying that the head isn't supposed to put the children's
> references, it goes the other way around. Children have refs to
> head, and everything is destroyed once the head is put down.
>
>> through 'io_notif_tw_complete' to be queued back into request queues,
>> if any nodes whose reference was not handled(all nodes get a reference
>> of 1 at allocation) goes through the method, then the warning will
>> trigger.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-22 8:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19 9:03 [PATCH] io_uring: fix incorrect io_kiocb reference in io_link_skb Yang Xiuwei
2025-09-19 11:18 ` Pavel Begunkov
[not found] ` <CAAZOf24YaETroWiDjmTxu=2b2KVTxA1+rq_p5uxqtJqTVBfsJw@mail.gmail.com>
2025-09-19 11:25 ` David Kahurani
2025-09-19 14:16 ` Pavel Begunkov
2025-09-19 14:28 ` David Kahurani
2025-09-22 7:52 ` Pavel Begunkov
2025-09-22 8:17 ` David Kahurani
2025-09-19 13:06 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox