linux_dsm_epyc7002/include/uapi
Daniel Borkmann 05c74e5e53 bpf: add bpf_skb_load_bytes helper
When hacking tc programs with eBPF, one of the issues that come up
from time to time is to load addresses from headers. In eBPF as in
classic BPF, we have BPF_LD | BPF_ABS | BPF_{B,H,W} instructions that
extract a byte, half-word or word out of the skb data though helpers
such as bpf_load_pointer() (interpreter case).

F.e. extracting a whole IPv6 address could possibly look like ...

  union v6addr {
    struct {
      __u32 p1;
      __u32 p2;
      __u32 p3;
      __u32 p4;
    };
    __u8 addr[16];
  };

  [...]

  a.p1 = htonl(load_word(skb, off));
  a.p2 = htonl(load_word(skb, off +  4));
  a.p3 = htonl(load_word(skb, off +  8));
  a.p4 = htonl(load_word(skb, off + 12));

  [...]

  /* access to a.addr[...] */

This work adds a complementary helper bpf_skb_load_bytes() (we also
have bpf_skb_store_bytes()) as an alternative where the same call
would look like from an eBPF program:

  ret = bpf_skb_load_bytes(skb, off, addr, sizeof(addr));

Same verifier restrictions apply as in ffeedafbf0 ("bpf: introduce
current->pid, tgid, uid, gid, comm accessors") case, where stack memory
access needs to be statically verified and thus guaranteed to be
initialized in first use (otherwise verifier cannot tell whether a
subsequent access to it is valid or not as it's runtime dependent).

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-18 16:04:50 -05:00
..
asm-generic mm: mlock: add mlock flags to enable VM_LOCKONFAULT usage 2015-11-05 19:34:48 -08:00
drm Merge tag 'topic/drm-fixes-2015-11-11' of git://anongit.freedesktop.org/drm-intel into drm-fixes 2015-11-13 09:54:31 +10:00
linux bpf: add bpf_skb_load_bytes helper 2015-12-18 16:04:50 -05:00
misc cxl: Add alternate MMIO error handling 2015-08-18 19:34:43 +10:00
mtd mtd: mtd-user: remove stdint.h include 2015-10-19 18:19:06 -07:00
rdma Initial 4.4 merge window submission 2015-11-07 13:33:07 -08:00
scsi cxlflash: Virtual LUN support 2015-08-26 18:05:39 -07:00
sound ASoC: Updates for v4.4 2015-10-26 12:14:49 +01:00
video
xen xen/gntdev: use types from linux/types.h in userspace headers 2015-10-23 14:20:45 +01:00
Kbuild