bpf: Allow bpf_spin_{lock,unlock} in sleepable progs
[linux-block.git] / kernel / bpf / verifier.c
index 4b638eb1bdad56503d6560d9b3ebb547cdcd8c31..bb78212fa5b27305e6672931ae815def8e931fe9 100644 (file)
@@ -5064,7 +5064,9 @@ bad_type:
  */
 static bool in_rcu_cs(struct bpf_verifier_env *env)
 {
-       return env->cur_state->active_rcu_lock || !env->prog->aux->sleepable;
+       return env->cur_state->active_rcu_lock ||
+              env->cur_state->active_lock.ptr ||
+              !env->prog->aux->sleepable;
 }
 
 /* Once GCC supports btf_type_tag the following mechanism will be replaced with tag check */
@@ -16975,11 +16977,6 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env,
                        verbose(env, "tracing progs cannot use bpf_spin_lock yet\n");
                        return -EINVAL;
                }
-
-               if (prog->aux->sleepable) {
-                       verbose(env, "sleepable progs cannot use bpf_spin_lock yet\n");
-                       return -EINVAL;
-               }
        }
 
        if (btf_record_has_field(map->record, BPF_TIMER)) {