Skip to content

Research notes / Recovery metadata

Restoring Linux ACLs: identical bytes, different permissions

Published / Updated / Controlled metadata and retained-access observations

Our local rsync copy preserved every byte and the file mode 0660, yet changed the owning-group entry from no permissions to read/write. Adding ACL preservation prevented that change. A successful content comparison can therefore miss a consequential difference in recovery metadata.

On this page14 sections

The same 0660 can describe different access rules

The source fixture had owner read/write, a named-user entry granting read/write, no owning-group permissions, a read/write mask and no permissions for others. Its numeric mode was 0660. After rsync -a into a fresh destination without inherited ACLs, the named-user entry and mask were absent. The remaining owning-group entry was read/write. The mode stayed 0660 and all 448 payload bytes were identical.

This follows from how Linux maps an extended POSIX ACL to mode bits: when a mask exists, the middle mode digit represents that mask, not the owning-group entry alone. Without the extended ACL, those same bits represent the owning group directly. [1] Thus losing ACL metadata can broaden one entry while removing another, not merely make the restored file more restrictive.

Rsync documents that archive mode does not imply ACL preservation. The -A option preserves ACLs; -X handles extended attributes separately. Our -aX control still lost the ACL, while -aA retained it exactly. These options have distinct contracts even where a filesystem internally stores ACLs as attributes. Compatible ACL semantics and sufficient permissions remain prerequisites. [2]

Eleven controls, two mount types

We repeated each scenario three times on ext4 and tmpfs: 66 case executions on one host, running Linux 6.8.0-146-generic, rsync version 3.2.7 protocol version 31 and setfacl 2.3.2. Every repetition produced the outcomes below. This is a repeatability check, not 66 independent systems or an estimate of incident frequency.

All payloads matched byte-for-byte. Effective entry permissions are calculated from the recorded ACL and mask; no second-user login was performed. UID 12345 is a fixture identifier, not a real participant.
OperationResulting modeUID 12345 entry, effectiveOwning-group entry, effective
Copy: rsync -a0660No entryrw-
Copy: rsync -aX0660No entryrw-
Copy: rsync -aA0660rw----
chmod 0660 on masked ACL0660rw----
Add second user; automatic mask0660rw----
Add second user; retain mask (-n)0640r-----
Set ACL, then chmod 06000600------
chmod 0600, then set ACL0640r-----
Create 0666, no default ACL0600No entry---
Create 0666, with default ACL0660rw----
Create 0600, with default ACL0600------

Copy cases start from mask rw-. The chmod, editing and restore-order cases start from a named-user entry rw- restricted by mask r--. Creation controls use umask 0077 and either no default ACL or a default ACL with named-user and mask permissions rwx. Each scenario uses fresh fixtures; rows are not successive edits to one file.

A later chmod can reactivate a stored permission

Changing the masked fixture from mode 0640 to 0660 left its named-user entry at rw- and widened the mask. The entry's effective permissions changed from r-- to rw-, although no command explicitly edited that user. The owning-group entry remained ---. The Linux v6.8 implementation makes the distinction explicit: __posix_acl_chmod_masq() changes the mask when present, otherwise the owning-group entry. [5]

There is a second path to the same outcome. Adding a read-only entry for UID 12346 using ordinary setfacl -m recalculated the mask and re-enabled UID 12345's stored write permission. With setfacl -n -m, the original read-only mask survived. The utility documents this recalculation; it is not a kernel defect. [3] Review the whole ACL after an edit, including permissions that existed but were previously masked.

The restore-order controls applied deliberately conflicting targets: an ACL equivalent to mode 0640 and a chmod target of 0600. Applying chmod last suppressed the named entry; applying the ACL last restored its effective read permission and mode 0640. No ordering rule can satisfy two contradictory targets simultaneously. Decide which complete policy is authoritative, then verify the final state.

Finish ownership changes before accepting final permissions

chown changes the owning user or group, whereas chmod changes mode bits. Those operations are not independent: Linux ownership changes on executable files can clear setuid/setgid execution bits and file capabilities. Do not assume every ownership change clears both bits; the documented non-group-executable setgid exception matters. [20]

The GNU coreutils 9.5 install implementation performs ownership changes before setting the final mode, explicitly to avoid losing special bits. This is implementation evidence for an ordering constraint, not a complete backup procedure. Later writes can also clear execution privilege bits. The remaining metadata operations require sufficient authority after ownership changes. [33] [15]

