]> git.baikalelectronics.ru Git - 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:05 +0000 (14:23 +0200)
commit482f126e76151dba812bfc562ca5efd825c0e615
tree23f6db7f3977bdca7f2d43898cbb64cb37cc4716
parent48bbd4eb93198f6ef3f4d39a79ea7fbcce02fea4
ARM: findbit: fix overflowing offset

[ Upstream commit d7b6e6806bb79bfb35d9532938cf95294837c72f ]

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>
arch/arm/lib/findbit.S