]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bpf: return long from bpf_map_ops funcs
authorJP Kobryn <inwardvessel@gmail.com>
Wed, 22 Mar 2023 19:47:54 +0000 (12:47 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 Jul 2023 10:16:56 +0000 (12:16 +0200)
BugLink: https://bugs.launchpad.net/bugs/2025067
[ Upstream commit d7ba4cc900bf1eea2d8c807c6b1fc6bd61f41237 ]

This patch changes the return types of bpf_map_ops functions to long, where
previously int was returned. Using long allows for bpf programs to maintain
the sign bit in the absence of sign extension during situations where
inlined bpf helper funcs make calls to the bpf_map_ops funcs and a negative
error is returned.

The definitions of the helper funcs are generated from comments in the bpf
uapi header at `include/uapi/linux/bpf.h`. The return type of these
helpers was previously changed from int to long in commit bdb7b79b4ce8. For
any case where one of the map helpers call the bpf_map_ops funcs that are
still returning 32-bit int, a compiler might not include sign extension
instructions to properly convert the 32-bit negative value a 64-bit
negative value.

For example:
bpf assembly excerpt of an inlined helper calling a kernel function and
checking for a specific error:

; err = bpf_map_update_elem(&mymap, &key, &val, BPF_NOEXIST);
  ...
  46: call   0xffffffffe103291c ; htab_map_update_elem
; if (err && err != -EEXIST) {
  4b: cmp    $0xffffffffffffffef,%rax ; cmp -EEXIST,%rax

kernel function assembly excerpt of return value from
`htab_map_update_elem` returning 32-bit int:

movl $0xffffffef, %r9d
...
movl %r9d, %eax

...results in the comparison:
cmp $0xffffffffffffffef, $0x00000000ffffffef

Fixes: bdb7b79b4ce8 ("bpf: Switch most helper return values from 32-bit int to 64-bit long")
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
Link: https://lore.kernel.org/r/20230322194754.185781-3-inwardvessel@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
21 files changed:
include/linux/bpf.h
include/linux/filter.h
kernel/bpf/arraymap.c
kernel/bpf/bloom_filter.c
kernel/bpf/bpf_cgrp_storage.c
kernel/bpf/bpf_inode_storage.c
kernel/bpf/bpf_struct_ops.c
kernel/bpf/bpf_task_storage.c
kernel/bpf/cpumap.c
kernel/bpf/devmap.c
kernel/bpf/hashtab.c
kernel/bpf/local_storage.c
kernel/bpf/lpm_trie.c
kernel/bpf/queue_stack_maps.c
kernel/bpf/reuseport_array.c
kernel/bpf/ringbuf.c
kernel/bpf/stackmap.c
kernel/bpf/verifier.c
net/core/bpf_sk_storage.c
net/core/sock_map.c
net/xdp/xskmap.c

index cf0d88109e3f9b31fff7206608826b916d0e382e..8f9ad2722a2bae18f05bddaa739c89acce6a8a37 100644 (file)
@@ -95,11 +95,11 @@ struct bpf_map_ops {
 
        /* funcs callable from userspace and from eBPF programs */
        void *(*map_lookup_elem)(struct bpf_map *map, void *key);
-       int (*map_update_elem)(struct bpf_map *map, void *key, void *value, u64 flags);
-       int (*map_delete_elem)(struct bpf_map *map, void *key);
-       int (*map_push_elem)(struct bpf_map *map, void *value, u64 flags);
-       int (*map_pop_elem)(struct bpf_map *map, void *value);
-       int (*map_peek_elem)(struct bpf_map *map, void *value);
+       long (*map_update_elem)(struct bpf_map *map, void *key, void *value, u64 flags);
+       long (*map_delete_elem)(struct bpf_map *map, void *key);
+       long (*map_push_elem)(struct bpf_map *map, void *value, u64 flags);
+       long (*map_pop_elem)(struct bpf_map *map, void *value);
+       long (*map_peek_elem)(struct bpf_map *map, void *value);
        void *(*map_lookup_percpu_elem)(struct bpf_map *map, void *key, u32 cpu);
 
        /* funcs called by prog_array and perf_event_array map */
@@ -138,7 +138,7 @@ struct bpf_map_ops {
        struct bpf_local_storage __rcu ** (*map_owner_storage_ptr)(void *owner);
 
        /* Misc helpers.*/
-       int (*map_redirect)(struct bpf_map *map, u64 key, u64 flags);
+       long (*map_redirect)(struct bpf_map *map, u64 key, u64 flags);
 
        /* map_meta_equal must be implemented for maps that can be
         * used as an inner map.  It is a runtime check to ensure
@@ -156,7 +156,7 @@ struct bpf_map_ops {
        int (*map_set_for_each_callback_args)(struct bpf_verifier_env *env,
                                              struct bpf_func_state *caller,
                                              struct bpf_func_state *callee);
-       int (*map_for_each_callback)(struct bpf_map *map,
+       long (*map_for_each_callback)(struct bpf_map *map,
                                     bpf_callback_t callback_fn,
                                     void *callback_ctx, u64 flags);
 
index ccc4a4a58c7273cac8a8be3555ba0c856c083957..b08ba0a643f8c13c6eaadd532aae2cd00940c223 100644 (file)
@@ -1503,9 +1503,9 @@ static inline bool bpf_sk_lookup_run_v6(struct net *net, int protocol,
 }
 #endif /* IS_ENABLED(CONFIG_IPV6) */
 
-static __always_inline int __bpf_xdp_redirect_map(struct bpf_map *map, u64 index,
-                                                 u64 flags, const u64 flag_mask,
-                                                 void *lookup_elem(struct bpf_map *map, u32 key))
+static __always_inline long __bpf_xdp_redirect_map(struct bpf_map *map, u64 index,
+                                                  u64 flags, const u64 flag_mask,
+                                                  void *lookup_elem(struct bpf_map *map, u32 key))
 {
        struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
        const u64 action_mask = XDP_ABORTED | XDP_DROP | XDP_PASS | XDP_TX;
index 4847069595569d96da96d2f59fdd1977e752c124..cb80bcc880b44931342f713871873d6191ac16e4 100644 (file)
@@ -307,8 +307,8 @@ static int array_map_get_next_key(struct bpf_map *map, void *key, void *next_key
 }
 
 /* Called from syscall or from eBPF program */
-static int array_map_update_elem(struct bpf_map *map, void *key, void *value,
-                                u64 map_flags)
+static long array_map_update_elem(struct bpf_map *map, void *key, void *value,
+                                 u64 map_flags)
 {
        struct bpf_array *array = container_of(map, struct bpf_array, map);
        u32 index = *(u32 *)key;
@@ -386,7 +386,7 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
 }
 
 /* Called from syscall or from eBPF program */
-static int array_map_delete_elem(struct bpf_map *map, void *key)
+static long array_map_delete_elem(struct bpf_map *map, void *key)
 {
        return -EINVAL;
 }
@@ -686,8 +686,8 @@ static const struct bpf_iter_seq_info iter_seq_info = {
        .seq_priv_size          = sizeof(struct bpf_iter_seq_array_map_info),
 };
 
-static int bpf_for_each_array_elem(struct bpf_map *map, bpf_callback_t callback_fn,
-                                  void *callback_ctx, u64 flags)
+static long bpf_for_each_array_elem(struct bpf_map *map, bpf_callback_t callback_fn,
+                                   void *callback_ctx, u64 flags)
 {
        u32 i, key, num_elems = 0;
        struct bpf_array *array;
@@ -847,7 +847,7 @@ int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
        return 0;
 }
 
-static int fd_array_map_delete_elem(struct bpf_map *map, void *key)
+static long fd_array_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_array *array = container_of(map, struct bpf_array, map);
        void *old_ptr;
index 48ee750849f25772ebe7f5cc325be53c509b33b0..b386a8fdf28cc19671a0d676deacf6765db0dc18 100644 (file)
@@ -41,7 +41,7 @@ static u32 hash(struct bpf_bloom_filter *bloom, void *value,
        return h & bloom->bitset_mask;
 }
 
-static int bloom_map_peek_elem(struct bpf_map *map, void *value)
+static long bloom_map_peek_elem(struct bpf_map *map, void *value)
 {
        struct bpf_bloom_filter *bloom =
                container_of(map, struct bpf_bloom_filter, map);
@@ -56,7 +56,7 @@ static int bloom_map_peek_elem(struct bpf_map *map, void *value)
        return 0;
 }
 
-static int bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags)
+static long bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags)
 {
        struct bpf_bloom_filter *bloom =
                container_of(map, struct bpf_bloom_filter, map);
@@ -73,12 +73,12 @@ static int bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags)
        return 0;
 }
 
-static int bloom_map_pop_elem(struct bpf_map *map, void *value)
+static long bloom_map_pop_elem(struct bpf_map *map, void *value)
 {
        return -EOPNOTSUPP;
 }
 
-static int bloom_map_delete_elem(struct bpf_map *map, void *value)
+static long bloom_map_delete_elem(struct bpf_map *map, void *value)
 {
        return -EOPNOTSUPP;
 }
@@ -177,8 +177,8 @@ static void *bloom_map_lookup_elem(struct bpf_map *map, void *key)
        return ERR_PTR(-EINVAL);
 }
 
-static int bloom_map_update_elem(struct bpf_map *map, void *key,
-                                void *value, u64 flags)
+static long bloom_map_update_elem(struct bpf_map *map, void *key,
+                                 void *value, u64 flags)
 {
        /* The eBPF program should use map_push_elem instead */
        return -EINVAL;
index 6cdf6d9ed91df912aeb7036b9e577129225f471e..d4a074247b64dbc4abf1f6a2400958939135055b 100644 (file)
@@ -100,8 +100,8 @@ static void *bpf_cgrp_storage_lookup_elem(struct bpf_map *map, void *key)
        return sdata ? sdata->data : NULL;
 }
 
-static int bpf_cgrp_storage_update_elem(struct bpf_map *map, void *key,
-                                         void *value, u64 map_flags)
+static long bpf_cgrp_storage_update_elem(struct bpf_map *map, void *key,
+                                        void *value, u64 map_flags)
 {
        struct bpf_local_storage_data *sdata;
        struct cgroup *cgroup;
@@ -132,7 +132,7 @@ static int cgroup_storage_delete(struct cgroup *cgroup, struct bpf_map *map)
        return 0;
 }
 
-static int bpf_cgrp_storage_delete_elem(struct bpf_map *map, void *key)
+static long bpf_cgrp_storage_delete_elem(struct bpf_map *map, void *key)
 {
        struct cgroup *cgroup;
        int err, fd;
index 05f4c66c9089f69a40365651d5d490bcb40313bf..a8afc656808b293739a6a6f7b75a626d36c452b8 100644 (file)
@@ -97,8 +97,8 @@ static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key)
        return sdata ? sdata->data : NULL;
 }
 
-static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
-                                        void *value, u64 map_flags)
+static long bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
+                                            void *value, u64 map_flags)
 {
        struct bpf_local_storage_data *sdata;
        struct file *f;
@@ -133,7 +133,7 @@ static int inode_storage_delete(struct inode *inode, struct bpf_map *map)
        return 0;
 }
 
-static int bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key)
+static long bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key)
 {
        struct file *f;
        int fd, err;
index ece9870cab68e5240fabd095f8773a1860bb8782..36c17271d38bd7bb20977eaae3e2c3c26ee51eb4 100644 (file)
@@ -349,8 +349,8 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_links *tlinks,
                                           model, flags, tlinks, NULL);
 }
 
-static int bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
-                                         void *value, u64 flags)
+static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
+                                          void *value, u64 flags)
 {
        struct bpf_struct_ops_map *st_map = (struct bpf_struct_ops_map *)map;
        const struct bpf_struct_ops *st_ops = st_map->st_ops;
@@ -524,7 +524,7 @@ unlock:
        return err;
 }
 
-static int bpf_struct_ops_map_delete_elem(struct bpf_map *map, void *key)
+static long bpf_struct_ops_map_delete_elem(struct bpf_map *map, void *key)
 {
        enum bpf_struct_ops_state prev_state;
        struct bpf_struct_ops_map *st_map;
index 1e486055a523dd206e306ca4775109b2d5b377d4..b29f0bf28fd1579bdbe99218923fbf0c9ea4f694 100644 (file)
@@ -127,8 +127,8 @@ out:
        return ERR_PTR(err);
 }
 
