lkml.org 
[lkml]   [2018]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] xen: hypercall: fix out-of-bounds memcpy
Date
From: Boris Ostrovsky
> Sent: 02 February 2018 23:34
...
> > switch (cmd) {
> > + case EVTCHNOP_bind_interdomain:
> > + len = sizeof(struct evtchn_bind_interdomain);
> > + break;
> > + case EVTCHNOP_bind_virq:
> > + len = sizeof(struct evtchn_bind_virq);
> > + break;
> > + case EVTCHNOP_bind_pirq:
> > + len = sizeof(struct evtchn_bind_pirq);
> > + break;
> > case EVTCHNOP_close:
> > + len = sizeof(struct evtchn_close);
> > + break;
> > case EVTCHNOP_send:
> > + len = sizeof(struct evtchn_send);
> > + break;
> > + case EVTCHNOP_alloc_unbound:
> > + len = sizeof(struct evtchn_alloc_unbound);
> > + break;
> > + case EVTCHNOP_bind_ipi:
> > + len = sizeof(struct evtchn_bind_ipi);
> > + break;
> > + case EVTCHNOP_status:
> > + len = sizeof(struct evtchn_status);
> > + break;
> > case EVTCHNOP_bind_vcpu:
> > + len = sizeof(struct evtchn_bind_vcpu);
> > + break;
> > case EVTCHNOP_unmask:
> > - /* no output */
> > + len = sizeof(struct evtchn_unmask);
> > break;

Are the EVTCHNOP_xxx values dense?
In which case an array is almost certainly better than the switch statement.

David

\
 
 \ /
  Last update: 2018-02-05 13:10    [W:0.066 / U:0.076 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site