Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
[linux-block.git] / kernel / bpf / syscall.c
index 27760627370db821a5fc2741f73130e4e2bedb2f..4fb08c43420d19fd9e5c59bcd8800494e3d5fc01 100644 (file)
@@ -638,7 +638,10 @@ static void __bpf_map_put(struct bpf_map *map, bool do_idr_lock)
                bpf_map_free_id(map, do_idr_lock);
                btf_put(map->btf);
                INIT_WORK(&map->work, bpf_map_free_deferred);
-               schedule_work(&map->work);
+               /* Avoid spawning kworkers, since they all might contend
+                * for the same mutex like slab_mutex.
+                */
+               queue_work(system_unbound_wq, &map->work);
        }
 }
 
@@ -1437,9 +1440,9 @@ err_put:
 
 #define BPF_MAP_DELETE_ELEM_LAST_FIELD key
 
-static int map_delete_elem(union bpf_attr *attr)
+static int map_delete_elem(union bpf_attr *attr, bpfptr_t uattr)
 {
-       void __user *ukey = u64_to_user_ptr(attr->key);
+       bpfptr_t ukey = make_bpfptr(attr->key, uattr.is_kernel);
        int ufd = attr->map_fd;
        struct bpf_map *map;
        struct fd f;
@@ -1459,7 +1462,7 @@ static int map_delete_elem(union bpf_attr *attr)
                goto err_put;
        }
 
-       key = __bpf_copy_key(ukey, map->key_size);
+       key = ___bpf_copy_key(ukey, map->key_size);
        if (IS_ERR(key)) {
                err = PTR_ERR(key);
                goto err_put;
@@ -4941,7 +4944,7 @@ static int __sys_bpf(int cmd, bpfptr_t uattr, unsigned int size)
                err = map_update_elem(&attr, uattr);
                break;
        case BPF_MAP_DELETE_ELEM:
-               err = map_delete_elem(&attr);
+               err = map_delete_elem(&attr, uattr);
                break;
        case BPF_MAP_GET_NEXT_KEY:
                err = map_get_next_key(&attr);
@@ -5073,8 +5076,10 @@ BPF_CALL_3(bpf_sys_bpf, int, cmd, union bpf_attr *, attr, u32, attr_size)
 {
        switch (cmd) {
        case BPF_MAP_CREATE:
+       case BPF_MAP_DELETE_ELEM:
        case BPF_MAP_UPDATE_ELEM:
        case BPF_MAP_FREEZE:
+       case BPF_MAP_GET_FD_BY_ID:
        case BPF_PROG_LOAD:
        case BPF_BTF_LOAD:
        case BPF_LINK_CREATE: