All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 7/8] xfs: fix off-by-one error in xfs_rtalloc_query_range
Date: Thu, 21 Jun 2018 11:31:47 -0700	[thread overview]
Message-ID: <152960590720.26246.9373633806502479237.stgit@magnolia> (raw)
In-Reply-To: <152960586416.26246.8634761888260524091.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

In commit 8ad560d2565e6 ("xfs: strengthen rtalloc query range checks")
we strengthened the input parameter checks in the rtbitmap range query
function, but introduced an off-by-one error in the process.  The call
to xfs_rtfind_forw deals with the high key being rextents, but we clamp
the high key to rextents - 1.  This causes the returned results to stop
one block short of the end of the rtdev, which is incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_rtbitmap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 65fc4ed2e9a1..b228c821bae6 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1029,8 +1029,8 @@ xfs_rtalloc_query_range(
 	if (low_rec->ar_startext >= mp->m_sb.sb_rextents ||
 	    low_rec->ar_startext == high_rec->ar_startext)
 		return 0;
-	if (high_rec->ar_startext >= mp->m_sb.sb_rextents)
-		high_rec->ar_startext = mp->m_sb.sb_rextents - 1;
+	if (high_rec->ar_startext > mp->m_sb.sb_rextents)
+		high_rec->ar_startext = mp->m_sb.sb_rextents;
 
 	/* Iterate the bitmap, looking for discrepancies. */
 	rtstart = low_rec->ar_startext;


  parent reply	other threads:[~2018-06-21 18:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 18:31 [PATCH 0/8] xfs-4.18: various fixes Darrick J. Wong
2018-06-21 18:31 ` [PATCH 1/8] xfs: allow empty transactions while frozen Darrick J. Wong
2018-06-22  6:18   ` Allison Henderson
2018-06-22  6:31   ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 2/8] xfs: fix fdblocks accounting w/ RMAPBT per-AG reservation Darrick J. Wong
2018-06-22  6:21   ` Allison Henderson
2018-06-21 18:31 ` [PATCH 3/8] xfs: don't trip over negative free space in xfs_reserve_blocks Darrick J. Wong
2018-06-22  6:31   ` Christoph Hellwig
2018-06-22  6:32   ` Allison Henderson
2018-06-21 18:31 ` [PATCH 4/8] xfs: don't allow insert-range to shift extents past the maximum offset Darrick J. Wong
2018-06-22  6:33   ` Allison Henderson
2018-06-22  6:39   ` Christoph Hellwig
2018-06-22  6:47     ` Darrick J. Wong
2018-06-22 21:21   ` [PATCH v2 " Darrick J. Wong
2018-06-23  6:47     ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 5/8] xfs: recheck reflink state after grabbing ILOCK_SHARED for a write Darrick J. Wong
2018-06-22  6:40   ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 6/8] xfs: fix uninitialized field in rtbitmap fsmap backend Darrick J. Wong
2018-06-22  6:37   ` Allison Henderson
2018-06-22  6:41   ` Christoph Hellwig
2018-06-22  6:47     ` Darrick J. Wong
2018-06-22 21:22   ` [PATCH v2 " Darrick J. Wong
2018-06-23  6:47     ` Christoph Hellwig
2018-06-21 18:31 ` Darrick J. Wong [this message]
2018-06-22  6:41   ` [PATCH 7/8] xfs: fix off-by-one error in xfs_rtalloc_query_range Christoph Hellwig
2018-06-22  6:41   ` Allison Henderson
2018-06-21 18:31 ` [PATCH 8/8] xfs: ensure post-EOF zeroing happens after zeroing part of a file Darrick J. Wong
2018-06-22  6:29   ` Christoph Hellwig
2018-06-22  6:49     ` Darrick J. Wong
2018-06-22  6:42   ` Allison Henderson
2018-06-22  6:21 ` [PATCH 9/8] xfs: check leaf attribute block freemap in verifier 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=152960590720.26246.9373633806502479237.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --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.