1. 25 2月, 2020 1 次提交
    • A
      cifs: fix rename() by ensuring source handle opened with DELETE bit · 86f740f2
      Aurelien Aptel 提交于
      To rename a file in SMB2 we open it with the DELETE access and do a
      special SetInfo on it. If the handle is missing the DELETE bit the
      server will fail the SetInfo with STATUS_ACCESS_DENIED.
      
      We currently try to reuse any existing opened handle we have with
      cifs_get_writable_path(). That function looks for handles with WRITE
      access but doesn't check for DELETE, making rename() fail if it finds
      a handle to reuse. Simple reproducer below.
      
      To select handles with the DELETE bit, this patch adds a flag argument
      to cifs_get_writable_path() and find_writable_file() and the existing
      'bool fsuid_only' argument is converted to a flag.
      
      The cifsFileInfo struct only stores the UNIX open mode but not the
      original SMB access flags. Since the DELETE bit is not mapped in that
      mode, this patch stores the access mask in cifs_fid on file open,
      which is accessible from cifsFileInfo.
      
      Simple reproducer:
      
      	#include <stdio.h>
      	#include <stdlib.h>
      	#include <sys/types.h>
      	#include <sys/stat.h>
      	#include <fcntl.h>
      	#include <unistd.h>
      	#define E(s) perror(s), exit(1)
      
      	int main(int argc, char *argv[])
      	{
      		int fd, ret;
      		if (argc != 3) {
      			fprintf(stderr, "Usage: %s A B\n"
      			"create&open A in write mode, "
      			"rename A to B, close A\n", argv[0]);
      			return 0;
      		}
      
      		fd = openat(AT_FDCWD, argv[1], O_WRONLY|O_CREAT|O_SYNC, 0666);
      		if (fd == -1) E("openat()");
      
      		ret = rename(argv[1], argv[2]);
      		if (ret) E("rename()");
      
      		ret = close(fd);
      		if (ret) E("close()");
      
      		return ret;
      	}
      
      $ gcc -o bugrename bugrename.c
      $ ./bugrename /mnt/a /mnt/b
      rename(): Permission denied
      
      Fixes: 8de9e86c ("cifs: create a helper to find a writeable handle by path name")
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      86f740f2
  2. 07 2月, 2020 1 次提交
  3. 06 2月, 2020 2 次提交
  4. 05 2月, 2020 1 次提交
  5. 31 1月, 2020 1 次提交
    • R
      cifs: fix soft mounts hanging in the reconnect code · c54849dd
      Ronnie Sahlberg 提交于
      RHBZ: 1795429
      
      In recent DFS updates we have a new variable controlling how many times we will
      retry to reconnect the share.
      If DFS is not used, then this variable is initialized to 0 in:
      
      static inline int
      dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl)
      {
              return tl ? tl->tl_numtgts : 0;
      }
      
      This means that in the reconnect loop in smb2_reconnect() we will immediately wrap retries to -1
      and never actually get to pass this conditional:
      
                      if (--retries)
                              continue;
      
      The effect is that we no longer reach the point where we fail the commands with -EHOSTDOWN
      and basically the kernel threads are virtually hung and unkillable.
      
      Fixes: a3a53b76 (cifs: Add support for failover in smb2_reconnect())
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      CC: Stable <stable@vger.kernel.org>
      c54849dd
  6. 27 1月, 2020 4 次提交
  7. 13 12月, 2019 1 次提交
  8. 10 12月, 2019 1 次提交
  9. 08 12月, 2019 1 次提交
  10. 07 12月, 2019 1 次提交
  11. 04 12月, 2019 1 次提交
    • S
      smb3: query attributes on file close · 43f8a6a7
      Steve French 提交于
      Since timestamps on files on most servers can be updated at
      close, and since timestamps on our dentries default to one
      second we can have stale timestamps in some common cases
      (e.g. open, write, close, stat, wait one second, stat - will
      show different mtime for the first and second stat).
      
      The SMB2/SMB3 protocol allows querying timestamps at close
      so add the code to request timestamp and attr information
      (which is cheap for the server to provide) to be returned
      when a file is closed (it is not needed for the many
      paths that call SMB2_close that are from compounded
      query infos and close nor is it needed for some of
      the cases where a directory close immediately follows a
      directory open.
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Acked-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      43f8a6a7
  12. 03 12月, 2019 2 次提交
  13. 25 11月, 2019 5 次提交
  14. 09 10月, 2019 1 次提交
  15. 07 10月, 2019 1 次提交
  16. 26 9月, 2019 1 次提交
  17. 24 9月, 2019 2 次提交
  18. 17 9月, 2019 11 次提交
  19. 06 8月, 2019 2 次提交