"value":"In the Linux kernel, the following vulnerability has been resolved:\n\nxen/events: close evtchn after mapping cleanup\n\nshutdown_pirq and startup_pirq are not taking the\nirq_mapping_update_lock because they can't due to lock inversion. Both\nare called with the irq_desc->lock being taking. The lock order,\nhowever, is first irq_mapping_update_lock and then irq_desc->lock.\n\nThis opens multiple races:\n- shutdown_pirq can be interrupted by a function that allocates an event\n channel:\n\n CPU0 CPU1\n shutdown_pirq {\n xen_evtchn_close(e)\n __startup_pirq {\n EVTCHNOP_bind_pirq\n -> returns just freed evtchn e\n set_evtchn_to_irq(e, irq)\n }\n xen_irq_info_cleanup() {\n set_evtchn_to_irq(e, -1)\n }\n }\n\n Assume here event channel e refers here to the same event channel\n number.\n After this race the evtchn_to_irq mapping for e is invalid (-1).\n\n- __startup_pirq races with __unbind_from_irq in a similar way. Because\n __startup_pirq doesn't take irq_mapping_update_lock it can grab the\n evtchn that __unbind_from_irq is currently freeing and cleaning up. In\n this case even though the event channel is allocated, its mapping can\n be unset in evtchn_to_irq.\n\nThe fix is to first cleanup the mappings and then close the event\nchannel. In this way, when an event channel gets allocated it's\npotential previous evtchn_to_irq mappings are guaranteed to be unset already.\nThis is also the reverse order of the allocation where first the event\nchannel is allocated and then the mappings are setup.\n\nOn a 5.10 kernel prior to commit 3fcdaf3d7634 (\"xen/events: modify internal\n[un]bind interfaces\"),wehitaBUGlikethefollowingduringprobingofNVMe\ndevices.Theissueisthatduringnvme_setup_io_queues,pci_free_irq\niscalledforeverydevicewhichresultsinacalltoshutdown_pirq.\nWithmanynvmedevicesit'sthereforelikelytohitthisraceduring\nbootbecausetherewillbemultiplecallstoshutdown_pirqand\nstartup_pirqarerunningpotentiallyinparallel.\n\n------------[cuthere]------------\nblkfront:xvda:barrierorflush:disabled;persistentgrants:enabled;indirectdescriptors:enabled;bouncebuffer:enabled\nkernelBUGatdrivers/xen/events/events_base.c:499!\ninvalidopcode:0000[#1]SMPPTI\nCPU:44PID:375Comm:kworker/u257:23Nottainted5.10.201-191.748.amzn2.x86_64#1\nHardwarename:XenHVMdomU,BIOS4.11.amazon08/24/2006\nWorkqueue:nvme-reset-wqnvme_reset_work\nRIP:0010:bind_evtchn_to_cpu+0xdf/0xf0\nCode:5d415ec3cccccccc4489f7e82b55adff4989c54885c00f8464ffffff4c8b68304183feff0f8560ffffff<0f>0b66662e0f1f8400000000000f1f40000f1f440000\nRSP:0000:ffffc9000d533b08EFLAGS:00010046\nRAX:0000000000000000RBX:0000000000000000RCX:0000000000000006\nRDX:0000000000000028RSI:00000000ffffffffRDI:00000000ffffffff\nRBP:ffff888107419680R08:0000000000000000R09:ffffffff82d72b00\nR10:0000000000000000R11:0000000000000000R12:00000000000001ed\nR13:0000000000000000R14:00000000ffffffffR15:0000000000000002\nFS:0000000000000000(0000)GS:ffff88bc8b500000(0000)knlGS:0000000000000000\nCS:0010DS:0000ES:0000CR0:0000000080050033\nCR2:0000000000000000CR3:0000000002610001CR4:00000000001706e0\nDR0:0000000000000000DR1:0000000000000000DR2:0000000000000000\nDR3:0000000000000000DR6:00000000fffe0ff0DR7:0000000000000400\nCallTrace:\n?show_trace_log_lvl+0x1c1/0x2d9\n?show_trace_log_lvl+0x1c1/0x2d9\n?set_affinity_irq+0xdc/0x1c0\n?__die_body.cold+0x8/0xd\n?die+0x2b/0x50\n?do_trap+0x90/0x110\n?bind_evtchn_to_cpu+0xdf/0xf0\n?do_error_trap+0x65/0x80\n?bind_evtchn_to_cpu+0xdf/0xf0\n?exc_invalid_op+0x4e/0x70\n?bind_evtchn_to_cpu+0xdf/0xf0\n?asm_exc_invalid_op+0x12/0x20\n?bind_evtchn_to_cpu+0xdf/0x\n---truncat
"value":"En el kernel de Linux, se resolvi\u00f3 la siguiente vulnerabilidad: xen/events: cierre evtchn despu\u00e9s de la limpieza del mapeo. Shutdown_pirq y startup_pirq no est\u00e1n tomando irq_mapping_update_lock porque no pueden hacerlo debido a la inversi\u00f3n de bloqueo. Ambos se llaman con el irq_desc->lock en curso. Sin embargo, el orden de bloqueo es primero irq_mapping_update_lock y luego irq_desc->lock. Esto abre m\u00faltiples ejecuci\u00f3ns: - Shutdown_pirq puede ser interrumpido por una funci\u00f3n que asigna un canal de evento: CPU0 CPU1 Shutdown_pirq { xen_evtchn_close(e) __startup_pirq { EVTCHNOP_bind_pirq -> devuelve el evtchn e set_evtchn_to_irq(e, irq) reci\u00e9n liberado} xen_irq_info_cleanup() { set_evtchn_to_irq( e, -1) } } Supongamos que aqu\u00ed el canal de eventos e se refiere aqu\u00ed al mismo n\u00famero de canal de eventos. Despu\u00e9s de esta ejecuci\u00f3n, el mapeo evtchn_to_irq para e no es v\u00e1lido (-1). - __startup_pirq compite con __unbind_from_irq de manera similar. Debido a que __startup_pirq no toma irq_mapping_update_lock, puede tomar el evtchn que __unbind_from_irq est\u00e1 liberando y limpiando actualmente. En este caso, aunque el canal de eventos est\u00e9 asignado, su asignaci\u00f3n se puede desarmar en evtchn_to_irq. La soluci\u00f3n es limpiar primero las asignaciones y luego cerrar el canal de eventos. De esta manera, cuando se asigna un canal de eventos, se garantiza que sus posibles asignaciones anteriores de evtchn_to_irq ya no estar\u00e1n configuradas. Este es tambi\u00e9n el orden inverso de la asignaci\u00f3n donde primero se asigna el canal de evento y luego se configuran las asignaciones. En un kernel 5.10 antes de commit 3fcdaf3d7634 (\"xen/events: modificar interfaces internas [un]bind\"),encontramosunERRORcomoelsiguienteduranteelsondeodedispositivosNVMe.Elproblemaesquedurantenvme_setup_io_queues,sellamaapci_free_irqparacadadispositivo,loqueresultaenunallamadaaShutdown_pirq.Porlotanto,conmuchosdispositivosnvmeesprobablequealcanceestaejecuci\u00f3nduranteelarranqueporquehabr\u00e1m\u00faltiplesllamadasaShutdown_pirqystartup_pirqqueseejecutanpotencialmenteenparalelo.------------[cortaraqu\u00ed]------------blkfront:xvda:barreraodescarga:deshabilitado;subvencionespersistentes:habilitadas;descriptoresindirectos:habilitado;b\u00faferderebote:\u00a1ERRORdelkernelhabilitadoendrivers/xen/events/events_base.c:499!c\u00f3digodeoperaci\u00f3nnov\u00e1lido:0000[#1]SMPPTICPU:44PID:375Comm:kworker/u257:23Nocontaminado5.10.201-191.748.amzn2.x86_64#1Nombredehardware:XenHVMdomU,BIOS4.11.amazon24/08/2006Coladetrabajo:nvme-reset-wqnvme_reset_workRIP:0010:bind_evtchn_to_cpu+0xdf/0xf0C\u00f3digo:5d415ec3cccccccc4489f7e82b55adff4989c54885c00f8464ffffff4c8b68304183feff0f8560ffffff<0f>0b66662e0f1f8400000000000f1f40000f1f440000RSP:0000:ffffc9000d533b08EFLAGS:00010046RAX:0000000000000000RBX:0000000000000000RCX:0000000000000006RDX:0000000000000028RSI:00000000ffffffffRDI:00000000ffffffffRBP:ffff888107419680R08:0000000000000000R09:ffffffff82d72b00R10:00000000000000000R11:0000000000000000R12:00000000000001edR13:00000000000000000R14:00000000ffffffffR15:0000000000000002FS:0000000000000000(0000)GS:ffff88bc8b500000(0000)knlGS:0000000000000000CS:0010DS:0000ES:0000CR0:0000000080050033CR2:00000000000000000CR3:0000000002610001CR4:00000000001706e0DR0:0000000000000000DR1:00000000000000000DR2:0000000000000000DR3:0000000000000000DR6:00000000fffe0ff0DR7:0000000000000400Seguimientodellamadas:?show_trace_log_lvl+0x1c1/0x2d9?show_trace_log_lvl+0x1c1/0x2d9?set_affinity_irq+0xdc/0x1c0?__die_body.cold+0x8/0xd?morir+0x2b/0x50?do_trap+0x90/0x110?bind_evtchn_to_cpu+0xdf/0xf0?do_error_trap+0x65/0x80?bind_evtchn_to_cpu+0xdf/0xf0?exc_invalid_op+0x4e/0x70?bind_evtchn_to_cpu+0xdf/0xf0?asm_exc_invalid_op+0x12/0x20