9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Bounds checking bug ifcall(2) functions
Date: Fri, 16 Nov 2007 05:38:24 -0500	[thread overview]
Message-ID: <c03ff139454ba47fe3365466ffc8a5e4@quanstro.net> (raw)
In-Reply-To: <473CA225.86119D3C@null.net>

> Erik Dalén wrote:
> > On second thought I think you are correct. At the end of the function
> > the pointer might be one byte past the buffer size, but then it won't
> > do any reads or writes (But it could be a problem if the buffer is
> > right at the end of the virtual memory space :).
> 
> The C standard requires that pointer arithmetic work properly
> for one-past-the-end pointers.  On some architectures that may
> mean that each data segment has to have an extra (unused) byte
> allocated, but on most architectures nothing special has to be
> done.

i think what he's saying is that for machines with unsigned ptr
arithmetic, on a 16-bit machine, ~0 (0xffff) is not a legal address;
on a 32-bit machine ~0 (0xffffff) is not a legal address; &c.  on a
machine with page-based vm, i think this means the highest page 
isn't kosher.  (if signed, the problem is at 0x7f(ff)*.)  this is because
for all addresses a except ~0 a < a+1.  i suppose you could hand
out all but the last 2 bytes of the final page.

i don't think it means you have to allocate an extra byte. there's
no requirement that you may indirect the "one-past the end" address.

- erik


  reply	other threads:[~2007-11-16 10:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-09 22:20 [9fans] Bounds checking bug in fcall(2) functions Erik Dalén
2007-11-09 22:42 ` Charles Forsyth
2007-11-09 23:01   ` Erik Dalén
2007-11-09 23:41     ` Charles Forsyth
2007-11-10 17:55     ` Russ Cox
2007-11-16 10:18     ` [9fans] Bounds checking bug ifcall(2) functions Douglas A. Gwyn
2007-11-16 10:38       ` erik quanstrom [this message]
2007-11-19 10:14         ` Douglas A. Gwyn

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=c03ff139454ba47fe3365466ffc8a5e4@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@cse.psu.edu \
    /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).