switch (msg_type) { case SYNTH_KBD_PROTOCOL_RESPONSE: /* * Validate the information provided by the host. * If the host is giving us a bogus packet, * drop the packet (hoping the problem * goes away).
*/ if (msg_length < sizeof(struct synth_kbd_protocol_response)) {
dev_err(&hv_dev->device, "Illegal protocol response packet (len: %d)\n",
msg_length); break;
}
case SYNTH_KBD_EVENT: /* * Validate the information provided by the host. * If the host is giving us a bogus packet, * drop the packet (hoping the problem * goes away).
*/ if (msg_length < sizeof(struct synth_kbd_keystroke)) {
dev_err(&hv_dev->device, "Illegal keyboard event packet (len: %d)\n",
msg_length); break;
}
ks_msg = (struct synth_kbd_keystroke *)msg;
info = __le32_to_cpu(ks_msg->info);
/* * Inject the information through the serio interrupt.
*/
scoped_guard(spinlock_irqsave, &kbd_dev->lock) { if (kbd_dev->started) { if (info & IS_E0)
serio_interrupt(kbd_dev->hv_serio,
XTKBD_EMUL0, 0); if (info & IS_E1)
serio_interrupt(kbd_dev->hv_serio,
XTKBD_EMUL1, 0);
scan_code = __le16_to_cpu(ks_msg->make_code); if (info & IS_BREAK)
scan_code |= XTKBD_RELEASE;
/* * Only trigger a wakeup on key down, otherwise * "echo freeze > /sys/power/state" can't really enter the * state because the Enter-UP can trigger a wakeup at once.
*/ if (!(info & IS_BREAK))
pm_wakeup_hard_event(&hv_dev->device);
break;
default:
dev_err(&hv_dev->device, "unhandled message type %d\n", msg_type);
}
}
case VM_PKT_DATA_INBAND: /* * We have a packet that has "inband" data. The API used * for retrieving the packet guarantees that the complete * packet is read. So, minimally, we should be able to * parse the payload header safely (assuming that the host * can be trusted. Trusting the host seems to be a * reasonable assumption because in a virtualized * environment there is not whole lot you can do if you * don't trust the host. * * Nonetheless, let us validate if the host can be trusted * (in a trivial way). The interesting aspect of this * validation is how do you recover if we discover that the * host is not to be trusted? Simply dropping the packet, I * don't think is an appropriate recovery. In the interest * of failing fast, it may be better to crash the guest. * For now, I will just drop the packet!
*/
msg_sz = bytes_recvd - (desc->offset8 << 3); if (msg_sz <= sizeof(struct synth_kbd_msg_hdr)) { /* * Drop the packet and hope * the problem magically goes away.
*/
dev_err(&hv_dev->device, "Illegal packet (type: %d, tid: %llx, size: %d)\n",
desc->type, req_id, msg_sz); break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.