bsnmpd always died on HDD detach

Mikolaj Golub trociny at FreeBSD.org
Sat Sep 15 12:50:11 UTC 2012


On Sun, Sep 09, 2012 at 11:56:55PM +0200, Miroslav Lachman wrote:
> I am running bsnmpd with basic snmpd.config (only community and location 
> changed).
> 
> When there is a problem with HDD and disk disapeared from ATA channel 
> (eg.: disc physically removed) the bsnmpd always dumps core:
> 
> kernel: pid 1188 (bsnmpd), uid 0: exited on signal 11 (core dumped)
> 
> I see this for a long rime on all releases of 7.x and 8.x branches (i386 
> and amd64). I did not tested 9.x.

Ok, I was able to to reproduce this under qemu doing
  
  atacontrol detach ata1

It crashes in snmp_hostres module, in

  refresh_device_tbl->refresh_disk_storage_tbl->disk_OS_get_ATA_disks

when traversing device_map list and dereferencing map->entry_p, which
is NULL here.

device_map table is used for consistent device table indexing.

refresh_device_tbl(), refresh routine for hrDeviceTable, checks the
list of available devices and calls device_entry_delete() for devices
that have gone. It does not remove the entry from device_map table,
but just sets entry_p to NULL for it (to preserve index reuse by
another device).

Then refresh_disk_storage_tbl() is called, which in turn calls

 disk_OS_get_ATA_disks();
 disk_OS_get_MD_disks();
 disk_OS_get_disks();

and it crashes in disk_OS_get_ATA_disks() when the removed map entry
is dereferenced.

I am attaching the patch that fixes the issue for me.

I was wandering why the issue was not observed after md device
removal, as disk_OS_get_MD_disks() did the same things. It has turned
out that hostres just does not see md devices, so this function is
currently useless. hostres gets devices from devinfo(3), which does
not return md devices.

disk_OS_get_disks() calls kern.disks sysctl to get the list of disks,
and uses device_map differently, so it is not affected.

-- 
Mikolaj Golub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hostres_diskstorage_tbl.c.skip.patch
Type: text/x-diff
Size: 940 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20120915/71997662/hostres_diskstorage_tbl.c.skip.bin


More information about the freebsd-stable mailing list