-static int bpf_pid_task_storage_update_elem(struct bpf_map *map, void *key,
-                                           void *value, u64 map_flags)
+static long bpf_pid_task_storage_update_elem(struct bpf_map *map, void *key,
+                                            void *value, u64 map_flags)
 {
        struct bpf_local_storage_data *sdata;
        struct task_struct *task;
@@ -180,7 +180,7 @@ static int task_storage_delete(struct task_struct *task, struct bpf_map *map,
        return 0;
 }
 
-static int bpf_pid_task_storage_delete_elem(struct bpf_map *map, void *key)
+static long bpf_pid_task_storage_delete_elem(struct bpf_map *map, void *key)
 {
        struct task_struct *task;
        unsigned int f_flags;
index e0b2d016f0bf996e44aab4c706ddbceb06cc95e5..d33785bedbe5d61c5febd2429536c91bc2228a07 100644 (file)
@@ -540,7 +540,7 @@ static void __cpu_map_entry_replace(struct bpf_cpu_map *cmap,
        }
 }
 
-static int cpu_map_delete_elem(struct bpf_map *map, void *key)
+static long cpu_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_cpu_map *cmap = container_of(map, struct bpf_cpu_map, map);
        u32 key_cpu = *(u32 *)key;
@@ -553,8 +553,8 @@ static int cpu_map_delete_elem(struct bpf_map *map, void *key)
        return 0;
 }
 
-static int cpu_map_update_elem(struct bpf_map *map, void *key, void *value,
-                              u64 map_flags)
+static long cpu_map_update_elem(struct bpf_map *map, void *key, void *value,
+                               u64 map_flags)
 {
        struct bpf_cpu_map *cmap = container_of(map, struct bpf_cpu_map, map);
        struct bpf_cpumap_val cpumap_value = {};
@@ -667,7 +667,7 @@ static int cpu_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
        return 0;
 }
 
-static int cpu_map_redirect(struct bpf_map *map, u64 index, u64 flags)
+static long cpu_map_redirect(struct bpf_map *map, u64 index, u64 flags)
 {
        return __bpf_xdp_redirect_map(map, index, flags, 0,
                                      __cpu_map_lookup_elem);
index d01e4c55b376a3a96a96c74b1ed92435d7f286ea..95dafde24ba9cc67f05f487370009b70344693ec 100644 (file)
@@ -799,7 +799,7 @@ static void __dev_map_entry_free(struct rcu_head *rcu)
        kfree(dev);
 }
 
-static int dev_map_delete_elem(struct bpf_map *map, void *key)
+static long dev_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
        struct bpf_dtab_netdev *old_dev;
@@ -814,7 +814,7 @@ static int dev_map_delete_elem(struct bpf_map *map, void *key)
        return 0;
 }
 
-static int dev_map_hash_delete_elem(struct bpf_map *map, void *key)
+static long dev_map_hash_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
        struct bpf_dtab_netdev *old_dev;
@@ -885,8 +885,8 @@ err_out:
        return ERR_PTR(-EINVAL);
 }
 
-static int __dev_map_update_elem(struct net *net, struct bpf_map *map,
-                                void *key, void *value, u64 map_flags)
+static long __dev_map_update_elem(struct net *net, struct bpf_map *map,
+                                 void *key, void *value, u64 map_flags)
 {
        struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
        struct bpf_dtab_netdev *dev, *old_dev;
@@ -925,15 +925,15 @@ static int __dev_map_update_elem(struct net *net, struct bpf_map *map,
        return 0;
 }
 
-static int dev_map_update_elem(struct bpf_map *map, void *key, void *value,
-                              u64 map_flags)
+static long dev_map_update_elem(struct bpf_map *map, void *key, void *value,
+                               u64 map_flags)
 {
        return __dev_map_update_elem(current->nsproxy->net_ns,
                                     map, key, value, map_flags);
 }
 
-static int __dev_map_hash_update_elem(struct net *net, struct bpf_map *map,
-                                    void *key, void *value, u64 map_flags)
+static long __dev_map_hash_update_elem(struct net *net, struct bpf_map *map,
+                                      void *key, void *value, u64 map_flags)
 {
        struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
        struct bpf_dtab_netdev *dev, *old_dev;
@@ -985,21 +985,21 @@ out_err:
        return err;
 }
 
-static int dev_map_hash_update_elem(struct bpf_map *map, void *key, void *value,
-                                  u64 map_flags)
+static long dev_map_hash_update_elem(struct bpf_map *map, void *key, void *value,
+                                    u64 map_flags)
 {
        return __dev_map_hash_update_elem(current->nsproxy->net_ns,
                                         map, key, value, map_flags);
 }
 
-static int dev_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
+static long dev_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
 {
        return __bpf_xdp_redirect_map(map, ifindex, flags,
                                      BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS,
                                      __dev_map_lookup_elem);
 }
 
-static int dev_hash_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
+static long dev_hash_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
 {
        return __bpf_xdp_redirect_map(map, ifindex, flags,
                                      BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS,
index 5dfcb5ad0d068bea421c492b423e25b773e1ae21..90852e0e64f26a75d089588c936f13a69ce3c11e 100644 (file)
@@ -1057,8 +1057,8 @@ static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
 }
 
 /* Called from syscall or from eBPF program */
-static int htab_map_update_elem(struct bpf_map *map, void *key, void *value,
-                               u64 map_flags)
+static long htab_map_update_elem(struct bpf_map *map, void *key, void *value,
+                                u64 map_flags)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct htab_elem *l_new = NULL, *l_old;
@@ -1159,8 +1159,8 @@ static void htab_lru_push_free(struct bpf_htab *htab, struct htab_elem *elem)
        bpf_lru_push_free(&htab->lru, &elem->lru_node);
 }
 
-static int htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value,
-                                   u64 map_flags)
+static long htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value,
+                                    u64 map_flags)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct htab_elem *l_new, *l_old = NULL;
@@ -1226,9 +1226,9 @@ err:
        return ret;
 }
 
-static int __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
-                                        void *value, u64 map_flags,
-                                        bool onallcpus)
+static long __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
+                                         void *value, u64 map_flags,
+                                         bool onallcpus)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct htab_elem *l_new = NULL, *l_old;
@@ -1281,9 +1281,9 @@ err:
        return ret;
 }
 
-static int __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
-                                            void *value, u64 map_flags,
-                                            bool onallcpus)
+static long __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
+                                             void *value, u64 map_flags,
+                                             bool onallcpus)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct htab_elem *l_new = NULL, *l_old;
@@ -1348,21 +1348,21 @@ err:
        return ret;
 }
 
-static int htab_percpu_map_update_elem(struct bpf_map *map, void *key,
-                                      void *value, u64 map_flags)
+static long htab_percpu_map_update_elem(struct bpf_map *map, void *key,
+                                       void *value, u64 map_flags)
 {
        return __htab_percpu_map_update_elem(map, key, value, map_flags, false);
 }
 
-static int htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
-                                          void *value, u64 map_flags)
+static long htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
+                                           void *value, u64 map_flags)
 {
        return __htab_lru_percpu_map_update_elem(map, key, value, map_flags,
                                                 false);
 }
 
 /* Called from syscall or from eBPF program */
-static int htab_map_delete_elem(struct bpf_map *map, void *key)
+static long htab_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct hlist_nulls_head *head;
@@ -1398,7 +1398,7 @@ static int htab_map_delete_elem(struct bpf_map *map, void *key)
        return ret;
 }
 
-static int htab_lru_map_delete_elem(struct bpf_map *map, void *key)
+static long htab_lru_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct hlist_nulls_head *head;
@@ -2119,8 +2119,8 @@ static const struct bpf_iter_seq_info iter_seq_info = {
        .seq_priv_size          = sizeof(struct bpf_iter_seq_hash_map_info),
 };
 
-static int bpf_for_each_hash_elem(struct bpf_map *map, bpf_callback_t callback_fn,
-                                 void *callback_ctx, u64 flags)
+static long bpf_for_each_hash_elem(struct bpf_map *map, bpf_callback_t callback_fn,
+                                  void *callback_ctx, u64 flags)
 {
        struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
        struct hlist_nulls_head *head;
index e90d9f63edc5d34b09a6cbd93bf311acc5d9ff5b..66d8ce2ab5b343c4e6be0a9024b6c963c970cbd6 100644 (file)
@@ -141,8 +141,8 @@ static void *cgroup_storage_lookup_elem(struct bpf_map *_map, void *key)
        return &READ_ONCE(storage->buf)->data[0];
 }
 
