u64 (*func)(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
        bool gpl_only;
        bool pkt_access;
+       bool might_sleep;
        enum bpf_return_type ret_type;
        union {
                struct {
 
 static const struct bpf_func_proto bpf_ima_inode_hash_proto = {
        .func           = bpf_ima_inode_hash,
        .gpl_only       = false,
+       .might_sleep    = true,
        .ret_type       = RET_INTEGER,
        .arg1_type      = ARG_PTR_TO_BTF_ID,
        .arg1_btf_id    = &bpf_ima_inode_hash_btf_ids[0],
 static const struct bpf_func_proto bpf_ima_file_hash_proto = {
        .func           = bpf_ima_file_hash,
        .gpl_only       = false,
+       .might_sleep    = true,
        .ret_type       = RET_INTEGER,
        .arg1_type      = ARG_PTR_TO_BTF_ID,
        .arg1_btf_id    = &bpf_ima_file_hash_btf_ids[0],
        case BPF_FUNC_bprm_opts_set:
                return &bpf_bprm_opts_set_proto;
        case BPF_FUNC_ima_inode_hash:
-               return prog->aux->sleepable ? &bpf_ima_inode_hash_proto : NULL;
+               return &bpf_ima_inode_hash_proto;
        case BPF_FUNC_ima_file_hash:
-               return prog->aux->sleepable ? &bpf_ima_file_hash_proto : NULL;
+               return &bpf_ima_file_hash_proto;
        case BPF_FUNC_get_attach_cookie:
                return bpf_prog_has_trampoline(prog) ? &bpf_get_attach_cookie_proto : NULL;
 #ifdef CONFIG_NET
 
 const struct bpf_func_proto bpf_copy_from_user_proto = {
        .func           = bpf_copy_from_user,
        .gpl_only       = false,
+       .might_sleep    = true,
        .ret_type       = RET_INTEGER,
        .arg1_type      = ARG_PTR_TO_UNINIT_MEM,
        .arg2_type      = ARG_CONST_SIZE_OR_ZERO,
 const struct bpf_func_proto bpf_copy_from_user_task_proto = {
        .func           = bpf_copy_from_user_task,
        .gpl_only       = true,
+       .might_sleep    = true,
        .ret_type       = RET_INTEGER,
        .arg1_type      = ARG_PTR_TO_UNINIT_MEM,
        .arg2_type      = ARG_CONST_SIZE_OR_ZERO,
 
                return -EINVAL;
        }
 
+       if (!env->prog->aux->sleepable && fn->might_sleep) {
+               verbose(env, "helper call might sleep in a non-sleepable prog\n");
+               return -EINVAL;
+       }
+
        /* With LD_ABS/IND some JITs save/restore skb from r1. */
        changes_data = bpf_helper_changes_pkt_data(fn->func);
        if (changes_data && fn->arg1_type != ARG_PTR_TO_CTX) {
 
        case BPF_FUNC_get_task_stack:
                return &bpf_get_task_stack_proto;
        case BPF_FUNC_copy_from_user:
-               return prog->aux->sleepable ? &bpf_copy_from_user_proto : NULL;
+               return &bpf_copy_from_user_proto;
        case BPF_FUNC_copy_from_user_task:
-               return prog->aux->sleepable ? &bpf_copy_from_user_task_proto : NULL;
+               return &bpf_copy_from_user_task_proto;
        case BPF_FUNC_snprintf_btf:
                return &bpf_snprintf_btf_proto;
        case BPF_FUNC_per_cpu_ptr: