Subject: lib/179: [lib] Bug in libkvm...
To: None <gnats-admin>
From: Rafal Boni <rafal@rafal.slip.uiuc.edu>
List: netbsd-bugs
Date: 03/30/1994 21:50:02
>Number:         179
>Category:       lib
>Synopsis:       argument of klseek() not cast to off_t
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gnats-admin (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 30 21:50:02 1994
>Originator:     Rafal Boni
>Organization:
	...me organized? Ha!

>Release:        -current, Mar. 30, 94
>Environment:

System: NetBSD rafal.slip.uiuc.edu 0.9a RAFAL#1 i386
	System supped as of Mar. 30, mid-late afternoon.

>Description:

	Due to someone forgetting a cast in libkvm/kvm.c, ps's reads of
	process information are getting back some invalid data... This
	shows up on my system as:

USER       PID %CPU %MEM   VSZ  RSS TT  STAT STARTED       TIME COMMAND
rafal      389  0.0  2.5   244  204 vg  R+   31Dec69    0:00.13 ps -aux
rafal      388  0.0  3.7   436  308 vg  S+   25Oct65    0:00.13 tcsh -c ps -aux
						^^
						Not last I checked! 

>How-To-Repeat:

	1. Rebuild "ps" after rebuilding new libs with widened off_t.
	2. Do a "ps -aux"

>Fix:

*** kvm.c	Wed Mar 30 23:04:20 1994
--- kvm.c.fixed	Wed Mar 30 23:04:20 1994
***************
*** 695,703 ****
  	 * Read u-area one page at a time for the benefit of post-mortems
  	 */
  	up = (char *) p->p_addr;
  	for (i = 0; i < UPAGES; i++) {
! 		klseek(kmem, (long)up, 0);
  		if (read(kmem, user.upages[i], CLBYTES) != CLBYTES) {
  			setsyserr("cant read page %x of u of pid %d from %s",
  			    up, p->p_pid, kmemf);
  			return(NULL);
--- 695,703 ----
  	 * Read u-area one page at a time for the benefit of post-mortems
  	 */
  	up = (char *) p->p_addr;
  	for (i = 0; i < UPAGES; i++) {
! 		klseek(kmem, (off_t) up, 0);
  		if (read(kmem, user.upages[i], CLBYTES) != CLBYTES) {
  			setsyserr("cant read page %x of u of pid %d from %s",
  			    up, p->p_pid, kmemf);
  			return(NULL);
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------