Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV: not enough space or error in allocation for extenstion #233

Closed
minfrin opened this issue Dec 16, 2020 · 8 comments
Closed

SIGSEGV: not enough space or error in allocation for extenstion #233

minfrin opened this issue Dec 16, 2020 · 8 comments

Comments

@minfrin
Copy link
Contributor

minfrin commented Dec 16, 2020

When configuring snmpd to read a certificate that has been put in place via a symbolic link, snmpd crashes as follows:

[root@localhost tls]# systemctl status snmpd.service
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
   Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: core-dump) since Wed 2020-12-16 21:21:59 SAST; 16min ago
  Process: 53269 ExecStart=/usr/sbin/snmpd $OPTIONS -f (code=dumped, signal=SEGV)
 Main PID: 53269 (code=dumped, signal=SEGV)

Dec 16 21:21:57 localhost systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Dec 16 21:21:58 localhost snmpd[53269]: refusing to read world readable or writable key /etc/snmp/tls/certs/snmpd.crt
Dec 16 21:21:58 localhost snmpd[53269]: not enough space or error in allocation for extenstion
Dec 16 21:21:59 localhost systemd[1]: snmpd.service: Main process exited, code=dumped, status=11/SEGV
Dec 16 21:21:59 localhost systemd[1]: snmpd.service: Failed with result 'core-dump'.
Dec 16 21:21:59 localhost systemd[1]: Failed to start Simple Network Management Protocol (SNMP) Daemon..

Working backwards from the last (misspelled - "extension") error message:

https://github.com/haad/net-snmp/blob/c629882ba31aaf27c859de2d47a6401849661ccd/snmplib/snmp_openssl.c#L222

We return NULL from _cert_get_extension().

Searching for cases where we call _cert_get_extension() but don't handle a NULL result:

lf = strchr(str, '\n'); /* look for multiline strings */

@bvanassche
Copy link
Contributor

Please retest with the latest version of either the v5.9 branch or the master branch.

@minfrin
Copy link
Contributor Author

minfrin commented Dec 17, 2020

This problem was tested on v5.9 and exists in the v5.9 and master branch.

Please don't close issues until they have been properly investigated. I've pointed out the line of the code where the problem lies, github makes it trivial to see this problem on various branches.

I have a patch that avoids the crash, I have to mess about with forks before I can submit it. You'll see that shortly.

@bvanassche
Copy link
Contributor

Reopened. This issue was closed automatically by github since I used the "Fixes:" tag in a commit description.

@minfrin
Copy link
Contributor Author

minfrin commented Dec 18, 2020

No worries, github is being too clever for its own good.

@minfrin
Copy link
Contributor Author

minfrin commented Jan 5, 2021

@paride
Copy link

paride commented Jan 21, 2021

Hi, IIUC this is fixed in both the master and V5-9-patches branches (bb30f8e), and this issue is still open waiting for confirmation that the fix actually works, correct?

@minfrin
Copy link
Contributor Author

minfrin commented Jan 21, 2021

Hi, IIUC this is fixed in both the master and V5-9-patches branches (bb30f8e), and this issue is still open waiting for confirmation that the fix actually works, correct?

Not correct, no.

Two fixes were developed at the same time, and clashed. The first fix to the segfault only auto-closed this ticket (thanks github) and the ticket was reopened. The second fix also fixed the buffer-too-small that triggered the error path that caused the crash.

All outstanding PRs have been committed, this ticket can be closed.

@paride
Copy link

paride commented Jan 21, 2021

@minfrin thanks for clarifying, I see that the second fix (bb30f8e, your fix) landed, but doesn't have a Fixes: ... in the commit message. As you opened this issue you can also close it I think.

@minfrin minfrin closed this as completed Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants