Bug 505670 - double free in /usr/lib/sa/sadc in current rawhide sysstat
Summary: double free in /usr/lib/sa/sadc in current rawhide sysstat
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: sysstat
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-06-12 20:11 UTC by Jonathan Kamens
Modified: 2009-07-20 07:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-07-20 07:07:51 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
patch to fix double free (1.05 KB, patch)
2009-07-07 17:38 UTC, Jonathan Kamens
no flags Details | Diff

Description Jonathan Kamens 2009-06-12 20:11:57 UTC
This is the output of the "/usr/lib/sa/sa1 -S DISK 1 1" cron job on my system with everything current from Rawhide.  Running the same command with MALLOC_CHECK_=0 makes the crash go away.

*** glibc detected *** /usr/lib/sa/sadc: double free or corruption (!prev): 0x08c9ad28 ***
======= Backtrace: =========
/lib/libc.so.6[0x423231]
/usr/lib/sa/sadc[0x8049a2f]
/usr/lib/sa/sadc[0x804a6fd]
/lib/libc.so.6(__libc_start_main+0xe6)[0x3c9a66]
/usr/lib/sa/sadc[0x8048ff1]
======= Memory map: ========
002b5000-002df000 r-xp 00000000 08:01 15663140   /lib/libgcc_s-4.4.0-20090514.so.1
002df000-002e0000 rw-p 00029000 08:01 15663140   /lib/libgcc_s-4.4.0-20090514.so.1
0038f000-003af000 r-xp 00000000 08:01 15665608   /lib/ld-2.10.1.so
003af000-003b0000 r--p 0001f000 08:01 15665608   /lib/ld-2.10.1.so
003b0000-003b1000 rw-p 00020000 08:01 15665608   /lib/ld-2.10.1.so
003b3000-0051e000 r-xp 00000000 08:01 15665619   /lib/libc-2.10.1.so
0051e000-0051f000 ---p 0016b000 08:01 15665619   /lib/libc-2.10.1.so
0051f000-00521000 r--p 0016b000 08:01 15665619   /lib/libc-2.10.1.so
00521000-00522000 rw-p 0016d000 08:01 15665619   /lib/libc-2.10.1.so
00522000-00525000 rw-p 00000000 00:00 0 
00a25000-00a26000 r-xp 00000000 00:00 0          [vdso]
08048000-08058000 r-xp 00000000 08:01 9978787    /usr/lib/sa/sadc
08058000-0805a000 rw-p 0000f000 08:01 9978787    /usr/lib/sa/sadc
08c99000-08cba000 rw-p 00000000 00:00 0          [heap]
b808d000-b808f000 rw-p 00000000 00:00 0 
bfc27000-bfc3c000 rw-p 00000000 00:00 0          [stack]

Comment 1 Ivana Varekova 2009-06-15 06:41:29 UTC
Please which version of sysstat do you have?

Comment 2 Ivana Varekova 2009-06-15 07:55:08 UTC
Could you attach here your  /proc/stat, /proc/uptime, /proc/partitions, /proc/diskstats, /proc/interrupts, /proc/meminfo and /proc/self/mountstats files?

Comment 3 udas 2009-07-06 07:43:11 UTC
I found Debian bug #507659 looking very similar:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=507659

Comment 4 Jonathan Kamens 2009-07-06 19:42:40 UTC
Crash appears to be gone in rawhide.

Comment 5 Jonathan Kamens 2009-07-07 16:27:57 UTC
It's crashing again.  I'm investigating.

Comment 6 Jonathan Kamens 2009-07-07 17:38:47 UTC
Created attachment 350839 [details]
patch to fix double free

Well, it took me a while of banging my head against the code to figure it out, but I finally did.

The code was set up for two different activity structures, net_dev_act and net_edev_act, to share the same device count.  The issue arises when a change in the number of devices is detected while working with one of the activity structures.  When this occurs, the device count and buffer size for that structure are adjusted.  The changed device count bleeds through into the other activity structure, since the two structures share the same device count, but the buffer size for that other structure is *not* updated, and from that point, the program is vulnerable to memory overruns because of the too-small buffer.

The attached patch fixes the problem.

Comment 7 Jonathan Kamens 2009-07-09 17:48:11 UTC
FYI, the maintainer of sysstat says, "Congratulations for fixing this annoying bug that I was personally unable to reproduce. Your patch will be included into next sysstat release."

Comment 8 Ivana Varekova 2009-07-20 07:06:53 UTC
Thanks, fixed in 9.0.4.


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