COMPAT_32BIT oddness in rtld-elf (was: Re: /usr/lib/private)

Slawa Olhovchenkov slw at zxy.spb.ru
Sat Sep 7 12:22:17 UTC 2013


On Sat, Sep 07, 2013 at 01:48:13PM +0200, Dag-Erling Sm??rgrav wrote:

> I'm having trouble understanding this code in libexec/rtld-elf/rtld.c:
> 
> static void *
> path_enumerate(const char *path, path_enum_proc callback, void *arg)
> {
> #ifdef COMPAT_32BIT
>     const char *trans;
> #endif
>     if (path == NULL)
> 	return (NULL);
> 
>     path += strspn(path, ":;");
>     while (*path != '\0') {
> 	size_t len;
> 	char  *res;
> 
> 	len = strcspn(path, ":;");
> #ifdef COMPAT_32BIT
> 	trans = lm_findn(NULL, path, len);
> 	if (trans)
> 	    res = callback(trans, strlen(trans), arg);
> 	else
> #endif
> 	res = callback(path, len, arg);
> 
> 	if (res != NULL)
> 	    return (res);
> 
> 	path += len;
> 	path += strspn(path, ":;");
>     }
> 
>     return (NULL);
> }
> 
> This function is used to traverse paths, such as rtld's built-in search
> path, LD_LIBRARY_PATH, an Elf object's rpath, etc.  As far as I can
> tell, the result of this is that *in the COMPAT_32BIT case only* it is
> possible to list one directory as replacing another in libmap.conf.  In
> other words, we could have this in libmap32.conf:
> 
> /lib                    /lib32
> /usr/lib                /usr/lib32
> /usr/lib/private        /usr/lib32/private
> 
> instead of hardcoding a different standard search path in rtld.h.
> 
> What I don't understand is why this functionality is only available in
> the COMPAT_32BIT case.  It seems universally useful to me.

As you planed to touch this, can you build filtering of LD_PRELOAD
from one "environment" to another? For example:

1. For working webcam in linux skype his running with
LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so (linux library).
2. clicking by link in skype chat do running firefox (native binary),
with same LD_PRELOAD. But native binary can't found this library and
running failed.

Can we sanitize environment if running from linux enviroment to
native? Or in some other cases too?


More information about the freebsd-arch mailing list