-static int cgroup_storage_update_elem(struct bpf_map *map, void *key,
-                                     void *value, u64 flags)
+static long cgroup_storage_update_elem(struct bpf_map *map, void *key,
+                                      void *value, u64 flags)
 {
        struct bpf_cgroup_storage *storage;
        struct bpf_storage_buffer *new;
@@ -348,7 +348,7 @@ static void cgroup_storage_map_free(struct bpf_map *_map)
        bpf_map_area_free(map);
 }
 
-static int cgroup_storage_delete_elem(struct bpf_map *map, void *key)
+static long cgroup_storage_delete_elem(struct bpf_map *map, void *key)
 {
        return -EINVAL;
 }
index d833496e9e42633fb159a044d12ce41f1521fa8d..27980506fc7d50c0e16396fccb0744edf618f7a7 100644 (file)
@@ -300,8 +300,8 @@ static struct lpm_trie_node *lpm_trie_node_alloc(const struct lpm_trie *trie,
 }
 
 /* Called from syscall or from eBPF program */
-static int trie_update_elem(struct bpf_map *map,
-                           void *_key, void *value, u64 flags)
+static long trie_update_elem(struct bpf_map *map,
+                            void *_key, void *value, u64 flags)
 {
        struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
        struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL;
@@ -431,7 +431,7 @@ out:
 }
 
 /* Called from syscall or from eBPF program */
-static int trie_delete_elem(struct bpf_map *map, void *_key)
+static long trie_delete_elem(struct bpf_map *map, void *_key)
 {
        struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
        struct bpf_lpm_trie_key *key = _key;
index 8a5e060de63bc834bea5efea1434901ff62a66cc..80f958ff6396637d0446877bbb536a4e2b73c34c 100644 (file)
@@ -95,7 +95,7 @@ static void queue_stack_map_free(struct bpf_map *map)
        bpf_map_area_free(qs);
 }
 
-static int __queue_map_get(struct bpf_map *map, void *value, bool delete)
+static long __queue_map_get(struct bpf_map *map, void *value, bool delete)
 {
        struct bpf_queue_stack *qs = bpf_queue_stack(map);
        unsigned long flags;
@@ -124,7 +124,7 @@ out:
 }
 
 
-static int __stack_map_get(struct bpf_map *map, void *value, bool delete)
+static long __stack_map_get(struct bpf_map *map, void *value, bool delete)
 {
        struct bpf_queue_stack *qs = bpf_queue_stack(map);
        unsigned long flags;
@@ -156,32 +156,32 @@ out:
 }
 
 /* Called from syscall or from eBPF program */
-static int queue_map_peek_elem(struct bpf_map *map, void *value)
+static long queue_map_peek_elem(struct bpf_map *map, void *value)
 {
        return __queue_map_get(map, value, false);
 }
 
 /* Called from syscall or from eBPF program */
-static int stack_map_peek_elem(struct bpf_map *map, void *value)
+static long stack_map_peek_elem(struct bpf_map *map, void *value)
 {
        return __stack_map_get(map, value, false);
 }
 
 /* Called from syscall or from eBPF program */
-static int queue_map_pop_elem(struct bpf_map *map, void *value)
+static long queue_map_pop_elem(struct bpf_map *map, void *value)
 {
        return __queue_map_get(map, value, true);
 }
 
 /* Called from syscall or from eBPF program */
-static int stack_map_pop_elem(struct bpf_map *map, void *value)
+static long stack_map_pop_elem(struct bpf_map *map, void *value)
 {
        return __stack_map_get(map, value, true);
 }
 
 /* Called from syscall or from eBPF program */
-static int queue_stack_map_push_elem(struct bpf_map *map, void *value,
-                                    u64 flags)
+static long queue_stack_map_push_elem(struct bpf_map *map, void *value,
+                                     u64 flags)
 {
        struct bpf_queue_stack *qs = bpf_queue_stack(map);
        unsigned long irq_flags;
@@ -227,14 +227,14 @@ static void *queue_stack_map_lookup_elem(struct bpf_map *map, void *key)
 }
 
 /* Called from syscall or from eBPF program */
