{
  "slug": "file-sealing",
  "term": "Linux file sealing",
  "aliases": [
    "file seals",
    "memfd sealing"
  ],
  "definition": "Linux file sealing irreversibly restricts selected operations on a supported file, with restrictions shared by all descriptors referring to its inode.",
  "note": "Scope: F_ADD_SEALS adds irreversible inode-wide restrictions; F_GET_SEALS reads them. Adding seals requires a writable descriptor. F_SEAL_SEAL blocks further additions, not data changes. [seals-api]\n\nWrites: F_SEAL_WRITE blocks backing-object writes but requires releasing shared mappings with potential write capability. A PROT_READ mapping created from O_RDWR can still block it. FUTURE_WRITE leaves earlier shared writable mappings usable; private COW edits do not modify the file. [seals-api] [seals-capability]\n\nMapping order: downgrading an earlier shared mapping with mprotect need not revoke its potential write capability. A later shared read-only mapping created under FUTURE_WRITE cannot be upgraded. A separately reopened O_RDONLY mapping is distinct: it cannot be upgraded but sees other writers before sealing. [seals-mapping] [mprotect-api]\n\nSize: WRITE does not prevent resizing; add SHRINK and GROW to fix the extent. Volatile memfd seals provide neither persistence nor origin authentication. [seals-kernel]\n\nHandoff: SCM_RIGHTS and dup share an open file description's offset. Seals do not stop another holder from seeking. [handoff-unix] In a 4096-byte handoff, read and dup-read consumed 3072 unchanged suffix bytes after a sender seek to 1024; positional and reopened controls read all 4096. [hesela-handoff]\n\nConsumption: pread supplies an explicit offset. A complete reader still checks errors, short reads and expected coverage; byte stability and valid format do not prove complete consumption. [handoff-pread]",
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-23",
  "advantages": [
    "Kernel enforcement can constrain a peer that holds a writable descriptor."
  ],
  "limitations": [
    "A receiver still needs to inspect the actual seal mask and validate the application's data format."
  ],
  "related": [
    "memfd-create",
    "memory-mapped-file",
    "file-truncation",
    "copy-on-write",
    "open-file-description"
  ],
  "citations": [
    {
      "id": "seals-api",
      "title": "Linux man-pages: F_GET_SEALS / F_ADD_SEALS",
      "url": "https://man7.org/linux/man-pages/man2/F_ADD_SEALS.2const.html",
      "accessed": "2026-10-17"
    },
    {
      "id": "seals-kernel",
      "title": "Linux v6.12: memfd sealing implementation",
      "url": "https://github.com/torvalds/linux/blob/v6.12/mm/memfd.c",
      "accessed": "2026-10-17"
    },
    {
      "id": "seals-mapping",
      "title": "Linux v6.12: seal_check_write mapping checks",
      "url": "https://github.com/torvalds/linux/blob/v6.12/include/linux/mm.h",
      "accessed": "2026-10-17"
    },
    {
      "id": "seals-capability",
      "title": "Linux v6.12: shared mappings with potential write capability",
      "url": "https://github.com/torvalds/linux/blob/v6.12/include/linux/fs.h#L520-L547",
      "accessed": "2026-10-18"
    },
    {
      "id": "mprotect-api",
      "title": "Linux man-pages: mprotect(2), access changes and EACCES",
      "url": "https://man7.org/linux/man-pages/man2/mprotect.2.html",
      "accessed": "2026-10-18"
    },
    {
      "id": "handoff-unix",
      "title": "Linux man-pages: unix(7), SCM_RIGHTS shares the open file description",
      "url": "https://man7.org/linux/man-pages/man7/unix.7.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "handoff-pread",
      "title": "Linux man-pages: pread(2), explicit offsets and short reads",
      "url": "https://man7.org/linux/man-pages/man2/pread.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-handoff",
      "title": "Hesela: sealed bytes and a shared read cursor",
      "url": "https://hesela.com/analyses/mmap-visibility-size-durability/#sealed-handoff",
      "accessed": "2026-10-23"
    }
  ],
  "provenance": [
    "The companion probe tests seven sequential cases on one host, not a concurrent interprocess protocol.",
    "The source review uses Linux v6.12 code to explain mechanisms; the measured kernel is recorded separately.",
    "Three additional mapping-capability controls and raw observations: https://hesela.dev/research/file-seal-capability.json; runnable source: https://hesela.dev/research/file-seal-capability.py.",
    "A separate two-process SCM_RIGHTS supplement tests eleven ordered cases three times per capture; this does not change the earlier sequential experiments' populations. Raw evidence and reproduction guide: https://hesela.dev/research/sealed-handoff/README.md."
  ]
}
