Bug 1503119 - rexecd Could not allocate space for cmdbuf
Summary: rexecd Could not allocate space for cmdbuf
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rsh
Version: 28
Hardware: x86_64
OS: Linux
high
high
Target Milestone: ---
Assignee: Michal Ruprich
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1503108 1503112
Blocks: 1442779
TreeView+ depends on / blocked
 
Reported: 2017-10-17 12:11 UTC by Stepan Broz
Modified: 2019-01-16 02:19 UTC (History)
4 users (show)

Fixed In Version: rsh-0.17-87.fc28 rsh-0.17-89.fc29
Clone Of: 1503112
Environment:
Last Closed: 2019-01-16 01:42:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch (1.33 KB, patch)
2019-01-02 09:41 UTC, Michal Ruprich
no flags Details | Diff

Description Stepan Broz 2017-10-17 12:11:08 UTC
+++ This bug was initially created as a clone of Bug #1503112 +++

+++ This bug was initially created as a clone of Bug #1503108 +++

Description of problem:
Sometimes in.rexecd is unable to allocate memory for its cmdbug. This is because cmdbuflen = sysconf (_SC_ARG_MAX) returns a value that is too large.

Similar fix has been provided for rshd in BZ#802367 (https://bugzilla.redhat.com/show_bug.cgi?id=802367)

Version-Release number of selected component (if applicable):
rsh-server-0.17-64.el6_9.1.x86_64

How reproducible:
The reproduction scenario in our labs was not established yet. At one point, someone was able to reproduce the issue easily using the following rexec service configuration for xinetd:

service exec
{
	disable	= no
	socket_type		= stream
	wait			= no
	user			= root
	log_on_success		+= USERID
	log_on_failure 		+= USERID
	server			= /usr/sbin/in.rexecd
	per_source              = UNLIMITED
	instances               = UNLIMITED
	cps                     = 500 3
}


And issuing a simple rexec command (rexec -l username -p password hostname rm /tmp/one).

Actual results:

Strace of in.rexecd shows the following failed memory allocation:

4779 09:58:36.573128 getrlimit(RLIMIT_STACK, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0 <0.000005>
14779 09:58:36.573158 mmap(NULL, 4611686018427392000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory) <0.000005>
14779 09:58:36.573181 brk(0x40002b13d49b1000) = 0x2b13d49ad000 <0.000005>
14779 09:58:36.573199 mmap(NULL, 4611686018427523072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory) <0.000005>
14779 09:58:36.573219 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b13d49ad000 <0.000007>
14779 09:58:36.573240 munmap(0x2b13d49ad000, 56963072) = 0 <0.000008>
14779 09:58:36.573260 munmap(0x2b13dc000000, 10145792) = 0 <0.000006>
14779 09:58:36.573278 mprotect(0x2b13d8000000, 135168, PROT_READ|PROT_WRITE) = 0 <0.000006>
14779 09:58:36.573303 mmap(NULL, 4611686018427392000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory) <0.000005>
14779 09:58:36.573336 sendto(3, "<27>Oct 13 09:58:36 /usr/sbin/in.rexecd[14779]: Could not allocate space for cmdbuf", 83, MSG_NOSIGNAL, NULL, 0) = 83 <0.000025>
14779 09:58:36.573383 write(2, "\1", 1) = 1 <0.000025>
14779 09:58:36.573430 write(2, "Could not allocate space for cmdbuf\n", 36) = 36 <0.000007>
14779 09:58:36.573466 exit_group(1)     = ?
14779 09:58:36.573542 +++ exited with 1 +++

There are several mmaps with large requested memory:
mmap(NULL, 4611686018427523072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)

The in.rexecd server then exits with a failure. Some systems required a reboot after such failure (VMWare guest system).

Expected results:
Command executed successfully, with a similar cap for sysconf (_SC_ARG_MAX) return values as are present in rsh.

Additional info:
The issue is present in all RHEL and Fedora versions. Upstream development status unknown.

I suggest a patch (attached), that provides the same cap for too large values for rexecd and adds additional logging for both rexecd and rshd.

Please consider using a defined constant instead of the hardcoded value.

Comment 1 Fedora End Of Life 2018-05-03 07:59:09 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 2 Stepan Broz 2018-05-03 08:16:38 UTC
Switching version to F28, still not fixed, even though patch is available.

Comment 3 Michal Ruprich 2019-01-02 09:41:25 UTC
Created attachment 1517893 [details]
Patch

Comment 4 Fedora Update System 2019-01-02 10:05:42 UTC
rsh-0.17-89.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-b228f0453d

Comment 5 Fedora Update System 2019-01-02 10:05:46 UTC
rsh-0.17-87.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-849e1075e8

Comment 6 Fedora Update System 2019-01-03 04:00:21 UTC
rsh-0.17-87.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-849e1075e8

Comment 7 Fedora Update System 2019-01-03 05:07:31 UTC
rsh-0.17-89.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-b228f0453d

Comment 8 Fedora Update System 2019-01-16 01:42:21 UTC
rsh-0.17-87.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2019-01-16 02:19:26 UTC
rsh-0.17-89.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.