-static int queue_stack_map_update_elem(struct bpf_map *map, void *key,
-                                      void *value, u64 flags)
+static long queue_stack_map_update_elem(struct bpf_map *map, void *key,
+                                       void *value, u64 flags)
 {
        return -EINVAL;
 }
 
 /* Called from syscall or from eBPF program */
-static int queue_stack_map_delete_elem(struct bpf_map *map, void *key)
+static long queue_stack_map_delete_elem(struct bpf_map *map, void *key)
 {
        return -EINVAL;
 }
index 82c61612f382a688333904e1563b4166b4b49478..d1188b035091447cba835e2eb1c5c5608299b055 100644 (file)
@@ -59,7 +59,7 @@ static void *reuseport_array_lookup_elem(struct bpf_map *map, void *key)
 }
 
 /* Called from syscall only */
-static int reuseport_array_delete_elem(struct bpf_map *map, void *key)
+static long reuseport_array_delete_elem(struct bpf_map *map, void *key)
 {
        struct reuseport_array *array = reuseport_array(map);
        u32 index = *(u32 *)key;
index 80f4b4d88aafae0f8de0f7f3fa4fc289b87a9d23..ce8ca5511ac13741700b9a8e8a46f5734c49c2c5 100644 (file)
@@ -241,13 +241,13 @@ static void *ringbuf_map_lookup_elem(struct bpf_map *map, void *key)
        return ERR_PTR(-ENOTSUPP);
 }
 
-static int ringbuf_map_update_elem(struct bpf_map *map, void *key, void *value,
-                                  u64 flags)
+static long ringbuf_map_update_elem(struct bpf_map *map, void *key, void *value,
+                                   u64 flags)
 {
        return -ENOTSUPP;
 }
 
-static int ringbuf_map_delete_elem(struct bpf_map *map, void *key)
+static long ringbuf_map_delete_elem(struct bpf_map *map, void *key)
 {
        return -ENOTSUPP;
 }
index aecea7451b6103785203e32a832f2e9590b4abae..496ce1695dd8976ca19869249c96c8f626589346 100644 (file)
@@ -618,14 +618,14 @@ static int stack_map_get_next_key(struct bpf_map *map, void *key,
        return 0;
 }
 
-static int stack_map_update_elem(struct bpf_map *map, void *key, void *value,
-                                u64 map_flags)
+static long stack_map_update_elem(struct bpf_map *map, void *key, void *value,
+                                 u64 map_flags)
 {
        return -EINVAL;
 }
 
 /* Called from syscall or from eBPF program */
-static int stack_map_delete_elem(struct bpf_map *map, void *key)
+static long stack_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_stack_map *smap = container_of(map, struct bpf_stack_map, map);
        struct stack_map_bucket *old_bucket;
