9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: Re: [9fans] Kernel crash bug
Date: Sat,  1 Aug 2009 23:37:49 +0200	[thread overview]
Message-ID: <335ad4871879ca38a650196a26e6f200@gmx.de> (raw)
In-Reply-To: <Pine.LNX.4.64-044.0908011700100.6538@unix10.andrew.cmu.edu>

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

maybe the kernel should use something like this to validate pointers
to null terminated strings?

(this assumes that validaddr for a byte will also be valid for the whole page)

void
validstraddr(char *p)
{
	char *x;

	for(;;){
		validaddr((ulong)p, 1, 0);
		x = (char*)(((ulong)p & ~(BY2PG-1))+BY2PG);
		for(; p < x; p++){
			if(*p == 0)
				return;
		}
	}
}

--
cinap

[-- Attachment #2: Type: message/rfc822, Size: 3019 bytes --]

From: Elizabeth Jones <elly1@andrew.cmu.edu>
To: 9fans@9fans.net
Subject: [9fans] Kernel crash bug
Date: Sat, 1 Aug 2009 17:01:26 -0400 (EDT)
Message-ID: <Pine.LNX.4.64-044.0908011700100.6538@unix10.andrew.cmu.edu>

There exist crash bugs in some of the system call handlers to do with
string validation; sometimes, only the first byte of an argument string is
validated. The following program reliably causes a kernel panic for me:

#include <u.h>
#include <libc.h>

#define SEGBASE (char*)0x40000000
#define SEGSIZE 4096

int main() {
     segattach(0, "shared", SEGBASE, SEGSIZE);
     *(char*)(SEGBASE + SEGSIZE - 1) = 'a';
     exec((char*)SEGBASE + SEGSIZE - 1, nil);
     return 0;
}

-- Elly

  reply	other threads:[~2009-08-01 21:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-01 21:01 Elizabeth Jones
2009-08-01 21:37 ` cinap_lenrek [this message]
2009-08-01 22:01   ` Charles Forsyth
2009-08-01 22:08     ` Russ Cox
2009-08-01 22:47       ` Elizabeth Jones
2009-08-01 23:09         ` Russ Cox
2009-08-01 23:15         ` cinap_lenrek
2009-08-02  1:38         ` erik quanstrom
2009-08-02  2:13           ` erik quanstrom

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=335ad4871879ca38a650196a26e6f200@gmx.de \
    --to=cinap_lenrek@gmx.de \
    --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).