Page MenuHomeFreeBSD

Stop prepending prefix to the result of realpath(3).
ClosedPublic

Authored by kib on Jan 10 2020, 2:13 PM.

Details

Summary

The path is already absolute.

Noted by: rstone

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 28590

Event Timeline

kib created this revision.Jan 10 2020, 2:13 PM
rstone added inline comments.Jan 10 2020, 2:26 PM
libexec/rtld-elf/rtld.c
5571

This will change /foo/symlink to /bar/target where we didn't before. That's not an enormous deal, but realpath will fail within a capsicum sandbox as it needs to be able to stat every component of the path, including "/". I'd prefer to only use realpath on relative paths for this reason.

kib added inline comments.Jan 10 2020, 2:48 PM
libexec/rtld-elf/rtld.c
5571

So do you want realpath(3) at all there ?

kib added inline comments.Jan 10 2020, 2:53 PM
libexec/rtld-elf/rtld.c
5571

I can test with cap_getmode(2) and only call realpath if not in cap mode.

This is also a valid question for $ORIGIN resolution, where we use realpath(3) as well. See some minimal discussion with completely wrong patch at D23043.

kib updated this revision to Diff 66590.Jan 10 2020, 2:54 PM

Do not use realpath() on abs path.

rstone accepted this revision.Jan 10 2020, 4:35 PM
This revision is now accepted and ready to land.Jan 10 2020, 4:35 PM
This revision was automatically updated to reflect the committed changes.