Re: [patch 2.6.13-rc6] Fix kmem read on 32-bit archs

From: Linus Torvalds
Date: Sun Aug 14 2005 - 11:24:44 EST




On Sun, 14 Aug 2005, Chuck Ebbert wrote:
>
> The first thing drivers/char/mem.c:read_kmem does is convert the
> loff_t it gets as the offset for reading into an unsigned int. This
> patch makes the kmem driver's llseek operator do that up-front, so
> that fs/read_write.c:rw_verify_area doesn't return -EINVAL when
> we try to read from higher addresses.

Why would rw_verify_area() return -EINVAL? It does

if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
goto Einval;

but pos and "loff_t" is 64-bit, and if the thing is negative in 64 bits,
then that thing really _should_ fail.

Yes, the thing needs to be opened with O_LARGEFILE and you need to use
"llseek()" to seek into it, but once you do that, everything should be
fine.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/