Skip to contentSkip to conversation

tools/sched_ext: Fix data header access during free in scx_sdt

PATCH Applied Emil Tsalapatis 3 participants 3 messages Feb 2 Scheduler - sched_ext

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/sched_ext: Fix data header access during free in scx_sdt

Fix a pointer arithmetic error in scx_sdt during freeing that causes the allocator to use the wrong memory address for the allocation's data header.

Fixes f0262b102c7 ("tools/sched_ext: add scx_pair scheduler")
---
 tools/sched_ext/scx_sdt.bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/sched_ext/scx_sdt.bpf.c +1 -1
index d965f7d209de..31b09958e8d5 100644
@@ -312,7 +312,7 @@ int scx_alloc_free_idx(struct scx_allocator *alloc, __u64 idx)
 	pos = idx & mask;
 	data = chunk->data[pos];
 	if (likely(data)) {
-		data[pos] = (struct sdt_data) {
+		*data = (struct sdt_data) {
 			.tid.genn = data->tid.genn + 1,
 		};
 
Signature · 1 line
2.49.0
reviewer Acked-by on v1 1/1
#1 lore raw

Hi Emil,

Quoted 5 lines · Emil Tsalapatis

Fix a pointer arithmetic error in scx_sdt during freeing that causes the allocator to use the wrong memory address for the allocation's data header.

Fixes f0262b102c7 ("tools/sched_ext: add scx_pair scheduler")

I think this is fixing commig 36929ebd17ae6 ("tools/sched_ext: add arena based scheduler") in sched_ext/for-6.20, right?

Apart than that, LGTM:

Thanks,
-Andrea

Quoted 21 lines
---
 tools/sched_ext/scx_sdt.bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/sched_ext/scx_sdt.bpf.c +1 -1
index d965f7d209de..31b09958e8d5 100644
@@ -312,7 +312,7 @@ int scx_alloc_free_idx(struct scx_allocator *alloc, __u64 idx)
 	pos = idx & mask;
 	data = chunk->data[pos];
 	if (likely(data)) {
-		data[pos] = (struct sdt_data) {
+		*data = (struct sdt_data) {
 			.tid.genn = data->tid.genn + 1,
 		};
 
Signature · 1 line
2.49.0
reviewer Applied
#2 lore raw
In reply to Emil Tsalapatis

Applied to sched_ext/for-6.20 with the following modification:

Fixes f0262b102c7 ("tools/sched_ext: add scx_pair scheduler")

->

Fixes 36929ebd17ae ("tools/sched_ext: add arena based scheduler")

Thanks.

--
tejun