Our recovery inference is to finish payload writes and ownership changes before accepting the final security metadata. Coordinate the mode with the authoritative access ACL: a blanket final chmod can overwrite its mask and change effective named-user or group rights. Verify owner/group identities, mode, full ACL and any intentionally restored file capabilities together; do not re-enable privileged metadata merely because it exists in an archive. [1]

Check the resulting state as well as command errors. Linux can silently clear a requested setgid bit when the caller lacks CAP_FSETID and does not belong to the file's group. Path selection also matters: chown() follows a final symbolic link, while lchown() acts on that link itself. These are documented Linux and syscall distinctions, not new ownership-switching measurements, a recursive shell recipe or a crash-durability guarantee. [15] [20]

fchownat() with AT_SYMLINK_NOFOLLOW selects a final symbolic link; it does not stop following symbolic links in earlier pathname components. Its directory descriptor anchors relative lookup, but absolute paths ignore that descriptor and relative paths may leave the directory. Choosing the link itself is different from confining the lookup. [20] [34]

On Linux, ordinary symbolic links retain mode 0777: these bits do not control access and cannot be changed. Link ownership still matters for sticky-directory removal or rename and protected-symlink checks. For recovery, distinguish the link's metadata from its referent's metadata; a successful pathname operation alone does not establish which object the recovery policy intended. This is source-based guidance, not an additional measurement from our probe. [34]

An open descriptor avoids a fresh pathname lookup, but its data access mode is not a complete metadata-rights policy. The 2010 Capsicum paper uses fchmod on a read-only descriptor to motivate per-descriptor rights, and separately restricts directory-relative lookups to delegated namespaces. These are additional FreeBSD capability mechanisms, not guarantees supplied by an ordinary Linux directory descriptor or AT_SYMLINK_NOFOLLOW. For a restore helper, selecting the intended object, bounding namespace access and authorizing metadata changes are separate design decisions. This is a design comparison, not a Capsicum experiment or a claim that Linux CAP_CHOWN implements that capability model. [35]

A restrictive umask does not override a default ACL

The file mode creation mask (umask) removes permissions from the mode requested by the caller. Without a parent default ACL, Linux computes the permission bits as requested_mode & ~umask & 0777. It clears bits; it does not subtract octal numbers or add execute permission that the caller never requested. [4] [16]

Calculated examples without a parent default ACL. Inputs and outputs are octal permission bits, not complete file modes or new native observations.
Requested bitsUmaskResulting bits
066600220644
077700220755
060000770600
066600000666

The requested mode is an argument, not a universal starting value for every file or directory. Group ownership and a directory's inherited set-group-ID bit follow separate rules; the 0777 calculation covers only permission bits. [16]

Under umask 0077, our plain-directory creation with requested mode 0666 yielded mode 0600. The same call inside the default-ACL directory yielded 0660 with effective read/write for the named entry. Requesting mode 0600 in that directory retained the named entry but masked its permissions to zero.

This distinguishes the process umask from the ACL mask. Linux documents default-ACL inheritance as an alternative to applying the umask, while the requested creation mode still limits the resulting permissions. [4] A program that explicitly requests 0600 therefore differs from one requesting 0666 under umask 0077. The probe uses os.open with explicit arguments to avoid hiding that distinction behind a copying tool.

A child created by fork() inherits the process mask; execve() preserves it, and POSIX threads share it. Temporarily setting a mask and restoring the old value is not an atomic query; another thread can create a file in the interval. Reading Linux's /proc/self/status observes the mask without changing it, but does not freeze later state. [4] [17] For restore acceptance, check the restored directory default ACL and the creating program's requested mode as well as its umask.

Inheriting a group does not grant group write

A Linux setgid directory gives newly created children its group ownership. New subdirectories also inherit S_ISGID (02000). This directory rule differs from the credential change associated with executing a setgid program. It does not itself grant group write permission. [18] [19]

For a calculated example, assume successful creation under a setgid parent, no default ACL and umask 0027. Requesting 0666 for a regular file produces permission bits 0640. Requesting 0777 for a subdirectory produces 0750 plus inherited 02000, conventionally written 2750. Both receive the parent's group; neither is group-writable. These are derived examples, not new native observations or complete st_mode values. [12] [19]

