Public bug reported:

Crash reports for unpackaged, in-development executables under /var/tmp
are stored in /var/crash despite apport's documented default of ignoring
unpackaged binaries. This produces recurring desktop crash-report
popups, wasted disk (reports embed the full core), and noise for
whoopsie/triage.

Observed on Ubuntu 26.04.1 (apport 2.34.1-0ubuntu0.1): 19 crash reports
(~6.6 MB in one week) from development binaries under /var/tmp/opencode/
(local test mocks/binaries, an upstream build, small study scripts)
accumulated in /var/crash. Real packaged crashes (gdm3, input-remapper-
daemon, landscape-client, qemu) were correctly captured.

Reproducer (on stock apport)
----------------------------
1. Build a tiny segfaulting binary anywhere under /var/tmp:
     printf 'int main(){*(volatile int*)0=0;}\n' > /var/tmp/x/crasher.c
     gcc -o /var/tmp/x/crasher /var/tmp/x/crasher.c
2. Run it:  /var/tmp/x/crasher
3. A .crash file appears in /var/crash. The same binary under /tmp or $HOME
   produces no report - inconsistent behaviour.

Standalone run of the stock likely_packaged() logic (verbatim copy of
apport/fileutils.py from 2.34.1-0ubuntu0.1, identical in canonical/apport main):

    /var/tmp/x/crasher           -> likely_packaged=True
    /tmp/x/crasher               -> likely_packaged=False
    /home/me/x/crasher           -> likely_packaged=False
    /usr/bin/ls                  -> likely_packaged=True
    /usr/local/bin/foo           -> likely_packaged=False
    /var/lib/dpkg/x              -> likely_packaged=False

Root cause
----------
likely_packaged() (apport/fileutils.py) guesses via a directory allowlist:

    pkg_allowlist = ["/bin/", "/boot", "/etc/", "/initrd", "/lib",
                     "/sbin/", "/opt", "/usr/", "/var"]

    return (allowlist_match
            and not file.startswith("/usr/local/")
            and not file.startswith("/var/lib/"))

The bare "/var" entry matches /var/tmp/..., and the only post-exclusions are
"/usr/local/" and "/var/lib/". /var/tmp therefore passes likely_packaged(),
so the unpackaged gate in the core handler (/usr/share/apport/apport,
process_crash()) is never reached for such paths:

    if not apport.fileutils.likely_packaged(info["ExecutablePath"]):
        if not apport.fileutils.get_config("main", "unpackaged",
                                           False, boolean=True):
            logger.error("executable does not belong to a package, ignoring")
            return 0

/tmp, /home, /mnt, /srv etc. are not in the allowlist, so /var/tmp is the one
practical gap - and it is a standard location for ephemeral builds and scratch
work (pbuilder/cowbuilder outputs, editor swap/recovery files, session scratch
dirs). The generic package-hook (general-hooks/generic.py) shares the same
function for shared-library lookup, so it is affected consistently.

Proposed fix (mirrors the existing /var/lib/ exclusion precedent)
-----------------------------------------------------------------
    return (allowlist_match
            and not file.startswith("/usr/local/")
            and not file.startswith("/var/lib/")
            and not file.startswith("/var/tmp/"))

likely_packaged()'s docstring guarantees a False return is definitive; this
stays true because packages are not expected to ship executables in /var/tmp
(FHS reserves /var/tmp for transient data). find_file_package() uses
likely_packaged() as its fast path, so the change applies consistently there.

Verified locally (patch applied, plus a test in tests/test_fileutils.py -
pull request to follow):
- likely_packaged('/var/tmp/x/crasher') -> False; '/usr/bin/ls' -> True;
  '/usr/local/bin/foo' -> False; '/var/lib/dpkg/x' -> False (unchanged)
- End-to-end: segfaulting binary under /var/tmp -> no new .crash in /var/crash
  ("executable does not belong to a package, ignoring" in apport log);
  segfaulting packaged /usr/bin/python3.14 -> report still created.

Out of scope / noted: crashes of installed-package binaries *triggered by*
dev work (qemu booting a test ISO, ninja during a local build, ...) are still
captured - the filter is about binary provenance, not workload.

** Affects: apport (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174521

Title:
  apport writes crash reports for development binaries in /var/tmp;
  likely_packaged() treats all of /var as packaged

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/2174521/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to