sched_ext: initialize kit->cursor.flags
PATCH 1/1 sched_ext: initialize kit->cursor.flags
struct bpf_iter_scx_dsq *it maybe not initialized.
If we didn't call scx_bpf_dsq_move_set_vtime and scx_bpf_dsq_move_set_slice before scx_bpf_dsq_move, it would cause unexpected behaviors:
1. Assign a huge slice into p->scx.slice
2. Assign a invalid vtime into p->scx.dsq_vtime
Henry Huang (1):
sched_ext: initialize kit->cursor.flags
kernel/sched/ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
PATCH 1/1 sched_ext: initialize kit->cursor.flags
struct bpf_iter_scx_dsq *it maybe not initialized.
If we didn't call scx_bpf_dsq_move_set_vtime and scx_bpf_dsq_move_set_slice before scx_bpf_dsq_move, it would cause unexpected behaviors:
1. Assign a huge slice into p->scx.slice
2. Assign a invalid vtime into p->scx.dsq_vtime
--- kernel/sched/ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext.c +1 -1
@@ -7013,7 +7013,7 @@ __bpf_kfunc int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u64 dsq_id,return -ENOENT ;INIT_LIST_HEAD (&kit->cursor.node); - kit->cursor.flags |=SCX_DSQ_LNODE_ITER_CURSOR | flags; + kit->cursor.flags =SCX_DSQ_LNODE_ITER_CURSOR | flags; kit->cursor.priv =READ_ONCE (kit->dsq->seq);return 0 ;
Signature · 1 line
1.8.3.1
Tejun Heo
AppliedQuoted 7 lines · Henry Huang
struct
bpf_iter_scx_dsq*it maybe not initialized.
If we didn't callscx_bpf_dsq_move_set_vtimeandscx_bpf_dsq_move_set_slicebeforescx_bpf_dsq_move, it would cause unexpected behaviors:
1. Assign a huge slice intop->scx.slice
2. Assign a invalid vtime intop->scx.dsq_vtimeSigned-off-by Henry Huang <[email protected]>
Applied to sched_ext/for-6.13-fixes w/ Fixes tag and stable cc added.
Thanks.
Signature · 1 line
tejun