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=1795945819; b=ePbesqRdGDY7/kJaxFdSchvN3fpBpWlSg0IYSuDOCcQv171GXwkznQNGecgObekjcFbE wx485uKncdytITdh7nh8cRm5MN3359B9aLv2cmNN5gHCGIRSj60r4Dbwehf4IMW6ailQy QNGXNcNKP/GgYdO6oQxqqUbwovazUmd+Nfx1ANI7hXexFXOKzcEwEr50m8dq2RhvUTkBU QY8oGWvLG3BGOkgOkofLcVRQWeFt8BlziNbjTQECmJI0dKVbbQ3R0uMmq82oxP9OGKqbj i8sADxnejUBCSg5B758FxyLth1Zw9mFyAaxfzzX39ukjLm1ZmI3skbI3hoiE/JoFM3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795945819; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ovqmbxzor5UIRkLMJDEFACLddXjQTE4r2dxXIDdDQXg=; b=pY3QLiJC+gR6RjrH+NuB8QvZyyQnvfL5l+f+K3vzLs2EwcuX1yYTzW7LAw7zbGs5rqqt zGACVW7kEwN97k9NqBfLy/Xm9+fJ169NF9UQbwrrRLCBF9Ph27sqbm7vhC4ickYzaUnhy 51DiMwyUmch8foAdoSFw4MgjcZtz9Urq/NJG1swozaFnXVErd+ZkOBYoc2WNOIeC/kp7V ImmjqsS4hs8hwxjVElL73Fwo3sqeAmlvStiRnvd68WH4/TNqjdxgUN93hRw6mSsE167/O zWg6V6jchKq2z4LsRUNjhiP45C4BI8+vtP85XiOXbr0pSEMyqRTWXQJmWtq0C73/vEw== 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=NhvHfIi5; 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 C84DA606A32D for ; Sun, 29 Nov 2026 09:50:19 +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=NhvHfIi5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A5F1F00926; Sun, 29 Nov 2026 09:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795945819; bh=ovqmbxzor5UIRkLMJDEFACLddXjQTE4r2dxXIDdDQXg=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=NhvHfIi5dwojYBnbzPkVcgg3cSmnLwU71Vv+dGD4duOrO/6eppFQhX8hJdSN5mAzA 24fVtXQBJbIIJ7/Oj+kvJAnU1axodYQQa2QFblQBeNwpj2wNNcaY1aanuNT4fP8K/q 1vGNULilc3fS2bnQ9qru5LGI07ZCKRAaKHsBqyHc0vxHy9m68sJmpZbd4lgQ74JbBO vd40MncQRPuHdDIAmY4rcKwPPbzWplhAo3BwqaLvXY1dRLigI4YoDjVIG1HF/jH732 0zwHZNYuYFYAFpPEPRVcdnVYsaRfOSzVIIy4mem/0U3lug3QEv+SMBmUYiRsusphb+ jWYEYtBPkwgFA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix kernel OOB memory read in scx_bpf_x_bstr kfuncs Reply-To: sashiko-reviews@lists.linux.dev To: "Masoud Aghasi" , sched-ext@lists.linux.dev In-Reply-To: <20261129093555.3890002-1-maghasi@disroot.org> References: <20261129093555.3890002-1-maghasi@disroot.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 09:50:17 +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 2 potential issues to consider: - [High] sched_ext: non-const ___fmt in scx_bpf_bstr_preamble() fails __str verifier check - [Low] sched_ext: kernel-doc @fmt mismatch after fmt__str rename in *_bstr() kfuncs -- commit 2b70c95fa8aff160dd9f3bf21e32e37b0b12fac5 Author: Masoud Aghasi sched_ext: Fix kernel OOB memory read in scx_bpf_x_bstr kfuncs This commit adds the __str verifier suffix to the format string parameter of scx_bpf_exit_bstr(), scx_bpf_error_bstr(), scx_bpf_dump_bstr(), and scx_bpf_sub_kill_bstr(), and lowers the bpf_bprintf_prepare() length limit in __bstr_format() from UINT_MAX to INT_MAX. > diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c > index a9e36b5bb0386..b633d6c5843b2 100644 > --- a/kernel/sched/ext/ext.c > +++ b/kernel/sched/ext/ext.c [ ... ] > @@ -11369,7 +11369,7 @@ __bpf_kfunc_start_defs(); > * disabling. > */ > __printf(2, 0) > -__bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, char *fmt, > +__bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, const char *fmt__str, > unsigned long long *data, u32 data__sz, > const struct bpf_prog_aux *aux) > { [Severity: Low] Since the parameter was renamed to fmt__str, the kernel-doc comments for scx_bpf_exit_bstr(), scx_bpf_error_bstr(), scx_bpf_dump_bstr(), and scx_bpf_sub_kill_bstr() still document @fmt: instead of @fmt__str:, which triggers kernel-doc warnings under W=3D1 builds. > diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/i= nclude/scx/common.bpf.h > index 6194484d4d9a9..648188ce66066 100644 > --- a/tools/sched_ext/include/scx/common.bpf.h > +++ b/tools/sched_ext/include/scx/common.bpf.h > @@ -74,9 +74,9 @@ int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u= 64 dsq_id, u64 flags) __k > struct task_struct *bpf_iter_scx_dsq_next(struct bpf_iter_scx_dsq *it) _= _ksym __weak; > void bpf_iter_scx_dsq_destroy(struct bpf_iter_scx_dsq *it) __ksym __weak; > bool scx_bpf_dsq_reenq_task(struct bpf_iter_scx_dsq *it, struct task_str= uct *p) __ksym __weak; > -void scx_bpf_exit_bstr(s64 exit_code, char *fmt, unsigned long long *dat= a, u32 data__sz) __ksym __weak; > -void scx_bpf_error_bstr(char *fmt, unsigned long long *data, u32 data_le= n) __ksym; > -void scx_bpf_dump_bstr(char *fmt, unsigned long long *data, u32 data_len= ) __ksym __weak; > +void scx_bpf_exit_bstr(s64 exit_code, const char *fmt__str, unsigned lon= g long *data, u32 data__sz) __ksym __weak; > +void scx_bpf_error_bstr(const char *fmt__str, unsigned long long *data, = u32 data_len) __ksym; > +void scx_bpf_dump_bstr(const char *fmt__str, unsigned long long *data, u= 32 data_len) __ksym __weak; > u32 scx_bpf_cpuperf_cap(s32 cpu) __ksym __weak; > u32 scx_bpf_cpuperf_cur(s32 cpu) __ksym __weak; > void scx_bpf_cpuperf_set(s32 cpu, u32 perf) __ksym __weak; > @@ -123,7 +123,7 @@ u32 scx_bpf_cidperf_cur(s32 cid) __ksym __weak; > s32 scx_bpf_sub_grant(u64 cgroup_id, u64 caps, const struct scx_cmask __= arena *cmask__arena, struct scx_cmask __arena *denied_out__arena__nullable)= __ksym __weak; > void scx_bpf_sub_revoke(u64 cgroup_id, u64 caps, const struct scx_cmask = __arena *cmask__arena) __ksym __weak; > s32 scx_bpf_sub_caps(u64 cgroup_id, u64 caps, struct scx_cmask __arena *= out__arena) __ksym __weak; > -s32 scx_bpf_sub_kill_bstr(u64 cgroup_id, char *fmt, unsigned long long *= data, u32 data__sz) __ksym __weak; > +s32 scx_bpf_sub_kill_bstr(u64 cgroup_id, const char *fmt__str, unsigned = long long *data, u32 data__sz) __ksym __weak; > =20 > /* > * Use the following as @it__iter when calling scx_bpf_dsq_move[_vtime](= ) from [Severity: High] Does adding the __str suffix without making ___fmt const in scx_bpf_bstr_preamble() cause the verifier to reject every BPF program calling scx_bpf_exit(), scx_bpf_error(), scx_bpf_dump(), or scx_bpf_sub_kill()? With fmt__str, the verifier classifies the argument as ARG_PTR_TO_CONST_STR and checks bpf_map_is_rdonly() in check_arg_const_str(), requiring the format string to live in a frozen read-only map (.rodata). However, scx_bpf_bstr_preamble() in the same header still declares ___fmt without const: tools/sched_ext/include/scx/common.bpf.h: #define scx_bpf_bstr_preamble(fmt, args...) \ static char ___fmt[] =3D fmt; \ Because ___fmt is non-const, the compiler places it in the writable .data map instead of .rodata, causing check_arg_const_str() to fail verification with -EACCES ("fmt__str does not point to a readonly map"). In addition, existing pre-compiled sched_ext BPF binaries built with non-const ___fmt will also fail verification at load time. Declaring static const char ___fmt[] =3D fmt; in scx_bpf_bstr_preamble() places the format string in .rodata for newly compiled programs. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129093555.3890= 002-1-maghasi@disroot.org?part=3D1