From: "Michael S. Tsirkin" <mst@redhat.com>
To: Asias He <asias@redhat.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
target-devel@vger.kernel.org
Subject: Re: [PATCH] tcm_vhost: Use ACCESS_ONCE for vs->vs_tpg[target] access
Date: Tue, 2 Apr 2013 18:39:33 +0300 [thread overview]
Message-ID: <20130402153933.GA27410@redhat.com> (raw)
In-Reply-To: <1364916697-13212-1-git-send-email-asias@redhat.com>
On Tue, Apr 02, 2013 at 11:31:37PM +0800, Asias He wrote:
> In vhost_scsi_handle_vq:
>
> tv_tpg = vs->vs_tpg[target];
> if (!tv_tpg) {
> ....
> return
> }
>
> tv_cmd = vhost_scsi_allocate_cmd(tv_tpg, &v_req,
>
> 1) vs->vs_tpg[target] might change after the NULL check and 2) the above
> line might access tv_tpg from vs->vs_tpg[target]. To prevent 2), use
> ACCESS_ONCE. Thanks mst for catching this up!
>
> Signed-off-by: Asias He <asias@redhat.com>
OK this might be ok for 3.9.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Nicholas can you pick this up pls?
For 3.10 I still think it's best to get rid of it
and stick vs->vs_tpg in vq->private_data.
> ---
> drivers/vhost/tcm_vhost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index 0524267..32d95e3 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -668,7 +668,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
>
> /* Extract the tpgt */
> target = v_req.lun[1];
> - tv_tpg = vs->vs_tpg[target];
> + tv_tpg = ACCESS_ONCE(vs->vs_tpg[target]);
>
> /* Target does not exist, fail the request */
> if (unlikely(!tv_tpg)) {
> --
> 1.8.1.4
next prev parent reply other threads:[~2013-04-02 15:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 15:31 [PATCH] tcm_vhost: Use ACCESS_ONCE for vs->vs_tpg[target] access Asias He
2013-04-02 15:39 ` Michael S. Tsirkin [this message]
2013-04-02 23:42 ` Nicholas A. Bellinger
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=20130402153933.GA27410@redhat.com \
--to=mst@redhat.com \
--cc=asias@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=pbonzini@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=stefanha@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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