A default ACL changes permission initialization, not this distinction between group identity and granted rights. Its inherited access ACL is still constrained by the requested mode. On supporting filesystems, grpid/bsdgroups mount policy can also select the parent group without a parent setgid bit. A child's group alone therefore does not reveal which inheritance rule was used. [1] [20]

Our recovery inference is to verify directory group ownership, setgid state and default ACLs separately, then check newly created children under the intended identities. Setting setgid on the directory alone does not retroactively change existing children's groups or permissions. This source-based extension does not add a group-switching or cross-host restore experiment to the measurements above.

The overlooked recovery problem has a long history

Andreas Gruenbacher's 2003 FREENIX paper explains why extended ACLs map the group class to a mask, and separately examines backup and restore in section 13. Read together, these sections connect compatibility with old permission tools to a recovery obligation: file content and coarse modes do not encode the full policy. [6]

The paper describes implementations and tool limitations of its period. Its statements about archive-tool support must not be used as a current product matrix. Our contribution is a small, current, downloadable set of cross-operation controls that connects this design history to an actual rsync 3.2.7 run. It reproduces documented behavior rather than claiming a new vulnerability.

Include the permission policy in recovery acceptance

Access checks select entries in order; they do not combine every permission in the ACL. A matching named user whose masked entry denies the requested operation does not fall through to a permissive other entry. The owner is checked before named users. This documented selection rule is another reason our per-entry table is not an end-to-end access test. [5]

For a real restore, our recommendation is to compare content and metadata separately. Check numeric owner/group identities, complete access ACLs, default ACLs on directories and final mode bits after all post-processing. Confirm the intended identity mapping on the destination; matching an integer alone does not prove it represents the same person.

Then test representative operations as the intended identities, including directory traversal and creation of new children. This probe does not do that: entry-and-mask intersections are not a complete authorization decision. Parent-directory permissions, identity/group membership, capabilities and other security mechanisms can change the outcome. Windows and NFSv4 ACL translation also require their own checks.

This extends our backup verification analysis: identical payload hashes are useful evidence, but not a substitute for the application's recovery contract. For change discovery before capture, see the inotify experiment.

Linux uses a directory's x bit for search permission, not program execution. It permits looking up names inside that directory. POSIX.1-2017 opendir() requires search through the pathname prefix and read permission on the directory being listed. Read permission alone does not authorize resolving its child names. [26] [27]

Consider a fresh pathname open of a known file, with no privilege override or additional restriction. Search without directory read can allow reaching that name, while file read permission separately determines whether a read-only open is allowed. Conversely, listing the directory does not prove that the caller can open a listed file. These are documented permission distinctions, not new observations from our ACL-copy probe. [26] [12]

Creating a missing child or removing an existing name requires parent-directory write and pathname search. Write permission on the target file is not the permission to remove its name. The sticky-directory restriction and other controls still apply. Lookup starts from the operation's chosen root, working directory or directory descriptor; do not assume that a descriptor-relative lookup retraverses all ancestors. [12] [22] [26]

For restore acceptance, distinguish listing, known-name reads, child creation and name removal under the intended identities. Inspect the directory's access ACL and its mask: a named entry containing x can still lack effective search permission. A default ACL initializes new children; it does not grant access to the directory itself. This is recovery guidance inferred from the documented rules, not a complete authorization test. [1]

The sticky bit protects names, not file contents

The sticky bit, S_ISVTX or octal 01000, adds a restriction on removing or renaming entries in a Linux directory. The caller must own the affected file, own its containing directory, or have the relevant privilege. This is distinct from setgid group inheritance and default-ACL permission inheritance. [21]

Passing that ownership test does not grant ordinary directory write or path-search permission. Linux documents CAP_FOWNER as the privilege for bypassing the sticky check; other access checks and filesystem restrictions still apply. A file owner therefore cannot infer permission to unlink a name solely from owning the file. [22] [24]

For rename, check both sides when applicable: the source directory may restrict removal of the source name, and a sticky destination directory separately restricts replacement of an existing destination. Owning the source file does not itself authorize replacing another owner's destination. [23]

