]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
powerpc/64: Convert patch_instruction() to patch_u32()
authorBenjamin Gray <bgray@linux.ibm.com>
Wed, 15 May 2024 02:44:43 +0000 (12:44 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 21 Aug 2024 10:15:13 +0000 (20:15 +1000)
This use of patch_instruction() is working on 32 bit data, and can fail
if the data looks like a prefixed instruction and the extra write
crosses a page boundary. Use patch_u32() to fix the write size.

Fixes: 8734b41b3efe ("powerpc/module_64: Fix livepatching for RO modules")
Link: https://lore.kernel.org/all/20230203004649.1f59dbd4@yea/
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Tested-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Naveen N Rao <naveen@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240515024445.236364-4-bgray@linux.ibm.com
arch/powerpc/kernel/module_64.c

index 7112adc597a80bd3975c8e076494cc0a56c72263..e9bab599d0c2745e4d2b5cae04f2c56395c24654 100644 (file)
@@ -651,12 +651,11 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
        // func_desc_t is 8 bytes if ABIv2, else 16 bytes
        desc = func_desc(addr);
        for (i = 0; i < sizeof(func_desc_t) / sizeof(u32); i++) {
-               if (patch_instruction(((u32 *)&entry->funcdata) + i,
-                                     ppc_inst(((u32 *)(&desc))[i])))
+               if (patch_u32(((u32 *)&entry->funcdata) + i, ((u32 *)&desc)[i]))
                        return 0;
        }
 
-       if (patch_instruction(&entry->magic, ppc_inst(STUB_MAGIC)))
+       if (patch_u32(&entry->magic, STUB_MAGIC))
                return 0;
 
        return 1;