8000 xenbus: don't BUG() on user mode induced condition · bsd-unix/linux@0beef63 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0beef63

Browse files
jbeulichDavid Vrabel
authored andcommitted
xenbus: don't BUG() on user mode induced condition
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> Cc: <stable@vger.kernel.org> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
1 parent d2bd05d commit 0beef63

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/xen/xenbus/xenbus_dev_frontend.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,18 @@ static int xenbus_write_transaction(unsigned msg_type,
316316
rc = -ENOMEM;
317317
goto out;
318318
}
319+
} else {
320+
list_for_each_entry(trans, &u->transactions, list)
321+
if (trans->handle.id == u->u.msg.tx_id)
322+
break;
323+
if (&trans->list == &u->transactions)
324+
return -ESRCH;
319325
}
320326

321327
reply = xenbus_dev_request_and_reply(&u->u.msg);
322328
if (IS_ERR(reply)) {
323-
kfree(trans);
329+
if (msg_type == XS_TRANSACTION_START)
330+
kfree(trans);
324331
rc = PTR_ERR(reply);
325332
goto out;
326333
}
@@ -333,12 +340,7 @@ static int xenbus_write_transaction(unsigned msg_type,
333340
list_add(&trans->list, &u->transactions);
334341
}
335342
} else if (u->u.msg.type == XS_TRANSACTION_END) {
336-
list_for_each_entry(trans, &u->transactions, list)
337-
if (trans->handle.id == u->u.msg.tx_id)
338-
break;
339-
BUG_ON(&trans->list == &u->transactions);
340343
list_del(&trans->list);
341-
342344
kfree(trans);
343345
}
344346

0 commit comments

Comments
 (0)
0