Patch "bpf: Fix kfunc callback register type handling" has been added to the 6.6-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: Fix kfunc callback register type handling

to the 6.6-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-fix-kfunc-callback-register-type-handling.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 721eac1d82245da2733675f434629f920af9f542
Author: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
Date:   Wed Sep 13 01:32:10 2023 +0200

    bpf: Fix kfunc callback register type handling
    
    [ Upstream commit 06d686f771ddc27a8554cd8f5b22e071040dc90e ]
    
    The kfunc code to handle KF_ARG_PTR_TO_CALLBACK does not check the reg
    type before using reg->subprogno. This can accidently permit invalid
    pointers from being passed into callback helpers (e.g. silently from
    different paths). Likewise, reg->subprogno from the per-register type
    union may not be meaningful either. We need to reject any other type
    except PTR_TO_FUNC.
    
    Acked-by: Dave Marchevsky <davemarchevsky@xxxxxx>
    Fixes: 5d92ddc3de1b ("bpf: Add callback validation to kfunc verifier logic")
    Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230912233214.1518551-14-memxor@xxxxxxxxx
    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 9f180ae74e492..82c9e5c470319 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -11202,6 +11202,10 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_
 			break;
 		}
 		case KF_ARG_PTR_TO_CALLBACK:
+			if (reg->type != PTR_TO_FUNC) {
+				verbose(env, "arg%d expected pointer to func\n", i);
+				return -EINVAL;
+			}
 			meta->subprogno = reg->subprogno;
 			break;
 		case KF_ARG_PTR_TO_REFCOUNTED_KPTR:



[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