public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
	boris.ostrovsky@oracle.com, simon@invisiblethingslab.com,
	joao.m.martins@oracle.com
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xen: xenbus: Fix a possible data race in xs_request_enter
Date: Tue, 8 May 2018 09:02:06 +0200	[thread overview]
Message-ID: <ea5634a2-b0e2-0fac-e5ec-cef1083958fe@suse.com> (raw)
In-Reply-To: <20180508033429.12749-1-baijiaju1990@gmail.com>

On 08/05/18 05:34, Jia-Ju Bai wrote:
> The read operation to "req->type" is protected by
> the lock on line 128, but the write operation to
> this data on line 118 is not protected by the lock.
> Thus, there may exist a data race for "req->type".
> 
> To fix this data race, the write operation to "req->type" 
> should be also protected by the lock.

No, xs_request_enter() is never called for a request already visible to
another thread or processor. So no race exists.


Juergen

> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/xen/xenbus/xenbus_xs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
> index 49a3874ae6bb..274cdfee08b1 100644
> --- a/drivers/xen/xenbus/xenbus_xs.c
> +++ b/drivers/xen/xenbus/xenbus_xs.c
> @@ -115,10 +115,10 @@ static uint32_t xs_request_enter(struct xb_req_data *req)
>  {
>  	uint32_t rq_id;
>  
> -	req->type = req->msg.type;
> -
>  	spin_lock(&xs_state_lock);
>  
> +	req->type = req->msg.type;
> +
>  	while (!xs_state_users && xs_suspend_active) {
>  		spin_unlock(&xs_state_lock);
>  		wait_event(xs_state_enter_wq, xs_suspend_active == 0);
> 

  reply	other threads:[~2018-05-08  7:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08  3:34 [PATCH] xen: xenbus: Fix a possible data race in xs_request_enter Jia-Ju Bai
2018-05-08  7:02 ` Juergen Gross [this message]
2018-05-08  7:04   ` Jia-Ju Bai

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=ea5634a2-b0e2-0fac-e5ec-cef1083958fe@suse.com \
    --to=jgross@suse.com \
    --cc=baijiaju1990@gmail.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=joao.m.martins@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simon@invisiblethingslab.com \
    --cc=xen-devel@lists.xenproject.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