Patch "selftests/bpf: Avoid running unprivileged tests with alignment requirements" has been added to the 5.4-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

    selftests/bpf: Avoid running unprivileged tests with alignment requirements

to the 5.4-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:
     selftests-bpf-avoid-running-unprivileged-tests-with-.patch
and it can be found in the queue-5.4 subdirectory.

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



commit 7f4979bc30e7e18e52f05d39eb1b6b37518fcf25
Author: Björn Töpel <bjorn@xxxxxxxxxx>
Date:   Wed Nov 18 08:16:39 2020 +0100

    selftests/bpf: Avoid running unprivileged tests with alignment requirements
    
    [ Upstream commit c77b0589ca29ad1859fe7d7c1ecd63c0632379fa ]
    
    Some architectures have strict alignment requirements. In that case,
    the BPF verifier detects if a program has unaligned accesses and
    rejects them. A user can pass BPF_F_ANY_ALIGNMENT to a program to
    override this check. That, however, will only work when a privileged
    user loads a program. An unprivileged user loading a program with this
    flag will be rejected prior entering the verifier.
    
    Hence, it does not make sense to load unprivileged programs without
    strict alignment when testing the verifier. This patch avoids exactly
    that.
    
    Signed-off-by: Björn Töpel <bjorn.topel@xxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Acked-by: Luke Nelson <luke.r.nels@xxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20201118071640.83773-3-bjorn.topel@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 43224c5ec1e9b..1bd285dc55e94 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1091,6 +1091,19 @@ static void get_unpriv_disabled()
 
 static bool test_as_unpriv(struct bpf_test *test)
 {
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+	/* Some architectures have strict alignment requirements. In
+	 * that case, the BPF verifier detects if a program has
+	 * unaligned accesses and rejects them. A user can pass
+	 * BPF_F_ANY_ALIGNMENT to a program to override this
+	 * check. That, however, will only work when a privileged user
+	 * loads a program. An unprivileged user loading a program
+	 * with this flag will be rejected prior entering the
+	 * verifier.
+	 */
+	if (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)
+		return false;
+#endif
 	return !test->prog_type ||
 	       test->prog_type == BPF_PROG_TYPE_SOCKET_FILTER ||
 	       test->prog_type == BPF_PROG_TYPE_CGROUP_SKB;




[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