• Steve French's avatar
    [SMB3] Do not fall back to SMBWriteX in set_file_size error cases · 360aed84
    Steve French authored
    commit 646200a0 upstream.
    
    The error paths in set_file_size for cifs and smb3 are incorrect.
    
    In the unlikely event that a server did not support set file info
    of the file size, the code incorrectly falls back to trying SMBWriteX
    (note that only the original core SMB Write, used for example by DOS,
    can set the file size this way - this actually  does not work for the more
    recent SMBWriteX).  The idea was since the old DOS SMB Write could set
    the file size if you write zero bytes at that offset then use that if
    server rejects the normal set file info call.
    
    Fortunately the SMBWriteX will never be sent on the wire (except when
    file size is zero) since the length and offset fields were reversed
    in the two places in this function that call SMBWriteX causing
    the fall back path to return an error. It is also important to never call
    an SMB request from an SMB2/sMB3 session (which theoretically would
    be possible, and can cause a brief session drop, although the client
    recovers) so this should be fixed.  In practice this path does not happen
    with modern servers but the error fall back to SMBWriteX is clearly wrong.
    
    Removing the calls to SMBWriteX in the error paths in cifs_set_file_size
    
    Pointed out by PaX/grsecurity team
    Signed-off-by: default avatarSteve French <steve.french@primarydata.com>
    Reported-by: default avatarPaX Team <pageexec@freemail.hu>
    CC: Emese Revfy <re.emese@gmail.com>
    CC: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
    360aed84
inode.c 61.5 KB