• David Howells's avatar
    cifs: Fix reacquisition of volume cookie on still-live connection · dad80c6b
    David Howells authored
    During mount, cifs_mount_get_tcon() gets a tcon resource connection record
    and then attaches an fscache volume cookie to it.  However, it does this
    irrespective of whether or not the tcon returned from cifs_get_tcon() is a
    new record or one that's already in use.  This leads to a warning about a
    volume cookie collision and a leaked volume cookie because tcon->fscache
    gets reset.
    
    Fix this be adding a mutex and a "we've already tried this" flag and only
    doing it once for the lifetime of the tcon.
    
    [!] Note: Looking at cifs_mount_get_tcon(), a more general solution may
    actually be required.  Reacquiring the volume cookie isn't the only thing
    that function does: it also partially reinitialises the tcon record without
    any locking - which may cause live filesystem ops already using the tcon
    through a previous mount to malfunction.
    
    This can be reproduced simply by something like:
    
        mount //example.com/test /xfstest.test -o user=shares,pass=xxx,fsc
        mount //example.com/test /mnt -o user=shares,pass=xxx,fsc
    
    Fixes: 70431bfd ("cifs: Support fscache indexing rewrite")
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Acked-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.com>
    cc: Shyam Prasad N <sprasad@microsoft.com>
    cc: linux-cifs@vger.kernel.org
    cc: linux-fsdevel@vger.kernel.org
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    dad80c6b
cifsglob.h 77.5 KB