linux-next: manual merge of the bpf-next tree with the net-next tree

From: Stephen Rothwell
Date: Sun Nov 24 2019 - 18:58:57 EST


Hi all,

Today's linux-next merge of the bpf-next tree got a conflict in:

kernel/bpf/syscall.c

between commit:

84bb46cd6228 ("Revert "bpf: Emit audit messages upon successful prog load and unload"")

from the net-next tree and commit:

8793e6b23b1e ("bpf: Move bpf_free_used_maps into sleepable section")

from the bpf-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

--
Cheers,
Stephen Rothwell

diff --cc kernel/bpf/syscall.c
index 4ae52eb05f41,bb002f15b32a..000000000000
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@@ -23,14 -23,16 +23,15 @@@
#include <linux/timekeeping.h>
#include <linux/ctype.h>
#include <linux/nospec.h>
-#include <linux/audit.h>
#include <uapi/linux/btf.h>

- #define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \
- (map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
- (map)->map_type == BPF_MAP_TYPE_CGROUP_ARRAY || \
- (map)->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS)
+ #define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
+ (map)->map_type == BPF_MAP_TYPE_CGROUP_ARRAY || \
+ (map)->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS)
+ #define IS_FD_PROG_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY)
#define IS_FD_HASH(map) ((map)->map_type == BPF_MAP_TYPE_HASH_OF_MAPS)
- #define IS_FD_MAP(map) (IS_FD_ARRAY(map) || IS_FD_HASH(map))
+ #define IS_FD_MAP(map) (IS_FD_ARRAY(map) || IS_FD_PROG_ARRAY(map) || \
+ IS_FD_HASH(map))

#define BPF_OBJ_FLAG_MASK (BPF_F_RDONLY | BPF_F_WRONLY)

@@@ -1302,25 -1307,34 +1306,6 @@@ static int find_prog_type(enum bpf_prog
return 0;
}

- /* drop refcnt on maps used by eBPF program and free auxilary data */
- static void free_used_maps(struct bpf_prog_aux *aux)
- {
- enum bpf_cgroup_storage_type stype;
- int i;
-enum bpf_event {
- BPF_EVENT_LOAD,
- BPF_EVENT_UNLOAD,
-};
--
- for_each_cgroup_storage_type(stype) {
- if (!aux->cgroup_storage[stype])
- continue;
- bpf_cgroup_storage_release(aux->prog,
- aux->cgroup_storage[stype]);
- }
-static const char * const bpf_event_audit_str[] = {
- [BPF_EVENT_LOAD] = "LOAD",
- [BPF_EVENT_UNLOAD] = "UNLOAD",
-};
--
- for (i = 0; i < aux->used_map_cnt; i++)
- bpf_map_put(aux->used_maps[i]);
-static void bpf_audit_prog(const struct bpf_prog *prog, enum bpf_event event)
-{
- bool has_task_context = event == BPF_EVENT_LOAD;
- struct audit_buffer *ab;
--
- kfree(aux->used_maps);
- if (audit_enabled == AUDIT_OFF)
- return;
- ab = audit_log_start(audit_context(), GFP_ATOMIC, AUDIT_BPF);
- if (unlikely(!ab))
- return;
- if (has_task_context)
- audit_log_task(ab);
- audit_log_format(ab, "%sprog-id=%u event=%s",
- has_task_context ? " " : "",
- prog->aux->id, bpf_event_audit_str[event]);
- audit_log_end(ab);
--}
--
int __bpf_prog_charge(struct user_struct *user, u32 pages)
{
unsigned long memlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;

Attachment: pgpjO9Kir29ow.pgp
Description: OpenPGP digital signature