Message ID | 20221008144544.283945-1-xukuohai@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | clk: bcm: rpi: Fix an out-of-bound access to raspberrypi_clk_variants | expand |
Hi Xu, Am 08.10.22 um 16:45 schrieb Xu Kuohai: > From: Xu Kuohai <xukuohai@huawei.com> > > KASAN reports an out-of-bound access to raspberrypi_clk_variants[]: > > ================================================================== > BUG: KASAN: global-out-of-bounds in raspberrypi_clk_probe+0x1dc/0x690 > Read of size 1 at addr ffffcc7116d615a0 by task kworker/u8:0/8 > > CPU: 1 PID: 8 Comm: kworker/u8:0 Not tainted 6.0.0-rc3-00900-g08f4df4a3c53 raspberrypi#10 this kernel is a little bit older and doesn't contain bc163555603e ("clk: bcm: rpi: Prevent out-of-bounds access"). Can you please check Linux 6.0? Best regards
On 10/9/2022 1:07 AM, Stefan Wahren wrote: > Hi Xu, > > Am 08.10.22 um 16:45 schrieb Xu Kuohai: >> From: Xu Kuohai <xukuohai@huawei.com> >> >> KASAN reports an out-of-bound access to raspberrypi_clk_variants[]: >> >> ================================================================== >> BUG: KASAN: global-out-of-bounds in raspberrypi_clk_probe+0x1dc/0x690 >> Read of size 1 at addr ffffcc7116d615a0 by task kworker/u8:0/8 >> >> CPU: 1 PID: 8 Comm: kworker/u8:0 Not tainted 6.0.0-rc3-00900-g08f4df4a3c53 raspberrypi#10 > > this kernel is a little bit older and doesn't contain bc163555603e ("clk: bcm: rpi: Prevent out-of-bounds access"). > > Can you please check Linux 6.0? > Yes, the kernel branch I used was not updated, and the KASAN warning was gone after switching to 6.0 kernel, thanks. > Best regards >
diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c index 73518009a0f2..3ad0d2d2e3b6 100644 --- a/drivers/clk/bcm/clk-raspberrypi.c +++ b/drivers/clk/bcm/clk-raspberrypi.c @@ -356,10 +356,12 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi, if (ret) return ret; + clks[RPI_FIRMWARE_NUM_CLK_ID - 1].id = 0; + while (clks->id) { struct raspberrypi_clk_variant *variant; - if (clks->id > RPI_FIRMWARE_NUM_CLK_ID) { + if (clks->id >= RPI_FIRMWARE_NUM_CLK_ID) { dev_err(rpi->dev, "Unknown clock id: %u", clks->id); return -EINVAL; }