Skip to content
Commit 470d347b authored by Xuewen Yan's avatar Xuewen Yan Committed by Greg Kroah-Hartman
Browse files

sched/eevdf: Prevent vlag from going out of bounds in reweight_eevdf()

[ Upstream commit 1560d1f6 ]

It was possible to have pick_eevdf() return NULL, which then causes a
NULL-deref. This turned out to be due to entity_eligible() returning
falsely negative because of a s64 multiplcation overflow.

Specifically, reweight_eevdf() computes the vlag without considering
the limit placed upon vlag as update_entity_lag() does, and then the
scaling multiplication (remember that weight is 20bit fixed point) can
overflow. This then leads to the new vruntime being weird which then
causes the above entity_eligible() to go side-ways and claim nothing
is eligible.

Thus limit the range of vlag accordingly.

All this was quite rare, but fatal when it does happen.

Closes: https://lore.kernel.org/all/ZhuYyrh3mweP_Kd8@nz.home/
Closes: https://lore.kernel.org/all/CA+9S74ih+45M_2TPUY_mPPVDhNvyYfy1J1ftSix+KjiTVxg8nw@mail.gmail.com/
Closes: https://lore.kernel.org/lkml/202401301012.2ed95df0-oliver.sang@intel.com/
Fixes: eab03c23

 ("sched/eevdf: Fix vruntime adjustment on reweight")
Reported-by: default avatarSergei Trofimovich <slyich@gmail.com>
Reported-by: default avatarIgor Raits <igor@gooddata.com>
Reported-by: default avatarBreno Leitao <leitao@debian.org>
Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
Reported-by: default avatarYujie Liu <yujie.liu@intel.com>
Signed-off-by: default avatarXuewen Yan <xuewen.yan@unisoc.com>
Reviewed-and-tested-by: default avatarChen Yu <yu.c.chen@intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240422082238.5784-1-xuewen.yan@unisoc.com
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 2cf53d80
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment