greybus: svc: fix missing version-request sanity checks
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 19 Nov 2015 17:28:01 +0000 (18:28 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 20 Nov 2015 00:07:48 +0000 (16:07 -0800)
Add missing sanity checks on version-request payload size.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/svc.c

index 6c1a157c10c5bc390016b8aadcccf6bf5f5f2a8d..bd045678493f63e99b3e2b43f043082a2619c58e 100644 (file)
@@ -310,6 +310,14 @@ static int gb_svc_version_request(struct gb_operation *op)
        struct gb_protocol_version_request *request;
        struct gb_protocol_version_response *response;
 
+       if (op->request->payload_size < sizeof(*request)) {
+               pr_err("%d: short version request (%zu < %zu)\n",
+                               connection->intf_cport_id,
+                               op->request->payload_size,
+                               sizeof(*request));
+               return -EINVAL;
+       }
+
        request = op->request->payload;
 
        if (request->major > GB_SVC_VERSION_MAJOR) {