fs: Do not use IS_ERR_VALUE() to validate offset in lseek()
On 32-bit systems, checking for IS_ERR_VALUE(pos) is not
correct. Expanding that code we get (loff_t cast is added for clarity):

 (loff_t)pos >= (unsigned long)-MAX_ERRNO

given that loff_t is a 64-bit signed value, any perfectly valid seek
offset that is greater than 0xffffc000 will result in false positive.

Moreso, as a part of fix introduced in e10efc5080 ("fs: fix memory
access via /dev/mem for MIPS64") it doesn't really solve the problem
completely on on 64-bit platforms, becuase it still leaves out a
number of perfectly valid offsets (e.g. "md 0xffffffffffffff00"
doesn't work)

Undo the original change and convert the check to simply test if
offset is negative.

Changes neccessary to alllow access to end of 64-bit address space
will be implemented in the follow-up patch.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 0b80e3d commit 71cd98395789829b79dc6e748046549fb9e90135
@Andrey Smirnov Andrey Smirnov authored on 29 Jan 2019
Sascha Hauer committed on 4 Feb 2019
Showing 1 changed file
View
fs/fs.c