Bug 16871 - ldconfig -X should not touch symlinks
Summary: ldconfig -X should not touch symlinks
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.19
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-23 22:01 UTC by Martin von Gagern
Modified: 2015-02-18 14:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Gagern 2014-04-23 22:01:22 UTC
Currently (and since commit 647eb037f from 2001), ldconfig will unlink any file it considers a stale library symlink. It will do so even if the -X option is given on the command line, and it will also do so no matter what error occurred while executing stat64 on the real file name.

One problem with this is that people might reasonably expect unlink -X -N to have no side effects except its output. This is how I found the issue: the configure script of the xapian library calls “/sbin/ldconfig -N -X -v”, and does so only to parse its output, with no modification intended.

Another problem is that the errno resulting from the stat64 call is not checked. So any error accessing that file leads to removal of the symlink. In particular, insufficient permissions are affected by this as well. So if a group of admins were allowed to write /usr/lib and someone installed a symlink there to a library which is group-readable but not world-readable, then an admin not in that group might accidentially delete said symlink. With only root accessing these directories, access should normally not be a problem, but I guess the problem might reappear with e.g. nfs mapping root to non-root.

So on the whole, I suggest that you change the unlink condition to
if (errno == ENOENT && do_remove && strstr (direntry->d_name, ".so."))
or something like this.
Comment 1 Florian Weimer 2015-02-18 14:41:57 UTC
The incorrect deletion does not really cross a trust boundary, so no security issue.