]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ARM: findbit: fix overflowing offset
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 26 Jul 2022 22:51:48 +0000 (23:51 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:55:57 +0000 (11:55 +0200)
commitc78ffe9ba7d2b9b1ff34ebd1ed90785242c79874
treea618d5d2e2a871b309b936fb3815ab8e214e8422
parentca71b4211456a213185639004e2bed85deef827e
ARM: findbit: fix overflowing offset

BugLink: https://bugs.launchpad.net/bugs/1990162
[ Upstream commit ec85bd369fd2bfaed6f45dd678706429d4f75b48 ]

When offset is larger than the size of the bit array, we should not
attempt to access the array as we can perform an access beyond the
end of the array. Fix this by changing the pre-condition.

Using "cmp r2, r1; bhs ..." covers us for the size == 0 case, since
this will always take the branch when r1 is zero, irrespective of
the value of r2. This means we can fix this bug without adding any
additional code!

Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm/lib/findbit.S