lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 22 Jan 2014 23:31:00 +0900
From:	Akinobu Mita <akinobu.mita@...il.com>
To:	Lothar Waßmann <LW@...o-electronics.de>
Cc:	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	David Woodhouse <dwmw2@...radead.org>,
	Brian Norris <computersforpeace@...il.com>,
	Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Huang Shijie <b32955@...escale.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: mtd_oobtest: fix verify errors due to incorrect use
 of prandom_bytes_state()

2014/1/22 Lothar Waßmann <LW@...o-electronics.de>:
> Hi,
>
> Is anyone taking care of this?
>
> Lothar Waßmann wrote:
>> When using prandom_bytes_state() it is critical to use the same block
>> size in all invocations that are to produce the same random sequence.
>> Otherwise the state of the PRNG will be out of sync if the blocksize
>> is not divisible by 4.
>> This leads to bogus verification errors in several tests which use
>> different block sizes to initialize the buffer for writing and
>> comparison.
>>
>> Signed-off-by: Lothar Waßmann <LW@...O-electronics.de>
>> ---
>>  drivers/mtd/tests/oobtest.c |   14 ++++++++++++--
>>  1 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c
>> index 2e9e2d1..72c7359 100644
>> --- a/drivers/mtd/tests/oobtest.c
>> +++ b/drivers/mtd/tests/oobtest.c
>> @@ -213,8 +213,15 @@ static int verify_eraseblock_in_one_go(int ebnum)
>>       int err = 0;
>>       loff_t addr = ebnum * mtd->erasesize;
>>       size_t len = mtd->ecclayout->oobavail * pgcnt;
>> +     int i;
>> +
>> +     for (i = 0; i < pgcnt; i++)
>> +             prandom_bytes_state(&rnd_state, &writebuf[i * use_len],
>> +                             use_len);
>> +     if (len % use_len)
>> +             prandom_bytes_state(&rnd_state, &writebuf[i * use_len],
>> +                             len % use_len);
>>
>> -     prandom_bytes_state(&rnd_state, writebuf, len);
>>       ops.mode      = MTD_OPS_AUTO_OOB;
>>       ops.len       = 0;
>>       ops.retlen    = 0;

I would rather fix the use of prandom_bytes_state() in write_eraseblock()
than fix in verify_eraseblock_in_one_go().

>> @@ -594,7 +601,10 @@ static int __init mtd_oobtest_init(void)
>>               if (bbt[i] || bbt[i + 1])
>>                       continue;
>>               prandom_bytes_state(&rnd_state, writebuf,
>> -                                     mtd->ecclayout->oobavail * 2);
>> +                                     mtd->ecclayout->oobavail);
>> +             prandom_bytes_state(&rnd_state,
>> +                                     writebuf + mtd->ecclayout->oobavail,
>> +                                     mtd->ecclayout->oobavail);
>>               addr = (i + 1) * mtd->erasesize - mtd->writesize;
>>               ops.mode      = MTD_OPS_AUTO_OOB;
>>               ops.len       = 0;

The same goes for this.  I would rather fix prandom_bytes_state() when
writing OOBs.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