Nick Piggin wrote:
Ram Pai wrote:
there is a check in __do_page_cache_readahead() that validates this.
But it is still not guaranteed to work correctly against races.
The filesystem has to handle such out-of-bound requests gracefully.
However with Nick's fix in do_generic_mapping_read() the filesystem is gauranteed to be called with out-of-bound index, if the file size is a multiple of 4k. Without the fix, the filesystem might get
called with out-of-bound index only in racy conditions.
How's this?
It doesn't work. It correctly handles the case where *ppos is equal
to i_size on entry to the function (and this does work for files 0, 4k
and n * 4k in length), but it doesn't handle readahead inside the for
loop. The check needs to be in the for loop.