From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
Date: Thu, 18 May 2017 12:49:42 +0200 [thread overview]
Message-ID: <20170518104942.14588-3-jack@suse.cz> (raw)
In-Reply-To: <20170518104942.14588-1-jack@suse.cz>
There is an off-by-one error in loop termination conditions in
ext4_find_unwritten_pgoff() since 'end' may index a page beyond end of
desired range if 'endoff' is page aligned. It doesn't have any visible
effects but still it is good to fix it.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index bbea2dccd584..2b00bf84c05b 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -474,7 +474,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
endoff = (loff_t)end_blk << blkbits;
index = startoff >> PAGE_SHIFT;
- end = endoff >> PAGE_SHIFT;
+ end = (endoff - 1) >> PAGE_SHIFT;
pagevec_init(&pvec, 0);
do {
--
2.12.0
next prev parent reply other threads:[~2017-05-18 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:49 [PATCH 0/2 v3] ext4: Fix SEEK_HOLE implementation Jan Kara
2017-05-18 10:49 ` [PATCH 1/2] ext4: Fix SEEK_HOLE Jan Kara
2017-05-20 4:14 ` Theodore Ts'o
2017-05-18 10:49 ` Jan Kara [this message]
2017-05-20 4:15 ` [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff() Theodore Ts'o
-- strict thread matches above, loose matches on Subject: below --
2017-05-17 12:07 [PATCH 0/2 v2] ext4: Fix SEEK_HOLE implementation Jan Kara
2017-05-17 12:07 ` [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff() Jan Kara
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=20170518104942.14588-3-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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