WARNING: zero-size vmalloc in ubi_read_volume_table

From: Yang, Chenyuan
Date: Wed Jan 17 2024 - 11:31:11 EST


Hello,

 

We detected one crash, “WARNING: zero-size vmalloc in ubi_read_volume_table” for the volume management system UBI (under linux/drivers/mtd/ubi) by using our generated syscall specification for it.

 

This crash is triggered by `create_empty_lvol` (https://elixir.bootlin.com/linux/v6.7/source/drivers/mtd/ubi/vtbl.c#L484), which allocates a zero-size memory by using `vzalloc`. Additionally, this issue is associated with the `/dev/ubi_ctrl` driver, particularly when using IOCTL with the command value UBI_IOCATT. The size allocated can be manipulated through the `ubi_attach_req` argument by altering the `vid_hdr_offset` and `max_beb_per1024` fields.

 

To fix this issue, it would be better to implement a check step in the `create_empty_lvol` function.

 

The crash is reproducible by a C program, which is attached in the file.

If you have any questions or require more information, please feel free to contact us.

 

Best,

Chenyuan

Attachment: repro.cprog
Description: repro.cprog

Attachment: repro.log
Description: repro.log

Attachment: repro.prog
Description: repro.prog

Attachment: repro.report
Description: repro.report