All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: linux-kernel@vger.kernel.org,
	George Zhang <georgezhang@vmware.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] VMCI: integer overflow in vmci_datagram_dispatch()
Date: Fri, 29 Aug 2014 11:21:04 +0000	[thread overview]
Message-ID: <20140829112104.GF5071@mwanda> (raw)
In-Reply-To: <5400606B.8010905@bfs.de>

On Fri, Aug 29, 2014 at 01:13:47PM +0200, walter harms wrote:
> 
> 
> Am 29.08.2014 10:42, schrieb Dan Carpenter:
> > This is untrusted user data from vmci_host_do_send_datagram() so the
> > VMCI_DG_SIZE() macro can have an integer overflow.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
> > index f3cdd90..8226652 100644
> > --- a/drivers/misc/vmw_vmci/vmci_datagram.c
> > +++ b/drivers/misc/vmw_vmci/vmci_datagram.c
> > @@ -328,7 +328,8 @@ int vmci_datagram_dispatch(u32 context_id,
> >  
> >  	BUILD_BUG_ON(sizeof(struct vmci_datagram) != 24);
> >  
> > -	if (VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
> > +	if (dg->payload_size > VMCI_MAX_DG_SIZE ||
> > +	    VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
> >  		pr_devel("Payload (size=%llu bytes) too big to send\n",
> >  			 (unsigned long long)dg->payload_size);
> >  		return VMCI_ERROR_INVALID_ARGS;
> 
> Are your sure about that ">" ? maybe ">=" was intended ?

Yes, I'm sure.  As a rule of thumb, > is used for size comparisons and
>= is used for index comparisons.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: linux-kernel@vger.kernel.org,
	George Zhang <georgezhang@vmware.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] VMCI: integer overflow in vmci_datagram_dispatch()
Date: Fri, 29 Aug 2014 14:21:04 +0300	[thread overview]
Message-ID: <20140829112104.GF5071@mwanda> (raw)
In-Reply-To: <5400606B.8010905@bfs.de>

On Fri, Aug 29, 2014 at 01:13:47PM +0200, walter harms wrote:
> 
> 
> Am 29.08.2014 10:42, schrieb Dan Carpenter:
> > This is untrusted user data from vmci_host_do_send_datagram() so the
> > VMCI_DG_SIZE() macro can have an integer overflow.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
> > index f3cdd90..8226652 100644
> > --- a/drivers/misc/vmw_vmci/vmci_datagram.c
> > +++ b/drivers/misc/vmw_vmci/vmci_datagram.c
> > @@ -328,7 +328,8 @@ int vmci_datagram_dispatch(u32 context_id,
> >  
> >  	BUILD_BUG_ON(sizeof(struct vmci_datagram) != 24);
> >  
> > -	if (VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
> > +	if (dg->payload_size > VMCI_MAX_DG_SIZE ||
> > +	    VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
> >  		pr_devel("Payload (size=%llu bytes) too big to send\n",
> >  			 (unsigned long long)dg->payload_size);
> >  		return VMCI_ERROR_INVALID_ARGS;
> 
> Are your sure about that ">" ? maybe ">=" was intended ?

Yes, I'm sure.  As a rule of thumb, > is used for size comparisons and
>= is used for index comparisons.

regards,
dan carpenter


  reply	other threads:[~2014-08-29 11:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29  8:42 [patch] VMCI: integer overflow in vmci_datagram_dispatch() Dan Carpenter
2014-08-29  8:42 ` Dan Carpenter
2014-08-29 11:13 ` walter harms
2014-08-29 11:13   ` walter harms
2014-08-29 11:21   ` Dan Carpenter [this message]
2014-08-29 11:21     ` Dan Carpenter

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=20140829112104.GF5071@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=georgezhang@vmware.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wharms@bfs.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.