From: Jaegeuk Kim Date: Mon, 8 Sep 2014 17:59:43 +0000 (-0700) Subject: f2fs: fix negative value for lseek offset X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0b4c5afde9b57c08b55d26725d228d5314cfc57a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git f2fs: fix negative value for lseek offset If application throws negative value of lseek with SEEK_DATA|SEEK_HOLE, previous f2fs went into BUG_ON in get_dnode_of_data, which was reported by Tommi Rantala. He could make a simple code to detect this having: lseek(fd, -17595150933902LL, SEEK_DATA); This patch should resolve that bug. Reported-by: Tommi Rentala [Jaegeuk Kim: relocate the condition as suggested by Chao] Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 9f0ea3d3251b..5cde363cf7a8 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -353,6 +353,8 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence) maxbytes, i_size_read(inode)); case SEEK_DATA: case SEEK_HOLE: + if (offset < 0) + return -ENXIO; return f2fs_seek_block(file, offset, whence); }