mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Simon Gaiser <simon@invisiblethingslab.com>,
	xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] xen: xenbus: WARN_ON XS_TRANSACTION_{START,END} misuse
Date: Sat, 10 Feb 2018 11:57:35 -0500	[thread overview]
Message-ID: <8a0fd059-7acf-3279-10f9-649c19522e2a@oracle.com> (raw)
In-Reply-To: <20180207222236.7434-2-simon@invisiblethingslab.com>



On 02/07/2018 05:22 PM, Simon Gaiser wrote:
> As the previous commit shows it's quite easy to confuse the transaction
> reference counting by ending a transaction twice. So at least try to
> detect and report it.
> 
> Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
> ---
>   drivers/xen/xenbus/xenbus_xs.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
> index 3e59590c7254..aed954b09b9b 100644
> --- a/drivers/xen/xenbus/xenbus_xs.c
> +++ b/drivers/xen/xenbus/xenbus_xs.c
> @@ -137,11 +137,20 @@ static uint32_t xs_request_enter(struct xb_req_data *req)
>   
>   void xs_request_exit(struct xb_req_data *req)
>   {
> +	unsigned int users_old;
> +
>   	spin_lock(&xs_state_lock);
> +	users_old = xs_state_users;
>   	xs_state_users--;
>   	if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) ||
>   	    req->type == XS_TRANSACTION_END)
>   		xs_state_users--;
> +	if (WARN_ON(xs_state_users > users_old))


WARN_ON_ONCE()?

-boris


> +		/*
> +		 * Someone misused XS_TRANSACTION_{START,END}. Reset the
> +		 * reference counter so we might survive.
> +		 */
> +		xs_state_users = 0;
>   	spin_unlock(&xs_state_lock);
>   
>   	if (xs_suspend_active && !xs_state_users)
> 

  reply	other threads:[~2018-02-10 16:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 22:22 [PATCH 1/2] xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling Simon Gaiser
2018-02-07 22:22 ` [PATCH 2/2] xen: xenbus: WARN_ON XS_TRANSACTION_{START,END} misuse Simon Gaiser
2018-02-10 16:57   ` Boris Ostrovsky [this message]
2018-02-11  1:27     ` Simon Gaiser
2018-02-11 15:28       ` Boris Ostrovsky
2018-02-10 16:53 ` [PATCH 1/2] xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling Boris Ostrovsky
2018-02-12  8:49 ` Juergen Gross
2018-02-12  9:06   ` Juergen Gross
2018-02-20  4:56     ` Simon Gaiser
2018-03-02 14:19       ` Juergen Gross
2018-03-02 14:58         ` Simon Gaiser
2018-03-02 15:12           ` Juergen Gross

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=8a0fd059-7acf-3279-10f9-649c19522e2a@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.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

all inboxes | Powered by JetHome®