lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <AM6PR03MB50805D6F4B8710EDB304CF5C99F72@AM6PR03MB5080.eurprd03.prod.outlook.com>
Date: Wed,  5 Feb 2025 19:30:14 +0000
From: Juntong Deng <juntong.deng@...look.com>
To: ast@...nel.org,
	daniel@...earbox.net,
	john.fastabend@...il.com,
	andrii@...nel.org,
	martin.lau@...ux.dev,
	eddyz87@...il.com,
	song@...nel.org,
	yonghong.song@...ux.dev,
	kpsingh@...nel.org,
	sdf@...ichev.me,
	haoluo@...gle.com,
	jolsa@...nel.org,
	memxor@...il.com,
	tj@...nel.org,
	void@...ifault.com,
	arighi@...dia.com,
	changwoo@...lia.com
Cc: bpf@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [RFC PATCH bpf-next 2/8] sched_ext: Add filter for scx_kfunc_ids_select_cpu

This patch adds filter for scx_kfunc_ids_select_cpu.

The kfuncs in the scx_kfunc_ids_select_cpu set can be used in select_cpu
and other rq-locked operations.

Signed-off-by: Juntong Deng <juntong.deng@...look.com>
---
 kernel/sched/ext.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 8857c0709bdd..c92949aa23f6 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -6401,9 +6401,51 @@ BTF_KFUNCS_START(scx_kfunc_ids_select_cpu)
 BTF_ID_FLAGS(func, scx_bpf_select_cpu_dfl, KF_RCU)
 BTF_KFUNCS_END(scx_kfunc_ids_select_cpu)
 
+static int scx_kfunc_ids_other_rqlocked_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+	u32 moff = prog->aux->attach_st_ops_member_off;
+
+	if (moff == offsetof(struct sched_ext_ops, runnable) ||
+	    moff == offsetof(struct sched_ext_ops, dequeue) ||
+	    moff == offsetof(struct sched_ext_ops, stopping) ||
+	    moff == offsetof(struct sched_ext_ops, quiescent) ||
+	    moff == offsetof(struct sched_ext_ops, yield) ||
+	    moff == offsetof(struct sched_ext_ops, cpu_acquire) ||
+	    moff == offsetof(struct sched_ext_ops, running) ||
+	    moff == offsetof(struct sched_ext_ops, core_sched_before) ||
+	    moff == offsetof(struct sched_ext_ops, set_cpumask) ||
+	    moff == offsetof(struct sched_ext_ops, update_idle) ||
+	    moff == offsetof(struct sched_ext_ops, tick) ||
+	    moff == offsetof(struct sched_ext_ops, enable) ||
+	    moff == offsetof(struct sched_ext_ops, set_weight) ||
+	    moff == offsetof(struct sched_ext_ops, disable) ||
+	    moff == offsetof(struct sched_ext_ops, exit_task) ||
+	    moff == offsetof(struct sched_ext_ops, dump_task) ||
+	    moff == offsetof(struct sched_ext_ops, dump_cpu))
+		return 0;
+
+	return -EACCES;
+}
+
+static int scx_kfunc_ids_select_cpu_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+	u32 moff;
+
+	if (!btf_id_set8_contains(&scx_kfunc_ids_select_cpu, kfunc_id) ||
+	    prog->aux->st_ops != &bpf_sched_ext_ops)
+		return 0;
+
+	moff = prog->aux->attach_st_ops_member_off;
+	if (moff == offsetof(struct sched_ext_ops, select_cpu))
+		return 0;
+
+	return scx_kfunc_ids_other_rqlocked_filter(prog, kfunc_id);
+}
+
 static const struct btf_kfunc_id_set scx_kfunc_set_select_cpu = {
 	.owner			= THIS_MODULE,
 	.set			= &scx_kfunc_ids_select_cpu,
+	.filter			= scx_kfunc_ids_select_cpu_filter,
 };
 
 static bool scx_dsq_insert_preamble(struct task_struct *p, u64 enq_flags)
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