• David Howells's avatar
    afs: Add missing vnode validation checks · 3978d816
    David Howells authored
    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: default avatarDavid Howells <dhowells@redhat.com>
    Tested-by: default avatarMarkus 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/
    3978d816
dir.c 54.1 KB