OSDN Git Service

bpf: Add file mode configuration into bpf maps
authorChenbo Feng <fengc@google.com>
Wed, 18 Oct 2017 20:00:22 +0000 (13:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Oct 2017 12:32:59 +0000 (13:32 +0100)
commit6e71b04a82248ccf13a94b85cbc674a9fefe53f5
tree45cab2ff677b04d921a2813738dc1ada8c07eaec
parentaec72f3392b1d598a979e89c4fdb131965ae0ab3
bpf: Add file mode configuration into bpf maps

Introduce the map read/write flags to the eBPF syscalls that returns the
map fd. The flags is used to set up the file mode when construct a new
file descriptor for bpf maps. To not break the backward capability, the
f_flags is set to O_RDWR if the flag passed by syscall is 0. Otherwise
it should be O_RDONLY or O_WRONLY. When the userspace want to modify or
read the map content, it will check the file mode to see if it is
allowed to make the change.

Signed-off-by: Chenbo Feng <fengc@google.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/arraymap.c
kernel/bpf/devmap.c
kernel/bpf/hashtab.c
kernel/bpf/inode.c
kernel/bpf/lpm_trie.c
kernel/bpf/sockmap.c
kernel/bpf/stackmap.c
kernel/bpf/syscall.c
net/netfilter/xt_bpf.c