The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
Cc: Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+5585f47221c0de04168d@syzkaller.appspotmail.com
Subject: Re: [PATCH] ufs: validate block and fragment shifts
Date: Sun, 22 Nov 2026 16:20:13 +0000	[thread overview]
Message-ID: <20261122162013.GA453747@ZenIV> (raw)
In-Reply-To: <20260925043337.87879-1-matheus.aalmeida@inf.ufrgs.br>

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...

      parent reply	other threads:[~2026-11-22 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25  4:33 [PATCH] ufs: validate block and fragment shifts Matheus Alves de Almeida
2026-10-08  3:27 ` Matheus Alves de Almeida
2026-11-22 16:20 ` Al Viro [this message]

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=20261122162013.GA453747@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matheus.aalmeida@inf.ufrgs.br \
    --cc=syzbot+5585f47221c0de04168d@syzkaller.appspotmail.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