From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] segattach off-by-one?
Date: Fri, 25 Sep 2009 00:34:23 -0400 [thread overview]
Message-ID: <0394dacaee5cc8e182b6c87f23bd1c8f@brasstown.quanstro.net> (raw)
In-Reply-To: <<f75780240909242033k11fb23a0o237f7dbedf9a7bee@mail.gmail.com>>
(aside: "sig segattach" fails because nroff can elide
all leading space. /n/sources/patch/signit
one could argue for replacing the \*? in
selecting files with \** but no functions
return a **.)
i think segattach is already correct. consider this
#include <u.h>
#include <libc.h>
enum {
Sz = 0x1000,
};
void
main(void)
{
uchar *base, *rb;
base = (uchar*)0x10001001;
rb = segattach(0, "shared", base, Sz - 10);
print("%p\n", rb);
base[0] = 'a';
base[-1] = 'a';
base[Sz - 2] = 'a'; /* note this does not fault, even though Sz - 10 was used */
>> base[Sz - 1] = 'a';
exits("");
}
% 8.out
10001000 # not 10001001.
81 8.out: checked 8 page table entries
8.out 81: suicide: sys: trap: fault write addr=0x10002000 pc=0x1073
if i were to have used rb and not base, this base[-1] would have
faulted but base[Sz - 1] would have been okay. so i woud think
this is a misunderstanding of how segattach works.
if one wishes to disallow mapping the zero page this
condition should be changed:
if(va != 0 && va >= USTKTOP)
error(Ebadarg);
to
if(va < BY2PG || va >= USTKTOP)
- erik
next parent reply other threads:[~2009-09-25 4:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<f75780240909242033k11fb23a0o237f7dbedf9a7bee@mail.gmail.com>
2009-09-25 4:34 ` erik quanstrom [this message]
2009-09-25 18:01 ` Venkatesh Srinivas
2009-09-25 18:18 ` erik quanstrom
2009-09-25 18:32 ` erik quanstrom
2009-09-25 3:33 Venkatesh Srinivas
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=0394dacaee5cc8e182b6c87f23bd1c8f@brasstown.quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).