public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Robert Obkircher <r.obkircher@proxmox.com>
To: "Max R. Carrara" <m.carrara@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox v2 02/10] proxmox-alloc: document undefined behavior regarding custom allocs
Date: Wed, 02 Sep 2026 18:14:36 +0200	[thread overview]
Message-ID: <178836567690.287871.10965145059423868295.b4-review@b4> (raw)
In-Reply-To: <20260821140238.615302-3-m.carrara@proxmox.com>

> Add a new example at examples/ub.rs with tests that demonstrate
> incorrect usage & undefined behavior of custom allocations.

I don't think that it is a good idea to include a runnable example,
because it can theoretically format your hard drive, and it will likely
result in false positives from vulnerability scanners.

These examples also conflate allocation of DSTs and over-alignment to a
runtime value, which are completely separate concepts that can be
understood separately.

> 
> Add a hint in the `aware_boxed` module's docs that such an example
> exists in the crate.
> 
> Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
>
> diff --git a/proxmox-alloc/Cargo.toml b/proxmox-alloc/Cargo.toml
> index 4eeeb787..b16496f6 100644
> --- a/proxmox-alloc/Cargo.toml
> +++ b/proxmox-alloc/Cargo.toml
> @@ -11,6 +11,10 @@ repository.workspace = true
>  license.workspace = true
>  exclude.workspace = true
>  
> +[[example]]
> +crate-type = ["staticlib"]
> +name = "ub"
> +
>  [dependencies]
>  
>  [dev-dependencies]
> diff --git a/proxmox-alloc/examples/ub.rs b/proxmox-alloc/examples/ub.rs
> new file mode 100644
> index 00000000..aa97b02b
> --- /dev/null
> +++ b/proxmox-alloc/examples/ub.rs
> @@ -0,0 +1,99 @@
> +//! This example contains various tests that demonstrate [undefined behavior].
> +//! Needless to say, you should not use what's shown here in your own code.
> +//!
> +//! You can run this example's tests using the following command:
> +//!
> +//! ```text
> +//! cargo test --package proxmox-alloc --example ub
> +//! ```
> +//!
> +//! Alternatively, if you want to see what kinds of [undefined behavior] get
> +//! caught by [Miri], use the following instead:
> +//!
> +//! ```text
> +//! cargo +nightly miri nextest run --package proxmox-alloc --example ub
> +//! ```
> +//!
> +//! Note that this requires [`cargo nextest`][nextest] to be installed on your
> +//! nightly toolchain. This will guarantee that all tests are run, even if they
> +//! fail (which they do when you use Miri).
> +//!
> +//! [Miri]: https://github.com/rust-lang/miri
> +//! [nextest]: https://nexte.st/
> +//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
> +
> +#[cfg(test)]

This could be `#[cfg(all(test, miri))]`, but even then I don't think
miri supports something like #[should_panic] but for expected UB.

-- 
Robert Obkircher <r.obkircher@proxmox.com>




  reply	other threads:[~2026-09-02 16:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 14:02 [PATCH proxmox{,-backup} v2 00/10] Fix Undefined Behavior in Tape Block Header Deallocation Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox v2 01/10] proxmox-alloc: introduce proxmox-alloc with `LayoutAwareBox<T>` type Max R. Carrara
2026-09-02 16:14   ` Robert Obkircher
2026-08-21 14:02 ` [PATCH proxmox v2 02/10] proxmox-alloc: document undefined behavior regarding custom allocs Max R. Carrara
2026-09-02 16:14   ` Robert Obkircher [this message]
2026-09-02 16:17   ` Robert Obkircher
2026-08-21 14:02 ` [PATCH proxmox-backup v2 03/10] tape: move tape block structs into separate file module Max R. Carrara
2026-09-02 16:17   ` Robert Obkircher
2026-08-21 14:02 ` [PATCH proxmox-backup v2 04/10] tape: rename `BlockHeader` and `BlockHeaderFlags` Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox-backup v2 05/10] tape: blocked_{reader,writer}: rename `buffer` to `tape_block` Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox-backup v2 06/10] tape: tape block: represent tape block header with its own struct Max R. Carrara
2026-09-02 16:17   ` Robert Obkircher
2026-08-21 14:02 ` [PATCH proxmox-backup v2 07/10] tape: tape block: make `payload` field private Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox-backup v2 08/10] tape: blocked_{reader,writer}: remove haphazard `unsafe` blocks Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox-backup v2 09/10] tape: tape block: fix undefined behavior on tape block deallocation Max R. Carrara
2026-08-21 14:02 ` [PATCH proxmox-backup v2 10/10] tape: sgutils2: fix undefined behavior in dealloc of buffer Max R. Carrara
2026-09-02 16:36 ` [PATCH proxmox{,-backup} v2 00/10] Fix Undefined Behavior in Tape Block Header Deallocation 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=178836567690.287871.10965145059423868295.b4-review@b4 \
    --to=r.obkircher@proxmox.com \
    --cc=m.carrara@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