• S
    efi: Make efi_rts_work accessible to efi page fault handler · 95fc4624
    Sai Praneeth 提交于
    [ Upstream commit 9dbbedaa6171247c4c7c40b83f05b200a117c2e0 ]
    
    After the kernel has booted, if any accesses by firmware causes a page
    fault, the efi page fault handler would freeze efi_rts_wq and schedules
    a new process. To do this, the efi page fault handler needs
    efi_rts_work. Hence, make it accessible.
    
    There will be no race conditions in accessing this structure, because
    all the calls to efi runtime services are already serialized.
    
    [ Wen: This patch also fixes a memory corruption:
           #define efi_queue_work(_rts, _arg1, _arg2, _arg3, _arg4, _arg5)\
           ({                                                             \
            struct efi_runtime_work efi_rts_work;                           \
           …
            init_completion(&efi_rts_work.efi_rts_comp);                    \
            INIT_WORK(&efi_rts_work.work, efi_call_rts);                    \
           …
    
           efi_rts_work is on the stack, registering it to workqueue will cause
           the following error:
    
           ODEBUG: object (____ptrval____) is on stack (____ptrval____),
           but NOT annotated.
           ------------[ cut here ]------------
           WARNING: CPU: 6 PID: 1 at lib/debugobjects.c:368
           __debug_object_init+0x218/0x538
           Modules linked in:
           CPU: 6 PID: 1 Comm: swapper/0 Tainted: G        W         4.19.91 #19
           …
           Call trace:
           __debug_object_init+0x218/0x538
           debug_object_init+0x20/0x28
           __init_work+0x34/0x58
           virt_efi_get_time.part.5+0x6c/0x12c
           virt_efi_get_time+0x4c/0x58
           efi_read_time+0x40/0x9c
           __rtc_read_time+0x50/0x118
           rtc_read_time+0x60/0x1f0
           rtc_hctosys+0x74/0x124
           do_one_initcall+0xac/0x3d4
           kernel_init_freeable+0x49c/0x59c
           kernel_init+0x18/0x110 ]
    Tested-by: NBhupesh Sharma <bhsharma@redhat.com>
    Suggested-by: NMatt Fleming <matt@codeblueprint.co.uk>
    Based-on-code-from: Ricardo Neri <ricardo.neri@intel.com>
    Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
    Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
    Fixes: 3eb420e7 ("efi: Use a work queue to invoke EFI Runtime Services")
    Signed-off-by: NWen Yang <wenyang@linux.alibaba.com>
    Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
    95fc4624
efi.h 49.5 KB