Commit f9186dabd for clamav.net
commit f9186dabd780e94c2fa08214851e29ed67f52b8e
Merge: 146619b42 b437c7716
Author: Val S. <valsnyde@cisco.com>
Date: Mon Aug 17 20:18:53 2026 -0400
Support safe quarantine removal on FreeBSD (#1791)
* Support safe quarantine removal on FreeBSD
The CLAM-2959 quarantine hardening requires an atomic way to prove that a
pathname still identifies the source retained during scanning before removing
it. FreeBSD lacks the no-replace rename primitive used by the generic POSIX
capture path on supported releases, causing --move and --remove to fail with
ENOTSUP.
Detect funlinkat() and use it with the retained scan descriptor after securely
traversing to the source parent. FreeBSD atomically checks that the basename
still names the retained descriptor before unlinking it. Normalize EDEADLK to
EAGAIN so replacement races follow the existing action-failure behavior.
Resolve descriptor paths through F_KINFO so FreeBSD symlink submissions retain
the real scanned source path. Other platform implementations and the
conservative unsupported-POSIX fallback remain unchanged.
Reported-by: Hiroki Imai from Ricerca Security, Inc.
CLAM-2959
* Preserve resolved quarantine source paths
FreeBSD F_KINFO resolves a vnode through the name cache and may return a
different hard-link name from the path used to open the scanned file. Using
that result for a path-based quarantine action could remove another link and
leave the submitted path in place.
Retain the already-resolved path supplied to path-based action sources and use
descriptor path resolution only when no authoritative path is available. Guard
F_KINFO use so FreeBSD releases without that command fall back cleanly instead
of failing to compile. Add hard-link regression coverage for move and remove
actions.
CLAM-2959
* Fix macOS quarantine test result matching
On macOS, /tmp is reported as its canonical /private/tmp path. The quarantine
directory replacement tests compared the complete clamscan success message
against paths created from the noncanonical temporary directory. A successful
copy or move could therefore be misclassified as an action failure.
Match the stable copy and move action markers instead. Existing filesystem
assertions continue to verify that the payload reached the pinned quarantine
directory and was not redirected through a replaced path.
CLAM-2959