commit 8039190008e185d5df2e4e5483e5372a86e5a5b3
parent 0cb5198c0ab76933abf67167753562d4d8ca4050
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 11 Nov 2026 22:49:12 +0100
ipc: survive a refused kill() of a plugin; update the AppArmor profiles
Under AppArmor's signal mediation a confined application could not kill
its plugin processes and then hung in waitpid(), as the pipes were only
closed afterwards.
Also updated the profiles to allow the kill() and fixed paths.
Diffstat:
4 files changed, 52 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -5,7 +5,12 @@ Wed Nov 11 10:00:00 PM CET 2026
another thread of a multi-threaded application, and on macOS the
Objective-C runtime killed it as soon as a plugin's libraries
loaded Apple frameworks (FFmpeg, GStreamer). The helper is
- installed next to the plugins. -CG
+ installed next to the plugins.
+ Close the pipes to a plugin process before killing it, so that an
+ application whose kill() is refused (as by AppArmor's signal
+ mediation) no longer hangs waiting for it. Update the AppArmor
+ profiles for the helper, the signal, and current library and
+ GStreamer paths. -CG
Fri Aug 7 09:30:00 AM CEST 2026
Add sixteen plugins for a fast forensic/file-manager pass over large
diff --git a/contrib/apparmor/libextractor b/contrib/apparmor/libextractor
@@ -1,4 +1,4 @@
-# Last Modified: Mon Aug 31 18:30:49 2015
+# Last Modified: Wed Nov 11 2026
#include <tunables/global>
# vim:syntax=apparmor
@@ -7,23 +7,42 @@
profile libextractor {
#include <abstractions/base>
+ # libextractor kills the plugin process once it no longer needs it
+ signal (receive) set=(kill),
+
/dev/shm/LE-* r,
- @{HOME}/.cache/gstreamer-1.0/registry.x86_64.bin r,
- @{HOME}/.cache/gstreamer-1.0/registry.x86_64.bin.tmp* a,
- @{PROC}/cmdline r,
- @{PROC}/fd/ r,
+ @{HOME}/.cache/gstreamer-1.0/registry.*.bin r,
+ @{HOME}/.cache/gstreamer-1.0/registry.*.bin.tmp* a,
+ owner @{PROC}/@{pid}/cmdline r,
+ owner @{PROC}/@{pid}/fd/ r,
/sys/devices/system/cpu/ r,
/usr/lib/gstreamer-1.0/gst-plugin-scanner rix,
+ /usr/lib/@{multiarch}/gstreamer-1.0/gst-plugin-scanner rix,
+ /usr/lib/@{multiarch}/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner rix,
+ /usr/libexec/gstreamer-1.0/gst-plugin-scanner rix,
# the GStreamer-based plugins (thumbnailgst, previewgst) load their
# decoders and encoders from here at run time
/usr/lib/gstreamer-1.0/*.so mr,
/usr/lib/@{multiarch}/gstreamer-1.0/*.so mr,
- /usr/lib/@{multiarch}/gstreamer-1.0/gst-plugin-scanner rix,
- # note that no network rule appears anywhere in this profile: the
+ # GStreamer may not write its registry from here (other applications
+ # trust it), so it rescans its plugins in gst-plugin-scanner. That
+ # scan need not probe for devices, and orc falls back to C code
+ # without writing JIT code to files; deny both quietly.
+ deny @{HOME}/.cache/{,gstreamer-1.0/} w,
+ deny @{HOME}/orcexec.* w,
+ deny /tmp/orcexec.* w,
+ deny @{run}/user/*/orcexec.* w,
+ deny /dev/ r,
+ deny /sys/bus/ r,
+ deny /sys/class/ r,
+ deny network netlink raw,
+ # note that no network rule allows anything in this profile: the
# media plugins feed FFmpeg and GStreamer from a pipe and must never
# open a stream of their own
+ # (plugins installed below /usr/lib are covered by abstractions/base)
/usr/local/lib/libextractor/libextractor_*.so* mr,
/usr/local/lib/libextractor_common.so.* mr,
+ /etc/magic r,
/usr/share/file/misc/magic.mgc r,
}
diff --git a/contrib/apparmor/usr.bin.extract b/contrib/apparmor/usr.bin.extract
@@ -1,64 +1,28 @@
-# Last Modified: Wed Jul 15 15:26:31 2015
+# Last Modified: Wed Nov 11 2026
#include <tunables/global>
/usr/bin/extract {
- /dev/shm/LE-* rw,
-
- /etc/ld.so.cache mr,
+ #include <abstractions/base>
/usr/bin/extract mr,
- /usr/lib/gconv/gconv-modules r,
-
- /usr/lib/libFLAC.so.* mr,
- /usr/lib/libacl.so.* mr,
- /usr/lib/libarchive.so.* mr,
- /usr/lib/libattr.so.* mr,
- /usr/lib/libbz2.so.* mr,
- /usr/lib/libc-*.so mr,
- /usr/lib/libcrypto.so.* mr,
- /usr/lib/libdl-*.so mr,
- /usr/lib/libexiv2.so.* mr,
- /usr/lib/libexpat.so.* mr,
- /usr/lib/libextractor.so.* mr,
-
+ # libextractor and the libraries of its plugins are covered by
+ # abstractions/base; extract lists the plugin directory and runs each
+ # plugin in libextractor-helper, which switches itself to the
+ # libextractor profile and is killed once it is no longer needed
/usr/lib/libextractor/ r,
- /usr/lib/libextractor/libextractor_*.so mr,
- # runs the plugins, switching itself to the libextractor profile
+ /usr/lib/@{multiarch}/libextractor/ r,
/usr/lib/libextractor/libextractor-helper ix,
+ /usr/lib/@{multiarch}/libextractor/libextractor-helper ix,
+ change_profile -> libextractor,
+ signal (send) set=(kill) peer=libextractor,
- /usr/lib/libextractor_common.so.* mr,
-
- /usr/lib/libgcc_s.so.* mr,
- /usr/lib/libjpeg.so.* mr,
- /usr/lib/libltdl.so.* mr,
- /usr/lib/liblzma.so.* mr,
- /usr/lib/liblzo2.so.* mr,
- /usr/lib/libm-*.so mr,
- /usr/lib/libmagic.so.* mr,
- /usr/lib/libmpeg2.so.* mr,
- /usr/lib/libogg.so.* mr,
- /usr/lib/libpthread-*.so mr,
- /usr/lib/librt-*.so mr,
- /usr/lib/libstdc++.so.* mr,
- /usr/lib/libtiff.so.* mr,
- /usr/lib/libvorbis.so.* mr,
- /usr/lib/libvorbisfile.so.* mr,
- /usr/lib/libz.so.* mr,
-
- /usr/lib/locale/locale-archive r,
-
- /usr/share/file/misc/magic.mgc r,
-
- /usr/share/locale/fr/LC_MESSAGES/libc.mo r,
- /usr/share/locale/fr/LC_MESSAGES/libextractor.mo r,
- /usr/share/locale/locale.alias r,
+ /dev/shm/LE-* rw,
+ @{PROC}/@{pid}/maps r,
deny @{HOME}/.* r,
- deny @{HOME}/.*/** r,
+ deny @{HOME}/.*/** r,
#files where extract can be used
owner @{HOME}/** r,
/media/** r,
-
- @{PROC}/@{pid}/maps r,
}
diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c
@@ -468,14 +468,17 @@ EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel)
{
int status;
- if (0 != kill (channel->cpid, SIGKILL))
- LOG_STRERROR ("kill");
- if (-1 == waitpid (channel->cpid, &status, 0))
- LOG_STRERROR ("waitpid");
+ /* Close the pipes first: should the kill() not be permitted (for
+ example by AppArmor's signal mediation), the plugin still exits
+ once it reads end-of-file, so waitpid() does not block forever. */
if (0 != close (channel->cpipe_out))
LOG_STRERROR ("close");
if (0 != close (channel->cpipe_in))
LOG_STRERROR ("close");
+ if (0 != kill (channel->cpid, SIGKILL))
+ LOG_STRERROR ("kill");
+ if (-1 == waitpid (channel->cpid, &status, 0))
+ LOG_STRERROR ("waitpid");
if (NULL != channel->plugin)
channel->plugin->channel = NULL;
free (channel->mdata);