Bug 59760 - Reading systemStats table segfaults snmpd
Summary: Reading systemStats table segfaults snmpd
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: ucd-snmp
Version: 7.2
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-02-12 20:42 UTC by Hrunting Johnson
Modified: 2015-03-05 01:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-04-09 12:45:26 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2002:106 0 normal SHIPPED_LIVE Updated ucd-snmp packages available 2002-06-04 04:00:00 UTC

Description Hrunting Johnson 2002-02-12 20:42:27 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)

Description of problem:
I have an 8-way Compaq Proliant 8500 server.  When trying to fetch the 
systemStats snmp table with snmpwalk, snmpd segfaults.  No core file is left on 
the system to backtrace.  Other tables work fine.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Start snmpd
2. MIBS=ALL snmpwalk <ip> <community> systemStats
3. Wait
	

Actual Results:  The snmpwalk times out.  The snmpd server has segfaulted.

Expected Results:  The systemStats table should return its information and 
snmpd should still be running afterwards.

Additional info:

This is happening both with the ucd-snmp-4.2.1-7 package from RH7.2 updates and 
the ucd-snmp-4.2.3-5 package from rawhide.  I have the 4.2.1-7 package running 
on another two-way box just fine (querying the same table works).  Here's an 
strace from the snmpd process when the query is performed:

select(6, [4 5], [], [], NULL)          = 1 (in [5])
recvfrom(5, "0*\2\1\0\4\7j0ll13s\241\34\2\4h\272.\374\2\1\0\2\1\000"..., 8192, 
0, {sin_family=AF_INET, sin_port=htons(32943), sin_addr=inet_addr
("216.166.60.74")}}, [16]) = 44
sendto(5, "0-\2\1\0\4\7j0ll13s\242\37\2\4h\272.\374\2\1\0\2\1\000"..., 47, 0, 
{sin_family=AF_INET, sin_port=htons(32943), sin_addr=inet_addr
("216.166.60.74")}}, 16) = 47
gettimeofday({1013545003, 633208}, NULL) = 0
select(6, [4 5], [], [], NULL)          = 1 (in [5])
recvfrom(5, "0,\2\1\0\4\7j0ll13s\241\36\2\4h\272.\375\2\1\0\2\1\000"..., 8192, 
0, {sin_family=AF_INET, sin_port=htons(32943), sin_addr=inet_addr
("216.166.60.74")}}, [16]) = 46
sendto(5, "07\2\1\0\4\7j0ll13s\242)\2\4h\272.\375\2\1\0\2\1\0000\033"..., 57, 
0, {sin_family=AF_INET, sin_port=htons(32943), sin_addr=inet_addr
("216.166.60.74")}}, 16) = 57
gettimeofday({1013545003, 634503}, NULL) = 0
select(6, [4 5], [], [], NULL)          = 1 (in [5])
recvfrom(5, "0,\2\1\0\4\7j0ll13s\241\36\2\4h\272.\376\2\1\0\2\1\000"..., 8192, 
0, {sin_family=AF_INET, sin_port=htons(32943), sin_addr=inet_addr
("216.166.60.74")}}, [16]) = 46
open("/proc/stat", O_RDONLY)            = 7
read(7, "cpu  56703 73 201398 86198962\ncp"..., 1023) = 1023
close(7)                                = 0
--- SIGSEGV (Segmentation fault) ---

Again, no core file is left to backtrace.

Comment 1 Hrunting Johnson 2002-02-12 21:11:50 UTC
It looks like the reason it faults is because it doesn't read enough 
information from /proc/stat.  Here's a quick fix patch which at least works for 
me (my /proc/stat is about 2200 bytes in size, and I don't think anyone is 
going to go over 4096 bytes), but I think a better fix is to make sure to read 
enough information from /proc/stat to have all the data you need by iterating 
until everything needed is either found or the entire file is read (in this 
case, the ctxt information wasn't read because it fell outside of the default 
1024 byte range).

diff -u follows


--- ucd-snmp-4.2.3/agent/mibgroup/ucd-snmp/vmstat.c.orig        Tue Feb 12 
15:07:45 2002
+++ ucd-snmp-4.2.3/agent/mibgroup/ucd-snmp/vmstat.c     Tue Feb 12 14:57:24 2002
@@ -146,7 +146,7 @@
 
 
 #define VMSTAT_FILE "/proc/stat"
-#define BUFFSIZE 1024
+#define BUFFSIZE 4096
 static char buff[BUFFSIZE];
 
 void getstat(unsigned long *cuse, unsigned long *cice, unsigned long *csys,



Comment 2 Phil Knirsch 2002-02-24 17:57:07 UTC
Sounds as if your /proc/stat is quite large ;-)

Anyway, it sounds very reasonable to me to increase this buffer or even to make
it dynamic. It will be fixed in the next rawhide version.

Read ya, Phil

Comment 3 Phil Knirsch 2002-04-09 12:45:20 UTC
The updated to 4.2.4 should fix this problem as the code has been rewritten and
no static buffers are used anymore.

If you could give the latest rawhide version an report if it fixes the problem
you see i'd greately appreciate it.

Thanks,

Read ya, Phil

Comment 4 Phil Knirsch 2002-07-25 12:32:47 UTC
No news is good news, so i assume that the updated fixed the problem. :-)

If not, feel free to reopen the bug.

Read ya, Phil


Note You need to log in before you can comment on or make changes to this bug.