Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Oct 2009 17:51:04 +0200 (CEST)
From:      Alexander Best <alexbestms@math.uni-muenster.de>
To:        <freebsd-hackers@FreeBSD.org>
Subject:   mmap(2) with MAP_ANON honouring offset although it shouldn't
Message-ID:  <permail-200910211551041e86ffa80000182a-a_best01@message-id.uni-muenster.de>

next in thread | raw e-mail | index | archive | help
  This is a MIME encoded multipart message.

--+permail-200910211551041e86ffa80000182a-a_best01+
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

although the mmap(2) manual states in section MAP_ANON:

"The offset argument is ignored."

this doesn't seem to be true. running

printf("%p\n", mmap((void*)0x1000, 0x1000, PROT_NONE, MAP_ANON, -1,
0x12345678));

and

printf("%p\n", mmap((void*)0x1000, 0x1000, PROT_NONE, MAP_ANON, -1, 0));

produces different outputs. i've attached a patch to solve the problem. the
patch is similar to the one proposed in this PR, but should apply cleanly to
CURRENT: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/71258

cheers.
alex

--+permail-200910211551041e86ffa80000182a-a_best01+
Content-Type: text/plain
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename="vmmmap.c.patch.txt"

LS0tIHNyYy9zeXMvdm0vdm1fbW1hcC5jCTIwMDktMTAtMjEgMDQ6MTM6MjQuMDAwMDAwMDAwICsw
MjAwCisrKyBzcmMvc3lzL3ZtL3ZtX21tYXAuYwkyMDA5LTEwLTIxIDA0OjEzOjQzLjAwMDAwMDAw
MCArMDIwMApAQCAtMjQ1LDE1ICsyNDUsMTggQEAKIAl9CiAKIAkvKgotCSAqIEFsaWduIHRoZSBm
aWxlIHBvc2l0aW9uIHRvIGEgcGFnZSBib3VuZGFyeSwKLQkgKiBhbmQgc2F2ZSBpdHMgcGFnZSBv
ZmZzZXQgY29tcG9uZW50LgorCSAqIFVubGVzcyB0aGUgTUFQX0FOT04gZmxhZyBpcyBzZXQsIGFs
aWduIHRoZSBmaWxlIHBvc2l0aW9uCisJICogdG8gYSBwYWdlIGJvdW5kYXJ5IGFuZCBzYXZlIGl0
cyBwYWdlIG9mZnNldCBjb21wb25lbnQuCiAJICovCi0JcGFnZW9mZiA9IChwb3MgJiBQQUdFX01B
U0spOwotCXBvcyAtPSBwYWdlb2ZmOwotCi0JLyogQWRqdXN0IHNpemUgZm9yIHJvdW5kaW5nIChv
biBib3RoIGVuZHMpLiAqLwotCXNpemUgKz0gcGFnZW9mZjsJCQkvKiBsb3cgZW5kLi4uICovCi0J
c2l6ZSA9ICh2bV9zaXplX3QpIHJvdW5kX3BhZ2Uoc2l6ZSk7CS8qIGhpIGVuZCAqLworCWlmIChm
bGFncyAmIE1BUF9BTk9OKSB7CisJCXBhZ2VvZmYgPSBwb3MgPSAwOworCX0gZWxzZSB7CisJCXBh
Z2VvZmYgPSAocG9zICYgUEFHRV9NQVNLKTsKKwkJcG9zIC09IHBhZ2VvZmY7CisJCS8qIEFkanVz
dCBzaXplIGZvciByb3VuZGluZyAob24gYm90aCBlbmRzKS4gKi8KKwkJc2l6ZSArPSBwYWdlb2Zm
OwkJCS8qIGxvdyBlbmQuLi4gKi8KKwkJc2l6ZSA9ICh2bV9zaXplX3QpIHJvdW5kX3BhZ2Uoc2l6
ZSk7CS8qIGhpIGVuZCAqLworCX0KIAogCS8qCiAJICogQ2hlY2sgZm9yIGlsbGVnYWwgYWRkcmVz
c2VzLiAgV2F0Y2ggb3V0IGZvciBhZGRyZXNzIHdyYXAuLi4gTm90ZQpAQCAtMzAwLDcgKzMwMyw2
IEBACiAJCWhhbmRsZSA9IE5VTEw7CiAJCWhhbmRsZV90eXBlID0gT0JKVF9ERUZBVUxUOwogCQlt
YXhwcm90ID0gVk1fUFJPVF9BTEw7Ci0JCXBvcyA9IDA7CiAJfSBlbHNlIHsKIAkJLyoKIAkJICog
TWFwcGluZyBmaWxlLCBnZXQgZnAgZm9yIHZhbGlkYXRpb24gYW5kCg==

--+permail-200910211551041e86ffa80000182a-a_best01+--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-200910211551041e86ffa80000182a-a_best01>