Allow asan, msan and ubsan to be configured with shared libraries

The background story is that util/shlib_wrap.sh was setting LD_PRELOAD
or similar platform dependent variables, just in case the shared
libraries were built with -rpath.  Unfortunately, this doesn't work
too well with asan, msan or ubsan.

So, the solution is to forbid the combination of shared libraries,
-rpath and any of the sanity analyzers we can configure.

This changes util/shlib_wrap.sh so it only contains the code that sets
LD_PRELOAD when -rpath has been used when configuring.

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte 2016-09-07 20:56:20 +02:00
parent 978ecbb08b
commit 342a1a2379
4 changed files with 14 additions and 7 deletions

View File

@ -775,18 +775,14 @@ dist:
# Helper targets ##################################################### # Helper targets #####################################################
link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh link-utils: $(BLDDIR)/util/opensslwrap.sh
$(BLDDIR)/util/opensslwrap.sh: configdata.pm $(BLDDIR)/util/opensslwrap.sh: configdata.pm
@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
mkdir -p "$(BLDDIR)/util"; \ mkdir -p "$(BLDDIR)/util"; \
ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \ ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
fi fi
$(BLDDIR)/util/shlib_wrap.sh: configdata.pm
@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
mkdir -p "$(BLDDIR)/util"; \
ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
fi
FORCE: FORCE:
# Building targets ################################################### # Building targets ###################################################

View File

@ -300,7 +300,7 @@ my $default_ranlib;
$config{fips}=0; $config{fips}=0;
# Top level directories to build # Top level directories to build
$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "tools", "fuzz" ]; $config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ];
# crypto/ subdirectories to build # crypto/ subdirectories to build
$config{sdirs} = [ $config{sdirs} = [
"objects", "objects",
@ -780,6 +780,13 @@ foreach (@argvcopy)
} }
} }
if ($libs =~ /(^|\s)-Wl,-rpath,/
&& !$disabled{shared}
&& !($disabled{asan} && $disabled{msan} && $disabled{ubsan})) {
die "***** Cannot simultaneously use -rpath, shared libraries, and\n",
"***** any of asan, msan or ubsan\n";
}
if ($config{fips}) if ($config{fips})
{ {
delete $disabled{"shared"} if ($disabled{"shared"} =~ /^default/); delete $disabled{"shared"} if ($disabled{"shared"} =~ /^default/);

2
util/build.info Normal file
View File

@ -0,0 +1,2 @@
SCRIPTS_NO_INST=shlib_wrap.sh
SOURCE[shlib_wrap.sh]=shlib_wrap.sh.in

View File

@ -81,6 +81,7 @@ SunOS|IRIX*)
;; ;;
esac esac
{- output_off() if $config{ex_libs} !~ /(^|\s)-Wl,-rpath,/; ""; -}
if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
# Following three lines are major excuse for isolating them into # Following three lines are major excuse for isolating them into
# this wrapper script. Original reason for setting LD_PRELOAD # this wrapper script. Original reason for setting LD_PRELOAD
@ -96,6 +97,7 @@ if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO" # MacOS X DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO" # MacOS X
export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES
fi fi
{- output_on() if $config{ex_libs} !~ /(^|\s)-Wl,-rpath,/; ""; -}
cmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}" cmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}"
shift shift