public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Robert Obkircher <r.obkircher@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH v2 proxmox 4/6] io: remove boxed::uninitialized because it is unsound
Date: Wed, 12 Aug 2026 10:23:33 +0200	[thread overview]
Message-ID: <20260812082549.21561-5-r.obkircher@proxmox.com> (raw)
In-Reply-To: <20260812082549.21561-1-r.obkircher@proxmox.com>

Using this function could result in miscompilations, and it was also
missing a null check. Remove it, since it appears to be unused.

Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
---
 proxmox-io/src/boxed.rs | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/proxmox-io/src/boxed.rs b/proxmox-io/src/boxed.rs
index fb67bfd7..abd60a1f 100644
--- a/proxmox-io/src/boxed.rs
+++ b/proxmox-io/src/boxed.rs
@@ -1,15 +1,3 @@
-/// Uninitialized bytes, without `MaybeUninit`.
-///
-/// We're talking about bytes here, which we *allocate*. That is, we call a function, get a pointer
-/// to stuff, and can use it. It's not UB in that there's nothing undefined about what's going on
-/// here.
-pub fn uninitialized(len: usize) -> Box<[u8]> {
-    unsafe {
-        let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
-        Box::from_raw(std::ptr::slice_from_raw_parts_mut(data, len))
-    }
-}
-
 /// Zero-initialized bytes, meant for large sizes to avoid busting the stack.
 pub fn zeroed(len: usize) -> Box<[u8]> {
     // vec! guarantees not to over-allocate, so shrink_to_fit inside into_boxed_slice does nothing
-- 
2.47.3





  parent reply	other threads:[~2026-08-12  8:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  8:23 [PATCH v2 proxmox 0/6] uninitialized memory allocations fixes Robert Obkircher
2026-08-12  8:23 ` [PATCH v2 proxmox 1/6] uuid: avoid potential null dereference and memory leaks Robert Obkircher
2026-08-12  8:23 ` [PATCH v2 proxmox 2/6] io: request zeroed memory instead of manually clearing it Robert Obkircher
2026-08-12  8:23 ` [PATCH v2 proxmox 3/6] io: avoid potential null dereference and memory leak on error path Robert Obkircher
2026-08-12  8:23 ` Robert Obkircher [this message]
2026-08-12  8:23 ` [PATCH v2 proxmox 5/6] io: remove unused append_to_vec functions Robert Obkircher
2026-08-12  8:23 ` [PATCH v2 proxmox 6/6] io: remove unused ByteVecExt trait with grow_ and resize_uninitialized Robert Obkircher

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=20260812082549.21561-5-r.obkircher@proxmox.com \
    --to=r.obkircher@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal