Thread (2 messages) 2 messages, 2 authors, 2021-05-26

Re: [PATCH][V2][next] mm: selftests: fix potential integer overflow on shift of a int

From: Jason Gunthorpe <jgg@ziepe.ca>
Date: 2021-05-26 19:21:38
Also in: kernel-janitors, lkml

On Wed, May 26, 2021 at 06:05:30PM +0100, Colin King wrote:
From: Colin Ian King <redacted>

The left shift of the int mapped is evaluated using 32 bit arithmetic
and then assigned to an unsigned long. In the case where mapped is
0x80000 when PAGE_SHIFT is 12 will lead to the upper bits being
sign extended in the unsigned long. Larger values can lead to an
int overflow. Avoid this by making mapped an unsigned long.

Addresses-Coverity: ("Uninitentional integer overflow")
Fixes: 8b2a105c3794 ("mm: selftests for exclusive device memory")
Signed-off-by: Colin Ian King <redacted>
---

V2: Make mapped an unsigned long rather than casting it to unsigned long
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help