From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id DB7801FF0AB for ; Mon, 07 Sep 2026 13:44:28 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9AC6221488; Mon, 07 Sep 2026 13:44:26 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 07 Sep 2026 13:44:15 +0200 Message-Id: To: "Robert Obkircher" From: "Max R. Carrara" Subject: Re: [PATCH proxmox v2 02/10] proxmox-alloc: document undefined behavior regarding custom allocs X-Mailer: aerc 0.18.2-0-ge037c095a049 References: <20260821140238.615302-1-m.carrara@proxmox.com> <20260821140238.615302-3-m.carrara@proxmox.com> <178836567690.287871.10965145059423868295.b4-review@b4> In-Reply-To: <178836567690.287871.10965145059423868295.b4-review@b4> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788781449081 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.637 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: TLZQX62A53DRBUDAJ2PFTB2ZAGWH72BG X-Message-ID-Hash: TLZQX62A53DRBUDAJ2PFTB2ZAGWH72BG X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pbs-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed Sep 2, 2026 at 6:14 PM CEST, Robert Obkircher wrote: > > 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. Hmm, good point, I'll include reworked examples in the docs in v2, and mark them with `no_run`, since it's suggested to use this for documenting UB [no_run]. Thanks! > > These examples also conflate allocation of DSTs and over-alignment to a > runtime value, which are completely separate concepts that can be > understood separately. Fair, I'll try to separate the two. Thanks! [no_run]: https://doc.rust-lang.org/rustdoc/write-documentation/documentati= on-tests.html#no_run > > > > > Add a hint in the `aware_boxed` module's docs that such an example > > exists in the crate. > > > > Signed-off-by: Max R. Carrara > > > > 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 =3D true > > license.workspace =3D true > > exclude.workspace =3D true > > > > +[[example]] > > +crate-type =3D ["staticlib"] > > +name =3D "ub" > > + > > [dependencies] > > > > [dev-dependencies] > > diff --git a/proxmox-alloc/examples/ub.rs b/proxmox-alloc/examples/ub.r= s > > 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 be= havior]. > > +//! 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 behavio= r] 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, eve= n 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.