RE: [PATCH] xen: hypercall: fix out-of-bounds memcpy
From: David Laight
Date: Mon Feb 05 2018 - 07:10:33 EST
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