Merge tag 'net-next-6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[linux-2.6-microblaze.git] / kernel / bpf / bpf_iter.c
index 8af0cbf..2726a59 100644 (file)
@@ -722,9 +722,6 @@ const struct bpf_func_proto bpf_for_each_map_elem_proto = {
        .arg4_type      = ARG_ANYTHING,
 };
 
-/* maximum number of loops */
-#define MAX_LOOPS      BIT(23)
-
 BPF_CALL_4(bpf_loop, u32, nr_loops, void *, callback_fn, void *, callback_ctx,
           u64, flags)
 {
@@ -732,9 +729,13 @@ BPF_CALL_4(bpf_loop, u32, nr_loops, void *, callback_fn, void *, callback_ctx,
        u64 ret;
        u32 i;
 
+       /* Note: these safety checks are also verified when bpf_loop
+        * is inlined, be careful to modify this code in sync. See
+        * function verifier.c:inline_bpf_loop.
+        */
        if (flags)
                return -EINVAL;
-       if (nr_loops > MAX_LOOPS)
+       if (nr_loops > BPF_MAX_LOOPS)
                return -E2BIG;
 
        for (i = 0; i < nr_loops; i++) {