[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ea5634a2-b0e2-0fac-e5ec-cef1083958fe@suse.com>
Date: Tue, 8 May 2018 09:02:06 +0200
From: Juergen Gross <jgross@...e.com>
To: Jia-Ju Bai <baijiaju1990@...il.com>, boris.ostrovsky@...cle.com,
simon@...isiblethingslab.com, joao.m.martins@...cle.com
Cc: xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xen: xenbus: Fix a possible data race in xs_request_enter
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@...il.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);
>
Powered by blists - more mailing lists