Re: BUG: divide error in ubi_attach_mtd_dev

From: Zhihao Cheng
Date: Sat Apr 22 2023 - 23:23:51 EST


在 2023/4/21 4:36, Richard Weinberger 写道:
----- Ursprüngliche Mail -----
Can you please share the qemu command line?
qemu-system-x86_64 -m 2G -smp 2 -kernel
/home/test/Workspace/SyzGen/linux-distro/linux-6.2-debug/arch/x86/boot/bzImage
-append “console=ttyS0 root=/dev/sda net.ifnames=0” -hda
/home/test/Workspace/SyzGen/linux-distro/image/stretch.img -chardev
socket,id=SOCKSYZ,server=on,nowait,host=localhost,port=54640 -mon
chardev=SOCKSYZ,mode=control -device virtio-rng-pci -device
e1000,netdev=net0 -netdev
user,id=net0,restrict=on,hostfwd=tcp:127.0.0.1:11760-:22 -display none
-serial stdio -cpu host,migratable=off -no-reboot -name VM -snapshot
-enable-kvm

Within Linux you can query /proc/mtd or /sys/class/mtd/
to get infos about the MTD in question.


Thanks for the hints. We find that this is a “mtdram test device”.

root@syzkaller:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00001000 “mtdram test device”

Hmm, mtdram should be fine, erasesize is not zero.


I guess the zero-erasesize mtd device is dynamically generated in runtime, after looking through the code, I find erasesize is initiallized in specific flash driver and it won't be updated later(eg. ioctl\sysctl). And some mtd devices may have zero erasesize, eg. drivers/mtd/devices/mchp23k256.c[1]. Unfortunately, I don't know how to load/simulate this mtd, maybe it requires a real device? If we load this mtd device as ubi, it will trigger the problem?


[1] https://cloud.tencent.com/developer/ask/sof/114616431