|
|
8b47af |
From a9e8373030b39aadfc33af67443085df83e9e344 Mon Sep 17 00:00:00 2001
|
|
|
8b47af |
From: Daniel Berrange <berrange@redhat.com>
|
|
|
8b47af |
Date: Wed, 14 Aug 2013 16:00:56 +0200
|
|
|
8b47af |
Subject: [libusb-compat PATCH] Link with -znodelete to disallow unloading
|
|
|
8b47af |
|
|
|
8b47af |
Since libusb-0.1 did not have any init / exit function, code using the
|
|
|
8b47af |
libusb-0.1 API will not call libusb_exit.
|
|
|
8b47af |
|
|
|
8b47af |
Now, libgphoto uses libusb and will dlopen() and dlclose() it. Unfortunately
|
|
|
8b47af |
since there is no way to ensure libusb_close() is called, when libgphoto
|
|
|
8b47af |
dlcloses the libusb.so library, the thread from libusbx.so will not be
|
|
|
8b47af |
stopped. So a thread will remain running, executing code from a memory
|
|
|
8b47af |
region that has now been freed. Crash-tastic results ensue.
|
|
|
8b47af |
|
|
|
8b47af |
I don't see a good way to fix this from libusb or libusbx, given the need to
|
|
|
8b47af |
preserve the existing API of libusb.
|
|
|
8b47af |
|
|
|
8b47af |
If, however, we link libusb.so using -znodelete, we will prevent it from
|
|
|
8b47af |
ever being unloaded, despite the dlclose() calls. This is not ideal, but
|
|
|
8b47af |
better than allowing it to be unloaded which is a guaranteed crash.
|
|
|
8b47af |
|
|
|
8b47af |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
8b47af |
---
|
|
|
8b47af |
libusb/Makefile.am | 2 +-
|
|
|
8b47af |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
8b47af |
|
|
|
8b47af |
diff --git a/libusb/Makefile.am b/libusb/Makefile.am
|
|
|
8b47af |
index 33a609a..a20fdb5 100644
|
|
|
8b47af |
--- a/libusb/Makefile.am
|
|
|
8b47af |
+++ b/libusb/Makefile.am
|
|
|
8b47af |
@@ -5,5 +5,5 @@ libusb_la_SOURCES = core.c usbi.h
|
|
|
8b47af |
libusb_la_CFLAGS = -fvisibility=hidden $(AM_CFLAGS) $(LIBUSB_1_0_CFLAGS)
|
|
|
8b47af |
libusb_la_LIBADD = $(LIBUSB_1_0_LIBS)
|
|
|
8b47af |
libusb_la_LDFLAGS = -version-info $(LT_MAJOR):$(LT_REVISION):$(LT_AGE) \
|
|
|
8b47af |
- -release 0.1
|
|
|
8b47af |
+ -release 0.1 -Wl,-z -Wl,nodelete
|
|
|
8b47af |
|
|
|
8b47af |
--- libusb-compat-0.1.5.orig/libusb/Makefile.in 2013-05-21 00:40:35.000000000 +0100
|
|
|
8b47af |
+++ libusb-compat-0.1.5.orig/libusb/Makefile.in 2013-08-13 22:20:32.831532426 +0100
|
|
|
8b47af |
@@ -297,7 +297,7 @@ libusb_la_SOURCES = core.c usbi.h
|
|
|
8b47af |
libusb_la_CFLAGS = -fvisibility=hidden $(AM_CFLAGS) $(LIBUSB_1_0_CFLAGS)
|
|
|
8b47af |
libusb_la_LIBADD = $(LIBUSB_1_0_LIBS)
|
|
|
8b47af |
libusb_la_LDFLAGS = -version-info $(LT_MAJOR):$(LT_REVISION):$(LT_AGE) \
|
|
|
8b47af |
- -release 0.1
|
|
|
8b47af |
+ -release 0.1 -Wl,-z -Wl,nodelete
|
|
|
8b47af |
|
|
|
8b47af |
all: all-am
|
|
|
8b47af |
|
|
|
8b47af |
--
|
|
|
8b47af |
1.8.3.1
|
|
|
8b47af |
|