From: Pradeep Pragallapati <quic_pragalla@quicinc.com>
To: Yu Kuai <yukuai1@huaweicloud.com>, <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH V1] block: Fix null pointer dereference issue on struct io_cq
Date: Tue, 30 May 2023 18:45:42 +0530 [thread overview]
Message-ID: <00eefae6-8db4-139b-9f8a-9ed326817561@quicinc.com> (raw)
In-Reply-To: <b1b7e7f1-55c2-4833-040f-6cdb75f8c11b@quicinc.com>
Hi,
On 5/22/2023 11:49 AM, Pradeep Pragallapati wrote:
>
> On 5/18/2023 6:14 PM, Yu Kuai wrote:
>> Hi,
>>
>> 在 2023/05/18 20:16, Yu Kuai 写道:
>>
>>> @@ -173,18 +171,17 @@ void ioc_clear_queue(struct request_queue *q)
>>> {
>>> LIST_HEAD(icq_list);
>>>
>>> + rcu_read_lock();
>>
>> Sorry that I realized this is still not enough, following list_empty()
>> and list_entry() can still concurrent with list_del(). Please try the
>> following patch:
> sure will try and update the results.
At least for 80+hrs of testing, i didn't see the issue reproduced. seems
like it is helping my case.
>>> spin_lock_irq(&q->queue_lock);
>>> list_splice_init(&q->icq_list, &icq_list);
>>> spin_unlock_irq(&q->queue_lock);
>>>
>>> - rcu_read_lock();
>>> while (!list_empty(&icq_list)) {
>>> struct io_cq *icq =
>>> list_entry(icq_list.next, struct io_cq,
>>> q_node);
>>>
>>> spin_lock_irq(&icq->ioc->lock);
>>> - if (!(icq->flags & ICQ_DESTROYED))
>>> - ioc_destroy_icq(icq);
>>> + ioc_destroy_icq(icq);
>>> spin_unlock_irq(&icq->ioc->lock);
>>> }
>>> rcu_read_unlock();
>>>
>>> .
>>>
>>
>> diff --git a/block/blk-ioc.c b/block/blk-ioc.c
>> index 63fc02042408..47684d1e9006 100644
>> --- a/block/blk-ioc.c
>> +++ b/block/blk-ioc.c
>> @@ -78,6 +78,9 @@ static void ioc_destroy_icq(struct io_cq *icq)
>>
>> lockdep_assert_held(&ioc->lock);
>>
>> + if (icq->flags & ICQ_DESTROYED)
>> + return;
>> +
>> radix_tree_delete(&ioc->icq_tree, icq->q->id);
>> hlist_del_init(&icq->ioc_node);
>> list_del_init(&icq->q_node);
>> @@ -128,12 +131,7 @@ static void ioc_release_fn(struct work_struct
>> *work)
>> spin_lock(&q->queue_lock);
>> spin_lock(&ioc->lock);
>>
>> - /*
>> - * The icq may have been destroyed when the
>> ioc lock
>> - * was released.
>> - */
>> - if (!(icq->flags & ICQ_DESTROYED))
>> - ioc_destroy_icq(icq);
>> + ioc_destroy_icq(icq);
>>
>> spin_unlock(&q->queue_lock);
>> rcu_read_unlock();
>> @@ -175,19 +173,16 @@ void ioc_clear_queue(struct request_queue *q)
>>
>> spin_lock_irq(&q->queue_lock);
>> list_splice_init(&q->icq_list, &icq_list);
>> - spin_unlock_irq(&q->queue_lock);
>>
>> - rcu_read_lock();
>> while (!list_empty(&icq_list)) {
>> struct io_cq *icq =
>> list_entry(icq_list.next, struct io_cq, q_node);
>>
>> spin_lock_irq(&icq->ioc->lock);
>> - if (!(icq->flags & ICQ_DESTROYED))
>> - ioc_destroy_icq(icq);
>> + ioc_destroy_icq(icq);
>> spin_unlock_irq(&icq->ioc->lock);
>> }
>> - rcu_read_unlock();
>> + spin_unlock_irq(&q->queue_lock);
>> }
>> #else /* CONFIG_BLK_ICQ */
>> static inline void ioc_exit_icqs(struct io_context *ioc)
>>
next prev parent reply other threads:[~2023-05-30 13:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 8:44 Pradeep P V K
2023-05-17 8:55 ` Chaitanya Kulkarni
2023-05-17 8:58 ` Yu Kuai
2023-05-17 9:20 ` Damien Le Moal
2023-05-17 9:21 ` Christoph Hellwig
2023-05-17 9:31 ` Damien Le Moal
2023-05-18 9:25 ` Pradeep Pragallapati (QUIC)
2023-05-18 12:16 ` Yu Kuai
2023-05-18 12:44 ` Yu Kuai
2023-05-22 6:19 ` Pradeep Pragallapati
2023-05-30 13:15 ` Pradeep Pragallapati [this message]
2023-05-30 13:24 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00eefae6-8db4-139b-9f8a-9ed326817561@quicinc.com \
--to=quic_pragalla@quicinc.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®