The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: jnc@mercury.lcs.mit.edu (Noel Chiappa)
Subject: [TUHS] The evolution of Unix facilities and architecture
Date: Sun, 14 May 2017 17:44:19 -0400 (EDT)	[thread overview]
Message-ID: <20170514214419.EFC1618C0A2@mercury.lcs.mit.edu> (raw)

    > From: Random832

    > Ah. There's the other piece. You start the SUID program under the
    > debugger, and ... it simply starts it non-suid. *However*, in the
    > presence of shared text ...  you can make changes to the text image
    > ... which will be reused the *next* time it is started *without* the
    > debugger.

So I actually tried to do this (on a V6 system running on an emulator), after
whipping up a tiny test program (which prints "1", and the real and current
UIDs): the plan was to patch it to print a different number.

However, after a variety of stubbed toes and hiccups (gory details below, if
anyone cares), including a semi-interesting issue with the debugger and pure
texts), I'm punting: when trying to set a breakpoint in a pure text, I get the
error message "Can't set breakpoint", which sort of correlates with the
comment in the V6 sig$ptrace(): "write user I (for now, always an error)".

So it's not at all clear that the technique we thought would work would, in
fact, work - unless people weren't using a stock V6 system, but rather one
that had been tweaked to e.g. allow use of debuggers on pure-text programs
(including split I+D).

