bin/129170: truss segv for unknown syscall

Steven Hartland steven.hartland at multiplay.co.uk
Tue Nov 25 03:10:04 PST 2008


>Number:         129170
>Category:       bin
>Synopsis:       truss segv for unknown syscall
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 25 11:10:04 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Steven Hartland
>Release:        FreeBSD 7.0
>Organization:
Multiplay
>Environment:
FreeBSD loncore0.multiplay.co.uk 7.0-RELEASE-p3 FreeBSD 7.0-RELEASE-p3 #8: Sat Nov 22 18:46:41 GMT 2008     root at loncore0.multiplay.co.uk:/usr/src/sys/amd64/compile/MULTIPLAY  amd64
>Description:
If an application calls an unknown syscall truss will segfault due to an invalid range check on nsyscalls
>How-To-Repeat:
Run an application which calls a syscall that truss doesnt know of e.g. a linux application which calls a syscall >= 311 on FreeBSD 7.0.
>Fix:
Apply the attached patch or derivative there of.

Patch attached with submission follows:

--- amd64-fbsd.c.orig	2008-11-22 03:22:33.000000000 +0000
+++ amd64-fbsd.c	2008-11-22 03:24:57.000000000 +0000
@@ -143,5 +143,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ?  NULL : syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num >= nsyscalls) ?  NULL : syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);
--- amd64-fbsd32.c.orig	2008-11-22 03:22:41.000000000 +0000
+++ amd64-fbsd32.c	2008-11-22 03:24:52.000000000 +0000
@@ -153,5 +153,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL :
+    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL :
       freebsd32_syscallnames[syscall_num];
   if (!fsc.name) {
--- amd64-linux32.c.orig	2008-11-22 03:20:58.000000000 +0000
+++ amd64-linux32.c	2008-11-22 03:21:59.000000000 +0000
@@ -125,5 +125,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : linux32_syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux32_syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);
--- i386-fbsd.c.orig	2008-11-22 03:22:50.000000000 +0000
+++ i386-fbsd.c	2008-11-22 03:24:42.000000000 +0000
@@ -148,5 +148,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);
--- i386-linux.c.orig	2008-11-21 14:11:22.000000000 +0000
+++ i386-linux.c	2008-11-25 10:33:43.000000000 +0000
@@ -125,5 +125,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : linux_syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux_syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);
--- ia64-fbsd.c.orig	2008-11-22 03:22:57.000000000 +0000
+++ ia64-fbsd.c	2008-11-22 03:24:31.000000000 +0000
@@ -136,5 +136,5 @@
 
   fsc.number = syscall_num;
-  fsc.name = (syscall_num < 0 || syscall_num > nsyscalls)
+  fsc.name = (syscall_num < 0 || syscall_num >= nsyscalls)
       ? NULL : syscallnames[syscall_num];
   if (!fsc.name) {
--- powerpc-fbsd.c.orig	2008-11-22 03:23:04.000000000 +0000
+++ powerpc-fbsd.c	2008-11-22 03:24:17.000000000 +0000
@@ -150,5 +150,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);
--- sparc64-fbsd.c.orig	2008-11-25 10:35:56.000000000 +0000
+++ sparc64-fbsd.c	2008-11-25 10:35:45.000000000 +0000
@@ -146,5 +146,5 @@
   fsc.number = syscall_num;
   fsc.name =
-    (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num];
+    (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num];
   if (!fsc.name) {
     fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num);


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list