Patch "bpf: disallow attaching modify_return tracing functions to other BPF programs" has been added to the 5.8-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

    bpf: disallow attaching modify_return tracing functions to other BPF programs

to the 5.8-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:
     bpf-disallow-attaching-modify_return-tracing-functio.patch
and it can be found in the queue-5.8 subdirectory.

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



commit c1fe1cb5873ca1c260cccb05be97014a3bb35352
Author: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
Date:   Fri Sep 25 23:25:00 2020 +0200

    bpf: disallow attaching modify_return tracing functions to other BPF programs
    
    [ Upstream commit 1af9270e908cd50a4f5d815c9b6f794c7d57ed07 ]
    
    From the checks and commit messages for modify_return, it seems it was
    never the intention that it should be possible to attach a tracing program
    with expected_attach_type == BPF_MODIFY_RETURN to another BPF program.
    However, check_attach_modify_return() will only look at the function name,
    so if the target function starts with "security_", the attach will be
    allowed even for bpf2bpf attachment.
    
    Fix this oversight by also blocking the modification if a target program is
    supplied.
    
    Fixes: 18644cec714a ("bpf: Fix use-after-free in fmod_ret check")
    Fixes: 6ba43b761c41 ("bpf: Attachment verification for BPF_MODIFY_RETURN")
    Acked-by: Andrii Nakryiko <andriin@xxxxxx>
    Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 89b07db146763..c953dfbbaa6a9 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -10862,6 +10862,11 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
 		}
 
 		if (prog->expected_attach_type == BPF_MODIFY_RETURN) {
+			if (tgt_prog) {
+				verbose(env, "can't modify return codes of BPF programs\n");
+				ret = -EINVAL;
+				goto out;
+			}
 			ret = check_attach_modify_return(prog, addr);
 			if (ret)
 				verbose(env, "%s() is not modifiable\n",



[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