From: Mike Christie <michael.christie@oracle.com>
To: 张浩然 <wh1sper@zju.edu.cn>
Cc: mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com,
stefanha@redhat.com, eperezma@redhat.com,
virtualization@lists.linux.dev, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost/scsi: Fix improper cleanup in vhost_scsi_set_endpoint()
Date: Tue, 14 Jan 2025 11:44:32 -0600 [thread overview]
Message-ID: <e418a5ee-45ca-4d18-9b5d-6f8b6b1add8e@oracle.com> (raw)
In-Reply-To: <77e61a56.24e04.19463c158e1.Coremail.wh1sper@zju.edu.cn>
On 1/14/25 1:40 AM, 张浩然 wrote:
> After reevaluating the PoC, I realized that my initial claim was incorrect. The target WWN in the second vhost_scsi_set_endpoint() call is not the same as in the first one. Below is my targetcli status:
>
> o- vhost ......................................... [Targets: 3]
> | o- naa.500140501e23be28 ......................... [TPGs: 1]
> | | o- tpg1 ............. [naa.50014058f7da10b7, no-gen-acls]
> | | o- acls ..................................... [ACLs: 0]
> | | o- luns ..................................... [LUNs: 0]
> | o- naa.500140562c8936fa ......................... [TPGs: 2]
> | | o- tpg1 ............. [naa.50014058d133f962, no-gen-acls]
> | | | o- acls ..................................... [ACLs: 0]
> | | | o- luns ..................................... [LUNs: 3]
> | | | o- lun0 ... [block/disk0 (/dev/disk/...) (default_tg_pt_gp)]
> | | | o- lun1 .... [fileio/vhost-fileio (/root/fileio-vhost) (default_tg_pt_gp)]
> | | | o- lun2 ............. [ramdisk/rd (default_tg_pt_gp)]
> | | o- tpg2 ............. [naa.50014055c6fb4182, no-gen-acls]
> | | o- acls ..................................... [ACLs: 0]
> | | o- luns ..................................... [LUNs: 0]
>
> The bug occurs when `naa.500140562c8936fa` has already been set as an endpoint, and I send a VHOST_SCSI_SET_ENDPOINT ioctl command with `naa.500140501e23be28`. The ioctl returns -1 EEXIST (File exists), and the kernel logs a BUG message in dmesg.
I see now and can replicate it. I think there is a 2nd bug in
vhost_scsi_set_endpoint related to all this where we need to
prevent switching targets like this or else we'll leak some
other refcounts. If 500140501e23be28's tpg number was 3 then
we would overwrite the existing vs->vs_vhost_wwpn and never
be able to release the refounts on the tpgs from 500140562c8936fa.
I'll send a patchset to fix everything and cc you.
Thanks for all the work you did testing and debugging this
issue.
next prev parent reply other threads:[~2025-01-14 17:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-11 3:34 [PATCH] vhost/scsi: Fix improper cleanup in vhost_scsi_set_endpoint() Haoran Zhang
2025-01-11 5:45 ` Kuan-Wei Chiu
2025-01-11 8:14 ` 张浩然
2025-01-12 17:35 ` michael.christie
2025-01-12 21:19 ` Mike Christie
2025-01-14 2:17 ` Lei Yang
2025-01-14 8:41 ` 张浩然
2025-01-14 11:26 ` Michael S. Tsirkin
2025-01-14 17:13 ` Mike Christie
2025-01-14 7:40 ` 张浩然
2025-01-14 17:44 ` Mike Christie [this message]
2025-01-17 11:42 ` Haoran Zhang
2025-01-17 16:50 ` Mike Christie
2025-01-17 17:11 ` Mike Christie
2025-01-19 10:54 ` 张浩然
2025-01-19 6:50 ` 张浩然
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=e418a5ee-45ca-4d18-9b5d-6f8b6b1add8e@oracle.com \
--to=michael.christie@oracle.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=wh1sper@zju.edu.cn \
/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