The sticky bit alone does not make an existing file's contents read-only. Content access still depends on the applicable file permissions and other controls. Linux also has separate fs.protected_regular and fs.protected_fifos settings that can reject O_CREAT opens of already-existing objects in writable sticky directories under documented ownership conditions; those checks are not the deletion rule itself. [25]

For recovery acceptance, compare the directory's special mode bits and the ownership of both directory and files, alongside ACLs and payload bytes. Restoring the same ordinary rwx bits does not establish equivalent name-removal permissions. This is a consequence of the documented Linux rules, not an additional observation from the ACL-copy experiment above. [22] [23]

A restore must account for metadata that should disappear

Matching every archived extended attribute does not establish an identical metadata state. In a separate native experiment, GNU tar 1.35 restored both source user.* values onto an existing directory but left its destination-only user.hesela.extra. The payload and modes matched; the attribute sets did not. Adding --overwrite gave the same result. The regular file was recreated with the exact source set, so the directory result must not be generalized to every file.

Let S and D be selected name-to-byte-value maps before capture and after restore. Checking every pair in S proves only inclusion in D; equality also requires rejecting unexpected names in the authoritative domain. A defined empty value is not an absent attribute. Linux listxattr() may omit names inaccessible to its caller, so even this comparison is scoped to the observed namespace and identity. [28] [32]

11 scenarios, 132 executions on one host: two captures, ext4 and tmpfs, three fresh repetitions per filesystem. Each row represents 12 matching outcomes. All 285 payload bytes and modes 0640/0750 matched. Equality covers visible user.* attributes only; a matching file does not turn a failed command into an accepted restore.
ScenarioExitFile / directory sets equalAll source values match, file / directorySame inode as retained alias
tar: fresh0Yes / YesYes / YesNot applicable
tar: existing0Yes / NoYes / YesNo
tar: overwrite0Yes / NoYes / YesNo
tar: unlink first2Yes / NoYes / NoNo
tar: no xattrs0No / NoNo / NoNot applicable
rsync -a: fresh0No / NoNo / NoNot applicable
rsync -aX: fresh0Yes / YesYes / YesNot applicable
rsync -aX: existing0Yes / YesYes / YesYes
rsync -aX: receiver excluded0No / NoNo / NoYes
rsync -aX: extra key excluded0No / NoYes / YesYes
rsync -aX: changed payload0Yes / YesYes / YesNo

Unfiltered rsync 3.2.7 -aX reconciled the visible sets. Excluding the extra key retained it while updating the source values; the receiver-wide exclusion retained the old values too. Filters therefore define part of the recovery contract. The pinned implementation separately sets supplied values and removes eligible extra names. Plain archive mode does not imply xattr or ACL preservation. [2] [31]

Metadata-only rsync also changed a retained hard-link alias outside the destination subtree, because both paths still named the same inode. When the destination payload differed, the normal update replaced that inode and left the alias on its earlier bytes and attributes. Neither control used --inplace; no --link-dest run was performed. This extends the existing topology evidence from file relationships to selected metadata: pathname containment is insufficient evidence of isolation.

The tar --unlink-first control returned exit 2 for the nonempty directory while still replacing its child file. It is a partial failure, not a workaround or a rollback guarantee. The source release separates archived-key assignment and reuse of existing directories from regular-file extraction paths. [29] [30]

Our recovery inference is to declare authoritative, excluded and destination-specific metadata; compare exact selected maps on files and directories; inspect errors and partial effects; and verify intended inode sharing before making a restored tree available. Do not blindly remove privileged attributes. These are repeatability controls, not independent systems, failure-rate estimates or a new vulnerability. No privileged namespaces, ACL translation, concurrent writer, cross-host restore, crash or power interruption was tested; tmpfs is not persistent storage.

Inspect the generated outcomes, typed claims, version-pinned sources and offline reproduction bundle. The protocol specifies unprivileged Linux, Python 3, GNU tar, rsync, findmnt and two writable xattr-capable test locations. After extracting the bundle:

python3 -B verify.py
python3 -B test_probe.py
python3 -B probe.py --directory . --directory /dev/shm --repetitions 3 --output replay.json

The checker validates frozen fixture outcomes, not every machine or future release. The original two captures and MIT harness remain unchanged; the observation data are CC0.

Permission changes do not revoke every retained local access

