Bug 1782180

Summary: snmpd returns "invalid(4)" process state (hrSWRunStatus) for process names containing spaces
Product: Red Hat Enterprise Linux 7 Reporter: Apurbita Mukherjee <apmukher>
Component: net-snmpAssignee: Josef Ridky <jridky>
Status: CLOSED ERRATA QA Contact: Evgeny Fedin <efedin>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.7CC: djez, efedin, fkrska, jridky, ovasik
Target Milestone: rcKeywords: EasyFix, Patch, Reproducer
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: net-snmp-5.7.2-49.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-29 20:56:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1780582    

Description Apurbita Mukherjee 2019-12-11 10:52:47 UTC
Description of problem:
When querying the hrSWRunStatus table via SNMP when using snmpd, it should generally return 1 or 2 for processes that are running or runnable. However, if the process name contains a space, snmpd return 4 (invalid) for the process state. This appears to be because it's reading /proc/$PID/stat and simply splitting on space and then grabbing the third element, which would normally be the process status, but when the process name contains a space, this is no longer true.

Version-Release number of selected component (if applicable):
net-snmp-5.7.2-43.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Install above net-snmp version 
2. Configure SNMP using rocommunity 

3. As an example of a process where this is failing:

$ cat /proc/52425/stat
52425 (spamd child) S 52423 52423 52423 0 -1 1077944384 525 0 0 0 0 0 0 0 20 0 1 0 4144660 296542208 17648 18446744073709551615 1 1 0 0 0 0 0 4224 2048 18446744073709551615 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0

$ snmpwalk -v2c -c **** localhost .1.3.6.1.2.1.25.4.2.1.7.52425
HOST-RESOURCES-MIB::hrSWRunStatus.52425 = INTEGER: invalid(4)    <<<----

Actual results:
it should generally return 1 or 2 for processes that are running.

Expected results:
The snmpwalk result should be correct instead of returning any invalid error.


Additional info:
This looks to have been fixed in upstream snmpd in 5.7.3 in this commit https://github.com/net-snmp/net-snmp/commit/8fa46f29613c1792c4a14432944273b6d74e3f3c#diff-bdb35b3a9a24eb5464a067632ef01ddf which is the version after the one that's currently in RHEL7, - 5.7.2.

Comment 14 errata-xmlrpc 2020-09-29 20:56:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (net-snmp bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4037