linux/fs/cachefiles
David Howells 413a4a6b0b cachefiles: Fix volume coherency attribute
A network filesystem may set coherency data on a volume cookie, and if
given, cachefiles will store this in an xattr on the directory in the
cache corresponding to the volume.

The function that sets the xattr just stores the contents of the volume
coherency buffer directly into the xattr, with nothing added; the
checking function, on the other hand, has a cut'n'paste error whereby it
tries to interpret the xattr contents as would be the xattr on an
ordinary file (using the cachefiles_xattr struct).  This results in a
failure to match the coherency data because the buffer ends up being
shifted by 18 bytes.

Fix this by defining a structure specifically for the volume xattr and
making both the setting and checking functions use it.

Since the volume coherency doesn't work if used, take the opportunity to
insert a reserved field for future use, set it to 0 and check that it is
0.  Log mismatch through the appropriate tracepoint.

Note that this only affects cifs; 9p, afs, ceph and nfs don't use the
volume coherency data at the moment.

Fixes: 32e150037d ("fscache, cachefiles: Store the volume coherency data")
Reported-by: Rohith Surabattula <rohiths.msft@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Steve French <smfrench@gmail.com>
cc: linux-cifs@vger.kernel.org
cc: linux-cachefs@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-03-11 10:24:37 -08:00
..
cache.c cachefiles: Check that the backing filesystem supports tmpfiles 2022-01-21 21:36:28 +00:00
daemon.c cachefiles: set default tag name if it's unspecified 2022-01-21 21:36:28 +00:00
error_inject.c cachefiles: Add some error injection support 2022-01-07 13:40:56 +00:00
interface.c cachefiles: Fix incorrect length to fallocate() 2022-03-03 11:35:21 -08:00
internal.h cachefiles: Calculate the blockshift in terms of bytes, not pages 2022-01-21 21:36:28 +00:00
io.c netfs, cachefiles: Add a method to query presence of data in the cache 2022-02-01 10:29:18 -06:00
Kconfig cachefiles: Add some error injection support 2022-01-07 13:40:56 +00:00
key.c cachefiles: Implement key to filename encoding 2022-01-07 13:42:16 +00:00
main.c cachefiles: Implement object lifecycle funcs 2022-01-07 13:42:08 +00:00
Makefile cachefiles: Implement begin and end I/O operation 2022-01-07 13:42:44 +00:00
namei.c cachefiles: Trace active-mark failure 2022-01-21 21:36:28 +00:00
security.c cachefiles: Add security derivation 2022-01-07 13:41:14 +00:00
volume.c fscache, cachefiles: Store the volume coherency data 2022-01-07 13:43:03 +00:00
xattr.c cachefiles: Fix volume coherency attribute 2022-03-11 10:24:37 -08:00