From: Simon Gaiser <simon@invisiblethingslab.com>
To: xen-devel@lists.xenproject.org
Cc: Simon Gaiser <simon@invisiblethingslab.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Juergen Gross <jgross@suse.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] xen: xenbus: WARN_ON XS_TRANSACTION_{START,END} misuse
Date: Wed, 7 Feb 2018 23:22:36 +0100 [thread overview]
Message-ID: <20180207222236.7434-2-simon@invisiblethingslab.com> (raw)
In-Reply-To: <20180207222236.7434-1-simon@invisiblethingslab.com>
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))
+ /*
+ * 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)
--
2.15.1
next prev parent reply other threads:[~2018-02-07 22:24 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 ` Simon Gaiser [this message]
2018-02-10 16:57 ` [PATCH 2/2] xen: xenbus: WARN_ON XS_TRANSACTION_{START,END} misuse Boris Ostrovsky
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=20180207222236.7434-2-simon@invisiblethingslab.com \
--to=simon@invisiblethingslab.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--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