all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox] shared-memory: flush contents of newly created mmap file
Date: Wed, 22 Apr 2026 09:33:51 +0200	[thread overview]
Message-ID: <20260422073351.181581-1-c.ebner@proxmox.com> (raw)

The man page for mmap [0] states, that mappings create with
`MAP_SHARED` are not carried to the underlying file directly.

To avoid possible races between creating and initializing a new
mmapped file and opening while checking the header of this file,
msync the contents after init but before persisting the shared
memory backed file.

[0] https://man7.org/linux/man-pages/man2/mmap.2.html

Fixes: https://forum.proxmox.com/threads/182948/
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 proxmox-shared-memory/src/lib.rs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/proxmox-shared-memory/src/lib.rs b/proxmox-shared-memory/src/lib.rs
index 495812ef..4838ab42 100644
--- a/proxmox-shared-memory/src/lib.rs
+++ b/proxmox-shared-memory/src/lib.rs
@@ -190,6 +190,10 @@ impl<T: Sized + Init> SharedMemory<T> {
 
         let mmap = mmap_file(&mut file, true)?;
 
+        if skip_tmpfs_check {
+            mmap.msync(MsFlags::MS_SYNC)?;
+        }
+
         let res = {
             let path = CString::new(path.as_os_str().as_bytes())?;
             Errno::result(unsafe {
-- 
2.47.3





             reply	other threads:[~2026-04-22  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22  7:33 Christian Ebner [this message]
2026-04-24  9:36 ` applied: [PATCH proxmox] shared-memory: flush contents of newly created mmap file Fabian Grünbichler
2026-04-24  9:50 ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260422073351.181581-1-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal