From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD8419E7F7; Sat, 12 Sep 2026 08:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789201131; cv=none; b=M1di99fm+8DQW95bUmamv8PhoHsZ0OthAY81mm3fCyc+aMUH9Yq4FCGpbXUSiJdgii7wu/h7d/21xA7w6rGDq/1A9Dd82scSGnhHetRvX+I7xngW3dw8HXuB/FblHYwzcWWzMBHVWZjnIbeo3+8cZQDEU7f7KfbQxrKLw+elSMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789201131; c=relaxed/simple; bh=NEqRpvTRW0qsgTgclFMwM6B3kkTou8qykxvYbiwwKQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ucHvAPEux8TuqKuofruwaVtdAzpCWI52u7RsbZVrqCftAvG2irXTzSO+LLNSRwvzrt6c+WC2scyy5XbCajWsammsfwkEjRhlO0yPlyfNTF/GaQSHV1OVBzguTkILuC/Hi9F3LQSI5h+ttYO4xQcujQlr7Lqght4tN2DS1mWI2uQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rKjk2Jas; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rKjk2Jas" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD6CD1F000FF; Sat, 12 Sep 2026 08:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789201130; bh=q48Ge+bEb/C5uo8fVgUNHiQ2aWTHbMJagpweLzE39Tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rKjk2JasMGGFF/9dLqn4rNVu7X2r+FaCPOTiO3/ZzD182cs25IUsPiRA2iS2LWxqO 5J1k9X8hokxS4Zjxjk7xKtzCINQ5xr4kw6X+M9zqOm4S69pFXE6GeqpOg/B4ukcInW i8dI/fuFleuwAbrSY5ZoJm6bknnxUiuEHPy+8Gxo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yonghong Song , Leon Hwang , Kumar Kartikeya Dwivedi , Sasha Levin Subject: [PATCH 7.2 0933/1815] bpf, x86: Fix trampoline stack size for 128-bit arguments Date: Sat, 12 Sep 2026 08:44:43 +0200 Message-ID: <20260912065710.851136274@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yonghong Song [ Upstream commit 814cba835ef648e0c5eb79505c96c0493b29eea6 ] btf_distill_func_proto() accepts a function argument up to 16 bytes, so a 128-bit scalar such as __int128 reaches the x86 trampoline with arg_size == 16. But the current implementation assumes an __int128 argument only needs one register, so the register save area is under-allocated and save_args() overwrites adjacent stack slots. Compute the register count from arg_size for all arguments to fix it. Fixes: a9c5ad31fbdc ("bpf: x86: Support in-register struct arguments in trampoline programs") Signed-off-by: Yonghong Song Acked-by: Leon Hwang Link: https://lore.kernel.org/bpf/20260729050204.2586457-1-yonghong.song@linux.dev Signed-off-by: Kumar Kartikeya Dwivedi Signed-off-by: Sasha Levin --- arch/x86/net/bpf_jit_comp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 276d076d29938..d491bdd249497 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -3369,11 +3369,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im WARN_ON_ONCE((flags & BPF_TRAMP_F_INDIRECT) && (flags & ~(BPF_TRAMP_F_INDIRECT | BPF_TRAMP_F_RET_FENTRY_RET))); - /* extra registers for struct arguments */ - for (i = 0; i < m->nr_args; i++) { - if (m->arg_flags[i] & BTF_FMODEL_STRUCT_ARG) - nr_regs += (m->arg_size[i] + 7) / 8 - 1; - } + for (i = 0; i < m->nr_args; i++) + nr_regs += (m->arg_size[i] + 7) / 8 - 1; /* x86-64 supports up to MAX_BPF_FUNC_ARGS arguments. 1-6 * are passed through regs, the remains are through stack. -- 2.53.0