diff options
author | Jan Beulich <JBeulich@suse.com> | 2016-07-07 01:23:57 -0600 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-11-20 01:01:44 +0000 |
commit | e3ea2576a59f960617808253b6923538328a51a4 (patch) | |
tree | 7293845d7748ae19d103b5b0abc0e8610dc97ebd | |
parent | 13e7cda6f0ecffe0266cca709fb8ab9c81dbb2a2 (diff) | |
download | linux-stable-e3ea2576a59f960617808253b6923538328a51a4.tar.gz linux-stable-e3ea2576a59f960617808253b6923538328a51a4.tar.bz2 linux-stable-e3ea2576a59f960617808253b6923538328a51a4.zip |
xenbus: don't BUG() on user mode induced condition
commit 0beef634b86a1350c31da5fcc2992f0d7c8a622b upstream.
Inability to locate a user mode specified transaction ID should not
lead to a kernel crash. For other than XS_TRANSACTION_START also
don't issue anything to xenbus if the specified ID doesn't match that
of any active transaction.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Cc: Ed Swierk <eswierk@skyportsystems.com>
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | drivers/xen/xenfs/xenbus.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c index bbd000f88af7..e6a63eeadb07 100644 --- a/drivers/xen/xenfs/xenbus.c +++ b/drivers/xen/xenfs/xenbus.c @@ -310,11 +310,18 @@ static int xenbus_write_transaction(unsigned msg_type, rc = -ENOMEM; goto out; } + } else { + list_for_each_entry(trans, &u->transactions, list) + if (trans->handle.id == u->u.msg.tx_id) + break; + if (&trans->list == &u->transactions) + return -ESRCH; } reply = xenbus_dev_request_and_reply(&u->u.msg); if (IS_ERR(reply)) { - kfree(trans); + if (msg_type == XS_TRANSACTION_START) + kfree(trans); rc = PTR_ERR(reply); goto out; } @@ -324,12 +331,7 @@ static int xenbus_write_transaction(unsigned msg_type, list_add(&trans->list, &u->transactions); } else if (msg_type == XS_TRANSACTION_END) { - list_for_each_entry(trans, &u->transactions, list) - if (trans->handle.id == u->u.msg.tx_id) - break; - BUG_ON(&trans->list == &u->transactions); list_del(&trans->list); - kfree(trans); } |