"value":"In the Linux kernel, the following vulnerability has been resolved:\n\narm64: ftrace: consistently handle PLTs.\n\nSometimes it is necessary to use a PLT entry to call an ftrace\ntrampoline. This is handled by ftrace_make_call() and ftrace_make_nop(),\nwith each having *almost* identical logic, but this is not handled by\nftrace_modify_call() since its introduction in commit:\n\n 3b23e4991fb66f6d (\"arm64: implement ftrace with regs\")\n\nDuetothis,ifweeverweretocallftrace_modify_call()foracallsite\nwhichrequiresaPLTentryforatrampoline,theneither:\n\na)Iftheoldaddrrequiresatrampoline,ftrace_modify_call()willuse\nanout-of-rangeaddresstogeneratethe'old'branchinstruction.\nThiswillresultinwarningsfromaarch64_insn_gen_branch_imm()and\nftrace_modify_code(),andnoinstructionswillbemodified.As\nftrace_modify_call()willreturnanerror,thiswillresultin\nsubsequentinternalftraceerrors.\n\nb)Iftheoldaddrdoesnotrequireatrampoline,butthenewaddrdoes,\nftrace_modify_call()willuseanout-of-rangeaddresstogeneratethe\n'new'branchinstruction.Thiswillresultinwarningsfrom\naarch64_insn_gen_branch_imm(),andftrace_modify_code()willreplace\nthe'old'branchwithaBRK.Thiswillresultinakernelpanicwhen\nthisBRKislaterexecuted.\n\nPracticallyspeaking,case(a)isvastlymorelikelythancase(b),and\ntypicallythiswillresultininternalftraceerrorsthatdon't\nnecessarilyaffecttherestofthesystem.Thiscanbedemonstratedwith\nanout-of-treetestmodulewhichtriggersftrace_modify_call(),e.g.\n\n|#insmodtest_ftrace.ko\n|test_ftrace:Functiontest_functionraw=0xffffb3749399201c,callsite=0xffffb37493992024\n|branch_imm_common:offsetoutofrange\n|branch_imm_common:offsetoutofrange\n|------------[ftracebug]------------\n|ftracefailedtomodify\n|[<ffffb37493992024>]test_function+0x8/0x38[test_ftrace]\n|actual:1d:00:00:94\n|Updatingftracecallsitetocalladifferentftracefunction\n|ftracerecordflags:e0000002\n|(2)R\n|expectedtramp:ffffb374ae42ed54\n|------------[cuthere]------------\n|WARNING:CPU:0PID:165atkernel/trace/ftrace.c:2085ftrace_bug+0x280/0x2b0\n|Moduleslinkedin:test_ftrace(+)\n|CPU:0PID:165Comm:insmodNottainted5.19.0-rc2-00002-g4d9ead8b45ce#13\n|Hardwarename:linux,dummy-virt(DT)\n|pstate:60400005(nZCvdaif+PAN-UAO-TCO-DIT-SSBSBTYPE=--)\n|pc:ftrace_bug+0x280/0x2b0\n|lr:ftrace_bug+0x280/0x2b0\n|sp:ffff80000839ba00\n|x29:ffff80000839ba00x28:0000000000000000x27:ffff80000839bcf0\n|x26:ffffb37493994180x25:ffffb374b0991c28x24:ffffb374b0d70000\n|x23:00000000ffffffeax22:ffffb374afcc33b0x21:ffffb374b08f9cc8\n|x20:ffff572b8462c000x19:ffffb374b08f9000x18:ffffffffffffffff\n|x17:6c6c6163202c6331x16:ffffb374ae5ad110x15:ffffb374b0d51ee4\n|x14:0000000000000000x13:3435646532346561x12:3437336266666666\n|x11:203a706d61727420x10:6465746365707865x9:ffffb374ae5149e8\n|x8:336266666666203ax7:706d617274206465x6:00000000fffff167\n|x5:ffff572bffbc4a08x4:00000000fffff167x3:0000000000000000\n|x2:0000000000000000x1:ffff572b84461e00x0:0000000000000022\n|Calltrace:\n|ftrace_bug+0x280/0x2b0\n|ftrace_replace_code+0x98/0xa0\n|ftrace_modify_all_code+0xe0/0x144\n|arch_ftrace_update_code+0x14/0x20\n|ftrace_startup+0xf8/0x1b0\n|register_ftrace_function+0x38/0x90\n|test_ftrace_init+0xd0/0x1000[test_ftrace]\n|do_one_initcall+0x50/0x2b0\n|do_init_module+0x50/0x1f0\n|load_module+0x17c8/0x1d64\n|__do_sys_finit_module+0xa8/0x100\n|__arm64_sys_finit_module+0x2c/0x3c\n|invoke_syscall+0x50/0x120\n|el0_svc_common.constprop.0+0xdc/0x100\n|do_el0_svc+0x3c/0xd0\n|el0_svc+0x34/0xb0\n|el0t_64_sync_handler+0xbc/0x140\n|el0t_64_sync+0x18c/0x190\n|---[endtrace0000000000000000]---\n\nWecansolvethisbyconsistentlydeterminingwhethertouseaPLTentry\nforanaddress.\n\nNotethatsince(theearlier)commit:\n\nf1a54ae9\n---
"value":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: arm64: ftrace: gestiona PLT de manera consistente. A veces es necesario usar una entrada PLT para llamar a un trampol\u00edn ftrace. Esto lo gestionan ftrace_make_call() y ftrace_make_nop(), y cada uno tiene una l\u00f3gica *casi* id\u00e9ntica, pero esto no lo maneja ftrace_modify_call() desde su introducci\u00f3n en el commit: 3b23e4991fb66f6d (\"arm64: implement ftrace with regs\") Debido a esto, si alguna vez llam\u00e1ramos a ftrace_modify_call() para un sitio de llamada que requiere una entrada PLT para un trampol\u00edn, entonces: a) Si la direcci\u00f3n anterior requiere un trampol\u00edn, ftrace_modify_call() usar\u00e1 una direcci\u00f3n fuera de rango para generar la instrucci\u00f3n de rama \"anterior\".Estodar\u00e1comoresultadoadvertenciasdeaarch64_insn_gen_branch_imm()yftrace_modify_code(),ynosemodificar\u00e1ningunainstrucci\u00f3n.Comoftrace_modify_call()devolver\u00e1unerror,estodar\u00e1comoresultadoerroresftraceinternosposteriores.b)Siladirecci\u00f3nanteriornorequiereuntrampol\u00edn,perolanuevas\u00ed,ftrace_modify_call()usar\u00e1unadirecci\u00f3nfueraderangoparagenerarlainstrucci\u00f3nderama'nueva'.Estodar\u00e1comoresultadoadvertenciasdeaarch64_insn_gen_branch_imm(),yftrace_modify_code()reemplazar\u00e1larama'antigua'conunBRK.Estodar\u00e1comoresultadounp\u00e1nicodelkernelcuandoesteBRKseejecutem\u00e1starde.Ent\u00e9rminospr\u00e1cticos,elcaso(a)esmuchom\u00e1sprobablequeelcaso(b),ynormalmenteestodar\u00e1comoresultadoerroresftraceinternosquenonecesariamenteafectanalrestodelsistema.Estosepuededemostrarconunm\u00f3dulodepruebafueradel\u00e1rbolqueactivaftrace_modify_call(),e.g.|#insmodtest_ftrace.ko|test_ftrace:Functiontest_functionraw=0xffffb3749399201c,callsite=0xffffb37493992024|branch_imm_common:offsetoutofrange|branch_imm_common:offsetoutofrange|------------[ftracebug]------------|ftracefailedtomodify|[]test_function+0x8/0x38[test_ftrace]|actual:1d:00:00:94|Updatingftracecallsitetocalladifferentftracefunction|ftracerecordflags:e0000002|(2)R|expectedtramp:ffffb374ae42ed54|------------[cuthere]------------|WARNING:CPU:0PID:165atkernel/trace/ftrace.c:2085ftrace_bug+0x280/0x2b0|Moduleslinkedin:test_ftrace(+)|CPU:0PID:165Comm:insmodNottainted5.19.0-rc2-00002-g4d9ead8b45ce#13|Hardwarename:linux,dummy-virt(DT)|pstate:60400005(nZCvdaif+PAN-UAO-TCO-DIT-SSBSBTYPE=--)|pc:ftrace_bug+0x280/0x2b0|lr:ftrace_bug+0x280/0x2b0|sp:ffff80000839ba00|x29:ffff80000839ba00x28:0000000000000000x27:ffff80000839bcf0|x26:ffffb37493994180x25:ffffb374b0991c28x24:ffffb374b0d70000|x23:00000000ffffffeax22:ffffb374afcc33b0x21:ffffb374b08f9cc8|x20:ffff572b8462c000x19:ffffb374b08f9000x18:ffffffffffffffff|x17:6c6c6163202c6331x16:ffffb374ae5ad110x15:ffffb374b0d51ee4|x14:0000000000000000x13:3435646532346561x12:3437336266666666|x11:203a706d61727420x10:6465746365707865x9:ffffb374ae5149e8|x8:336266666666203ax7:706d617274206465x6:00000000fffff167|x5:ffff572bffbc4a08x4:00000000fffff167x3:0000000000000000|x2:0000000000000000x1:ffff572b84461e00x0:0000000000000022|Calltrace:|ftrace_bug+0x280/0x2b0|ftrace_replace_code+0x98/0xa0|ftrace_modify_all_code+0xe0/0x144|arch_ftrace_update_code+0x14/0x20|ftrace_startup+0xf8/0x1b0|register_ftrace_function+0x38/0x90|test_ftrace_init+0xd0/0x1000[test_ftrace]|do_one_initcall+0x50/0x2b0|do_init_module+0x50/0x1f0|load_module+0x17c8/0x1d64|__do_sys_finit_module+0xa8/0x100|__arm64_sys_finit_module+0x2c/0x3c|invoke_syscall+0x50/0x120|el0_svc_common.constprop.0+0xdc/0x100|do_el0_svc+0x3c/0xd0|el0_svc+0x34/0xb0|el0t_64_sync_handler+0xbc/0x140|el0t_64_sync+0x18c/0x190|---[endtrace0000000000000000]---Podemosresolverestodeterminandodemaneraconsistente