Bug 237120 - updatedb accesses excluded filesystems (risk of hang against broken NFS)
Summary: updatedb accesses excluded filesystems (risk of hang against broken NFS)
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: mlocate   
(Show other bugs)
Version: 5.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Miloslav Trmač
QA Contact:
Keywords: Reopened
Depends On:
TreeView+ depends on / blocked
Reported: 2007-04-19 15:09 UTC by Bob Gautier
Modified: 2018-10-19 22:18 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-10-08 07:55:39 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to remove realpath() calls from updatedb (995 bytes, patch)
2007-04-19 15:11 UTC, Bob Gautier
no flags Details | Diff
Don't call realpath() on all excluded filesystem paths if using /proc/self/mounts (493 bytes, patch)
2007-04-20 20:39 UTC, Miloslav Trmač
no flags Details | Diff

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2008:0920 normal SHIPPED_LIVE mlocate bug fix update 2008-10-08 07:55:35 UTC

Description Bob Gautier 2007-04-19 15:09:47 UTC
Description of problem:

updatedb does repeated lstat() calls against all mounted filesystems, even if
those filesystems are marked to be excluded in PRUNEFS.

This creates a risk that updatedb will hang when it attempts to access a
currently unavailable NFS filesystem (for example).

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Configure updatedb to exclude nfs filesystems
2. Mount an NFS filesystem on your test machine
   mount nfsserver:/exported_path /mountpoint
3. strace -o debug.out updatedb
4. Observe (in debug.out) that the NFS mountpoint is lstat()'ed at least once
5. Block I/O to the filesystem, e.g. with an iptables rule:
   /sbin/iptables -I OUTPUT 1 -d nfsserver -j DROP
6. Try to run updatedb again.
Actual results:

updatedb will hang if a broken NFS filesystem is mounted when it runs, even if
nfs filesystems are excluded.

Expected results:

updatedb should skip excluded filesystems and should (therefore) be immune to
their (non-)availability.

Additional info:

The problem appears to be in the realpath() calls that are performed in the
filesystem_is_excluded() function.  I am aware of BZ #235942 which has a comment
saying that realpath() calls are essential but they seem to be causing a serious
problem.  In our environment, patching updatedb to skip the realpath() calls
does not change its output.

Comment 1 Bob Gautier 2007-04-19 15:11:36 UTC
Created attachment 153011 [details]
Patch to remove realpath() calls from updatedb

Comment 2 Miloslav Trmač 2007-04-20 02:20:07 UTC
Thanks for your report.

The patch would break documeted behavior, and removing one of the realpath ()
calls would require an incompatible change (which happened anyway in rawhide

Have you tested the patch to verify it helps?  From looking at the code, scan ()
does an lstat () on the subdirectory anyway.  This lstat () can not be removed,
otherwise updatedb would not skip the file systems that are mounted after
updatedb starts.

Because the lstat () is necessary, the hangs can't be completely avoided.  The
best that can be done is probably enumerating all mounts matching PRUNEFS when
starting updatedb, and adding their paths to PRUNEPATHS - PRUNEPATHS are
processed before the lstat ().  This would help for long-term mounts (e.g.
mounts in /etc/fstab), but not for short-term mounts or autofs.

Comment 3 Bob Gautier 2007-04-20 09:31:21 UTC
I feared this would be incompatible with documented behaviour -- but it is also
makes updatedb behave like the version from RHEL3 (slocate-2.7-3), which is
where my client is upgrading from.

The patch does fix our problem; the test I described above is how I verified it.

Here is some more info on our environment, in case it helps:

We have nfs and autofs in our PRUNEFS.

/home is an autofs (and is always mounted).

/home is not in our PRUNEPATHS.

When someone logs on, their home directory is automounted (nfs).

Let's say that 'rgautier' is logged on, so /home/rgautier is mounted (nfs)

1. Without the patch, updatedb (in realpath) does lstat calls on /home/rgautier

2. With the patch, it doesn't.  I used strace to confirm this and can provide logs.

The test I ran was (with a few names changed for clarity):

% rm -f /var/lib/mlocate/mlocate.db
% strace -o /tmp/unpatched.out unpatched-updatedb
% rm -f /var/lib/mlocate/mlocate.db
% strace -o /tmp/patched.out patched-updatedb
% grep rgautier /tmp/unpatched.out
lstat64("/home/rgautier", {st_mode=S_IFDIR|0755, st_size=24576, ...}) = 0
% grep rgautier /tmp/patched.out

In particular, the lstat() on the subdirectory that you refer to in Comment #2
above does not seem to happen in *either* case.

I would appreciate detailed instructions for working around this, if it can't be
fixed in the code.

Alternatively, could we have an additional (command line) option to updatedb to
disable the realpath() calls?

Comment 4 Miloslav Trmač 2007-04-20 20:39:14 UTC
Created attachment 153211 [details]
Don't call realpath() on all excluded filesystem paths if using /proc/self/mounts

Thanks for the explanation, I didn't realize you were talking about mounts
inside an already excluded tree.

AFAICS it should be good enough to remove only the inner realpath () call to
fix the nested exclusion case.	This can be done safely because the paths in
/proc/self/mounts are always canonical.  Can you test that, please?

Comment 5 Bob Gautier 2007-04-24 14:27:06 UTC
Tested the above patch and it does the job - thanks.

Comment 6 Miloslav Trmač 2007-04-25 17:38:37 UTC
Fixed for Fedora in post-FC7 mlocate-0.17-1.

Comment 7 RHEL Product and Program Management 2007-06-05 20:30:31 UTC
This request was evaluated by Red Hat Product Management for
inclusion in a Red Hat Enterprise Linux release.  Since this
bugzilla is in a component that is not approved for the current
release, it has been closed with resolution deferred.  You may
reopen this bugzilla for consideration in the next release.

Comment 8 Bob Gautier 2007-06-05 22:44:41 UTC
I don't understand comment #7: are you saying that mlocate won't be in a future
RHEL5 release?

In any case, yes, please re-open this as it is directly affecting my client and
we need a fix as soon as possible.

Comment 9 Miloslav Trmač 2007-06-05 23:39:00 UTC
Please ignore comment #7, the bug should not have been just closed.

Comment 10 Bob Gautier 2007-10-18 16:24:05 UTC
Is there any progress on this?  Will the fix be in RHEL 5.1?

Comment 12 RHEL Product and Program Management 2007-12-03 20:42:06 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release.  This request will
be reviewed for a future Red Hat Enterprise Linux release.

Comment 14 RHEL Product and Program Management 2008-06-04 22:49:30 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update

Comment 19 errata-xmlrpc 2008-10-08 07:55:39 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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