• C
    livepatch/arm64: fix sleeping function called from invalid context by use kzalloc · 96bdd177
    Cheng Jian 提交于
    euler inclusion
    category: bugfix
    Bugzilla: 5507/5072
    CVE: N/A
    
    ----------------------------------------
    
    we use arch__klp_enable_func in atomic context to patched instruction
    	arch__klp_enable_func
    		-=>	kzalloc(XXX, GFP_KERNEL)
    but it might_sleep here, when we enale an livepatch module, cause crash,
    use GFP_ATOMIC instead of GFP_KERNEL
    
    the call trace is like:
    
    livepatch: enabling patch 'klp_testEL_HOTPATCH_ADDFUNTOMULTIFILE_FUN_001'
    BUG: sleeping function called from invalid context at mm/slub.c:1287
    in_atomic(): 1, irqs_disabled(): 128, pid: 13, name: migration/1
    Preemption disabled at:[<ffffffc0002397b4>] smpboot_thread_fn+0x27c/0x2a4
    
    CPU: 1 PID: 13 Comm: migration/1 Tainted: G        W  O  K 4.4.159+ #3
    Hardware name: hisilicon,hi1213-fpga (DT)
    Call trace:
    [<ffffffc000207f88>] dump_backtrace+0x0/0x13c
    [<ffffffc0002080e8>] show_stack+0x24/0x30
    [<ffffffc00041d338>] dump_stack+0x90/0xb0
    [<ffffffc00023db1c>] ___might_sleep+0x18c/0x19c
    [<ffffffc00023dbac>] __might_sleep+0x80/0x90
    [<ffffffc0003251d4>] kmem_cache_alloc_trace+0x60/0x248
    [<ffffffc000211f28>] arch__klp_enable_func+0x70/0x144
    [<ffffffc0002726a8>] klp_try_enable_patch+0x114/0x1e0
    [<ffffffc0002a25c0>] multi_cpu_stop+0xb0/0x104
    [<ffffffc0002a2828>] cpu_stopper_thread+0xa0/0x130
    [<ffffffc0002397b4>] smpboot_thread_fn+0x27c/0x2a4
    [<ffffffc000235e90>] kthread+0x114/0x11c
    [<ffffffc000203dd0>] ret_from_fork+0x10/0x40
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    Reviewed-by: NLi Bin <huawei.libin@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    96bdd177
livepatch.c 7.3 KB