Skip to contentSkip to conversation

linux-2.6.18/xenbus: fix overflow check in xenbus_dev_write()

PATCH In review Jan Beulich 3 participants 3 messages Oct 16, 2012 – Oct 17, 2012 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-2.6.18/xenbus: fix overflow check in xenbus_dev_write()

drivers/xen/xenbus/xenbus_dev.c +1 -1
@@ -239,7 +239,7 @@ static ssize_t xenbus_dev_write(struct f
 	if (!is_xenstored_ready())
 		return -ENODEV;
 
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		rc = -EINVAL;
 		goto out;
 	}

xenbus: fix overflow check in xenbus_dev_write()

drivers/xen/xenbus/xenbus_dev.c +1 -1
@@ -239,7 +239,7 @@ static ssize_t xenbus_dev_write(struct f
 	if (!is_xenstored_ready())
 		return -ENODEV;
 
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		rc = -EINVAL;
 		goto out;
 	}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Jan Beulich

CC-ing Konrad since I think that modulo tweaking the path this ought to apply as is to upstream kernels.

Quoted 15 lines
drivers/xen/xenbus/xenbus_dev.c +1 -1
@@ -239,7 +239,7 @@ static ssize_t xenbus_dev_write(struct f
 	if (!is_xenstored_ready())
 		return -ENODEV;
 
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		rc = -EINVAL;
 		goto out;
 	}
#2 lore raw
Quoted 16 lines · Ian Campbell
Quoted 2 lines · Jan Beulich

CC-ing Konrad since I think that modulo tweaking the path this ought to apply as is to upstream kernels.

Quoted 7 lines
drivers/xen/xenbus/xenbus_dev.c +0 -0
@@ -239,7 +239,7 @@ static ssize_t xenbus_dev_write(struct f
 	if (!is_xenstored_ready())
 		return -ENODEV;
 
Quoted 8 lines

drivers/xen/xenbus/xenbus_dev.c static ssize_t xenbus_dev_write(struct f · line 245

Quoted 8 lines
drivers/xen/xenbus/xenbus_dev.c +1 -1
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		rc = -EINVAL;
 		goto out;
 	}

Like this:

drivers/xen/xenbus/xenbus_dev_frontend.c +1 -1
index 89f7625..ac72702 100644
@@ -458,7 +458,7 @@ static ssize_t xenbus_file_write(struct file *filp,
 		goto out;
 
 	/* Can't write a xenbus message larger we can buffer */
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		/* On error, dump existing buffer */
 		u->len = 0;
 		rc = -EINVAL;