mailing list of musl libc
 help / color / mirror / code / Atom feed
* realpath() and setfsuid programs
@ 2015-02-07  7:53 Timo Teras
  2015-02-07 12:26 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Timo Teras @ 2015-02-07  7:53 UTC (permalink / raw)
  To: musl

Hi,

It seems realpath() does not work in binaries using setfsuid(). (At
least on grsec kernels, vanilla kernel might be affected too.)

The problem is that realpath() opens the file, and then
uses just readlink on /proc/self/fd/<fd> to read the canonicalized
path.

However, /proc/self/fd is not accessible if setfsuid() has been used to
drop privileges.

The problem I'm looking at in this case is fuse. fusermount, the
suid wrapper to do user fuse mounts, seems to basically do:
 oldfsuid = setfsuid(getuid())
 oldfsgid = setfsgid(getgid())
 take realpath of mountpoint
 chdir("/")
 setfsuid(oldfsuid)
 setfsgid(oldfsgid)

I believe they want to drop privileges so it works as also access check
to the mount point directory. As realpath() in practice checks that the
user has access to the entry too.

This works glibc, as realpath() canonicalizes the path
component-by-component in userland. But musl breaks due to the /proc
not being accessible while privileges dropped.

Any suggestions?

Thanks,
Timo


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-07 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-07  7:53 realpath() and setfsuid programs Timo Teras
2015-02-07 12:26 ` Rich Felker
2015-02-07 12:32   ` Rich Felker
2015-02-07 14:28     ` Timo Teras
2015-02-07 16:04       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).