Re: [PATCH 20/79] block: rnull: add discard support

Alice Ryhl
2026-03-16T10:52:37Z

On Mon, Feb 16, 2026 at 12:35:07AM +0100, Andreas Hindborg wrote:
> +configfs_attribute!(DeviceConfig, 10,
> + show: |this, page| show_field(this.data.lock().discard, page),
> + store: |this, page| store_with_power_check(this, page, |this, page| {
> + if !this.data.lock().memory_backed {
> + return Err(EINVAL);
> + }
> + this.data.lock().discard = kstrtobool_bytes(page)?;

Similar to the race I mentioned earlier with store_with_power_check(),
this is also a TOCTOU race.

> + discard: u8 {
> + default: 0,
> + description:
> + "Support discard operations (requires memory-backed null_blk device). Default: false",
> + },

kstrtobool again here...

> -type TreeNode = Owned<SafePage>;
> +const _CHEKC_STATUS_WIDTH: () = build_assert!((PAGE_SIZE >> SECTOR_SHIFT) <= 64);

Use static_assert! or assert! here.

Alice