Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4e31cf0 authored by David S. Miller's avatar David S. Miller
Browse files


Daniel Borkmann says:

====================
pull-request: bpf-next 2018-03-03

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) Extend bpftool to build up CFG information of eBPF programs and add an
   option to dump this in DOT format such that this can later be used with
   DOT graphic tools (xdot, graphviz, etc) to visualize it. Part of the
   analysis performed is sub-program detection and basic-block partitioning,
   from Jiong.

2) Multiple enhancements for bpftool's batch mode, more specifically the
   parser now understands comments (#), continuation lines (\), and arguments
   enclosed between quotes. Also, allow to read from stdin via '-' as input
   file, all from Quentin.

3) Improve BPF kselftests by i) unifying the rlimit handling into a helper
   that is then used by all tests, and ii) add support for testing tail calls
   to test_verifier plus add tests covering all corner cases. The latter is
   especially useful for testing JITs, from Daniel.

4) Remove x64 JIT's bpf_flush_icache() since flush_icache_range() is a noop
   on x64, from Daniel.

5) Fix one more occasion in BPF samples where we do not detach the BPF program
   from the cgroup after completion, from Prashant.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b72c8a7e c51a6379
Loading
Loading
Loading
Loading
+2 −13
Original line number Original line Diff line number Diff line
@@ -11,10 +11,10 @@
#include <linux/netdevice.h>
#include <linux/netdevice.h>
#include <linux/filter.h>
#include <linux/filter.h>
#include <linux/if_vlan.h>
#include <linux/if_vlan.h>
#include <asm/cacheflush.h>
#include <linux/bpf.h>

#include <asm/set_memory.h>
#include <asm/set_memory.h>
#include <asm/nospec-branch.h>
#include <asm/nospec-branch.h>
#include <linux/bpf.h>


/*
/*
 * assembly code in arch/x86/net/bpf_jit.S
 * assembly code in arch/x86/net/bpf_jit.S
@@ -103,16 +103,6 @@ static int bpf_size_to_x86_bytes(int bpf_size)
#define X86_JLE 0x7E
#define X86_JLE 0x7E
#define X86_JG  0x7F
#define X86_JG  0x7F


static void bpf_flush_icache(void *start, void *end)
{
	mm_segment_t old_fs = get_fs();

	set_fs(KERNEL_DS);
	smp_wmb();
	flush_icache_range((unsigned long)start, (unsigned long)end);
	set_fs(old_fs);
}

#define CHOOSE_LOAD_FUNC(K, func) \
#define CHOOSE_LOAD_FUNC(K, func) \
	((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
	((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)


@@ -1266,7 +1256,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
		bpf_jit_dump(prog->len, proglen, pass + 1, image);
		bpf_jit_dump(prog->len, proglen, pass + 1, image);


	if (image) {
	if (image) {
		bpf_flush_icache(header, image + proglen);
		if (!prog->is_func || extra_pass) {
		if (!prog->is_func || extra_pass) {
			bpf_jit_binary_lock_ro(header);
			bpf_jit_binary_lock_ro(header);
		} else {
		} else {
+1 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ cleanup_and_exit()


	[ -n "$msg" ] && echo "ERROR: $msg"
	[ -n "$msg" ] && echo "ERROR: $msg"


	test_cgrp2_sock -d ${CGRP_MNT}/sockopts
	ip li del cgrp2_sock
	ip li del cgrp2_sock
	umount ${CGRP_MNT}
	umount ${CGRP_MNT}


+3 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,9 @@ function attach_bpf {
}
}


function cleanup {
function cleanup {
	if [ -d /tmp/cgroupv2/foo ]; then
		test_cgrp2_sock -d /tmp/cgroupv2/foo
	fi
	ip link del veth0b
	ip link del veth0b
	ip netns delete at_ns0
	ip netns delete at_ns0
	umount /tmp/cgroupv2
	umount /tmp/cgroupv2
+12 −6
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ MAP COMMANDS
=============
=============


|	**bpftool** **prog { show | list }** [*PROG*]
|	**bpftool** **prog { show | list }** [*PROG*]
|	**bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes**}]
|	**bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual**}]
|	**bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes**}]
|	**bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes**}]
|	**bpftool** **prog pin** *PROG* *FILE*
|	**bpftool** **prog pin** *PROG* *FILE*
|	**bpftool** **prog load** *OBJ* *FILE*
|	**bpftool** **prog load** *OBJ* *FILE*
@@ -39,12 +39,18 @@ DESCRIPTION
		  Output will start with program ID followed by program type and
		  Output will start with program ID followed by program type and
		  zero or more named attributes (depending on kernel version).
		  zero or more named attributes (depending on kernel version).


	**bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** }]
	**bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** }]
		  Dump eBPF instructions of the program from the kernel.
		  Dump eBPF instructions of the program from the kernel. By
		  If *FILE* is specified image will be written to a file,
		  default, eBPF will be disassembled and printed to standard
		  otherwise it will be disassembled and printed to stdout.
		  output in human-readable format. In this case, **opcodes**
		  controls if raw opcodes should be printed as well.


		  **opcodes** controls if raw opcodes will be printed.
		  If **file** is specified, the binary image will instead be
		  written to *FILE*.

		  If **visual** is specified, control flow graph (CFG) will be
		  built instead, and eBPF instructions will be presented with
		  CFG in DOT format, on standard output.


	**bpftool prog dump jited**  *PROG* [{ **file** *FILE* | **opcodes** }]
	**bpftool prog dump jited**  *PROG* [{ **file** *FILE* | **opcodes** }]
		  Dump jited image (host machine code) of the program.
		  Dump jited image (host machine code) of the program.
+9 −4
Original line number Original line Diff line number Diff line
@@ -147,7 +147,7 @@ _bpftool()


    # Deal with simplest keywords
    # Deal with simplest keywords
    case $prev in
    case $prev in
        help|key|opcodes)
        help|key|opcodes|visual)
            return 0
            return 0
            ;;
            ;;
        tag)
        tag)
@@ -224,8 +224,13 @@ _bpftool()
                            ;;
                            ;;
                    *)
                    *)
                        _bpftool_once_attr 'file'
                        _bpftool_once_attr 'file'
                        if _bpftool_search_list 'xlated'; then
                            COMPREPLY+=( $( compgen -W 'opcodes visual' -- \
                                "$cur" ) )
                        else
                            COMPREPLY+=( $( compgen -W 'opcodes' -- \
                            COMPREPLY+=( $( compgen -W 'opcodes' -- \
                                "$cur" ) )
                                "$cur" ) )
                        fi
                        return 0
                        return 0
                        ;;
                        ;;
                    esac
                    esac
Loading