bin/115631: make dlclose atexit-aware (patch)
Mikhail T.
mi at aldan.algebra.com
Sun Aug 19 14:00:04 PDT 2007
>Number: 115631
>Category: bin
>Synopsis: make dlclose atexit-aware (patch)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Aug 19 21:00:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator: Mikhail T.
>Release: FreeBSD 6.2-STABLE amd64
>Organization:
Virtual Estates, Inc.
>Environment:
System: FreeBSD 6.2-STABLE
>Description:
Currently, an application can shoot itself in the tail by
registering a symbol with atexit and then dlclose-ing the
library, which provides the symbol.
Programs aren't supposed to that, but sometimes they do --
most notably ImageMagick, which dlopens libjasper, which
registers its own clean-up routine with atexit.
The proposed patch will make such bugs easier to diagnose --
the ImageMagick problem (crash upon exiting) was mystifying
people for years...
>How-To-Repeat:
>Fix:
The up-to-date version of the patch can be found here:
http://aldan.algebra.com/~mi/dlclose-atexit.patch
It exposes the __atexit pointer defined in atexit.c and its
type and modifies dlclose to scan through all listed functions
looking for those, that belong to the object being dlclosed.
The method to check whether a symbol belongs to an object
is to check, whether the address is between mapbase and
mapbase+mapsize of the entry.
What could be improved is the addition of a an addr_to_name
lookup -- to print the _name_ of the function found to be
registered with atexit, rather than merely the function's
address.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list