]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
scsi: bsg: fix buffer overflow in scsi_bsg_uring_cmd()
authorDan Carpenter <error27@gmail.com>
Fri, 10 Apr 2026 10:14:52 +0000 (13:14 +0300)
committerJens Axboe <axboe@kernel.dk>
Fri, 10 Apr 2026 12:41:26 +0000 (06:41 -0600)
commit0a42ca4d2bff6306dd574a7897258fd02c2e6930
tree85285f6821308760f67ce4bd6b5e7ea804a71fc2
parent539fb773a3f7c07cf7fd00617f33ed4e33058d72
scsi: bsg: fix buffer overflow in scsi_bsg_uring_cmd()

The bounds checking in scsi_bsg_uring_cmd() does not work because
cmd->request_len is a u32 and scmd->cmd_len is a u16.  We check that
scmd->cmd_len is valid but if the cmd->request_len is more than
USHRT_MAX it would still lead to a buffer overflow when we do the
copy_from_user().

Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://patch.msgid.link/adjNnMYK7A7KMNkA@stanley.mountain
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/scsi/scsi_bsg.c