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>
Showing
- include/linux/bpf.h 5 additions, 3 deletionsinclude/linux/bpf.h
- include/uapi/linux/bpf.h 6 additions, 0 deletionsinclude/uapi/linux/bpf.h
- kernel/bpf/arraymap.c 5 additions, 1 deletionkernel/bpf/arraymap.c
- kernel/bpf/devmap.c 4 additions, 1 deletionkernel/bpf/devmap.c
- kernel/bpf/hashtab.c 3 additions, 2 deletionskernel/bpf/hashtab.c
- kernel/bpf/inode.c 10 additions, 5 deletionskernel/bpf/inode.c
- kernel/bpf/lpm_trie.c 2 additions, 1 deletionkernel/bpf/lpm_trie.c
- kernel/bpf/sockmap.c 4 additions, 1 deletionkernel/bpf/sockmap.c
- kernel/bpf/stackmap.c 4 additions, 1 deletionkernel/bpf/stackmap.c
- kernel/bpf/syscall.c 78 additions, 10 deletionskernel/bpf/syscall.c
- net/netfilter/xt_bpf.c 1 addition, 1 deletionnet/netfilter/xt_bpf.c
Loading
Please register or sign in to comment