all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox] shared-memory: flush contents of newly created mmap file
@ 2026-04-22  7:33 Christian Ebner
  2026-04-24  9:36 ` applied: " Fabian Grünbichler
  2026-04-24  9:50 ` Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Ebner @ 2026-04-22  7:33 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* applied: [PATCH proxmox] shared-memory: flush contents of newly created mmap file
  2026-04-22  7:33 [PATCH proxmox] shared-memory: flush contents of newly created mmap file Christian Ebner
@ 2026-04-24  9:36 ` Fabian Grünbichler
  2026-04-24  9:50 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2026-04-24  9:36 UTC (permalink / raw)
  To: Christian Ebner, pbs-devel

just FTR, this one got applied already in
acd33a15c29cfe617ce5ecc69c78f692b2f20a8b

On April 22, 2026 9:33 am, Christian Ebner wrote:
> 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
> 
> 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* applied: [PATCH proxmox] shared-memory: flush contents of newly created mmap file
  2026-04-22  7:33 [PATCH proxmox] shared-memory: flush contents of newly created mmap file Christian Ebner
  2026-04-24  9:36 ` applied: " Fabian Grünbichler
@ 2026-04-24  9:50 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2026-04-24  9:50 UTC (permalink / raw)
  To: pbs-devel, Christian Ebner

On Wed, 22 Apr 2026 09:33:51 +0200, Christian Ebner wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] shared-memory: flush contents of newly created mmap file
      commit: acd33a15c29cfe617ce5ecc69c78f692b2f20a8b




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-24 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22  7:33 [PATCH proxmox] shared-memory: flush contents of newly created mmap file Christian Ebner
2026-04-24  9:36 ` applied: " Fabian Grünbichler
2026-04-24  9:50 ` Thomas Lamprecht

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