From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.karo-electronics.de ([81.173.242.67]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5yVs-0007MY-IW for linux-mtd@lists.infradead.org; Wed, 22 Jan 2014 14:10:41 +0000 Date: Wed, 22 Jan 2014 15:09:59 +0100 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= To: Lothar =?UTF-8?B?V2HDn21hbm4=?= Subject: Re: [PATCH] mtd: mtd_oobtest: fix verify errors due to incorrect use of prandom_bytes_state() Message-ID: <20140122150959.78cf2827@ipc1.ka-ro> In-Reply-To: <1389608739-10945-1-git-send-email-LW@KARO-electronics.de> References: <1389608739-10945-1-git-send-email-LW@KARO-electronics.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Artem Bityutskiy , Akinobu Mita , linux-kernel@vger.kernel.org, Huang Shijie , linux-mtd@lists.infradead.org, Andrew Morton , Brian Norris , David Woodhouse List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi, Is anyone taking care of this? Lothar Wa=C3=9Fmann 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. >=20 > Signed-off-by: Lothar Wa=C3=9Fmann > --- > drivers/mtd/tests/oobtest.c | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) >=20 > 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 =3D 0; > loff_t addr =3D ebnum * mtd->erasesize; > size_t len =3D mtd->ecclayout->oobavail * pgcnt; > + int i; > + > + for (i =3D 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); > =20 > - prandom_bytes_state(&rnd_state, writebuf, len); > ops.mode =3D MTD_OPS_AUTO_OOB; > ops.len =3D 0; > ops.retlen =3D 0; > @@ -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 =3D (i + 1) * mtd->erasesize - mtd->writesize; > ops.mode =3D MTD_OPS_AUTO_OOB; > ops.len =3D 0; --=20 ___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra=C3=9Fe 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch=C3=A4ftsf=C3=BChrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info@karo-electronics.de ___________________________________________________________