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]
Message-ID: <CACna6rzd8q5ziy3FkN2F5j7DaV6tsM1s1z8jeLzEEurvnEQ_Ow@mail.gmail.com>
Date:	Sun, 24 Jan 2016 10:44:06 +0100
From:	Rafał Miłecki <zajec5@...il.com>
To:	Brian Norris <computersforpeace@...il.com>,
	Hauke Mehrtens <hauke@...ke-m.de>
Cc:	"Maciej W. Rozycki" <macro@...ux-mips.org>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Javier Martinez Canillas <javier@....samsung.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Fengguang Wu <fengguang.wu@...el.com>,
	Michael Ellerman <mpe@...erman.id.au>,
	Luis de Bethencourt <luisbg@....samsung.com>,
	Jeremy Kerr <jk@...abs.org>,
	Neelesh Gupta <neelegup@...ux.vnet.ibm.com>,
	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	David Woodhouse <dwmw2@...radead.org>,
	Cyril Bur <cyrilbur@...il.com>
Subject: Re: [PATCH] mtd: bcm47xxsflash: use devm_ioremap_nocache() instead of KSEG0ADDR()

On 23 January 2016 at 22:49, Brian Norris <computersforpeace@...il.com> wrote:
> On Sat, Jan 16, 2016 at 01:38:11AM +0100, Rafał Miłecki wrote:
>> So I wanted to stick to the cached mapping, [...]
>
> I mentioned this earlier on, but I don't feel like I've gotten a clear
> answer. Is a cached mapping actually safe here? From the looks of it,
> the memory mapping is a read-only memory-mapped flash, and flash writes
> / erasures are done through a different bus (register writes vis BCMA
> bus). So if we have a cached mapping of that memory, it doens't
> naturally synchronize with any write/erase operations. Doesn't this mean
> you might get stale data if you do a sequence of read / erase / read,
> for instance, since the 2nd read will return cached data from the 1st
> read?
>
> IIUC, this could be solved by:
> (a) using an uncached mapping or
> (b) explicitly invalidating the relevant region after doing flash writes
> or erasures
>
> But I wonder why you haven't seen any problems if you've been using
> KSEG0 (cached) this whole time. Maybe just luck? Or you don't actually
> write to the flash that much?

Now you pointed this difference between reads and writes I sounds
worrying indeed. I'm not aware of ever hitting this problem but maybe
I just didn't use flash in a way triggering it?

I'm looking for a way to test it. Using user space I could try doing
something like:
echo foo > a.txt
cat a.txt
echo bar > a.txt
cat a.txt

I guess even more reliable test would to be test in in kernel space. I
guess I could modify bcm47xxsflash_write to read flash region that is
going to be modified: before modification and after. Both reads using
KSEG0ADDR. Then compare if the second read matches was was written.

Does my idea for tests make sense?

-- 
Rafał

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