Skip to content

Commit 8fe5ab4

Browse files
HW42Boris Ostrovsky
authored andcommitted
xen: xenbus_dev_frontend: Verify body of XS_TRANSACTION_END
By guaranteeing that the argument of XS_TRANSACTION_END is valid we can assume that the transaction has been closed when we get an XS_ERROR response from xenstore (Note that we already verify that it's a valid transaction id). Signed-off-by: Simon Gaiser <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent b93008d commit 8fe5ab4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/xen/xenbus/xenbus_dev_frontend.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ static int xenbus_write_transaction(unsigned msg_type,
429429
{
430430
int rc;
431431
struct xenbus_transaction_holder *trans = NULL;
432+
struct {
433+
struct xsd_sockmsg hdr;
434+
char body[];
435+
} *msg = (void *)u->u.buffer;
432436

433437
if (msg_type == XS_TRANSACTION_START) {
434438
trans = kzalloc(sizeof(*trans), GFP_KERNEL);
@@ -437,11 +441,15 @@ static int xenbus_write_transaction(unsigned msg_type,
437441
goto out;
438442
}
439443
list_add(&trans->list, &u->transactions);
440-
} else if (u->u.msg.tx_id != 0 &&
441-
!xenbus_get_transaction(u, u->u.msg.tx_id))
444+
} else if (msg->hdr.tx_id != 0 &&
445+
!xenbus_get_transaction(u, msg->hdr.tx_id))
442446
return xenbus_command_reply(u, XS_ERROR, "ENOENT");
447+
else if (msg_type == XS_TRANSACTION_END &&
448+
!(msg->hdr.len == 2 &&
449+
(!strcmp(msg->body, "T") || !strcmp(msg->body, "F"))))
450+
return xenbus_command_reply(u, XS_ERROR, "EINVAL");
443451

444-
rc = xenbus_dev_request_and_reply(&u->u.msg, u);
452+
rc = xenbus_dev_request_and_reply(&msg->hdr, u);
445453
if (rc && trans) {
446454
list_del(&trans->list);
447455
kfree(trans);

0 commit comments

Comments
 (0)