The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: imp@bsdimp.com (Warner Losh)
Subject: [TUHS] Harvard and Von Neumann Architectures and Unix
Date: Mon, 27 Nov 2017 11:14:08 -0700	[thread overview]
Message-ID: <CANCZdfoiZAaa4UF-n2Dz78wA_-PCFQ-T9Q4t5DLYBJG83RJLSg@mail.gmail.com> (raw)
In-Reply-To: <20171127165046.GD3430@mcvoy.com>

On Mon, Nov 27, 2017 at 9:50 AM, Larry McVoy <lm at mcvoy.com> wrote:

> On Mon, Nov 27, 2017 at 11:11:41AM -0500, Noel Chiappa wrote:
> >     > From: Doug McIlroy
> >
> >     > But if that had been in D space, it couldn't have been executed.
> >
> > Along those lines, I was wondering about modern OS's, which I gather for
> > security reasons prevent execution of data, and prevent writing to code.
> >
> > Programs which emit these little 'custom code fragments' (I prefer that
> term,
> > since they aren't really 'self-modifying code' - which I define as 'a
> program
> > which _changes_ _existing_ instructions) must have some way of having a
> chunk
> > of memory into which they can write, but which can also be executed.
>
> Isn't that how dtrace works?
>

That's not self modifying code. I've written some self-modifying code (I
was young, it was sexy, I thought), and it's all about rewriting your own
instruction stream. And doing so based on data you get so far. Not every
modification of a text page is self-modifying code.

dtrace, and every debugger that doesn't have hardware assist debug
registers (or overflows them) modifies the text pages to allow breakpoints,
watchpoints, tracepoints and the like to work. Even the OS creates code to
run at runtime. The signal trampoline that's used to return from a signal
handler in BSD is a small bit of code the OS fills in bits of out of a
template. It's one of the things that slowed adoption of turning off the X
bit for stack pages in response to many of the buffer overflow attacks.

On modern architectures, a fair amount of PTE and/or cache dancing needs to
happen to make this stuff work sometimes. Some processors make this easy
with dual mappings, others are... what's the right word... tedious.

Warner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20171127/59598dd0/attachment.html>


  parent reply	other threads:[~2017-11-27 18:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 16:11 Noel Chiappa
2017-11-27 16:50 ` Larry McVoy
2017-11-27 17:08   ` Clem Cole
2017-11-27 18:21     ` Lawrence Stewart
2017-11-27 18:30       ` Lars Brinkhoff
2017-11-27 18:14   ` Warner Losh [this message]
2017-11-27 18:26     ` Paul Winalski
2017-11-27 17:35 ` Ian Zimmerman
2017-11-28 14:55 ` Tim Bradshaw
2017-11-28 19:45   ` Paul Winalski
  -- strict thread matches above, loose matches on Subject: below --
2017-11-27 17:11 Noel Chiappa
2017-11-28  0:23 ` Dave Horsfall
2017-11-25 17:34 Doug McIlroy
2017-11-25 14:24 Noel Chiappa
2017-11-25 15:58 ` Lawrence Stewart
2017-11-25 16:10 ` Lars Brinkhoff
2017-11-25 19:59 ` Steve Simon
2017-11-25 21:59 ` Bakul Shah
2017-11-25  3:14 Doug McIlroy
2017-11-25  4:16 ` Jon Steinhart
2017-11-25  5:17   ` ron minnich
2017-11-25 14:23 ` Ralph Corderoy
2017-11-24 21:43 Noel Chiappa
2017-11-24 21:50 ` Jon Steinhart
2017-11-25 21:55   ` William Cheswick
2017-11-25 23:15     ` Dave Horsfall
2017-11-24 22:20 ` Mike Markowski
2017-11-24 22:31   ` Dave Horsfall
2017-11-24 19:25 Will Senn
2017-11-24 19:28 ` Jon Steinhart
2017-11-27 14:50 ` Tony Finch

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=CANCZdfoiZAaa4UF-n2Dz78wA_-PCFQ-T9Q4t5DLYBJG83RJLSg@mail.gmail.com \
    --to=imp@bsdimp.com \
    /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).