package/netsnmp: fix memory leak in IP-MIB when running without IPv6
PATCH 1/1 package/netsnmp: fix memory leak in IP-MIB when running without IPv6
In a Linux system without IPv6 support (or booted with "ipv6.disable=1") file /proc/net/snmp6 is not present. If such file is not present an allocated memory is not freed. Memory leak occurs even without snmp queries.
Problem seen at least since netsnmp 5.7.3 (probably even v5.6.1). Patch backported from netsnmp 5.9, where the problem does not appear any more.
--- ...-Linux-Fix-a-memory-leak-in-an-error-path.patch | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch
package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch new file +37 -0
@@ -0,0 +1,37 @@ +From 7c073e3a1b736689135fd2ed44ede5b83790bd37 Mon Sep 17 00:00:00 2001 +From: Bart Van Assche <[email protected]> +Date: Mon, 26 Aug 2019 18:32:08 -0700 +Subject: IP-MIB, Linux: Fix a memory leak in an error path + +When a Linux system is booted with "ipv6.disable=1" in the kernel command +line, the file "/proc/net/snmp6" is not created. Fix the memory leak in +_systemstats_v6_load_systemstats() that is triggered with IPv6 disabled. + +See also https://sourceforge.net/p/net-snmp/bugs/2976/. + +Reported-by: Mark E Rusk <[email protected]> +--- + agent/mibgroup/ip-mib/data_access/systemstats_linux.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c +index e28ff93..f68d122 100644 +--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c ++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c +@@ -560,10 +560,12 @@ _systemstats_v6_load_systemstats(netsnmp_container* container, u_int load_flags) + * try to open file. If we can't, that's ok - maybe the module hasn't + * been loaded yet. + */ +- if (!(devin = fopen(filename, "r"))) { ++ devin = fopen(filename, "r"); ++ if (!devin) { + DEBUGMSGTL(("access:systemstats", + "Failed to load Systemstats Table (linux1), cannot open %s\n", + filename)); ++ netsnmp_access_systemstats_entry_free(entry); + return 0; + } + +-- +2.7.4 +
Signature · 1 line
2.7.4
PATCH 1/1 package/netsnmp: fix memory leak in IP-MIB when running without IPv6
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Adam" == Adam Wujek <[email protected]> writes:
In a Linux system without IPv6 support (or booted with "ipv6.disable=1") file
/proc/net/snmp6is not present. If such file is not present an allocated memory is not freed. Memory leak occurs even without snmp queries.Problem seen at least since netsnmp 5.7.3 (probably even v5.6.1). Patch backported from netsnmp 5.9, where the problem does not appear any more.
Committed, thanks.
This function is only called once, right?
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/netsnmp: fix memory leak in IP-MIB when running without IPv6
Quoted 1 line
This function is only called once, right?
Unfortunately not. The bug fixed in this commit causes a leak of 356 bytes every 60 seconds! To hit this problem your system has to fulfil the following:
--Linux system with no IPv6 support (precisely, no /proc/net/snmp6 file in the system) --included IP-MIB in the netsnmp
The leak also happens when snmp queries are not performed.
Note: in netsnmp 5.7.3 there is an option for configure "--enable-ipv6", even without this option enabled the bug show up. In 5.8 the option is contrary "--disable-ipv6", but I haven't checked if the problem is when the disable of ipv6 is activated. For sure the leak happens if netsnmp is compiled with ipv6 support, but there is no such support by a Linux kernel. In 5.9 this problem is fixed.
IMHO: this patch should be pushed to all maintenance branches. Would you like to send such patch (with appropriate header) to this mailing list?
??????? Original Message ???????
Quoted 19 lines · Peter Korsgaard
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Adam" == Adam Wujek
dev_publicat wujek.eu writes:In a Linux system without IPv6 support (or booted with "ipv6.disable=1")
file
/proc/net/snmp6is not present. If such file is not present an allocatedmemory is not freed. Memory leak occurs even without snmp queries.
Problem seen at least since netsnmp 5.7.3 (probably even v5.6.1).
Patch backported from netsnmp 5.9, where the problem does not appear any more.
Committed, thanks.
This function is only called once, right?
----------------------------------------------------------------
Bye, Peter Korsgaard
PATCH 1/1 package/netsnmp: fix memory leak in IP-MIB when running without IPv6
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"wujek" == wujek dev <[email protected]> writes:
This function is only called once, right?
Unfortunately not. The bug fixed in this commit causes a leak of 356 bytes every 60 seconds! To hit this problem your system has to fulfil the following:
--Linux system with no IPv6 support (precisely, no/proc/net/snmp6file in the system) --included IP-MIB in the netsnmpThe leak also happens when snmp queries are not performed.
Ok :/
Quoted 11 lines
Note: in netsnmp 5.7.3 there is an option for configure "--enable-ipv6", even without this option enabled the bug show up. In 5.8 the option is contrary "--disable-ipv6", but I haven't checked if the problem is when the disable of ipv6 is activated. For sure the leak happens if netsnmp is compiled with ipv6 support, but there is no such support by a Linux kernel.
In 5.9 this problem is fixed.IMHO: this patch should be pushed to all maintenance branches. Would you like to send such patch (with appropriate header) to this mailing list?
Don't worry, I'll take care of backporting it myself.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/netsnmp: fix memory leak in IP-MIB when running without IPv6
In reply to Adam WujekQuoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Adam" == Adam Wujek <[email protected]> writes:
In a Linux system without IPv6 support (or booted with "ipv6.disable=1") file
/proc/net/snmp6is not present. If such file is not present an allocated memory is not freed. Memory leak occurs even without snmp queries.Problem seen at least since netsnmp 5.7.3 (probably even v5.6.1). Patch backported from netsnmp 5.9, where the problem does not appear any more.
Signed-off-by Adam Wujek <[email protected]>
Committed to 2020.02.x, 2020.08.x and 2020.11.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard