ubifs_scan: corrupt empty space
Brian Hill
brian at houston-radar.com
Sat Jun 27 08:09:08 PDT 2015
On 6/27/2015 3:28 AM, Sheng Yong wrote:
> On 6/26/2015 10:31 PM, Brian Hill wrote:
>> I thought I might try and answer "what would happen?" myself with the nandsim kernel module, but I find it can't provide bitflips in erased data - they are always simulated as "perfect".
> Nandsim can generate bitflips by setting bitflips=n. Then read will set a random
> bitflip in the read buffer. But this does not always happen. You can read do_bit_flips()
> in drivers/mtd/nand/nandsim.c and you will see that only if (bitflips && prandom_u32() < (1<<22)),
> (but "prandom_u32() < (1 << 22)" seems unlikely happen) bitflip is generated. So if you
> would like to make bitflip likely happen, you could change the condition.
>
> thanks,
> Sheng
Sheng,
Bit flips are never simulated on erased pages, they are always 0xFFs.
static void read_page(struct nandsim *ns, int num)
{
union ns_mem *mypage;
if (ns->cfile) {
if (!test_bit(ns->regs.row, ns->pages_written)) {
NS_DBG("read_page: page %d not written\n", ns->regs.row);
memset(ns->buf.byte, 0xFF, num); <----- perfect 0xFFs
} else {
loff_t pos;
ssize_t tx;
NS_DBG("read_page: page %d written, reading from %d\n",
ns->regs.row, ns->regs.column + ns->regs.off);
if (do_read_error(ns, num))
return;
pos = (loff_t)NS_RAW_OFFSET(ns) + ns->regs.off;
tx = read_file(ns, ns->cfile, ns->buf.byte, num, pos);
if (tx != num) {
NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx);
return;
}
do_bit_flips(ns, num); <----- not reached for erased pages
}
return;
}
Thanks,
-Brian Hill
More information about the linux-mtd
mailing list