afs: Add missing vnode validation checks
authorDavid Howells <dhowells@redhat.com>
Wed, 1 Sep 2021 18:22:50 +0000 (19:22 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 13 Sep 2021 08:10:39 +0000 (09:10 +0100)
commit3978d816523991dd86cf9aae88c295230a5ea3b2
treeb7f9045e2544d879129f26dee2b40e0e2cc517c7
parent581b2027af0018944ba301d68e7af45c6d1128b5
afs: Add missing vnode validation checks

afs_d_revalidate() should only be validating the directory entry it is
given and the directory to which that belongs; it shouldn't be validating
the inode/vnode to which that dentry points.  Besides, validation need to
be done even if we don't call afs_d_revalidate() - which might be the case
if we're starting from a file descriptor.

In order for afs_d_revalidate() to be fixed, validation points must be
added in some other places.  Certain directory operations, such as
afs_unlink(), already check this, but not all and not all file operations
either.

Note that the validation of a vnode not only checks to see if the
attributes we have are correct, but also gets a promise from the server to
notify us if that file gets changed by a third party.

Add the following checks:

 - Check the vnode we're going to make a hard link to.
 - Check the vnode we're going to move/rename.
 - Check the vnode we're going to read from.
 - Check the vnode we're going to write to.
 - Check the vnode we're going to sync.
 - Check the vnode we're going to make a mapped page writable for.

Some of these aren't strictly necessary as we're going to perform a server
operation that might get the attributes anyway from which we can determine
if something changed - though it might not get us a callback promise.

Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Markus Suvanto <markus.suvanto@gmail.com>
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/163111667354.283156.12720698333342917516.stgit@warthog.procyon.org.uk/
fs/afs/dir.c
fs/afs/file.c
fs/afs/write.c