NetBSD Problem Report #7722

Received: (qmail 8491 invoked from network); 6 Jun 1999 18:06:17 -0000
Message-Id: <199906061801.VAA00739@kolster.fi>
Date: Sun, 6 Jun 1999 21:01:48 +0300 (EEST)
From: Antti Kantee <pooka@iki.fi>
Reply-To: pooka@iki.fi
To: gnats-bugs@gnats.netbsd.org
Subject: any user can freeze the system via mmap + write
X-Send-Pr-Version: 3.95

>Number:         7722
>Category:       kern
>Synopsis:       any user can freeze the system via mmap + write
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    thorpej
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 06 11:20:00 +0000 1999
>Closed-Date:    Mon Jun 07 19:24:21 +0000 1999
>Last-Modified:  Mon Jun 07 19:24:54 +0000 1999
>Originator:     Antti Kantee
>Release:        NetBSD/i386 1.4C
>Organization:
>Environment:
NetBSD/i386 1.4C, supped and compiled (kernel) today

>Description:
By following the actions described in How-To-Repeat any user can freeze 
(note: not panic, but freeze) the system completely. X becomes totally
unresponsive. The text console becomes unresposive too, pressing 
CTRL-Z prints out ^Z, but nothing else intelligent happens. This box
is completely alone, so I have no way of testing is it really dead or
just faking. Nothing happened in the following 10 minutes that I bothered
to wait.

>How-To-Repeat:
I suspect that there are also other ways to make this problem surface,
but here's the one I ran into. Compile and run the following code.

--SNIP--
#include <sys/types.h>
#include <sys/mman.h>

#include <fcntl.h>
#include <unistd.h>

int
main() {

   int fd1, fd2;
   void *file1;

   fd1 = open("/etc/passwd", O_RDONLY);
   file1 = mmap(0, 100, PROT_READ, MAP_FILE, fd1, 0);

   fd2 = open("/dev/audio", O_WRONLY);
   write(fd2, file1, 10010);
}
--UNSNIP--

Note that the problem depends on the last argument to write, 101 or 1001
bytes were not enough to freeze the system (my system), but 10010 worked
'like a charm'.

>Fix:
	Don't do it. (admittedly not a very good fix..)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: thorpej 
State-Changed-When: Mon Jun 7 12:02:25 PDT 1999 
State-Changed-Why:  
This appears to be a bug in audio_write().  I'm looking at how to fix it. 
Responsible-Changed-From-To: kern-bug-people->thorpej 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Mon Jun 7 12:02:55 PDT 1999 
Responsible-Changed-Why:  
I've analyzed the problem, and will work on the fix. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: thorpej 
State-Changed-When: Mon Jun 7 12:24:21 PDT 1999 
State-Changed-Why:  
Fixed in rev 1.115 of sys/dev/audio.c 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.