It's interesting to speculate on what the 'right' fix would be, if somehow the
techique above did work. The 'simple' fix, on systems with a PWB1-line XWRIT
flag, would be to ignore SETUID bits when doing an exec() of a pure text that
had been modified. But probably 'the' right fix would be to give someone
debugging a pure-text program their own private copy of the text. (This would
also prevent people who try to run the program from hitting breakpoints while
it's being debugged. :-)


But anyway, it's clear that back when, when I thought I'd found the bug, I
clearly hadn't - which is why when I looked into the source, it looked like it
had been 'already' been fixed. (And why Jim G hemmed and hawed...)

But I'm kind of curious about that mod in PWB1 that writes a modified pure
text back to the swap area when the last process using it exits. What was the
thinking behind that? What's the value to allowing someone to patch the
in-core pure text, and then save those patches? And there's also the 'other
people who try and run a program beind debugged are going to hit breakpoints'
issue, if you do allow writing into pure texts...


	Noel


--------


For the gory details: to start with, attempting to run a pure-text program
(whether SUID or not) under the debugger produced a "Can't execute
{program-name} Process terminated."  error message.

'cdb' is printing this error message just after the call to exec() (if that
fails, and returns). I modified it to print the error number when that
happens, and it's ETXTBSY. I had a quick look at the V6 source, to see if I
could see what the problem is, and it seems to be be (in sys1$exec()):

    if(u.u_arg[1]!=0 && (ip->i_flag&ITEXT)==0 && ip->i_count!=1) {
		     u.u_error = ETXTBSY;
			       goto bad;
			       }

What that code does is a little obscure; I'm not sure I understand it. The
first term checks to see if the size of the text segment is non-zero (which it
is not, in both 0407 and 0410 files). The second is, I think, looking to see
if the inode is marked as being in use for a pure text (which it isn't, until
later in exec()). The third checks to make sure nobody else is using the file.

So I guess this prevents exec() of a file which is already open, and not for a
pure text. (Why this is the Right Thing is not instantly clear to me...)

Anyway, the reason this fails under 'cdb' is that the debugger already has it
open (to be able to read the code). So I munged the debugger to close it
before doing the exec(), and then the error went away.

Then I ran into a long series of issues, the details of which are not at all
interesting, connected with the fact that the version of 'cdb' I was using
(one I got off a Tim Shoppa modified V6 disk) doesn't correspond to either of
the sources I have for 'cdb'.

When I switched to the latest source (so I could fix the issue above), it had
some bug where it wouldn't work unless there was a 'core' file. But eventually
I kludged it enough to get the 'can't set breakpoints' message, at which point
I threw in the towel.



             reply	other threads:[~2017-05-14 21:44 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-14 21:44 Noel Chiappa [this message]
     [not found] <mailman.1.1494986402.2329.tuhs@minnie.tuhs.org>
2017-05-19 14:31 ` David
  -- strict thread matches above, loose matches on Subject: below --
2017-05-16 13:20 Noel Chiappa
2017-05-16 13:46 ` Clem Cole
2017-05-13  1:25 Noel Chiappa
2017-05-13  0:44 Noel Chiappa
2017-05-13  0:51 ` Random832
2017-05-13  0:55   ` Dave Horsfall
2017-05-13  1:17   ` Chris Torek
2017-05-13 15:25   ` Steve Simon
2017-05-13 16:55     ` Clem Cole
2017-05-13 17:19       ` William Pechter
2017-05-14 12:55         ` Derek Fawcus
2017-05-14 22:12           ` Dave Horsfall
2017-05-15  1:24             ` Nemo
2017-05-15 18:00               ` Steve Johnson
2017-05-16 22:33                 ` Ron Natalie
2017-05-16 23:13                   ` Arthur Krewat
2017-05-16 23:18                     ` Ron Natalie
2017-05-13 23:01     ` Dave Horsfall
2017-05-12 23:30 Noel Chiappa
2017-05-12 23:38 ` Dave Horsfall
2017-05-12 23:52   ` Random832
2017-05-13  0:26     ` Dave Horsfall
2017-05-13  0:48       ` Random832
2017-05-13  0:22 ` Clem Cole
2017-05-13  0:23   ` Clem Cole
2017-05-12 18:43 Doug McIlroy
2017-05-12 18:56 ` Dan Cross
2017-05-12 19:43   ` Clem Cole
2017-05-12 20:06     ` Clem Cole
2017-05-12 20:40       ` Jeremy C. Reed
2017-05-12 21:29         ` Clem Cole
2017-05-12 21:29   ` Ron Natalie
2017-05-12 15:12 Noel Chiappa
2017-05-12 15:17 ` Clem Cole
2017-05-12 15:18   ` Clem Cole
2017-05-12 15:46     ` Clem Cole
2017-05-11 17:08 Noel Chiappa
2017-05-11 21:34 ` Dave Horsfall
2017-05-11 14:07 Noel Chiappa
2017-05-11 14:21 ` Larry McVoy
2017-05-11 16:17   ` Clem Cole
2017-05-11 17:11     ` Michael Kjörling
2017-05-11 21:44       ` Dave Horsfall
2017-05-11 22:06         ` Warner Losh
2017-05-12  6:24         ` Hellwig Geisse
2017-05-12 21:12           ` Dave Horsfall
2017-05-12 23:25             ` Hellwig Geisse
2017-05-11 16:15 ` Clem Cole
2017-05-11 16:52   ` Warner Losh
2017-05-11 17:12     ` Clem Cole
2017-05-11 20:37       ` Ron Natalie
2017-05-11 22:25         ` Larry McVoy
2017-05-11 22:30           ` Ron Natalie
2017-05-11 23:47           ` Dave Horsfall
2017-05-11 23:48             ` Ron Natalie
2017-05-12  0:21               ` Larry McVoy
2017-05-12  2:42                 ` Warner Losh
2017-05-12  0:16             ` Larry McVoy
2017-05-12  1:41               ` Wesley Parish
2017-05-12  1:05             ` Toby Thain
2017-05-12  8:17               ` Michael Kjörling
2017-05-12 13:56                 ` Tim Bradshaw
2017-05-12 14:22                   ` Michael Kjörling
2017-05-12 14:30                   ` Larry McVoy
2017-05-12 15:11                     ` Tim Bradshaw
2017-05-12 15:52                     ` Chet Ramey
2017-05-12 16:21                       ` Warner Losh
2017-05-12  8:15             ` Harald Arnesen
2017-05-14  4:30           ` Theodore Ts'o
2017-05-14 17:40             ` Clem Cole
2017-05-10 14:08 Diomidis Spinellis
2017-05-10 14:38 ` Steffen Nurpmeso
2017-05-10 23:09   ` Erik Berls
2017-05-11 12:40     ` Steffen Nurpmeso
2017-05-11  0:49 ` Clem Cole

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=20170514214419.EFC1618C0A2@mercury.lcs.mit.edu \
    --to=jnc@mercury.lcs.mit.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).