All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Mortimer <richm@oldelvet.org.uk>
To: sparclinux@vger.kernel.org
Subject: Re: mmap breakage
Date: Sat, 04 Dec 2004 23:16:41 +0000	[thread overview]
Message-ID: <1102202201.15654.111.camel@duncow> (raw)
In-Reply-To: <Pine.LNX.4.61.0412032354010.1963@bobcat>

[-- Attachment #1: Type: text/plain, Size: 832 bytes --]

FWIW. I forgot to attach the program that demonstrates the behaviour.

Richard

On Sat, 2004-12-04 at 23:13, Richard Mortimer wrote:
> On Sat, 2004-12-04 at 05:22, Jurij Smakov wrote:

> Well I can demonstrate the behaviour (see attached test program) on sparc64 and i386. It allows mappings to be fully or partially replaced and even allows you to replace bits in the middle of a mapping.


> P.S. You can see the overwriting of mappings if you look at
> /proc/<pid>/maps. You will see that the second mapping has totally
> superceded the first and the third mapping has split the second one up.
> 
> 01000000-01002000 rw-p 00000000 00:0b 8               /dev/zero
> 01002000-01004000 rw-p 00000000 03:02 863336          /var/log/messages
> 01004000-01020000 rw-p 00004000 00:0b 8               /dev/zero
-- 
richm@oldelvet.org.uk

[-- Attachment #2: mmaptest2.c --]
[-- Type: text/x-csrc, Size: 687 bytes --]

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>

int main()
{
	char *addr1;
	char *addr2;
	char *addr3;
	int fd1;
	int fd2;
	int fd3;
	fd1 = open("/var/log/syslog", O_RDONLY);
	fd2 = open("/dev/zero", O_RDWR);
	fd3 = open("/var/log/messages", O_RDONLY);
	addr1 = mmap((void*)0x1000000, 0x2000, PROT_READ, MAP_PRIVATE|MAP_FIXED, fd1,0);
	addr2 = mmap((void*)0x1000000, 0x20000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, fd2,0);
	addr3 = mmap((void*)0x1002000, 0x2000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, fd3,0);
	printf("addr1 is %p\n", addr1);
	printf("addr2 is %p\n", addr2);
	printf("addr3 is %p\n", addr3);

	sleep(100);
	return 0;
}

  parent reply	other threads:[~2004-12-04 23:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-04  5:22 mmap breakage Jurij Smakov
2004-12-04 23:13 ` Richard Mortimer
2004-12-04 23:16 ` Richard Mortimer [this message]
2004-12-06  4:30 ` Jurij Smakov
2004-12-06  5:23 ` David S. Miller
2004-12-07  6:00 ` Jurij Smakov
2004-12-07  6:06 ` David S. Miller
2004-12-07  6:11 ` Keith M Wesolowski
2004-12-07  6:20 ` David S. Miller
2004-12-07  6:31 ` Jurij Smakov
2004-12-07  7:47 ` David S. Miller
2004-12-07  8:24 ` Jakub Jelinek
2004-12-07 15:38 ` Jurij Smakov
2004-12-08  0:54 ` Richard Mortimer
2004-12-09  5:24 ` David S. Miller
2004-12-09  7:34 ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1102202201.15654.111.camel@duncow \
    --to=richm@oldelvet.org.uk \
    --cc=sparclinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.