From: 张浩然 <wh1sper@zju.edu.cn>
To: "Lei Yang" <leiyang@redhat.com>
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,
"Mike Christie" <michael.christie@oracle.com>
Subject: Re: Re: [PATCH] vhost/scsi: Fix improper cleanup in vhost_scsi_set_endpoint()
Date: Tue, 14 Jan 2025 16:41:46 +0800 (GMT+08:00) [thread overview]
Message-ID: <2b10f430.24ffd.19463f9dc80.Coremail.wh1sper@zju.edu.cn> (raw)
In-Reply-To: <CAPpAL=xC7+f_8V4D==JvZxs5X-CePa_VftOH=KDc8H1vPSNp9w@mail.gmail.com>
Yes, and it also protects the kernel from the PoC, as I've tested.
On 2025-01-14 10:17:50 Lei Yang wrote:
> I tested this patch with virtio-net regression tests, everything works fine.
>
> Tested-by: Lei Yang <leiyang@redhat.com>
>
>
> On Mon, Jan 13, 2025 at 5:20 AM Mike Christie
> <michael.christie@oracle.com> wrote:
> >
> > On 1/12/25 11:35 AM, michael.christie@oracle.com wrote:
> > > So I think to fix the issue, we would want to:
> > >
> > > 1. move the
> > >
> > > memcpy(vs_tpg, vs->vs_tpg, len);
> > >
> > > to the end of the function after we do the vhost_scsi_flush. This will
> > > be more complicated than the current memcpy though. We will want to
> > > merge the local vs_tpg and the vs->vs_tpg like:
> > >
> > > for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
> > > if (vs_tpg[i])
> > > vs->vs_tpg[i] = vs_tpg[i])
> > > }
> >
> > I think I wrote that in reverse. We would want:
> >
> > vhost_scsi_flush(vs);
> >
> > if (vs->vs_tpg) {
> > for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
> > if (vs->vs_tpg[i])
> > vs_tpg[i] = vs->vs_tpg[i])
> > }
> > }
> >
> > kfree(vs->vs_tpg);
> > vs->vs_tpg = vs_tpg;
> >
> > or we could just allocate the vs_tpg with the vhost_scsi like:
> >
> > struct vhost_scsi {
> > ....
> >
> > struct vhost_scsi_tpg *vs_tpg[VHOST_SCSI_MAX_TARGET];
> >
> > then when we loop in vhost_scsi_set/clear_endpoint set/clear the
> > every vs_tpg entry.
> >
next prev parent reply other threads:[~2025-01-14 8:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-11 3:34 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 ` 张浩然 [this message]
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
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=2b10f430.24ffd.19463f9dc80.Coremail.wh1sper@zju.edu.cn \
--to=wh1sper@zju.edu.cn \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=leiyang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.christie@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
/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®