linux/fs/fscache
David Howells c8aedb3b36 FS-Cache: Handle a write to the page immediately beyond the EOF marker
commit 102f4d900c upstream.

Handle a write being requested to the page immediately beyond the EOF
marker on a cache object.  Currently this gets an assertion failure in
CacheFiles because the EOF marker is used there to encode information about
a partial page at the EOF - which could lead to an unknown blank spot in
the file if we extend the file over it.

The problem is actually in fscache where we check the index of the page
being written against store_limit.  store_limit is set to the number of
pages that we're allowed to store by fscache_set_store_limit() - which
means it's one more than the index of the last page we're allowed to store.
The problem is that we permit writing to a page with an index _equal_ to
the store limit - when we should reject that case.

Whilst we're at it, change the triggered assertion in CacheFiles to just
return -ENOBUFS instead.

The assertion failure looks something like this:

CacheFiles: Assertion failed
1000 < 7b1 is false
------------[ cut here ]------------
kernel BUG at fs/cachefiles/rdwr.c:962!
...
RIP: 0010:[<ffffffffa02c9e83>]  [<ffffffffa02c9e83>] cachefiles_write_page+0x273/0x2d0 [cachefiles]

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[ kamal: backport to 3.13-stable: no __kernel_write(); thanks Ben H. ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
History 2015-12-13 17:49:53 +00:00
..
cache.c fs/fscache: convert printk to pr_foo() 2014-06-04 16:53:51 -07:00
cookie.c fs/fscache: convert printk to pr_foo() 2014-06-04 16:53:51 -07:00
fsdef.c FS-Cache: Provide the ability to enable/disable cookies 2013-09-27 18:40:25 +01:00
histogram.c fs/fscache: replace seq_printf by seq_puts 2014-06-04 16:53:52 -07:00
internal.h fs/fscache: convert printk to pr_foo() 2014-06-04 16:53:51 -07:00
Kconfig fscache: drop references to slow-work 2010-07-22 22:58:58 +02:00
main.c fscache: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:16 -07:00
Makefile FS-Cache: Allow the current state of all objects to be dumped 2009-11-19 18:11:04 +00:00
netfs.c FS-Cache: Don't override netfs's primary_index if registering failed 2015-12-13 17:49:24 +00:00
object-list.c fs/fscache: replace seq_printf by seq_puts 2014-06-04 16:53:52 -07:00
object.c FS-Cache: Handle removal of unadded object to the fscache_object_list rb tree 2014-02-17 13:47:35 -08:00
operation.c fs/fscache: convert printk to pr_foo() 2014-06-04 16:53:51 -07:00
page.c FS-Cache: Handle a write to the page immediately beyond the EOF marker 2015-12-13 17:49:53 +00:00
proc.c FS-Cache: Allow the current state of all objects to be dumped 2009-11-19 18:11:04 +00:00
stats.c fs/fscache/stats.c: fix memory leak 2013-04-29 15:54:27 -07:00