"value":"In the Linux kernel, the following vulnerability has been resolved:\n\nHID: logitech-hidpp: Fix kernel crash on receiver USB disconnect\n\nhidpp_connect_event() has *four* time-of-check vs time-of-use (TOCTOU)\nraces when it races with itself.\n\nhidpp_connect_event() primarily runs from a workqueue but it also runs\non probe() and if a \"device-connected\"packetisreceivedbythehw\nwhenthethreadrunninghidpp_connect_event()fromprobe()iswaitingon\nthehw,thenasecondthreadrunninghidpp_connect_event()willbe\nstartedfromtheworkqueue.\n\nThisopensthefollowingraces(notethebelowcodeissimplified):\n\n1.Retrieving+printingtheprotocol(harmlessrace):\n\n\tif(!hidpp->protocol_major){\n\t\thidpp_root_get_protocol_version()\n\t\thidpp->protocol_major=response.rap.params[0];\n\t}\n\nWecanactuallyseethisracehitinthedmesgintheabrtoutput\nattachedtorhbz#2227968:\n\n[3064.624215]logitech-hidpp-device0003:046D:4071.0049:HID++4.5deviceconnected.\n[3064.658184]logitech-hidpp-device0003:046D:4071.0049:HID++4.5deviceconnected.\n\nTestingwithextraloggingaddedhasshownthatafterthisthe2threads\ntaketurngrabbingthehwaccessmutex(send_mutex)sotheyping-pong\nthroughalltheotherTOCTOUcasesmanagingtohitallofthem:\n\n2.UpdatingthenametotheHIDPPname(harmlessrace):\n\n\tif(hidpp->name==hdev->name){\n\t\t...\n\t\thidpp->name=new_name;\n\t}\n\n3.Initializingthepower_supplyclassforthebattery(problematic!):\n\nhidpp_initialize_battery()\n{\nif(hidpp->battery.ps)\nreturn0;\n\n\tprobe_battery();/*Blocks,threadstaketurnsexecutingthis*/\n\n\thidpp->battery.desc.properties=\n\t\tdevm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);\n\n\thidpp->battery.ps=\n\t\tdevm_power_supply_register(&hidpp->hid_dev->dev,\n\t\t\t\t\t&hidpp->battery.desc,cfg);\n}\n\n4.Creatingdelayedinput_device(potentiallyproblematic):\n\n\tif(hidpp->delayed_input)\n\t\treturn;\n\n\thidpp->delayed_input=hidpp_allocate_input(hdev);\n\nThereallybigproblemhereis3.Hittingtheraceleadstothefollowing\nsequence:\n\n\thidpp->battery.desc.properties=\n\t\tdevm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);\n\n\thidpp->battery.ps=\n\t\tdevm_power_supply_register(&hidpp->hid_dev->dev,\n\t\t\t\t\t&hidpp->battery.desc,cfg);\n\n\t...\n\n\thidpp->battery.desc.properties=\n\t\tdevm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);\n\n\thidpp->battery.ps=\n\t\tdevm_power_supply_register(&hidpp->hid_dev->dev,\n\t\t\t\t\t&hidpp->battery.desc,cfg);\n\nSonowwehaveregistered2powersuppliesforthesamebattery,\nwhichlooksabitweirdfromuserspace'spovbutthisisnoteven\nthereallybigproblem.\n\nNoticehow:\n\n1.Thisisalldevm-maganaged\n2.Thehidpp->battery.descstructissharedbetweenthe2powersupplies\n3.hidpp->battery.desc.propertiespointstotheresultfromthesecond\ndevm_kmemdup()\n\nThiscausesauseafterfreescenarioonUSBdisconnectofthereceiver:\n1.Thelastregisteredpowersupplyclassdevicegetsunregistered\n2.Thememoryfromthelastdevm_kmemdup()callgetsfreed,\nhidpp->battery.desc.propertiesnowpointstofreedmemory\n3.Thefirstregisteredpowersupplyclassdevicegetsunregistered,\nthisinvolvessendingaremoveueventtouserspacewhichinvokes\npower_supply_uevent()tofilltheueventdata\n4.power_supply_uevent()useshidpp->battery.desc.propertieswhich\nnowpointstofreedmemoryleadingtobacktraceslikethisone:\n\nSep2220:01:35erickernel:BUG:unabletohandlepagefaultforaddress:ffffb2140e017f08\n...\nSep2220:01:35erickernel:Workqueue:usb_hub_wqhub_event\nSep2220:01:35erickernel:RIP:0010:power_supply_uevent+0xee/0x1d0\n...\nSep2220:01:35erickernel:?asm_exc_page_fault+0x26/0x30\nSep2220:01:35erickernel:?power_supply_uevent+0xee/0x1d0\nSep2220:01:35erickernel:?power_supply_uevent+0x10d/0x1d0\nSep2220:01:35erickernel:dev_uevent+0x10f/0x2d0\nSep2220:01:35ericke
"value":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: HID: logitech-hidpp: soluciona el fallo del kernel en la desconexi\u00f3n del USB del receptor hidpp_connect_event() tiene *cuatro* carreras de tiempo de verificaci\u00f3n versus tiempo de uso (TOCTOU) cuando corre consigo mismo. hidpp_connect_event() se ejecuta principalmente desde una cola de trabajo, pero tambi\u00e9n se ejecuta en probe() y si el hw recibe un paquete \"dispositivo conectado\"cuandoelsubprocesoqueejecutahidpp_connect_event()desdeprobe()est\u00e1esperandoenelhw,entoncesseejecutaunsegundoElhiloqueejecutahidpp_connect_event()seiniciar\u00e1desdelacoladetrabajo.Estoabrelassiguientescarreras(tengaencuentaqueelc\u00f3digosiguienteest\u00e1simplificado):1.Retrieving+printingtheprotocol(harmlessrace):if(!hidpp->protocol_major){hidpp_root_get_protocol_version()hidpp->protocol_major=response.rap.params[0];}Wecanactuallyseethisracehitinthedmesgintheabrtoutputattachedtorhbz#2227968:[3064.624215]logitech-hidpp-device0003:046D:4071.0049:HID++4.5deviceconnected.[3064.658184]logitech-hidpp-device0003:046D:4071.0049:HID++4.5deviceconnected.Testingwithextraloggingaddedhasshownthatafterthisthe2threadstaketurngrabbingthehwaccessmutex(send_mutex)sotheyping-pongthroughalltheotherTOCTOUcasesmanagingtohitallofthem:2.UpdatingthenametotheHIDPPname(harmlessrace):if(hidpp->name==hdev->name){...hidpp->name=new_name;}3.Initializingthepower_supplyclassforthebattery(problematic!):hidpp_initialize_battery(){if(hidpp->battery.ps)return0;probe_battery();/*Blocks,threadstaketurnsexecutingthis*/hidpp->battery.desc.properties=devm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);hidpp->battery.ps=devm_power_supply_register(&hidpp->hid_dev->dev,&hidpp->battery.desc,cfg);}4.Creatingdelayedinput_device(potentiallyproblematic):if(hidpp->delayed_input)return;hidpp->delayed_input=hidpp_allocate_input(hdev);Thereallybigproblemhereis3.Hittingtheraceleadstothefollowingsequence:hidpp->battery.desc.properties=devm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);hidpp->battery.ps=devm_power_supply_register(&hidpp->hid_dev->dev,&hidpp->battery.desc,cfg);...hidpp->battery.desc.properties=devm_kmemdup(dev,hidpp_battery_props,cnt,GFP_KERNEL);hidpp->battery.ps=devm_power_supply_register(&hidpp->hid_dev->dev,&hidpp->battery.desc,cfg);Sonowwehaveregistered2powersuppliesforthesamebattery,whichlooksabitweirdfromuserspace'spovbutthisisnoteventhereallybigproblem.Noticehow:1.Thisisalldevm-maganaged2.Thehidpp->battery.descstructissharedbetweenthe2powersupplies3.hidpp->battery.desc.propertiespointstotheresultfromtheseconddevm_kmemdup()ThiscausesauseafterfreescenarioonUSBdisconnectofthereceiver:1.Thelastregisteredpowersupplyclassdevicegetsunregistered2.Thememoryfromthelastdevm_kmemdup()callgetsfreed,hidpp->battery.desc.propertiesnowpointstofreedmemory3.Thefirstregisteredpowersupplyclassdevicegetsunregistered,thisinvolvessendingaremoveueventtouserspacewhichinvokespower_supply_uevent()tofilltheueventdata4.power_supply_uevent()useshidpp->battery.desc.propertieswhichnowpointstofreedmemoryleadingtobacktraceslikethisone:Sep2220:01:35erickernel:BUG:unabletohandlepagefaultforaddress:ffffb2140e017f08...Sep2220:01:35erickernel:Workqueue:usb_hub_wqhub_eventSep2220:01:35erickernel:RIP:0010:power_supply_uevent+0xee/0x1d0...Sep2220:01:35erickernel:?asm_exc_page_fault+0x26/0x30Sep2220:01:35erickernel:?power_supply_uevent+0xee/0x1d0Sep2220:01:35erickernel:?power_supply_uevent+0x10d/0x1d0Sep2220:01:35erickernel:dev_uevent+0x10f/0x2d0Sep2220:01:35erickernel:kobject_ueven