OSDN Git Service

cachefiles: Fix volume coherency attribute
authorDavid Howells <dhowells@redhat.com>
Fri, 11 Mar 2022 16:02:18 +0000 (16:02 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Mar 2022 18:24:37 +0000 (10:24 -0800)
commit413a4a6b0b5553f2423d210f65e98c211b99c3f8
treed01761f4125f6ab11bfb0d2d539defda2f450185
parent173ce1ca47c489135b2799f70f550e1319ba36d8
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: 32e150037dce ("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>
fs/cachefiles/xattr.c
include/trace/events/cachefiles.h