lkml.org 
[lkml]   [2014]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] VMCI: integer overflow in vmci_datagram_dispatch()
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



\
 
 \ /
  Last update: 2014-08-29 13:41    [W:0.062 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site