NetBSD Problem Report #17438
Received: (qmail 1903 invoked by uid 605); 30 Jun 2002 11:48:47 -0000
Message-Id: <20020629182908.6B78646A3@stasis.kittenz.org>
Date: Sat, 29 Jun 2002 19:29:08 +0100 (BST)
From: xs@kittenz.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: xs@kittenz.org
To: gnats-bugs@gnats.netbsd.org
Subject: null pointer dereference in systrace
X-Send-Pr-Version: 3.95
>Number: 17438
>Category: kern
>Synopsis: null pointer dereference in systrace
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: thorpej
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 30 11:49:00 +0000 2002
>Closed-Date: Tue Jul 02 16:23:39 +0000 2002
>Last-Modified: Tue Jul 02 16:23:39 +0000 2002
>Originator: xs@kittenz.org
>Release: NetBSD 1.6B
>Organization:
>Environment:
/sys/kern/kern_systrace.c:
$NetBSD: kern_systrace.c,v 1.2 2002/06/18 01:24:15 thorpej Exp $
System: NetBSD stasis 1.6B NetBSD 1.6B (STASIS) #13: Sat Jun 29 19:10:55 BST 2002 xs@stasis:/usr/src/sys/arch/i386/compile/STASIS i386
Architecture: i386
Machine: i386
>Description:
systrace_enter() permits strp to become NULL at function exit, but
the emulation handling code does not account for this.
>How-To-Repeat:
#include <sys/types.h>
#include <dev/systrace.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include <stdio.h>
#define X(x) if ((x) < 0) err(1, "failure: %s", ""#x);
int
main()
{
int fd;
pid_t pid;
X(pid = fork());
if (pid == 0) {
for (;;)
sleep(600);
_exit(1);
}
/* parent */
X(fd = open("/dev/systrace", O_RDONLY, 0));
X(ioctl(fd, STRIOCATTACH, &pid));
X(fork());
X(ioctl(fd, STRIOCDETACH, &pid));
X(ioctl(fd, STRIOCATTACH, &pid));
X(ioctl(fd, STRIOCDETACH, &pid));
X(ioctl(fd, STRIOCATTACH, &pid));
exit(0);
}
>Fix:
Index: kern_systrace.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/kern_systrace.c,v
retrieving revision 1.2
diff -u -r1.2 kern_systrace.c
--- kern_systrace.c 2002/06/18 01:24:15 1.2
+++ kern_systrace.c 2002/06/29 18:35:37
@@ -689,10 +690,13 @@
if (fst) {
SYSTRACE_UNLOCK(fst, p);
}
- if (error == 0)
- strp->oldemul = p->p_emul;
- else
- strp->oldemul = NULL;
+ if (strp != NULL) {
+ if (error == 0)
+ strp->oldemul = p->p_emul;
+ else
+ strp->oldemul = NULL;
+ }
+
return error;
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: thorpej
State-Changed-When: Tue Jul 2 09:23:17 PDT 2002
State-Changed-Why:
Patch applied.
Responsible-Changed-From-To: kern-bug-people->thorpej
Responsible-Changed-By: thorpej
Responsible-Changed-When: Tue Jul 2 09:23:17 PDT 2002
Responsible-Changed-Why:
I applied patch.
>Unformatted:
(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.