index c61216f88ad6a43f8e9bc1817643bb7173a5b9de..bb8579a3bf310200fb57c24fdc8b44d2960485c4 100644 (file)
@@ -16113,21 +16113,21 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
                        BUILD_BUG_ON(!__same_type(ops->map_lookup_elem,
                                     (void *(*)(struct bpf_map *map, void *key))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_delete_elem,
-                                    (int (*)(struct bpf_map *map, void *key))NULL));
+                                    (long (*)(struct bpf_map *map, void *key))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_update_elem,
-                                    (int (*)(struct bpf_map *map, void *key, void *value,
+                                    (long (*)(struct bpf_map *map, void *key, void *value,
                                              u64 flags))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_push_elem,
-                                    (int (*)(struct bpf_map *map, void *value,
+                                    (long (*)(struct bpf_map *map, void *value,
                                              u64 flags))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_pop_elem,
-                                    (int (*)(struct bpf_map *map, void *value))NULL));
+                                    (long (*)(struct bpf_map *map, void *value))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_peek_elem,
-                                    (int (*)(struct bpf_map *map, void *value))NULL));
+                                    (long (*)(struct bpf_map *map, void *value))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_redirect,
-                                    (int (*)(struct bpf_map *map, u64 index, u64 flags))NULL));
+                                    (long (*)(struct bpf_map *map, u64 index, u64 flags))NULL));
                        BUILD_BUG_ON(!__same_type(ops->map_for_each_callback,
-                                    (int (*)(struct bpf_map *map,
+                                    (long (*)(struct bpf_map *map,
                                              bpf_callback_t callback_fn,
                                              void *callback_ctx,
                                              u64 flags))NULL));
index bb378c33f542c219df099ce25d40209c9ce4d740..6a4b3e931324137b3998e785c4deed3c50ee5eb9 100644 (file)
@@ -100,8 +100,8 @@ static void *bpf_fd_sk_storage_lookup_elem(struct bpf_map *map, void *key)
        return ERR_PTR(err);
 }
 
-static int bpf_fd_sk_storage_update_elem(struct bpf_map *map, void *key,
-                                        void *value, u64 map_flags)
+static long bpf_fd_sk_storage_update_elem(struct bpf_map *map, void *key,
+                                         void *value, u64 map_flags)
 {
        struct bpf_local_storage_data *sdata;
        struct socket *sock;
@@ -120,7 +120,7 @@ static int bpf_fd_sk_storage_update_elem(struct bpf_map *map, void *key,
        return err;
 }
 
-static int bpf_fd_sk_storage_delete_elem(struct bpf_map *map, void *key)
+static long bpf_fd_sk_storage_delete_elem(struct bpf_map *map, void *key)
 {
        struct socket *sock;
        int fd, err;
index a68a7290a3b2b1f618960a0ac91961418ee13449..a055139f410e2f9bf99aec47e9863a67e79a10d0 100644 (file)
@@ -437,7 +437,7 @@ static void sock_map_delete_from_link(struct bpf_map *map, struct sock *sk,
        __sock_map_delete(stab, sk, link_raw);
 }
 
-static int sock_map_delete_elem(struct bpf_map *map, void *key)
+static long sock_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_stab *stab = container_of(map, struct bpf_stab, map);
        u32 i = *(u32 *)key;
@@ -587,8 +587,8 @@ out:
        return ret;
 }
 
-static int sock_map_update_elem(struct bpf_map *map, void *key,
-                               void *value, u64 flags)
+static long sock_map_update_elem(struct bpf_map *map, void *key,
+                                void *value, u64 flags)
 {
        struct sock *sk = (struct sock *)value;
        int ret;
@@ -916,7 +916,7 @@ static void sock_hash_delete_from_link(struct bpf_map *map, struct sock *sk,
        raw_spin_unlock_bh(&bucket->lock);
 }
 
-static int sock_hash_delete_elem(struct bpf_map *map, void *key)
+static long sock_hash_delete_elem(struct bpf_map *map, void *key)
 {
        struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map);
        u32 hash, key_size = map->key_size;
index 771d0fa90ef58e3d94a714853f514e9f8f196ab8..3436a8efb8dc7beef989e716d3fe907bc07cd4e9 100644 (file)
@@ -150,8 +150,8 @@ static void *xsk_map_lookup_elem_sys_only(struct bpf_map *map, void *key)
        return ERR_PTR(-EOPNOTSUPP);
 }
 
-static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
-                              u64 map_flags)
+static long xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
+                               u64 map_flags)
 {
        struct xsk_map *m = container_of(map, struct xsk_map, map);
        struct xdp_sock __rcu **map_entry;
@@ -211,7 +211,7 @@ out:
        return err;
 }
 
-static int xsk_map_delete_elem(struct bpf_map *map, void *key)
+static long xsk_map_delete_elem(struct bpf_map *map, void *key)
 {
        struct xsk_map *m = container_of(map, struct xsk_map, map);
        struct xdp_sock __rcu **map_entry;
@@ -231,7 +231,7 @@ static int xsk_map_delete_elem(struct bpf_map *map, void *key)
        return 0;
 }
 
-static int xsk_map_redirect(struct bpf_map *map, u64 index, u64 flags)
+static long xsk_map_redirect(struct bpf_map *map, u64 index, u64 flags)
 {
        return __bpf_xdp_redirect_map(map, index, flags, 0,
                                      __xsk_map_lookup_elem);