Date: Wed, 9 Mar 2005 21:58:39 +0100 (CET) From: Jean-Yves Lefort <jylefort@brutele.be> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/78646: [patch] libmap should canonicalize pathnames before matching them against constraints Message-ID: <20050309205839.799348380@jsite.lefort.net> Resent-Message-ID: <200503092100.j29L097b088158@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 78646 >Category: bin >Synopsis: [patch] libmap should canonicalize pathnames before matching them against constraints >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 09 21:00:09 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Jean-Yves Lefort >Release: FreeBSD 5.3-RELEASE-p5 i386 >Organization: >Environment: System: FreeBSD jsite.lefort.net 5.3-RELEASE-p5 FreeBSD 5.3-RELEASE-p5 #0: Mon Feb 14 18:06:40 CET 2005 jylefort@jsite.lefort.net:/usr/obj/usr/src/sys/JSITE i386 >Description: lm_find() should canonicalize the pathname it passes to lmp_find(), in order to follow symbolic links, etc. >How-To-Repeat: [/foo1/bar.so] lib.so replacement.so If /foo2/bar.so (a symlink to /foo1/bar.so) is dlopen()ed, the libmap.conf mapping will not be honoured, because libmap matches /foo2/bar.so instead of /foo1/bar.so. >Fix: --- libexec/rtld-elf/libmap.c.orig Wed Mar 9 21:17:50 2005 +++ libexec/rtld-elf/libmap.c Wed Mar 9 21:19:05 2005 @@ -8,6 +8,7 @@ #include <stdlib.h> #include <sys/queue.h> #include <sys/param.h> +#include <limits.h> #include "debug.h" #include "rtld.h" @@ -200,15 +201,24 @@ dbg("%s(\"%s\", \"%s\")", __func__, p, f); - if (p != NULL && (lml = lmp_find(p)) != NULL) { - t = lml_find(lml, f); - if (t != NULL) { - /* - * Add a global mapping if we have - * a successful constrained match. - */ - lm_add(NULL, f, t); - return (t); + if (p != NULL) { + char *rp; + char rpbuf[PATH_MAX]; + + rp = realpath(p, rpbuf); + if (rp != NULL) + p = rp; + + if ((lml = lmp_find(p)) != NULL) { + t = lml_find(lml, f); + if (t != NULL) { + /* + * Add a global mapping if we have + * a successful constrained match. + */ + lm_add(NULL, f, t); + return (t); + } } } lml = lmp_find("$DEFAULT$"); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050309205839.799348380>