[Devel] [PATCH RHEL7 COMMIT] ms/ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jul 26 11:01:38 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.33.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.33.17
------>
commit 79dcf67e5adf486ce43a2385ea8e512064d4d906
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Wed Jul 26 12:01:38 2017 +0400

    ms/ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
    
    Backport 3f1d5bad3fae983da07be01cff2fde13293bb7b9 from ml:
    
        ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
    
        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 at suse.cz>
        Signed-off-by: Theodore Ts'o <tytso at mit.edu>
    
    https://jira.sw.ru/browse/PSBM-68292
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 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 da5851e..be8da78 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -443,7 +443,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
 	endoff = (loff_t)end_blk << blkbits;
 
 	index = startoff >> PAGE_CACHE_SHIFT;
-	end = endoff >> PAGE_CACHE_SHIFT;
+	end = (endoff - 1) >> PAGE_CACHE_SHIFT;
 
 	pagevec_init(&pvec, 0);
 	do {


More information about the Devel mailing list