snmptrapd Segmentation Faults When Calling my_load_defaults()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
net-snmp (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Medium
|
Matthew Ruffell |
Bug Description
[Impact]
When starting snmptrapd configured to connect to a mysql server, we segmentation fault when calling my_load_defaults():
$ sudo /usr/sbin/snmptrapd -LOw -f
Segmentation fault (core dumped)
(gdb) bt
#0 0x00007efd8d9f15b0 in MEM_ROOT::Alloc (length=56, this=this@
#1 init_default_
#2 0x00007efd8d9f817a in my_load_defaults (conf_file=
#3 0x00007efd8e74fe1b in netsnmp_mysql_init () from /lib/x86_
#4 0x0000555a8a9e3873 in main (argc=<optimized out>, argv=<optimized out>) at snmptrapd.c:1196
What happens is that we are calling my_load_defaults() even though we have mysql_options(), and the arguments we pass into my_load_defaults() are NULL, which eventually get de-referenced.
The fix is to change the configure script to only call my_load_defaults() if we don't have mysql_options().
[Testcase]
$ sudo apt update
$ sudo apt install snmp snmpd snmptrapd snmp-mibs-
Edit /etc/snmp/
disableAuthoriz
traphandle default /usr/bin/logger
sqlMaxQueue 1
sqlSaveInterval 9
Save and exit.
It is easier to reproduce if you stop and disable all services:
$ sudo systemctl stop snmptrapd.service
$ sudo systemctl stop snmpd.service
Then try running:
$ sudo /usr/sbin/snmptrapd -LOw -f
Segmentation fault (core dumped)
There is a test package available in the following ppa:
https:/
When running this test package, you will instead see:
$ sudo /usr/sbin/snmptrapd -LOw -f
mysql_real_
Error 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/
(I don't have a mysql server configured, but we don't segfault anymore).
[Where problems can occur]
We are changing how snmptrapd initialises and begins connections to a mysql server, and if a regression were to occur, it would be limited to users of snmptrapd with the mysql backend. Other database backends would not be affected.
Other binaries produced would also not be affected.
[Other Info]
The issue was fixed upstream by the following commit:
commit 011342d8e453b9e
Author: Bart Van Assche <email address hidden>
Date: Sat Aug 18 09:28:14 2018 -0700
Subject: snmptrapd: Let configure check for mysql_options()
Link: https:/
Changed in net-snmp (Ubuntu): | |
status: | New → Fix Released |
Changed in net-snmp (Ubuntu Focal): | |
status: | New → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Matthew Ruffell (mruffell) |
tags: | added: focal sts |
description: | updated |
description: | updated |
tags: | added: sts-sponsor |
tags: |
added: sts-sponsor-mfo removed: sts-sponsor |
Attached is a patch that resolves the issue on Focal.