Patch "s390/bpf: Fix clobbering the caller's backchain in the trampoline" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    s390/bpf: Fix clobbering the caller's backchain in the trampoline

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     s390-bpf-fix-clobbering-the-caller-s-backchain-in-th.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ba9735e804bd6e7ae8a50f1349a5531547420260
Author: Ilya Leoshkevich <iii@xxxxxxxxxxxxx>
Date:   Tue Oct 10 22:20:09 2023 +0200

    s390/bpf: Fix clobbering the caller's backchain in the trampoline
    
    [ Upstream commit ce10fc0604bc6a0d626ed8e5d69088057edc71ab ]
    
    One of the first things that s390x kernel functions do is storing the
    the caller's frame address (backchain) on stack. This makes unwinding
    possible. The backchain is always stored at frame offset 152, which is
    inside the 160-byte stack area, that the functions allocate for their
    callees. The callees must preserve the backchain; the remaining 152
    bytes they may use as they please.
    
    Currently the trampoline uses all 160 bytes, clobbering the backchain.
    This causes kernel panics when using __builtin_return_address() in
    functions called by the trampoline.
    
    Fix by reducing the usage of the caller-reserved stack area by 8 bytes
    in the trampoline.
    
    Fixes: 528eb2cb87bc ("s390/bpf: Implement arch_prepare_bpf_trampoline()")
    Reported-by: Song Liu <song@xxxxxxxxxx>
    Signed-off-by: Ilya Leoshkevich <iii@xxxxxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20231010203512.385819-2-iii@xxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 2861e3360affc..9a9733e4bc801 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -2260,8 +2260,12 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
 	tjit->run_ctx_off = alloc_stack(tjit,
 					sizeof(struct bpf_tramp_run_ctx));
 	tjit->tccnt_off = alloc_stack(tjit, sizeof(u64));
-	/* The caller has already reserved STACK_FRAME_OVERHEAD bytes. */
-	tjit->stack_size -= STACK_FRAME_OVERHEAD;
+	/*
+	 * In accordance with the s390x ABI, the caller has allocated
+	 * STACK_FRAME_OVERHEAD bytes for us. 8 of them contain the caller's
+	 * backchain, and the rest we can use.
+	 */
+	tjit->stack_size -= STACK_FRAME_OVERHEAD - sizeof(u64);
 	tjit->orig_stack_args_off = tjit->stack_size + STACK_FRAME_OVERHEAD;
 
 	/* aghi %r15,-stack_size */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux