• C
    livepatch/arm64: fix arch specific alternative section · 2137a1eb
    Cheng Jian 提交于
    hulk inclusion
    category: bugfix
    bugzilla: 5507
    CVE: NA
    
    ----------------------------------------------
    
    Override arch_klp_init_object_loaded() to perform additional
    arch-specific tasks when a target module loads, such as applying
    arch-specific sections. On arm64, we must apply per-object
    .altinstructions sections when a target module loads.
    
    These sections are prefixed with ".klp.arch.$objname.$secname",
    so that they can be easily identified when iterating through
    a patch module's Elf sections.
    
    Fix next calltrace:
    	livepatch: enabling patch 'livepatch_0001_test_per_cpu_cmdline'
    	Unable to handle kernel paging request at virtual address ffff34dc4663e018
    	pc : cmdline_proc_show+0x24/0xc40 [livepatch_0001_test_per_cpu_cmdline]
    	lr : seq_read+0xd4/0x4a8
    	sp : ffff0000d0a73c30
    	Call trace:
    	  cmdline_proc_show+0x24/0xc40 [livepatch_0001_test_per_cpu_cmdline]
    	  seq_read+0xd4/0x4a8
    	  proc_reg_read+0x80/0xd8
    	  __vfs_read+0x60/0x188
    	  vfs_read+0x94/0x150
    	  ksys_read+0x74/0xf0
    	  __arm64_sys_read+0x24/0x30
    	  el0_svc_common+0xa0/0x180
    	  el0_svc_handler+0x38/0x78
    	  el0_svc+0x8/0xc
    	  Code: d503201f f0274aa2 91006042 d538d083 (b8636842)
    	---[ end trace 1256914246c5a0cf ]---
    
    Testcase livepatch code:
    	fs/proc/cmdline.c
    	static int cmdline_proc_show(struct seq_file *m, void *v)
    	{
    	+	seq_printf(m, "[%d] ", raw_smp_processor_id());
    		seq_puts(m, saved_command_line);
    			seq_putc(m, '\n');
    				return 0;
    	}
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    Reviewed-by: NBin Li <huawei.libin@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    2137a1eb
livepatch.c 9.7 KB