提交 4583a31d 编写于 作者: D Dan Carpenter 提交者: Yang Yingliang

kdb: do a sanity check on the cpu in kdb_per_cpu()

[ Upstream commit b586627e10f57ee3aa8f0cfab0d6f7dc4ae63760 ]

The "whichcpu" comes from argv[3].  The cpu_online() macro looks up the
cpu in a bitmap of online cpus, but if the value is too high then it
could read beyond the end of the bitmap and possibly Oops.

Fixes: 5d5314d6 ("kdb: core for kgdb back end (1 of 2)")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NDouglas Anderson <dianders@chromium.org>
Signed-off-by: NDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 74d837e4
...@@ -2604,7 +2604,7 @@ static int kdb_per_cpu(int argc, const char **argv) ...@@ -2604,7 +2604,7 @@ static int kdb_per_cpu(int argc, const char **argv)
diag = kdbgetularg(argv[3], &whichcpu); diag = kdbgetularg(argv[3], &whichcpu);
if (diag) if (diag)
return diag; return diag;
if (!cpu_online(whichcpu)) { if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) {
kdb_printf("cpu %ld is not online\n", whichcpu); kdb_printf("cpu %ld is not online\n", whichcpu);
return KDB_BADCPUNUM; return KDB_BADCPUNUM;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册