From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 69-171-232-181.mail-mxout.facebook.com (69-171-232-181.mail-mxout.facebook.com [69.171.232.181]) (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 3D49E345CAF for ; Thu, 7 May 2026 21:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=69.171.232.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778189437; cv=none; b=dVDEiHP0X59bEAB5ZOLFWEfFOzBt/i2iqchev4cdp65De6DnpfG4Upzc8sUAgaOB1Zoq+f8nkQyOgGxOnBVWmSVotwcrGeHAGb/9oVJ+Ky7+d6Z2+ACj7Up3ulCib+ghhJxBpVNIvZywiKyHtljwpj+OsA55cUgG6czCQowR+/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778189437; c=relaxed/simple; bh=wPzjK1Ck/Tt/wKwqoxMIiucQYVOUpsi+wLc/JzKVwhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YwKUpb6fafefcSVigKXOz23Lp0+a5tMqL8N51SDc0FAnRbeUkmfPA70R89NnRczncSyPqyaZxrbCenrxQxSwn9L7Y37Fg09dfaCD3KBP4dRCKn8sIppi96085q5VTLDHJT/RUaur+LzvVrsq5qOeCF80pxFovUWehq9N+PFMVZc= 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=69.171.232.181 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 4966F92BAA4D3; Thu, 7 May 2026 14:30:34 -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 , Puranjay Mohan Subject: [PATCH bpf-next v2 10/23] bpf: Reject stack arguments in non-JITed programs Date: Thu, 7 May 2026 14:30:34 -0700 Message-ID: <20260507213034.1130443-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260507212942.1122000-1-yonghong.song@linux.dev> References: <20260507212942.1122000-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 r11 (BPF_REG_PARAMS) used for stack arguments. So reject interpreter usage if stack arguments are used either in the main program or any subprogram. Acked-by: Puranjay Mohan Signed-off-by: Yonghong Song --- kernel/bpf/core.c | 2 +- kernel/bpf/fixups.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index ae10b9ca018d..6f94b0ef3659 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2599,7 +2599,7 @@ struct bpf_prog *__bpf_prog_select_runtime(struct b= pf_verifier_env *env, struct 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_cnt) jit_needed =3D true; =20 if (!bpf_prog_select_interpreter(fp)) diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c index 0ff8cdf4394f..4c630d97eaad 100644 --- a/kernel/bpf/fixups.c +++ b/kernel/bpf/fixups.c @@ -1412,6 +1412,12 @@ int bpf_fixup_call_args(struct bpf_verifier_env *e= nv) verbose(env, "calling kernel functions are not allowed in non-JITed pr= ograms\n"); return -EINVAL; } + for (i =3D 1; i < env->subprog_cnt; i++) { + if (bpf_in_stack_arg_cnt(&env->subprog_info[i])) { + 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.53.0-Meta