Re: [PATCH] ufs: validate block and fragment shifts
From: Al Viro
Date: Sun Nov 22 2026 - 11:20:24 EST
On Fri, Sep 25, 2026 at 01:33:37AM -0300, Matheus Alves de Almeida wrote:
> + if (uspi->s_fshift != ilog2(uspi->s_fsize)) {
> + pr_err("%s(): fragment size shift %u does not match fragment size %u\n",
> + __func__, uspi->s_fshift, uspi->s_fsize);
> + goto failed;
> + }
That's an odd way to do it:
if fsize is not a power of 2
fail
if fsize is below 512 or above 4096
fail
if fshift is not equal to ilog2(fsize)
fail
Why not
if fshift < 9 || fshift > 12
fail
if fsize != (1 << fshift)
fail
and, while we are at it,
if fmask != fsize - 1
fail
is also missing there...