Recovery has another boundary: a file's current permissions and a running workload's retained access are not the same state. In a separate native experiment on one Linux 6.8.0-146-generic host, chmod 000 denied new pathname opens on ext4 and tmpfs but did not stop reads or writes through an existing O_RDWR open description. A duplicate created after the change could still write after the original descriptor closed. Duplicating a descriptor refers to the same open description; it does not repeat pathname admission. [7]

A shared writable mapping created after the mode change also stored a new byte after its input descriptor closed. The before-change mapping control did the same. The mapping can outlive that descriptor; Linux v6.8 checks the open description's write mode when admitting a shared writable mapping, alongside other restrictions. [8] [9]

9 scenarios, 108 recorded executions and 108 matching replay records. Two compiler configurations, three fresh-fixture repetitions per mount, one host. OK means the operation succeeded; Not tested means that operation was absent. A was the initial byte and Z the replacement.
ScenarioModeFresh read / read-write openRetained read, write or storeShared writable mapProcfs reopenFresh readback
Retained read0000EACCES / EACCESOKNot testedNot testedA
Retained write0000EACCES / EACCESOKNot testedNot testedZ
Duplicate, then write0000EACCES / EACCESOKNot testedNot testedZ
Read; reopen after narrowing0000EACCES / EACCESOKNot testedEACCESA
Map before chmod; store after close0000EACCES / EACCESOKOKNot testedZ
Map after chmod; store after close0000EACCES / EACCESOKOKNot testedZ
Read-only handle after widening0600OK / OKEBADFEACCESNot testedA
Read-only handle; reopen read/write0600OK / OKEBADFEACCESOKZ
Create mode 0000; write0000EACCES / EACCESOKNot testedNot testedZ

The reverse control is equally useful: widening permissions from 0400 to 0600 did not upgrade an existing O_RDONLY handle. Writes through it and its duplicate failed with EBADF; shared writable mapping failed with EACCES. A fresh read/write open through /proc/self/fd could write Z. Reopening and duplicating are different operations, and the procfs path has its own permission checks. [10] [11] Creating a file with mode 0000 could also return a usable read/write descriptor: creation mode restricts subsequent access, not necessarily the creating open. [12]

Do not generalize this to "Linux checks permissions only at open." The inspected v6.8 read/write path still invokes security_file_permission, and mapping admission invokes security_mmap_file. [13] [14] Upstream v6.8 explains the mechanism, not every patch in the tested Ubuntu kernel. The chmod manual documents different already-open-file behavior on NFS; no NFS or changed security-policy experiment was performed here. [15]

These same-owner fixtures test operation lifetime, not named-user ACL selection or hostile-user isolation. The mapping cases verify that the input descriptor is closed before the memory store. Permissions are restored only for the final fresh readback. That readback establishes visibility, not crash durability; tmpfs is not persistent storage. No concurrent writer, reboot or power interruption was tested. This reproduces documented behavior, not a new vulnerability.

Our engineering inference: denying new opens is insufficient evidence that an earlier local writer has stopped. Recovery acceptance should separately verify metadata policy, fresh access under intended identities, retained descriptors and mappings, application quiescence, and the required durability boundary. Closing one visible descriptor alone does not establish that boundary.

Inspect the derived result table, complete native observations, typed claims and evidence links, and reproducibility bundle. The bundle preserves both captures, source receipts, the MIT C/Python harness and its tests; observation data are CC0. Extract it into a writable directory and run as an unprivileged user:

python3 run.py --directory . --directory /dev/shm --repetitions 3 --output my-observations.json
python3 -m unittest -v test_run.py

Requirements: Linux, Python 3, a C11 compiler named cc, findmnt, usable procfs and writable test directories. Root or effective capabilities are rejected. The full protocol and limits distinguish same-host replay from independent confirmation. Related concepts: open file description, memory-mapped file and file descriptor.

Reproduce and inspect the full ACLs

Download the MIT-licensed Python probe and CC0 observation JSON. Requirements: Linux, Python 3, getfacl, setfacl, rsync with ACL support, findmnt and writable ACL-capable test directories.

python3 acl-restore.py --directory . --directory /dev/shm --repetitions 3 --output observations.json

The probe runs unprivileged, creates private temporary directories, removes inherited ACLs on its test roots and deletes only its own fixtures. It records full numeric access ACLs, modes, exact-byte checks, hashes, versions and its own SHA-256. Unsupported operations fail the run rather than silently become successful cases. The observations contain no user data.

Both mounts were on one host. There were no concurrent writers, cross-host restores, arbitrary ownership changes, impersonated access checks or power interruptions. The result establishes these metadata transformations in this environment; it does not certify a backup product or the durability of a recovery.

Primary sources

  1. Linux ACL project: acl(5), permission-bit correspondence and object creation. Accessed 2026-10-19.
  2. Rsync manual: --archive, --acls and --xattrs. Accessed 2026-10-19.
  3. Linux ACL project: setfacl(1), mask recalculation. Accessed 2026-10-19.
  4. Linux man-pages: umask(2), interaction with default ACLs. Accessed 2026-10-19.
  5. Linux v6.8: fs/posix_acl.c, __posix_acl_chmod_masq and posix_acl_create. Accessed 2026-10-19.
  6. Andreas Gruenbacher: POSIX Access Control Lists on Linux, USENIX FREENIX 2003, pp. 259-272. Accessed 2026-10-19.
  7. Linux man-pages: dup(2), shared open description. Accessed 2026-11-05.
  8. Linux man-pages: mmap(2), mapping and descriptor lifetime. Accessed 2026-11-05.
  9. Linux v6.8: do_mmap and FMODE_WRITE. Accessed 2026-11-05.
  10. Linux man-pages: F_GETFL / F_SETFL, access modes. Accessed 2026-11-05.
  11. Linux man-pages: proc_pid_fd(5), reopen permission checks. Accessed 2026-11-05.
  12. Linux man-pages: open(2), creation mode and access mode. Accessed 2026-11-05.
  13. Linux v6.8: rw_verify_area and vfs_write. Accessed 2026-11-05.
  14. Linux v6.8: vm_mmap_pgoff security hook. Accessed 2026-11-05.
  15. Linux man-pages: chmod(2), NFS qualification. Accessed 2026-11-05.
  16. Linux man-pages: mkdir(2), creation permissions and group inheritance. Accessed 2026-11-15.
  17. Linux man-pages: pthreads(7), shared process attributes. Accessed 2026-11-15.
  18. Linux man-pages: inode(7), S_ISGID on directories and executables. Accessed 2026-11-15.
  19. Linux man-pages: mkdir(2), group ownership and setgid inheritance. Accessed 2026-11-15.
  20. Linux man-pages: chown(2), new-file group ownership and mount policy. Accessed 2026-11-15.
  21. Linux man-pages: inode(7), S_ISVTX and directory mode. Accessed 2026-11-15.
  22. Linux man-pages: rename(2), source and destination restrictions. Accessed 2026-11-15.
  23. Linux man-pages: capabilities(7), CAP_FOWNER versus access overrides. Accessed 2026-11-15.
  24. Linux kernel documentation: protected_regular and protected_fifos. Accessed 2026-11-15.
  25. Linux man-pages: path_resolution(7), search permissions and lookup start. Accessed 2026-11-16.
  26. POSIX.1-2017: opendir, directory read and pathname-prefix search. Accessed 2026-11-16.
  27. Linux man-pages: xattr(7), namespace and empty-value semantics. Accessed 2026-11-16.
  28. GNU tar 1.35 manual: extended attributes and extraction options. Accessed 2026-11-16.
  29. GNU tar 1.35 source release: xattr setter and extraction paths. Accessed 2026-11-16.
  30. Rsync 3.2.7 xattrs.c: scoped setting and removal of attributes. Accessed 2026-11-16.
  31. Linux man-pages: listxattr(2), caller-visible attribute names. Accessed 2026-11-16.
  32. GNU coreutils 9.5: install.c, ownership before final mode. Accessed 2026-11-16.
  33. Watson, Anderson, Laurie and Kennaway: Capsicum, USENIX Security 2010, sections 2.1-2.2. Accessed 2026-11-16.

Published by Hesela team · Published · Updated

Report a correction · Editorial standards · Reuse guidance

Change history

: first published.

: latest recorded update. A detailed change note is not available for this revision.

New-publication RSS · Correction RSS

Cite this page
Hesela team. Restoring Linux ACLs: identical bytes, different permissions. Hesela. 2026-11-16. https://hesela.com/analyses/posix-acl-restore-permissions/