]> www.infradead.org Git - users/jedix/linux-maple.git/commit
io_uring/kbuf: fix unintentional sign extension on shift of reg.bgid
authorColin Ian King <colin.i.king@gmail.com>
Wed, 4 Dec 2024 15:39:23 +0000 (15:39 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 23 Dec 2024 15:20:00 +0000 (08:20 -0700)
commitfebfbf767174b8a027efb7aa434f9a9416adc23d
tree5009edfe5ba35faee86f6c4ed1814bb9bd96c059
parent546d191427cf5cf3215529744c2ea8558f0279db
io_uring/kbuf: fix unintentional sign extension on shift of reg.bgid

Shifting reg.bgid << IORING_OFF_PBUF_SHIFT results in a promotion
from __u16 to a 32 bit signed integer, this is then sign extended
to a 64 bit unsigned long on 64 bit architectures. If reg.bgid is
greater than 0x7fff then this leads to a sign extended result where
all the upper 32 bits of mmap_offset are set to 1. Fix this by
casting reg.bgid to the same type as mmap_offset before performing
the shift.

Fixes: ef62de3c4ad5 ("io_uring/kbuf: use region api for pbuf rings")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20241204153923.401674-1-colin.i.king@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/kbuf.c