]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Introduce ARG_PTR_TO_{INT,LONG} arg types
authorAndrey Ignatov <rdna@fb.com>
Mon, 18 Mar 2019 23:57:10 +0000 (16:57 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Apr 2019 20:54:59 +0000 (13:54 -0700)
commit45091ede66b59de1cd16c887ef4c1485d03a8dbf
treedfe95f1ef2311cd1426916df144922892135c9c1
parent51eb96805aa6c06643b9d544acd59ee882ebeb34
bpf: Introduce ARG_PTR_TO_{INT,LONG} arg types

Currently the way to pass result from BPF helper to BPF program is to
provide memory area defined by pointer and size: func(void *, size_t).

It works great for generic use-case, but for simple types, such as int,
it's overkill and consumes two arguments when it could use just one.

Introduce new argument types ARG_PTR_TO_INT and ARG_PTR_TO_LONG to be
able to pass result from helper to program via pointer to int and long
correspondingly: func(int *) or func(long *).

New argument types are similar to ARG_PTR_TO_MEM with the following
differences:
* they don't require corresponding ARG_CONST_SIZE argument, predefined
  access sizes are used instead (32bit for int, 64bit for long);
* it's possible to use more than one such an argument in a helper;
* provided pointers have to be aligned.

It's easy to introduce similar ARG_PTR_TO_CHAR and ARG_PTR_TO_SHORT
argument types. It's not done due to lack of use-case though.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
kernel/bpf/verifier.c