Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	bpf@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v2 5/6] s390/bpf: Add kCFI support
Date: Mon, 27 Jul 2026 14:47:30 +0000	[thread overview]
Message-ID: <20260727144730.68E141F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727140514.116501-6-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The s390 BPF JIT leaks `s390_jit_data` and its associated `jit.addrs` array when JIT compilation fails during a multi-subprogram compilation.
--

--- Patch [5]: [PATCH v2 5/6] s390/bpf: Add kCFI support ---
commit 90cf9cf344f10dd1f477562c9b9f57c7b89998a9
Author: Heiko Carstens <hca@linux.ibm.com>

s390/bpf: Add kCFI support

This commit adds kCFI support for BPF on the s390 architecture, mirroring
the existing arm64 implementation.

> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c

[ ... ]

> @@ -2401,11 +2417,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
>  		jit_data->ctx = jit;
>  		jit_data->pass = pass;
>  	}
> -	fp->bpf_func = (void *) jit.prg_buf;
> +	fp->bpf_func = (void *)jit.prg_buf + cfi_get_offset();
>  	fp->jited = 1;
> -	fp->jited_len = jit.size;
> +	fp->jited_len = jit.size - cfi_get_offset();
>  
>  	if (!fp->is_func || extra_pass) {
> +		for (int i = 0; i < fp->len; i++)
> +			jit.addrs[i] -= cfi_get_offset();
>  		bpf_prog_fill_jited_linfo(fp, jit.addrs + 1);
>  free_addrs:
>  		kvfree(jit.addrs);

[Severity: High]
This is a pre-existing issue, but does this code leak jit_data and jit.addrs
when JIT compilation fails during a multi-subprogram compilation?

When extra_pass is false and fp->is_func is true in bpf_int_jit_compile(),
the function skips the block above and returns without freeing jit.addrs
and jit_data.

These resources rely on bpf_jit_free() for cleanup on error paths, such as
when a subsequent subprogram fails to JIT. However, since s390 does not
implement a custom bpf_jit_free(), the generic version in kernel/bpf/core.c
is called. This generic function only frees the binary header and leaves
fp->aux->jit_data behind.

Could this be repeatedly triggered by a user loading a multi-subprogram BPF
object that fails during JIT, potentially leading to resource exhaustion?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727140514.116501-1-hca@linux.ibm.com?part=5

  reply	other threads:[~2026-07-27 14:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 14:05 [PATCH v2 0/6] s390: Add kCFI support Heiko Carstens
2026-07-27 14:05 ` [PATCH v2 1/6] s390/tools: Pass symbol name to do_relocs() Heiko Carstens
2026-07-27 14:39   ` sashiko-bot
2026-07-27 14:05 ` [PATCH v2 2/6] s390/tools/relocs: Ignore __kcfi_typeid_ relocations Heiko Carstens
2026-07-27 14:36   ` sashiko-bot
2026-07-27 14:05 ` [PATCH v2 3/6] s390: Add ftrace_stub_graph Heiko Carstens
2026-07-27 14:40   ` sashiko-bot
2026-07-27 14:05 ` [PATCH v2 4/6] s390/diag: Generate CFI type information for assembly functions Heiko Carstens
2026-07-27 14:38   ` sashiko-bot
2026-07-27 14:05 ` [PATCH v2 5/6] s390/bpf: Add kCFI support Heiko Carstens
2026-07-27 14:47   ` sashiko-bot [this message]
2026-07-27 15:37   ` Ilya Leoshkevich
2026-07-27 14:05 ` [PATCH v2 6/6] s390/Kconfig: Select ARCH_SUPPORTS_CFI Heiko Carstens
2026-07-27 14:39   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260727144730.68E141F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox