staging: unisys: visorbus: Check controlvm message payload size
authorDavid Binder <david.binder@unisys.com>
Wed, 1 Feb 2017 22:38:55 +0000 (17:38 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Feb 2017 12:10:48 +0000 (13:10 +0100)
Checks the controlvm message's payload size before copying it into a
parser_context struct's name region.

Signed-off-by: David Binder <david.binder@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorchipset.c

index 4e630ea527e85a3836f97b02e2f20f07874a1ab7..df2dfeb14027707dba73ab5fe0fa55e1e484d203 100644 (file)
@@ -399,6 +399,10 @@ parser_name_get(struct parser_context *ctx)
        struct spar_controlvm_parameters_header *phdr = NULL;
 
        phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+
+       if (phdr->name_offset + phdr->name_length > ctx->param_bytes)
+               return NULL;
+
        ctx->curr = ctx->data + phdr->name_offset;
        ctx->bytes_remaining = phdr->name_length;
        return parser_string_get(ctx);