Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
After the fix for CVE-2018-1000001, getcwd returns ENOENT if the current directory is unreachable and does not have a name.
This happens because this:
/* Initialize change_dir() here because on some old systems getcwd
* (implemented by forking "pwd" and reading its output) doesn't
* work when there are other child processes. Also, on all systems
* that implement getcwd that way "pwd" can't be found after chroot. */
change_dir(NULL, CD_NORMAL);
And this:
/* Like chdir(), but it keeps track of the current directory (in the
* global "curr_dir"), and ensures that the path size doesn't overflow.
* Also cleans the path using the clean_fname() function. */
int change_dir(const char *dir, int set_path_only)
{
static int initialised, skipped_chdir;
unsigned int len;
if (!initialised) {
initialised = 1;
if (getcwd(curr_dir, sizeof curr_dir - 1) == NULL) {
rsyserr(FERROR, errno, "getcwd()");
exit_cleanup(RERR_FILESELECT);
}
curr_dir_len = strlen(curr_dir);
}
This error is reached even if all input paths to rsync are absolute and the current directory path is never needed.
To trigger this, it is sufficient to execve rsync from a process whose current directory has a pending lazy umount (MNT_DETACH/umount -l). The execve makes the current directory unreachable in the new process image (at least on kernel 4.14.14).
Reportedly, this break glusterfs geo-replication.
References:
https://lists.gluster.org/pipermail/gluster-users/2018-January/033293.htmlhttps://sourceware.org/ml/libc-alpha/2018-02/msg00152.htmlhttps://bugs.launchpad.net/bugs/1746995
I've dig into the issue a bit more.
Actually there is bug in rsync which *allowed* it to operate if directory is unavailable (i.e. getcwd() returned (unavailable)/path before the CVE fixed). It's clear from the util.c:change_dir() and [1] that it was designed to prevent this situation as it may lead undefined behavior.
IMO Gluster's code should be changed to not exec() applications from unmounted directory instead of putting all rsync users on risk of running from withing unavailable directory.
Small reproducer is in [1] and looks like: mkdir test && cd test && rmdir ../test && rsync /etc/fstab /tmp/
[1] https://bugzilla.samba.org/show_bug.cgi?id=6422
Based on #13 I'm closing this bug.
@Florian, thank you for your time and patch provided. However it's too risky to operate if current directory is not available and upper level software (in this case it's gluster) should take care of this.