From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>
Cc: linux-rdma@vger.kernel.org,
syzbot+b8b7a6774bf40cf8296b@syzkaller.appspotmail.com
Subject: Re: [PATCH rdma-next] RDMA/core: Skip initialized but not leaked GID entries
Date: Thu, 5 Sep 2024 14:54:26 +0800 [thread overview]
Message-ID: <df0c32a0-87d5-4d87-b994-16a34c584f68@linux.dev> (raw)
In-Reply-To: <20240904153457.GO4026@unreal>
在 2024/9/4 23:34, Leon Romanovsky 写道:
> On Wed, Sep 04, 2024 at 11:31:13AM -0300, Jason Gunthorpe wrote:
>> On Mon, Sep 02, 2024 at 04:42:52PM +0300, Leon Romanovsky wrote:
>>> From: Leon Romanovsky <leonro@nvidia.com>
>>>
>>> Failure in driver initialization can lead to a situation where the GID
>>> entries are set but not used yet. In this case, the kref will be equal to 1,
>>> which will trigger a false positive leak detection.
>>
>> Why does that happen??
>>
>>
>>> For example, these messages are printed during the driver initialization
>>> and followed by release_gid_table() call:
>>>
>>> infiniband syz1: ib_query_port failed (-19)
>>> infiniband syz1: Couldn't set up InfiniBand P_Key/GID cache
>>
>> Okay, but who set the ref=1?
>>
>>> diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
>>> index b7c078b7f7cf..c6aec2e04d4c 100644
>>> --- a/drivers/infiniband/core/cache.c
>>> +++ b/drivers/infiniband/core/cache.c
>>> @@ -800,13 +800,15 @@ static void release_gid_table(struct ib_device *device,
>>> return;
>>>
>>> for (i = 0; i < table->sz; i++) {
>>> + int gid_kref;
>>> +
>>> if (is_gid_entry_free(table->data_vec[i]))
>>> continue;
>>>
>>> - WARN_ONCE(true,
>>> + gid_kref = kref_read(&table->data_vec[i]->kref);
>>> + WARN_ONCE(gid_kref > 1,
>>> "GID entry ref leak for dev %s index %d ref=%u\n",
>>> - dev_name(&device->dev), i,
>>> - kref_read(&table->data_vec[i]->kref));
>>> + dev_name(&device->dev), i, gid_kref);
>>> }
>>
>> I'm not convinced, I think the bug here is something wrong on the
>> refcounting side not the freeing side. Ref should not be 1. Seems like
>> missing error unwinding in the init side.
>
> I dropped this patch as the real fix is here 1403c8b14765 ("IB/core: Fix ib_cache_setup_one error flow cleanup")
The commit 1403c8b14765 ("IB/core: Fix ib_cache_setup_one error flow
cleanup") is in the link
https://patchwork.kernel.org/project/linux-rdma/patch/79137687d829899b0b1c9835fcb4b258004c439a.1725273354.git.leon@kernel.org/
Zhu Yanjun
>
> Thanks
>
>>
>> Jason
>>
prev parent reply other threads:[~2024-09-05 6:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 13:42 [PATCH rdma-next] RDMA/core: Skip initialized but not leaked GID entries Leon Romanovsky
2024-09-02 22:46 ` Zhu Yanjun
2024-09-03 7:26 ` Leon Romanovsky
2024-09-04 8:33 ` Leon Romanovsky
2024-09-04 14:31 ` Jason Gunthorpe
2024-09-04 15:34 ` Leon Romanovsky
2024-09-05 6:54 ` Zhu Yanjun [this message]
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=df0c32a0-87d5-4d87-b994-16a34c584f68@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=syzbot+b8b7a6774bf40cf8296b@syzkaller.appspotmail.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