fix: libmount not notify mount event - #23
Conversation
When mnt_context_mount() retries a failed mount as read-only, it calls mnt_context_prepare_update() again, which invokes mnt_update_start() a second time. Without checking whether act_fd is already open, the old fd is overwritten and leaked, and its LOCK_SH prevents mnt_update_end() from unlinking the act file. Guard mnt_update_start() with an act_fd >= 0 check: if the act file is already open and locked, reuse the existing fd instead of opening a new one. When mnt_context_mount() fails in mnt_context_do_mount(), the mnt_context_update_tabs() call is guarded by if (!rc) and gets skipped. This means mnt_update_end() -- the only function that unlinks /run/mount/utab.act -- never runs, leaving the act file orphaned on disk. mnt_free_update() only close()s act_fd without releasing the lock or unlinking the act file. Fix this by calling mnt_update_end() before unreffing members, which properly unlocks, unlinks and closes the act file. Add a fallback close() for the case where mnt_update_end() fails to acquire the lock and returns early without closing the fd. The utab.act file was introduced in v2.40 (commit 9218c96) and this leak has been present since then through the current master. A leftover utab.act causes mnt_monitor's kernel_event_verify() to veil all subsequent kernel mount events (monitor.c: kernel_veiled + access(utab.act)==0), making consumers like udisksd miss real mount/umount notifications. PMS: BUG-374891 Upstream: util-linux/util-linux#4572
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes libmount’s utab.act lifecycle across mount retries and failures by reusing existing locks/descriptors and reliably ending updates, preventing orphaned act files that can veil subsequent kernel mount events. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
TAG Bot TAG: 2.40.4-3deepin14 |
|
/integrate |
|
AutoIntegrationPr Bot |
When mnt_context_mount() retries a failed mount as read-only, it calls mnt_context_prepare_update() again, which invokes mnt_update_start() a second time. Without checking whether act_fd is already open, the old fd is overwritten and leaked, and its LOCK_SH prevents mnt_update_end() from unlinking the act file.
Guard mnt_update_start() with an act_fd >= 0 check: if the act file is already open and locked, reuse the existing fd instead of opening a new one.
When mnt_context_mount() fails in mnt_context_do_mount(), the mnt_context_update_tabs() call is guarded by if (!rc) and gets skipped. This means mnt_update_end() -- the only function that unlinks /run/mount/utab.act -- never runs, leaving the act file orphaned on disk.
mnt_free_update() only close()s act_fd without releasing the lock or unlinking the act file. Fix this by calling mnt_update_end() before unreffing members, which properly unlocks, unlinks and closes the act file. Add a fallback close() for the case where mnt_update_end() fails to acquire the lock and returns early without closing the fd.
The utab.act file was introduced in v2.40 (commit 9218c96) and this leak has been present since then through the current master. A leftover utab.act causes mnt_monitor's
kernel_event_verify() to veil all subsequent kernel mount events (monitor.c: kernel_veiled + access(utab.act)==0), making consumers like udisksd miss real mount/umount notifications.
PMS: BUG-374891
Upstream: util-linux/util-linux#4572
Summary by Sourcery
Fix libmount active update file handling so failed or retried mounts do not suppress subsequent kernel mount events.
Bug Fixes:
Enhancements:
Chores: