]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.16.4/ext4-fix-offset-overflow-on-32-bit-archs-in-ext4_iomap_begin.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / ext4-fix-offset-overflow-on-32-bit-archs-in-ext4_iomap_begin.patch
CommitLineData
0f23eb5b
GKH
1From fe23cb65c2c394ea306f3714a17d46ab2e6a0af1 Mon Sep 17 00:00:00 2001
2From: Jiri Slaby <jslaby@suse.cz>
3Date: Thu, 22 Mar 2018 11:50:26 -0400
4Subject: ext4: fix offset overflow on 32-bit archs in ext4_iomap_begin()
5
6From: Jiri Slaby <jslaby@suse.cz>
7
8commit fe23cb65c2c394ea306f3714a17d46ab2e6a0af1 upstream.
9
10ext4_iomap_begin() has a bug where offset returned in the iomap
11structure will be truncated to unsigned long size. On 64-bit
12architectures this is fine but on 32-bit architectures obviously not.
13Not many places actually use the offset stored in the iomap structure
14but one of visible failures is in SEEK_HOLE / SEEK_DATA implementation.
15If we create a file like:
16
17dd if=/dev/urandom of=file bs=1k seek=8m count=1
18
19then
20
21lseek64("file", 0x100000000ULL, SEEK_DATA)
22
23wrongly returns 0x100000000 on unfixed kernel while it should return
240x200000000. Avoid the overflow by proper type cast.
25
26Fixes: 545052e9e35a ("ext4: Switch to iomap for SEEK_HOLE / SEEK_DATA")
27Signed-off-by: Jiri Slaby <jslaby@suse.cz>
28Signed-off-by: Jan Kara <jack@suse.cz>
29Signed-off-by: Theodore Ts'o <tytso@mit.edu>
30Cc: stable@vger.kernel.org # v4.15
31Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32
33---
34 fs/ext4/inode.c | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37--- a/fs/ext4/inode.c
38+++ b/fs/ext4/inode.c
39@@ -3524,7 +3524,7 @@ retry:
40 iomap->flags |= IOMAP_F_DIRTY;
41 iomap->bdev = inode->i_sb->s_bdev;
42 iomap->dax_dev = sbi->s_daxdev;
43- iomap->offset = first_block << blkbits;
44+ iomap->offset = (u64)first_block << blkbits;
45 iomap->length = (u64)map.m_len << blkbits;
46
47 if (ret == 0) {