From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796056899; b=LOGuSSxdzxKAN7VuPZjkHuMdJAU9lnk6E3h9B39vzl/I6jFbUg8X/CQ3iFPZGitoHfBS M+8hMjmNjOxO9D7HuKLcaKjJFaklq/t2LPwUw8QxRhniclvxoN/q1tBxM4qXRG/e7oakN XBFUgccOGl9CXWUjn/RUborXqVJys6aOC4VfRAgMg3GsSvZNIhHZkPWLUJe3M+tUY9Vod ArHIKmGETEOvZw4MWxyU2JTgHQq8PeX7zmA5/mfmBDs3r3p7aVhvEArHtXOn8DhsAlER1 QZwG+XMdfLe1ODsIQPsq3PYitCfYPQYGXJS3cj0Cqa0UKgjuGRiiwKJbeI5MJJqS71w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796056899; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=o1p6TCyhB5PmPaGtAp+nSVOGcZAun4qAR/M5BkNG3Ho=; b=hV2wpfYQOg4XghKQjoP5QRy7Os4zLZMouP6z2KLai5dJufpynoI7oV+7XlzAetOFYTch wyyukS8s9uObSAk5RyMT+cxIitbUnAm0nAFtkGGhLtQ1+VOpDnArrkzT2m8JSLLeMMT+4 CvHv7jVbcurmAff+IozOFgpWCXfyyC4RN6EVGjXNquGyp6i5+UtbgDKjHtrNHLzjhnP0o BkLIDdi9ZHSfx//tZANHvHzfZkX/247SR+VnI0H35ztO6xEBGVAcUBCfR+WGKTTFMnCx8 Y88tFqjcwWO4TLBNQRl/+IKjFmStjMpZeFbExHyZ0mdYaPdtc2gNwmFmW6NRHRn4eqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hHJZFs64; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DB2A606A320 for ; Mon, 30 Nov 2026 16:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hHJZFs64 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A351F00898; Mon, 30 Nov 2026 16:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796056898; bh=o1p6TCyhB5PmPaGtAp+nSVOGcZAun4qAR/M5BkNG3Ho=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hHJZFs64iDW/IOLw1UXgh20oGBo5AVHnurRLSM6RMohr9juHo1JtFqblcJl1PG187 oFcapPvlNwANru70c1P+aA6wa8SoxstEK3tHS2fJ5aBo9pqulMqZCdK9RHy1cIXUYy qWEY8P5gL6lAmd95eQtH8+r4PUJIRRLy8N393ICCHj47ynVGlsKPUahfrh/wfjDcPf Ckyv0p67Plgtj4HBDlmivpqcTl1ibd9q92Cam5aO3fhYof1z45Kiy1acMGdJkwYpjN HFZ+JlaH0w3XhzVzoawFOX2aENsU/otFilKkK5RIBRCbiQqjy/eBYdwZZPF9CXXN4q SKyVyt1tv86KA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] sched_ext: Fix unbounded format string reads in the bstr kfuncs Reply-To: sashiko-reviews@lists.linux.dev To: "Andrea Righi" Cc: sched-ext@lists.linux.dev In-Reply-To: <20261130161913.1379563-3-arighi@nvidia.com> References: <20261130161913.1379563-1-arighi@nvidia.com> <20261130161913.1379563-3-arighi@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 16:41:38 +0000 X-Mailing-List: sched-ext@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] sched_ext: missing re-entrancy guard in scx_bpf_dump_bstr() for stable -- commit 96c34c3723cdfae7a173919614dbc82435b3aff5 Author: Andrea Righi sched_ext: Fix unbounded format string reads in the bstr kfuncs This commit copies BPF format strings into a bounded kernel buffer via strncpy_from_kernel_nofault() before calling bpf_bprintf_prepare() and bstr_printf(). Link: https://lore.kernel.org/r/20261130054957.570822-1-maghasi@disroot.org > diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c > index 27502dcae0433..7483b10587a90 100644 > --- a/kernel/sched/ext/ext.c > +++ b/kernel/sched/ext/ext.c [ ... ] > @@ -11303,18 +11326,17 @@ static s32 __bstr_format(struct scx_sched *sch,= u64 *data_buf, char *line_buf, > return ret; > } > =20 > - ret =3D bpf_bprintf_prepare(fmt, UINT_MAX, data_buf, data__sz / 8, > - &bprintf_data); > + ret =3D bpf_bprintf_prepare(fmt_buf, SCX_BSTR_FMT_LEN, data_buf, > + data__sz / 8, &bprintf_data); > if (ret < 0) { > scx_error(sch, "format preparation failed (%d)", ret); > return ret; > } > =20 > - ret =3D bstr_printf(line_buf, line_size, fmt, > - bprintf_data.bin_args); > + ret =3D bstr_printf(line_buf, line_size, fmt_buf, bprintf_data.bin_args= ); > bpf_bprintf_cleanup(&bprintf_data); > if (ret < 0) { > - scx_error(sch, "(\"%s\", %p, %u) failed to format", fmt, data, data__s= z); > + scx_error(sch, "(\"%s\", %p, %u) failed to format", fmt_buf, data, dat= a__sz); > return ret; > } > =20 [ ... ] > @@ -11441,11 +11463,11 @@ __bpf_kfunc void scx_bpf_dump_bstr(char *fmt, u= nsigned long long *data, > } > =20 > /* append the formatted string to the line buf */ > - ret =3D __bstr_format(sch, buf->data, buf->line + dd->cursor, > + ret =3D __bstr_format(sch, buf->data, buf->fmt, buf->line + dd->cursor, > sizeof(buf->line) - dd->cursor, fmt, data, data__sz); > if (ret < 0) { > scx_dump_line(dd->s, "%s[!] (\"%s\", %p, %u) failed to format (%d)", > - dd->prefix, fmt, data, data__sz, ret); > + dd->prefix, buf->fmt, data, data__sz, ret); > return; > } [Severity: Medium] As reported by Tejun Heo on v1 [1], can re-entering scx_bpf_dump_bstr() on dd->cpu overwrite the shared buf->fmt and cause a NULL pointer dereference = in bstr_printf()? scx_bpf_dump_bstr() (fmt=3D"hello", data__sz=3D0) __bstr_format() scx_snapshot_fmt(buf->fmt, ..., "hello") bpf_bprintf_prepare(buf->fmt, ..., num_args=3D0, &bprintf_data) bprintf_data.bin_args =3D NULL cpu> scx_bpf_dump_bstr() (fmt=3D"%s", data__sz=3D8) __bstr_format() scx_snapshot_fmt(buf->fmt, ..., "%s") ... bstr_printf(..., buf->fmt, bprintf_data.bin_args) <-- dereferences NULL bin_args for "%s" The earlier commit "sched_ext: Disallow scx_bpf_dump_bstr() from tracing programs" in this series blocks tracing callers via scx_kfunc_ids_no_tracin= g, which was added in the current cycle. However, this commit is tagged for v6.12+ stable trees where scx_kfunc_ids_no_tracing does not exist, so scx_bpf_dump_bstr() still needs an in-function re-entrancy guard around __bstr_format() (such as a busy flag in scx_dump_data or temporarily cleari= ng dd->cpu). [1] https://lore.kernel.org/r/9a62510c0dd0fe29ed5a40e89aa80e83@kernel.org --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130161913.1379= 563-1-arighi@nvidia.com?part=3D2