Commit 86ecb1c
sched_ext: Clear ops->priv on scx_alloc_and_add_sched() error paths
scx_alloc_and_add_sched() can fail after @sch has been assigned to
ops->priv. In those cases @sch is torn down (either via kfree() through
the err_free_* chain or via kobject_put() -> scx_kobj_release() -> RCU
work), but @ops->priv is left pointing at the about-to-be-freed pointer.
With the recent -EBUSY gate in scx_root_enable_workfn() and
scx_sub_enable_workfn() that rejects an attach when @ops->priv is still
non-NULL, see commit bbf30b3 ("sched_ext: Fix ops->priv clobber on
concurrent attach/detach"), a dangling @ops->priv permanently locks the
kdata out: every future attach attempt sees a stale binding and returns
-EBUSY even though no scheduler is actually attached.
Clear @ops->priv on the post-assign failure paths so that the kdata
returns to its pre-attach state when the function returns ERR_PTR().
Fixes: bbf30b3 ("sched_ext: Fix ops->priv clobber on concurrent attach/detach")
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>1 parent bbf30b3 commit 86ecb1c
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6670 | 6670 | | |
6671 | 6671 | | |
6672 | 6672 | | |
| 6673 | + | |
6673 | 6674 | | |
6674 | 6675 | | |
6675 | 6676 | | |
6676 | 6677 | | |
6677 | 6678 | | |
6678 | 6679 | | |
6679 | 6680 | | |
| 6681 | + | |
6680 | 6682 | | |
6681 | 6683 | | |
6682 | 6684 | | |
6683 | 6685 | | |
6684 | 6686 | | |
6685 | 6687 | | |
6686 | 6688 | | |
| 6689 | + | |
6687 | 6690 | | |
6688 | 6691 | | |
6689 | 6692 | | |
| |||
6692 | 6695 | | |
6693 | 6696 | | |
6694 | 6697 | | |
| 6698 | + | |
6695 | 6699 | | |
6696 | 6700 | | |
6697 | 6701 | | |
| |||
0 commit comments