From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FCC428D8DB for ; Sun, 12 Apr 2026 05:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.220.144.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775970011; cv=none; b=tjIiMnCWbnsbHy4Si50iBi9OuGH1Q78c1dtEA6ba7kMPxq9yPcC62uWU0kwIeFGDSVgqLLfo3y8fweBeB3dwNp12bWX14aR5fkO3XgVHJyLNNhti9mdFvBFFYnEqKju12hSjgxDURcbA7bGXmif1ryfd3ovqw3OJG28l2GqFS2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775970011; c=relaxed/simple; bh=bgdBNz4U6+yJF9we8S7QuIfJVZA9Yn6oJHi2bnykx2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nQb8nM8/7X2+D5m0k3BqXZEI6WLPU6jZ4AnLPvRgoOZnN7wT2V+fmrBXeLtDBIZmrNV3+sTA0RrBrRUMtY3ioou5hzODBMAfqbbb2WMDZIxNKIfvi5iluqKp5KV/tlXHLZ9Y4oAT4a8eaMm6nKZq9vtsnUjBWb5nFpHyJl7AHs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=66.220.144.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id A03A43B021BC7; Sat, 11 Apr 2026 22:00:05 -0700 (PDT) From: Yonghong Song To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , "Jose E . Marchesi" , kernel-team@fb.com, Martin KaFai Lau Subject: [PATCH bpf-next v4 11/18] bpf: Reject stack arguments in non-JITed programs Date: Sat, 11 Apr 2026 22:00:05 -0700 Message-ID: <20260412050005.264809-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260412045826.254200-1-yonghong.song@linux.dev> References: <20260412045826.254200-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The interpreter does not understand the bpf register r12 (BPF_REG_STACK_ARG_BASE) used for stack argument addressing. So reject interpreter usage if stack arguments are used either in the main program or any subprogram. Signed-off-by: Yonghong Song --- kernel/bpf/core.c | 3 ++- kernel/bpf/verifier.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 76a4e208f34e..1bd8a19d7b61 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2555,7 +2555,8 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf= _prog *fp, int *err) goto finalize; =20 if (IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) || - bpf_prog_has_kfunc_call(fp)) + bpf_prog_has_kfunc_call(fp) || + fp->aux->stack_arg_depth) jit_needed =3D true; =20 if (!bpf_prog_select_interpreter(fp)) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index bfeecd73e66e..20fb53ead728 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -24030,6 +24030,12 @@ static int fixup_call_args(struct bpf_verifier_e= nv *env) verbose(env, "calling kernel functions are not allowed in non-JITed pr= ograms\n"); return -EINVAL; } + for (i =3D 0; i < env->subprog_cnt; i++) { + if (env->subprog_info[i].incoming_stack_arg_depth) { + verbose(env, "stack args are not supported in non-JITed programs\n"); + return -EINVAL; + } + } if (env->subprog_cnt > 1 && env->prog->aux->tail_call_reachable) { /* When JIT fails the progs with bpf2bpf calls and tail_calls * have to be rejected, since interpreter doesn't support them yet. --=20 2.52.0