From nobody@FreeBSD.org  Mon Aug 24 11:39:15 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1528B106568B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Aug 2009 11:39:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 03DA48FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Aug 2009 11:39:15 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n7OBdE7u036181
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Aug 2009 11:39:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n7OBdE4N036180;
	Mon, 24 Aug 2009 11:39:14 GMT
	(envelope-from nobody)
Message-Id: <200908241139.n7OBdE4N036180@www.freebsd.org>
Date: Mon, 24 Aug 2009 11:39:14 GMT
From: Mikolaj Golub <to.my.trociny@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] pstat -t coredumps when reading from kernel crashdump
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         138131
>Category:       bin
>Synopsis:       [patch] pstat(8): pstat -t coredumps when reading from kernel crashdump
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 24 11:40:01 UTC 2009
>Closed-Date:    Thu Jan 27 19:09:17 UTC 2011
>Last-Modified:  Thu Jan 27 19:10:08 UTC 2011
>Originator:     Mikolaj Golub
>Release:        7.2-STABLE but all versions are affected
>Organization:
>Environment:
FreeBSD zhuzha.ua1 7.2-STABLE FreeBSD 7.2-STABLE #2: Fri Jul  3 08:58:49 EEST 2009     root@zhuzha.ua1:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
"pstat -t -M <vmcore>" crashes with segmentation fault.

#0  0x0804912f in ttymode_kvm () at /usr/src/usr.sbin/pstat/pstat.c:249
249                     tp = TAILQ_NEXT(tp, t_list);
(gdb) list
244                     XT_COPY(ilowat);
245                     XT_COPY(ohiwat);
246                     XT_COPY(olowat);
247     #undef XT_COPY
248                     ttyprt(&xt);
249                     tp = TAILQ_NEXT(tp, t_list);
250             }
251     }
252
253     static void
(gdb) bt
#0  0x0804912f in ttymode_kvm () at /usr/src/usr.sbin/pstat/pstat.c:249
#1  0x08049274 in ttymode () at /usr/src/usr.sbin/pstat/pstat.c:282
#2  0x08048f56 in main (argc=0, argv=0xbfbfeda0) at /usr/src/usr.sbin/pstat/pstat.c:196

>How-To-Repeat:
pstat -t -M /dev/mem 

>Fix:
Attached patch fixes the problem.

Patch attached with submission follows:

--- usr.sbin/pstat/pstat.c.orig	2009-08-24 14:15:10.000000000 +0300
+++ usr.sbin/pstat/pstat.c	2009-08-24 14:16:10.000000000 +0300
@@ -246,7 +246,7 @@ ttymode_kvm(void)
 		XT_COPY(olowat);
 #undef XT_COPY
 		ttyprt(&xt);
-		tp = TAILQ_NEXT(tp, t_list);
+		tp = TAILQ_NEXT(&tty, t_list);
 	}
 }
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wxs 
State-Changed-When: Tue Oct 13 16:38:26 UTC 2009 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138131 
State-Changed-From-To: closed->open 
State-Changed-By: wxs 
State-Changed-When: Wed Oct 14 15:36:52 UTC 2009 
State-Changed-Why:  
Closed the wrong PR. Sorry. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138131 
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Tue Jun 1 18:08:02 UTC 2010 
State-Changed-Why:  
Fixed in head and stable/8 (r178987). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138131 
Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Fri Jul 30 00:44:22 UTC 2010 
Responsible-Changed-Why:  
Assign to remko as MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138131 
State-Changed-From-To: patched->closed 
State-Changed-By: remko 
State-Changed-When: Thu Jan 27 19:09:16 UTC 2011 
State-Changed-Why:  
Finally merged to stable/7, closing the PR. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/138131: commit references a PR
Date: Thu, 27 Jan 2011 19:08:06 +0000 (UTC)

 Author: remko
 Date: Thu Jan 27 19:08:01 2011
 New Revision: 217957
 URL: http://svn.freebsd.org/changeset/base/217957
 
 Log:
   MFC r178987
   
     Fix pstat behaviour when using coredumps. The reference to tp was
     incorrect and should have been poining to &tty, tp is a virtual
     address from the coredump, while we should obtain the address through
     the tty struct.
   
     Approved by:	imp (mentor, implicit trivial changes)
     MFC after:	1 week
     Submitted by:	Ed Schouten (ed at 80836 dot nl)
   
   PR:		138131
 
 Modified:
   stable/7/usr.sbin/pstat/pstat.c
 Directory Properties:
   stable/7/usr.sbin/pstat/   (props changed)
 
 Modified: stable/7/usr.sbin/pstat/pstat.c
 ==============================================================================
 --- stable/7/usr.sbin/pstat/pstat.c	Thu Jan 27 19:05:43 2011	(r217956)
 +++ stable/7/usr.sbin/pstat/pstat.c	Thu Jan 27 19:08:01 2011	(r217957)
 @@ -246,7 +246,7 @@ ttymode_kvm(void)
  		XT_COPY(olowat);
  #undef XT_COPY
  		ttyprt(&xt);
 -		tp = TAILQ_NEXT(tp, t_list);
 +		tp = TAILQ_NEXT(&tty, t_list);
  	}
  }
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
