mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Kershner <david.kershner@unisys.com>
Cc: gregkh@linuxfoundation.org, jes.sorensen@gmail.com,
	linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org,
	sparmaintainer@unisys.com, erik.arfvidson@gmail.com,
	wadgaonkarsam@gmail.com, Tim Sell <Timothy.Sell@unisys.com>
Subject: Re: [PATCH 1/2] staging: unisys: visorbus: address theoretical int overflows
Date: Tue, 28 Nov 2017 17:11:49 +0300	[thread overview]
Message-ID: <20171128141148.3pkz6pwteuzoo2aa@mwanda> (raw)
In-Reply-To: <1510939659-15039-2-git-send-email-david.kershner@unisys.com>

> --- a/drivers/staging/unisys/visorbus/visorchipset.c
> +++ b/drivers/staging/unisys/visorbus/visorchipset.c
> @@ -581,7 +581,8 @@ static void *parser_name_get(struct parser_context *ctx)
>  	struct visor_controlvm_parameters_header *phdr;
>  
>  	phdr = &ctx->data;
> -	if (phdr->name_offset + phdr->name_length > ctx->param_bytes)
> +	if ((unsigned long)phdr->name_offset +
> +	    (unsigned long)phdr->name_length > ctx->param_bytes)
>  		return NULL;
>  	ctx->curr = (char *)&phdr + phdr->name_offset;
>  	ctx->bytes_remaining = phdr->name_length;


I haven't reviewed this code very thouroughly.  This should fix the
issue on 64 bit systems, but it's a no-op on 32 bit systems.  Which
might be fine?  I would be more comfortable if we just checked for
integer overflow explicitly.  There are bunch of ways to do that:

	if (phdr->name_offset > ctx->param_bytes ||
	    phdr->name_length > ctx->param_bytes ||
	    phdr->name_offset + phdr->name_length > ctx->param_bytes)

Or:

	if (phdr->name_offset + phdr->name_length < phdr->name_offset ||
	    phdr->name_offset + phdr->name_length > ctx->param_bytes)
		return NULL;

regards,
dan carpenter

  reply	other threads:[~2017-11-28 14:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 17:27 [PATCH 0/2] drivers: Move visorbus from staging to drivers/visorbus David Kershner
2017-11-17 17:27 ` [PATCH 1/2] staging: unisys: visorbus: address theoretical int overflows David Kershner
2017-11-28 14:11   ` Dan Carpenter [this message]
2017-11-17 17:27 ` [PATCH 2/2] drivers: visorbus: move driver out of staging David Kershner
2017-11-17 19:17   ` Christoph Hellwig
2017-11-17 21:11     ` Kershner, David A
2017-11-18 10:26   ` Greg KH
2017-11-18 14:30     ` Kershner, David A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128141148.3pkz6pwteuzoo2aa@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=Timothy.Sell@unisys.com \
    --cc=david.kershner@unisys.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=erik.arfvidson@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparmaintainer@unisys.com \
    --cc=wadgaonkarsam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®