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] [day] [month] [year] [list]
Date:	Mon, 06 Jul 2009 20:44:57 -0400
From:	Valdis.Kletnieks@...edu
To:	Arnd Bergmann <arnd@...db.de>
Cc:	michal.simek@...alogix.com, Paul Mundt <lethal@...ux-sh.org>,
	Linux Kernel list <linux-kernel@...r.kernel.org>,
	LTP <ltp-list@...ts.sourceforge.net>,
	John Williams <john.williams@...alogix.com>,
	Ingo Molnar <mingo@...e.hu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Grant Likely <grant.likely@...retlab.ca>,
	subrata@...ux.vnet.ibm.com
Subject: Re: mmap syscall problem

On Mon, 06 Jul 2009 16:16:11 +0200, Arnd Bergmann said:

> What happens in a simple user space program that mmaps the same
> page to two addresses? Something like
> 
> #include <sys/mman.h>
> #include <fcntl.h>
> int main(void)
> {
> 	int fd = open("existing-4k-file", O_RDWR);
> 	char *p1 = mmap(0, 4096, PROT_READ | PROT_WRITE,
> 				MAP_SHARED, fd, 0);
> 	char *p2 = mmap(p1 + 4096, 4096, PROT_READ | PROT_WRITE,
> 				MAP_SHARED | MAP_FIXED, fd, 0);
> 
> 	*p1 = 0xaa; *p2 = 0x55;
> 
> 	return *p1; /* returns 0xaa if broken, 0x55 if correct */
> }

Strictly speaking, doesn't that need a barrier of some sort between the two
assignments?  I mean, how is gcc supposed to intuit that p1 and p2 alias
each other and it needs to reload *p1 before returning that value?

(And in more complicated code, I could even see the compiler re-ordering those
two assignments, so the in-file value is different as well as the return; value)


Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