From: Eric Sandeen <sandeen@redhat.com>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH] xfs_repair: don't let bplist index go negative in prefetch
Date: Thu, 15 May 2014 13:59:43 -0500 [thread overview]
Message-ID: <53750E9F.3010301@redhat.com> (raw)
After:
bbd3275 repair: don't unlock prefetch tree to read discontig buffers
Coverity spotted that it's possible for us to arrive at the loop
below with num == 1, and then we decrement it to 0, and try to
index bplist[num-1].
I think this was possible before the change, i.e. it's probably
not a regression.
Fix this by not trying to shrink the window unless we have
more than one buffer in the array.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 4595310..b6d4755 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -505,7 +505,7 @@ pf_batch_read(
first_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[0]));
last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) +
XFS_BUF_SIZE(bplist[num-1]);
- while (last_off - first_off > pf_max_bytes) {
+ while (num > 1 && last_off - first_off > pf_max_bytes) {
num--;
last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) +
XFS_BUF_SIZE(bplist[num-1]);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2014-05-15 18:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 18:59 Eric Sandeen [this message]
2014-05-16 2:22 ` [PATCH] xfs_repair: don't let bplist index go negative in prefetch Eric Sandeen
2014-05-16 2:32 ` Dave Chinner
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=53750E9F.3010301@redhat.com \
--to=sandeen@redhat.com \
--cc=xfs@oss.sgi.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