From nobody@FreeBSD.ORG  Mon Oct 30 22:18:48 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id B000B37B479; Mon, 30 Oct 2000 22:18:48 -0800 (PST)
Message-Id: <20001031061848.B000B37B479@hub.freebsd.org>
Date: Mon, 30 Oct 2000 22:18:48 -0800 (PST)
From: iwaki@bc.niigata-u.ac.jp
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: linprocfs causes system down and reboot
X-Send-Pr-Version: www-1.0

>Number:         22435
>Category:       kern
>Synopsis:       linprocfs causes system down and reboot
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 30 22:20:01 PST 2000
>Closed-Date:    Tue Oct 31 00:54:38 PST 2000
>Last-Modified:  Sat Nov  4 21:00:02 PST 2000
>Originator:     Mamoru Iwaki
>Release:        FreeBSD 4.1.1-STABLE
>Organization:
Niigata University
>Environment:
FreeBSD mi000.merlin.gs.niigata-u.ac.jp 4.1.1-STABLE FreeBSD 4.1.1-STABLE #0: Tue Oct 31 14:34:58 JST 2000     root@mi000.merlin.gs.niigata-u.ac.jp:/usr/obj/amd/mi004/home2/FreeBSD-src/stable4/src/sys/MI  i386

>Description:
Using linprocfs on 4.1.1-STABLE system, 

% cat /compat/linux/proc/stat

or

% cat /compat/linux/proc/uptime

cause a panic with the following message

 Fatal trap 18: integer divide fault while in kernel mode
 instruction pointer     = 0x8:0xc0933030
 stack pointer           = 0x10:0xc60dddc8
 frame pointer           = 0x10:0xc60dde20
 code segment            = base 0x0, limit 0xfffff, type 0x1b
                         = DPL 0, pres 1, def32 1, gran 1
 processor eflags        = interrupt enabled, resume, IOPL = 0
 current process         = 325 (cat)
 interrupt mask          = none
 trap number             = 18
 panic: integer divide fault

and then the system reboots immediately.  At least, this problem has
exist since 4.1.1-STABLE around 24 Oct., but around 17 Oct..  

This is dangerous because every user can make system down easily.  

I heard that the CURRENT around 28 Oct. works good with the same
operations, so this problem maybe exist only in 4.1.1-STABLE.  
>How-To-Repeat:
Use the above commands on 4.1.1-STABLE around 24 Oct.  
>Fix:
In private communication, assar@freebsd.org proposed the following 
patch, which looks working well.  

In src/sys/i386/linux/linprocfs, 

--- linprocfs_misc.c.org        Fri Sep 22 17:01:45 2000
+++ linprocfs_misc.c    Tue Oct 31 10:10:18 2000
@@ -65,8 +65,8 @@
 
 #include <i386/linux/linprocfs/linprocfs.h>
 
-#define T2J(x) (((x) * 100) / stathz)
-#define T2S(x) ((x) / stathz)
+#define T2J(x) (((x) * 100) / (stathz ? stathz : hz))		/* ticks to jiffies */
+#define T2S(x) ((x) / (stathz ? stathz : hz))		/* ticks to seconds */
 
 int
 linprocfs_domeminfo(curp, p, pfs, uio)


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Tue Oct 31 00:38:03 PST 2000 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22435 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Tue Oct 31 00:54:38 PST 2000 
State-Changed-Why:  
Already fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22435 

From: Dag-Erling Smorgrav <des@ofug.org>
To: iwaki@bc.niigata-u.ac.jp
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/22435: linprocfs causes system down and reboot
Date: 31 Oct 2000 09:54:14 +0100

 iwaki@bc.niigata-u.ac.jp writes:
 > Using linprocfs on 4.1.1-STABLE system, 
 > 
 > % cat /compat/linux/proc/stat
 > 
 > or
 > 
 > % cat /compat/linux/proc/uptime
 > 
 > cause a panic with the following message
 
 This happens when stathz is 0 - I MFCed a fix yesterday, so your PR
 came just a few hours too late :)
 
 DES
 -- 
 Dag-Erling Smorgrav - des@ofug.org
 

From: Mamoru Iwaki <iwaki@bc.niigata-u.ac.jp>
To: des@ofug.org
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/22435: linprocfs causes system down and reboot
Date: Tue, 31 Oct 2000 18:25:43 +0900

 From: Dag-Erling Smorgrav <des@ofug.org>
 Subject: Re: kern/22435: linprocfs causes system down and reboot
 Date: 31 Oct 2000 09:54:14 +0100
 
 > This happens when stathz is 0 - I MFCed a fix yesterday, so your PR
 > came just a few hours too late :)
 
 Yes, thank you.
 ---
 -----
 Mamoru IWAKI   (iwaki@bc.niigata-u.ac.jp)
 Graduate School of Science and Technology, Niigata University
 

From: Mamoru Iwaki <iwaki@bc.niigata-u.ac.jp>
To: des@ofug.org
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/22435: linprocfs causes system down and reboot
Date: Sun, 05 Nov 2000 13:52:03 +0900

 From: Dag-Erling Smorgrav <des@ofug.org>
 Subject: Re: kern/22435: linprocfs causes system down and reboot
 Date: 31 Oct 2000 09:54:14 +0100
 
 > > % cat /compat/linux/proc/stat
 
 > > cause a panic with the following message
 > 
 > This happens when stathz is 0 - I MFCed a fix yesterday, so your PR
 > came just a few hours too late :)
 
 In my system like 
 
 % uname -a
 FreeBSD mi000.merlin.gs.niigata-u.ac.jp 4.2-BETA FreeBSD 4.2-BETA #0: Sat Nov  4 17:46:31 JST 2000     root@mi000.merlin.gs.niigata-u.ac.jp:/usr/obj/amd/mi004/home2/FreeBSD-src/stable4/src/sys/MI  i386
 
 the following command still makes system down immediately: 
 
 % cat /compat/linux/proc/0/stat
 
 even if the user is not a super user.  DANGEROUS!
 ---
 -----
 Mamoru IWAKI   (iwaki@bc.niigata-u.ac.jp)
 Graduate School of Science and Technology, Niigata University
 
>Unformatted:
