Message ID | 20240307041411.3792061-8-zhanggenjian@126.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix the UAF issue caused by the loop driver | expand |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index eadb189be0cc..c999eef4e345 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1298,6 +1298,11 @@ loop_set_status_from_info(struct loop_device *lo, lo->lo_offset = info->lo_offset; lo->lo_sizelimit = info->lo_sizelimit; + + /* loff_t vars have been assigned __u64 */ + if (lo->lo_offset < 0 || lo->lo_sizelimit < 0) + return -EOVERFLOW; + memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE); memcpy(lo->lo_crypt_name, info->lo_crypt_name, LO_NAME_SIZE); lo->lo_file_name[LO_NAME_SIZE-1] = 0;