cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/9] gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block
Date: Thu, 11 Oct 2018 21:20:38 +0200	[thread overview]
Message-ID: <20181011192045.20546-3-agruenba@redhat.com> (raw)
In-Reply-To: <20181011192045.20546-1-agruenba@redhat.com>

We already have a function that checks if a block is within a resource
group, so use that in gfs2_rbm_from_block as well.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/rgrp.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7f8b562d1cbe..6eb2addcbff5 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -273,15 +273,10 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len,
 
 static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
 {
-	u64 rblock = block - rbm->rgd->rd_data0;
-
-	if (WARN_ON_ONCE(rblock > UINT_MAX))
-		return -EINVAL;
-	if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data)
+	if (!rgrp_contains_block(rbm->rgd, block))
 		return -E2BIG;
-
 	rbm->bii = 0;
-	rbm->offset = (u32)(rblock);
+	rbm->offset = block - rbm->rgd->rd_data0;
 	/* Check if the block is within the first block */
 	if (rbm->offset < rbm_bi(rbm)->bi_blocks)
 		return 0;
-- 
2.17.1



  parent reply	other threads:[~2018-10-11 19:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11 19:20 [Cluster-devel] [PATCH 0/9] gfs2: Minor cleanups and fixes Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 1/9] gfs2: Always check the result of gfs2_rbm_from_block Andreas Gruenbacher
2018-10-11 19:20 ` Andreas Gruenbacher [this message]
2018-10-11 19:20 ` [Cluster-devel] [PATCH 3/9] gfs2: Move rs_{sizehint, rgd_gh} fields into the inode Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 4/9] gfs2: Remove unused RGRP_RSRV_MINBYTES definition Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 5/9] gfs2: Rename bitmap.bi_{len => bytes} Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 6/9] gfs2: Fix some minor typos Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 7/9] gfs2: Fix marking bitmaps non-full Andreas Gruenbacher
2018-10-12  9:15   ` Steven Whitehouse
2018-10-12 11:40     ` Andreas Gruenbacher
2018-10-12 12:06     ` Bob Peterson
2018-10-12 12:07       ` Steven Whitehouse
2018-10-11 19:20 ` [Cluster-devel] [PATCH 8/9] gfs2: Remove unnecessary gfs2_rlist_alloc parameter Andreas Gruenbacher
2018-10-11 19:20 ` [Cluster-devel] [PATCH 9/9] gfs2: Pass resource group to rgblk_free Andreas Gruenbacher
2018-10-12 12:48 ` [Cluster-devel] [PATCH 0/9] gfs2: Minor cleanups and fixes Bob Peterson

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=20181011192045.20546-3-agruenba@redhat.com \
    --to=agruenba@redhat.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;
as well as URLs for NNTP newsgroup(s).