All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, chandanbabu@kernel.org, hch@lst.de
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/3] xfs: fix 32-bit truncation in xfs_compute_rextslog
Date: Sun, 03 Dec 2023 11:05:34 -0800	[thread overview]
Message-ID: <170162990659.3038044.14647028784739611036.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <170162990622.3038044.5313475096294285406.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

It's quite reasonable that some customer somewhere will want to
configure a realtime volume with more than 2^32 extents.  If they try to
do this, the highbit32() call will truncate the upper bits of the
xfs_rtbxlen_t and produce the wrong value for rextslog.  This in turn
causes the rsumlevels to be wrong, which results in a realtime summary
file that is the wrong length.  Fix that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_rtbitmap.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 1c9fed76a356..0626909a2481 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1132,14 +1132,14 @@ xfs_rtbitmap_blockcount(
 
 /*
  * Compute the maximum level number of the realtime summary file, as defined by
- * mkfs.  The use of highbit32 on a 64-bit quantity is a historic artifact that
- * prohibits correct use of rt volumes with more than 2^32 extents.
+ * mkfs.  The historic use of highbit32 on a 64-bit quantity prohibited correct
+ * use of rt volumes with more than 2^32 extents.
  */
 uint8_t
 xfs_compute_rextslog(
 	xfs_rtbxlen_t		rtextents)
 {
-	return rtextents ? xfs_highbit32(rtextents) : 0;
+	return rtextents ? xfs_highbit64(rtextents) : 0;
 }
 
 /*


  parent reply	other threads:[~2023-12-03 19:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-03 19:00 [PATCHSET 0/3] xfs: fix realtime geometry integer overflows Darrick J. Wong
2023-12-03 19:05 ` [PATCH 1/3] xfs: make rextslog computation consistent with mkfs Darrick J. Wong
2023-12-04  4:55   ` Christoph Hellwig
2023-12-04 18:52     ` Darrick J. Wong
2023-12-03 19:05 ` Darrick J. Wong [this message]
2023-12-04  4:55   ` [PATCH 2/3] xfs: fix 32-bit truncation in xfs_compute_rextslog Christoph Hellwig
2023-12-03 19:05 ` [PATCH 3/3] xfs: don't allow overly small or large realtime volumes Darrick J. Wong
2023-12-03 19:09   ` Darrick J. Wong
2023-12-04  4:56   ` Christoph Hellwig
2023-12-07  2:23 [PATCHSET v2 0/3] xfs: fix realtime geometry integer overflows Darrick J. Wong
2023-12-07  2:28 ` [PATCH 2/3] xfs: fix 32-bit truncation in xfs_compute_rextslog Darrick J. Wong

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=170162990659.3038044.14647028784739611036.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=chandanbabu@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.