lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251217174559.GB2944334@google.com>
Date: Wed, 17 Dec 2025 17:45:59 +0000
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Eric Biggers <ebiggers@...nel.org>
Cc: dm-devel@...ts.linux.dev, Alasdair Kergon <agk@...hat.com>,
	Mike Snitzer <snitzer@...nel.org>,
	Mikulas Patocka <mpatocka@...hat.com>,
	Benjamin Marzinski <bmarzins@...hat.com>,
	Eran Messeri <eranm@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/7] dm-verity: make dm_verity_fec_io::bufs
 variable-length

On Tue, Dec 16, 2025 at 03:06:09PM -0800, Eric Biggers wrote:
> When correcting a data block, the FEC code performs optimally when it
> has enough buffers to hold all the needed RS blocks.  That number of
> buffers is '1 << (v->data_dev_block_bits - DM_VERITY_FEC_BUF_RS_BITS)'.
> 
> However, since v->data_dev_block_bits isn't a compile-time constant, the
> code actually used PAGE_SHIFT instead.
> 
> With the traditional PAGE_SIZE == data_block_size == 4096, this was
> fine.  However, when PAGE_SIZE > data_block_size, this wastes space.
> E.g., with data_block_size == 4096 && PAGE_SIZE == 16384, struct
> dm_verity_fec_io is 9240 bytes, when in fact only 3096 bytes are needed.
> 
> Fix this by making dm_verity_fec_io::bufs a variable-length array.
> 
> This makes the macros DM_VERITY_FEC_BUF_MAX and
> fec_for_each_extra_buffer() no longer apply, so remove them.  Also
> remove the related macro fec_for_each_prealloc_buffer(), since
> DM_VERITY_FEC_BUF_PREALLOC is fixed at 1 and was already assumed to be 1
> (considering that mempool_alloc() shouldn't be called in a loop).

> [..]

>  static struct dm_verity_fec_io *fec_alloc_and_init_io(struct dm_verity *v)
>  {
> +	const unsigned int max_nbufs = fec_max_nbufs(v);
>  	struct dm_verity_fec *f = v->fec;
>  	struct dm_verity_fec_io *fio;
>  	unsigned int n;
>  
>  	fio = mempool_alloc(&f->fio_pool, GFP_NOIO);
>  	fio->rs = mempool_alloc(&f->rs_pool, GFP_NOIO);
>  
> -	memset(fio->bufs, 0, sizeof(fio->bufs));
> -
> -	fec_for_each_prealloc_buffer(n)
> -		fio->bufs[n] = mempool_alloc(&f->prealloc_pool, GFP_NOIO);
> +	static_assert(DM_VERITY_FEC_BUF_PREALLOC == 1);
> +	fio->bufs[0] = mempool_alloc(&f->prealloc_pool, GFP_NOIO);

Can we just remove DM_VERITY_FEC_BUF_PREALLOC completely instead?

Sami

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