Copy-on-Pin: The Missing Piece for Correct Copy-on-Write

David Hildenbrand, Martin Schulz, Nadav Amit

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

1 Scopus citations

Abstract

Operating systems utilize Copy-on-Write (COW) to conserve memory and improve performance. During the last two decades, a series of COW-related bugs - which compromised security, corrupted memory and degraded performance - was found. The majority of these bugs are related to page "pinning", which operating systems employ to access process memory efficiently and to perform direct I/O. Unfortunately, the true cause of these bugs is not well understood, resulting in incomplete bug fixes. We show this by: (1) surveying previously reported pinning-related COW bugs; (2) uncovering new such bugs in Linux, FreeBSD, and NetBSD; and (3) showing that they occur because the COW logic does not consider page pinnings correctly, resulting in incorrect behavior (e.g., I/O of stale data). We then address the underlying problem by deriving when/how shared pages must be copied and under which conditions pinned pages can be shared to maintain correctness. Based on this assessment, we introduce the "Copy-on-Pin (COP)"scheme, an extension of the COW mechanism that handles pinned pages correctly by ensuring pinned pages and shared pages are mutually exclusive. However, we find that a naive implementation of this scheme hampers performance and increases complexity if pages are copied only when strictly necessary. To compensate, we introduce a relaxed-COP design, which does not require precise tracking of page sharing, maintains correctness without increasing complexity, and (while potentially needlessly copying pages in some corner cases) marginally improves performance. Our relaxed-COP solution has been integrated into Linux 5.19.

Original languageEnglish
Title of host publicationASPLOS 2023 - Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems
EditorsTor M. Aamodt, Natalie Enright Jerger, Michael Swift
PublisherAssociation for Computing Machinery
Pages176-191
Number of pages16
ISBN (Electronic)9781450399166
DOIs
StatePublished - 27 Jan 2023
Event28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS 2023 - Vancouver, Canada
Duration: 25 Mar 202329 Mar 2023

Publication series

NameInternational Conference on Architectural Support for Programming Languages and Operating Systems - ASPLOS
Volume2

Conference

Conference28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS 2023
Country/TerritoryCanada
CityVancouver
Period25/03/2329/03/23

Keywords

  • COW
  • copy-on-write
  • fork
  • memory deduplication
  • page pinning
  • page sharing
  • virtual memory

Fingerprint

Dive into the research topics of 'Copy-on-Pin: The Missing Piece for Correct Copy-on-Write'. Together they form a unique fingerprint.

Cite this