sched/smt: Fix unbalance sched_smt_present dec/inc

commit e22f910a26cc2a3ac9c66b8e935ef2a7dd881117 upstream.

I got the following warn report while doing stress test:

jump label: negative count!
WARNING: CPU: 3 PID: 38 at kernel/jump_label.c:263 static_key_slow_try_dec+0x9d/0xb0
Call Trace:
 <TASK>
 __static_key_slow_dec_cpuslocked+0x16/0x70
 sched_cpu_deactivate+0x26e/0x2a0
 cpuhp_invoke_callback+0x3ad/0x10d0
 cpuhp_thread_fun+0x3f5/0x680
 smpboot_thread_fn+0x56d/0x8d0
 kthread+0x309/0x400
 ret_from_fork+0x41/0x70
 ret_from_fork_asm+0x1b/0x30
 </TASK>

Because when cpuset_cpu_inactive() fails in sched_cpu_deactivate(),
the cpu offline failed, but sched_smt_present is decremented before
calling sched_cpu_deactivate(), it leads to unbalanced dec/inc, so
fix it by incrementing sched_smt_present in the error path.

BUG=b/372870109
TEST=presubmit
RELEASE_NOTE=Fixed CVE-2024-44958 in the Linux kernel.

cos-patch: security-moderate
Fixes: c5511d03ec09 ("sched/smt: Make sched_smt_present track topology")
Cc: [email protected]
Change-Id: Ie46e83db104e51326f37f37bae23d0a4ab078d8d
Signed-off-by: Yang Yingliang <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Chen Yu <[email protected]>
Reviewed-by: Tim Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Kernel CVE Triage Automation <[email protected]>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/83423
Reviewed-by: Kevin Berry <[email protected]>
Tested-by: Cusky Presubmit Bot <[email protected]>
Reviewed-by: Arnav Kansal <[email protected]>
1 file changed