FAILED: patch "[PATCH] smb: client: fix uid/gid override in getattr with posix" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x cf4d35896621b7298eef51b7a465e5c0cb22f670
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026091636-plot-cobalt-bbd3@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From cf4d35896621b7298eef51b7a465e5c0cb22f670 Mon Sep 17 00:00:00 2001
From: Paulo Alcantara <[email protected]>
Date: Sun, 6 Sep 2026 14:39:44 -0300
Subject: [PATCH] smb: client: fix uid/gid override in getattr with posix
extensions
When mounting with 'multiuser,posix' options, cifs_getattr() overrides the server-provided uid/gid with the current process's fsuid/fsgid. This is because the condition only checks for unix extensions (tcon->unix_ext) but not posix extensions (tcon->posix_extensions).
With SMB3 POSIX extensions, the server provides real uid/gid values just like with unix extensions, so they should be preserved rather than replaced with the caller's credentials.
Add a tcon->posix_extensions check to the condition so that uid/gid from the server are properly reported in stat results.
fs/smb/client/inode.c +4 -4
@@ -2992,14 +2992,14 @@ int cifs_getattr(struct mnt_idmap *idmap, const struct path *path, stat->attributes |=STATX_ATTR_ENCRYPTED ;/* -* If on a multiuser mount without unix extensions or cifsacl being -* enabled, and the admin hasn't overridden them, set the ownership -* to the fsuid/fsgid of the current process. +* If on a multiuser mount without unix extensions, posix extensions +* or cifsacl being enabled, and the admin hasn't overridden them, +* set the ownership to the fsuid/fsgid of the current process. */ sbflags =cifs_sb_flags (cifs_sb);if ((sbflags &CIFS_MOUNT_MULTIUSER ) && !(sbflags &CIFS_MOUNT_CIFS_ACL ) && - !tcon->unix_ext) { + !tcon->unix_ext && !tcon->posix_extensions) {if (!(sbflags &CIFS_MOUNT_OVERR_UID )) stat->uid =current_fsuid ();if (!(sbflags &CIFS_MOUNT_OVERR_GID ))
Sasha Levin
maintainerPATCH 1/2 smb: client: use atomic_t for mnt_cifs_flags
From: Paulo Alcantara <[email protected]>
[ Upstream commit 4fc3a433c13944ee5766ec5b9bf6f1eb4d29b880 ]
Use atomic_t for cifs_sb_info::mnt_cifs_flags as it's currently accessed locklessly and may be changed concurrently in mount/remount and reconnect paths.
Adapt the dependency to the 5.10 client under fs/cifs. Keep its existing smb_vol mount setup, CIFS_SB interface and cifs_remap implementation; omit upstream-only cached directory, reparse and shutdown changes. Convert all mount flag readers, including the older DFS and fscache paths, and use atomic bit operations for updates after mount setup. Initialize the flags once from the existing mount options.
Provide cifs_sb_flags as a single-evaluation macro so this backport adds no functions. Retain the cifs_getattr flag snapshot needed for cf4d35896621b7298eef51b7a465e5c0cb22f670 to cherry-pick cleanly, while leaving its POSIX ownership fix to that target commit.
[ sashal: Reduced backport -- upstream 4fc3a433c1394 touches 27 file(s), this
backport carries 19. Not backported here:
fs/smb/client/cached_dir.c
fs/smb/client/cifsacl.c
fs/smb/client/cifsfs.c
fs/smb/client/cifs_fs_sb.h
fs/smb/client/cifsglob.h
fs/smb/client/cifs_ioctl.h
fs/smb/client/cifs_unicode.c
fs/smb/client/cifs_unicode.h
... and 19 more
This note is generated from the file lists only; see the resolution record for the reasoning. ]
Stable-dep-of: cf4d35896621 ("smb: client: fix uid/gid override in getattr with posix extensions")
--- fs/cifs/cifs_dfs_ref.c | 2 +- fs/cifs/cifs_fs_sb.h | 6 ++- fs/cifs/cifs_unicode.c | 4 +- fs/cifs/cifsacl.c | 6 +-- fs/cifs/cifsfs.c | 68 ++++++++++++++--------------- fs/cifs/cifsglob.h | 10 +++-- fs/cifs/connect.c | 97 +++++++++++++++++++++--------------------- fs/cifs/dir.c | 16 +++---- fs/cifs/file.c | 38 ++++++++--------- fs/cifs/fscache.c | 2 +- fs/cifs/inode.c | 90 ++++++++++++++++++++------------------- fs/cifs/link.c | 4 +- fs/cifs/misc.c | 10 ++--- fs/cifs/readdir.c | 18 ++++---- fs/cifs/smb1ops.c | 4 +- fs/cifs/smb2misc.c | 4 +- fs/cifs/smb2ops.c | 2 +- fs/cifs/smb2pdu.c | 4 +- fs/cifs/xattr.c | 6 +-- 19 files changed, 201 insertions(+), 190 deletions(-)
fs/cifs/cifs_dfs_ref.c +1 -1
@@ -317,7 +317,7 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt) mnt =ERR_PTR (-ENOMEM ); cifs_sb =CIFS_SB (mntpt->d_sb); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_DFS ) { mnt =ERR_PTR (-EREMOTE ); goto cdda_exit; }
fs/cifs/cifs_fs_sb.h +5 -1
@@ -20,6 +20,7 @@#ifndef _CIFS_FS_SB_H#define _CIFS_FS_SB_H +#include <linux/atomic.h> #include <linux/backing-dev.h> #define CIFS_MOUNT_NO_PERM 1/* do not do client vfs_perm check */
@@ -56,6 +57,9 @@#define CIFS_MOUNT_RO_CACHE 0x20000000/* assumes share will not change */ #define CIFS_MOUNT_RW_CACHE 0x40000000/* assumes only client accessing */ +/* Mount and reconnect paths may update these flags concurrently. */ +#define cifs_sb_flags (cifs_sb) ((unsigned int)atomic_read(&(cifs_sb)->mnt_cifs_flags)) +struct cifs_sb_info {struct rb_root tlink_tree;spinlock_t tlink_tree_lock;
@@ -72,7 +76,7 @@ struct cifs_sb_info {kgid_t mnt_backupgid;umode_t mnt_file_mode;umode_t mnt_dir_mode; -unsigned int mnt_cifs_flags; +atomic_t mnt_cifs_flags;char *mountdata;/* options received at mount time or via DFS refs */ struct delayed_work prune_tlinks;struct rcu_head rcu;
fs/cifs/cifs_unicode.c +2 -2
@@ -18,9 +18,9 @@ int cifs_remap(struct cifs_sb_info *cifs_sb) {int map_type; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SFM_CHR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MAP_SFM_CHR ) map_type =SFM_MAP_UNI_RSVD ; -else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ) +else if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MAP_SPECIAL_CHR ) map_type =SFU_MAP_UNI_RSVD ;else map_type =NO_MAP_UNI_RSVD ;
fs/cifs/cifsacl.c +3 -3
@@ -359,7 +359,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,return -EIO ; } -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) || +if ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UID_FROM_ACL ) || (cifs_sb_master_tcon (cifs_sb)->posix_extensions)) {uint32_t unix_id;bool is_group;
@@ -1332,12 +1332,12 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,return -ENOMEM ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MODE_FROM_SID ) mode_from_sid = true;else mode_from_sid = false; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UID_FROM_ACL ) id_from_sid = true;else id_from_sid = false;
fs/cifs/cifsfs.c +34 -34
156 lines not on this page · raw message
fs/cifs/cifsglob.h +7 -3
@@ -1452,9 +1452,13 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file);#define CIFS_CACHE_RW_FLG (CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)#define CIFS_CACHE_RHW_FLG (CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG) -#define CIFS_CACHE_READ (cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)) +#define CIFS_CACHE_READ (cinode) \ + (((cinode)->oplock & CIFS_CACHE_READ_FLG) || \ + (cifs_sb_flags(CIFS_SB((cinode)->vfs_inode.i_sb)) & CIFS_MOUNT_RO_CACHE))#define CIFS_CACHE_HANDLE (cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG) -#define CIFS_CACHE_WRITE (cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)) +#define CIFS_CACHE_WRITE (cinode) \ + (((cinode)->oplock & CIFS_CACHE_WRITE_FLG) || \ + (cifs_sb_flags(CIFS_SB((cinode)->vfs_inode.i_sb)) & CIFS_MOUNT_RW_CACHE))/* * One of these for each file inode
@@ -1515,7 +1519,7 @@ CIFS_FILE_SB(struct file *file)static inline char CIFS_DIR_SEP (const struct cifs_sb_info *cifs_sb) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_POSIX_PATHS )return '/' ;else return '\\' ;
fs/cifs/connect.c +49 -48
233 lines not on this page · raw message
fs/cifs/dir.c +8 -8
@@ -107,7 +107,7 @@ build_path_from_dentry_optional_prefix(struct dentry *direntry, bool prefix)else dfsplen =0 ; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_USE_PREFIX_PATH ) pplen = cifs_sb->prepath ?strlen (cifs_sb->prepath) +1 :0 ; cifs_bp_rename_retry:
@@ -181,7 +181,7 @@ build_path_from_dentry_optional_prefix(struct dentry *direntry, bool prefix)if (dfsplen) {strncpy (full_path, tcon->treeName, dfsplen); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_POSIX_PATHS ) {int i;for (i =0 ; i < dfsplen; i++) {if (full_path[i] =='\\' )
@@ -208,7 +208,7 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon) le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))return -ENAMETOOLONG ; -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS )) { +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_POSIX_PATHS )) {for (i =0 ; i < direntry->d_name.len; i++) {if (direntry->d_name.name[i] =='\\' ) {cifs_dbg (FYI ,"Invalid file name\n" );
@@ -384,7 +384,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, .device = 0, }; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SET_UID ) { args.uid =current_fsuid ();if (inode->i_mode &S_ISGID ) args.gid = inode->i_gid;
@@ -418,10 +418,10 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,if (newinode) {if (server->ops->set_lease_key) server->ops->set_lease_key (newinode, fid); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_DYNPERM ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_DYNPERM ) newinode->i_mode = mode;if ((*oplock &CIFS_CREATE_ACTION ) && - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID )) { + (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SET_UID )) { newinode->i_uid =current_fsuid ();if (inode->i_mode &S_ISGID ) newinode->i_gid = inode->i_gid;
@@ -545,8 +545,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, }if (file->f_flags &O_DIRECT && -CIFS_SB (inode->i_sb)->mnt_cifs_flags &CIFS_MOUNT_STRICT_IO ) { -if (CIFS_SB (inode->i_sb)->mnt_cifs_flags &CIFS_MOUNT_NO_BRL ) +cifs_sb_flags (CIFS_SB (inode->i_sb)) &CIFS_MOUNT_STRICT_IO ) { +if (cifs_sb_flags (CIFS_SB (inode->i_sb)) &CIFS_MOUNT_NO_BRL ) file->f_op = &cifs_file_direct_nobrl_ops;else file->f_op = &cifs_file_direct_ops;
fs/cifs/file.c +19 -19
@@ -473,7 +473,7 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,* close because it may cause a error when we open this file * again and get at least level II oplock. */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_STRICT_IO ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_STRICT_IO )set_bit (CIFS_INO_INVALID_MAPPING , &cifsi->flags);cifs_set_oplock_level (cifsi,0 ); }
@@ -544,8 +544,8 @@ int cifs_open(struct inode *inode, struct file *file) inode, file->f_flags, full_path);if (file->f_flags &O_DIRECT && - cifs_sb->mnt_cifs_flags &CIFS_MOUNT_STRICT_IO ) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_BRL ) +cifs_sb_flags (cifs_sb) &CIFS_MOUNT_STRICT_IO ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_BRL ) file->f_op = &cifs_file_direct_nobrl_ops;else file->f_op = &cifs_file_direct_ops;
@@ -657,7 +657,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) && - ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) + ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) rc =cifs_push_posix_locks (cfile);else rc = tcon->ses->server->ops->push_mand_locks (cfile);
@@ -1361,7 +1361,7 @@ cifs_push_locks(struct cifsFileInfo *cfile)if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) && - ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) + ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) rc =cifs_push_posix_locks (cfile);else rc = tcon->ses->server->ops->push_mand_locks (cfile);
@@ -1741,7 +1741,7 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) && - ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) + ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) posix_lck = true;if (!lock && !unlock) {
@@ -1789,7 +1789,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) && - ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) + ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) posix_lck = true;/* * BB add code here to normalize offset and length to account for
@@ -1919,7 +1919,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb);/* only filter by fsuid on multiuser mounts */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MULTIUSER )) fsuid_only = false;spin_lock (&cifs_inode->open_file_lock);
@@ -1975,7 +1975,7 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags, cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb);/* only filter by fsuid on multiuser mounts */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MULTIUSER )) fsuid_only = false;spin_lock (&cifs_inode->open_file_lock);
@@ -2526,7 +2526,7 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,struct cifs_sb_info *cifs_sb =CIFS_SB (cfile->dentry->d_sb);__u32 pid; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_RWPIDFORWARD ) pid = cfile->pid;else pid = current->tgid;
@@ -2608,7 +2608,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end, } tcon =tlink_tcon (smbfile->tlink); -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) { +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOSSYNC )) { server = tcon->ses->server;if (server->ops->flush ==NULL ) { rc = -ENOSYS ;
@@ -2653,7 +2653,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync) file, datasync); tcon =tlink_tcon (smbfile->tlink); -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) { +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOSSYNC )) { server = tcon->ses->server;if (server->ops->flush ==NULL ) { rc = -ENOSYS ;
@@ -2900,7 +2900,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,size_t start;unsigned int xid; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_RWPIDFORWARD ) pid = open_file->pid;else pid = current->tgid;
@@ -3301,7 +3301,7 @@ cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)if (CIFS_CACHE_WRITE (cinode)) {if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) - && ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) { + && ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) { written =generic_file_write_iter (iocb, from); goto out; }
@@ -3638,7 +3638,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, server =cifs_pick_channel (tlink_tcon (open_file->tlink)->ses); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_RWPIDFORWARD ) pid = open_file->pid;else pid = current->tgid;
@@ -4012,7 +4012,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)if (cap_unix (tcon->ses) && (CIFS_UNIX_FCNTL_CAP &le64_to_cpu (tcon->fsUnixInfo.Capability)) && - ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOPOSIXBRL ) ==0 )) + ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NOPOSIXBRL ) ==0 ))return generic_file_read_iter (iocb, to);/*
@@ -4066,7 +4066,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)return -ENOSYS ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_RWPIDFORWARD ) pid = open_file->pid;else pid = current->tgid;
@@ -4397,7 +4397,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,return rc; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_RWPIDFORWARD ) pid = open_file->pid;else pid = current->tgid;
@@ -4629,7 +4629,7 @@ bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)struct cifs_sb_info *cifs_sb; cifs_sb =CIFS_SB (cifsInode->vfs_inode.i_sb); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_DIRECT_IO ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_DIRECT_IO ) {/* since no page cache to corrupt on directio we can change size safely */ return true;
fs/cifs/fscache.c +1 -1
@@ -164,7 +164,7 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)if (cifsi->fscache)return ; -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_FSCACHE )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_FSCACHE ))return ;cifs_fscache_acquire_inode_cookie (cifsi, tcon);
fs/cifs/inode.c +46 -44
299 lines not on this page · raw message
fs/cifs/link.c +2 -2
@@ -638,7 +638,7 @@ cifs_get_link(struct dentry *direntry, struct inode *inode,* First try Minshall+French Symlinks, if configured * and fallback to UNIX Extensions Symlinks. */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MF_SYMLINKS ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MF_SYMLINKS ) rc =query_mf_symlink (xid, tcon, cifs_sb, full_path, &target_path);
@@ -694,7 +694,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)cifs_dbg (FYI ,"symname is %s\n" , symname);/* BB what if DFS and this volume is on different share? BB */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MF_SYMLINKS ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MF_SYMLINKS ) rc =create_mf_symlink (xid, pTcon, cifs_sb, full_path, symname);else if (pTcon->unix_ext) rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
fs/cifs/misc.c +5 -5
@@ -537,13 +537,13 @@ dump_smb(void *buf, int smb_buf_length)void cifs_autodisable_serverino (struct cifs_sb_info *cifs_sb) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SERVER_INUM ) {struct cifs_tcon *tcon =NULL ;if (cifs_sb->master_tlink) tcon =cifs_sb_master_tcon (cifs_sb); - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM ; +atomic_andnot (CIFS_MOUNT_SERVER_INUM , &cifs_sb->mnt_cifs_flags); cifs_sb->mnt_cifs_serverino_autodisabled = true;cifs_dbg (VFS ,"Autodisabling the use of server inode numbers on %s\n" , tcon ? tcon->treeName :"new server" );
@@ -643,11 +643,11 @@ void cifs_done_oplock_break(struct cifsInodeInfo *cinode)bool backup_cred (struct cifs_sb_info *cifs_sb) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_BACKUPUID ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_CIFS_BACKUPUID ) {if (uid_eq (cifs_sb->mnt_backupuid,current_fsuid ()))return true; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_BACKUPGID ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_CIFS_BACKUPGID ) {if (in_group_p (cifs_sb->mnt_backupgid))return true; }
@@ -1206,7 +1206,7 @@ int update_super_prepath(struct cifs_tcon *tcon, char *prefix) }else cifs_sb->prepath =NULL ; - cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_USE_PREFIX_PATH ; +atomic_or (CIFS_MOUNT_USE_PREFIX_PATH , &cifs_sb->mnt_cifs_flags); out:cifs_put_tcon_super (sb);
fs/cifs/readdir.c +9 -9
@@ -112,7 +112,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,* want to clobber the existing one with the one that * the readdir code created. */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SERVER_INUM )) fattr->cf_uniqueid =CIFS_I (inode)->uniqueid;/* update inode in place
@@ -220,11 +220,11 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)* may look wrong since the inodes may not have timed out by the time * "ls" does a stat() call on them. */ -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) || - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID )) +if ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_CIFS_ACL ) || + (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MODE_FROM_SID )) fattr->cf_flags |=CIFS_FATTR_NEED_REVAL ; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL && +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UNX_EMUL && fattr->cf_cifsattrs &ATTR_SYSTEM ) {if (fattr->cf_eof ==0 ) { fattr->cf_mode &= ~S_IFMT ;
@@ -435,7 +435,7 @@ initiate_cifs_search(const unsigned int xid, struct file *file,else if ((tcon->ses->capabilities & tcon->ses->server->vals->cap_nt_find) ==0 ) { cifsFile->srch_inf.info_level =SMB_FIND_FILE_INFO_STANDARD ; - }else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM ) { + }else if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SERVER_INUM ) { cifsFile->srch_inf.info_level =SMB_FIND_FILE_ID_FULL_DIR_INFO ; }else /* not srvinos - BB fixme add check for backlevel? */ { cifsFile->srch_inf.info_level =SMB_FIND_FILE_DIRECTORY_INFO ;
@@ -455,8 +455,8 @@ initiate_cifs_search(const unsigned int xid, struct file *file,else if STATUS_STOPPED_ON_SYMLINK call get_symlink_reparse_path and retry with new path */ else if ((rc == -EOPNOTSUPP) && - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM ; + (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM)) { +atomic_andnot (CIFS_MOUNT_SERVER_INUM , &cifs_sb->mnt_cifs_flags); goto ffirst_retry; } error_exit:
@@ -908,14 +908,14 @@ static int cifs_filldir(char *find_entry, struct file *file,break ; } -if (de.ino && (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )) { +if (de.ino && (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SERVER_INUM )) { fattr.cf_uniqueid = de.ino; }else { fattr.cf_uniqueid =iunique (sb,ROOT_I );cifs_autodisable_serverino (cifs_sb); } -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MF_SYMLINKS ) && +if ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MF_SYMLINKS ) &&couldbe_mf_symlink (&fattr))/* * trying to get the type and mode can be slow,
fs/cifs/smb1ops.c +2 -2
@@ -1052,7 +1052,7 @@ cifs_make_node(unsigned int xid, struct inode *inode, .mtime = NO_CHANGE_64, .device = dev, }; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SET_UID ) { args.uid =current_fsuid (); args.gid =current_fsgid (); }else {
@@ -1077,7 +1077,7 @@ cifs_make_node(unsigned int xid, struct inode *inode,* SMB1 SFU emulation: should work with all servers, but only * support block and char device (no socket & fifo) */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UNX_EMUL )) goto out;if (!S_ISCHR (mode) && !S_ISBLK (mode))
fs/cifs/smb2misc.c +2 -2
@@ -477,9 +477,9 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb)__le16 *to;int map_type; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SFM_CHR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MAP_SFM_CHR ) map_type =SFM_MAP_UNI_RSVD ; -else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ) +else if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_MAP_SPECIAL_CHR ) map_type =SFU_MAP_UNI_RSVD ;else map_type =NO_MAP_UNI_RSVD ;
fs/cifs/smb2ops.c +1 -1
@@ -5108,7 +5108,7 @@ smb2_make_node(unsigned int xid, struct inode *inode,* supports block and char device (no socket & fifo), * and was used by default in earlier versions of Windows */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UNX_EMUL )) goto out;/*
fs/cifs/smb2pdu.c +2 -2
@@ -2805,7 +2805,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,bool set_mode;bool set_owner; -if ((oparms->cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID ) && +if ((cifs_sb_flags (oparms->cifs_sb) &CIFS_MOUNT_MODE_FROM_SID ) && (oparms->mode !=ACL_NO_MODE )) set_mode = true;else {
@@ -2813,7 +2813,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, oparms->mode =ACL_NO_MODE ; } -if (oparms->cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) +if (cifs_sb_flags (oparms->cifs_sb) &CIFS_MOUNT_UID_FROM_ACL ) set_owner = true;else set_owner = false;
fs/cifs/xattr.c +3 -3
@@ -154,7 +154,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,break ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR ) goto out;if (pTcon->ses->server->ops->set_EA) {
@@ -321,7 +321,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,break ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR ) goto out;if (pTcon->ses->server->ops->query_all_EAs)
@@ -402,7 +402,7 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)struct cifs_tcon *pTcon;char *full_path; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR )return -EOPNOTSUPP ; tlink =cifs_sb_tlink (cifs_sb);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 smb: client: fix uid/gid override in getattr with posix extensions
From: Paulo Alcantara <[email protected]>
[ Upstream commit cf4d35896621b7298eef51b7a465e5c0cb22f670 ]
When mounting with 'multiuser,posix' options, cifs_getattr() overrides the server-provided uid/gid with the current process's fsuid/fsgid. This is because the condition only checks for unix extensions (tcon->unix_ext) but not posix extensions (tcon->posix_extensions).
With SMB3 POSIX extensions, the server provides real uid/gid values just like with unix extensions, so they should be preserved rather than replaced with the caller's credentials.
Add a tcon->posix_extensions check to the condition so that uid/gid from the server are properly reported in stat results.
--- fs/cifs/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/cifs/inode.c +4 -4
@@ -2418,14 +2418,14 @@ int cifs_getattr(const struct path *path, struct kstat *stat, stat->attributes |=STATX_ATTR_ENCRYPTED ;/* -* If on a multiuser mount without unix extensions or cifsacl being -* enabled, and the admin hasn't overridden them, set the ownership -* to the fsuid/fsgid of the current process. +* If on a multiuser mount without unix extensions, posix extensions +* or cifsacl being enabled, and the admin hasn't overridden them, +* set the ownership to the fsuid/fsgid of the current process. */ sbflags =cifs_sb_flags (cifs_sb);if ((sbflags &CIFS_MOUNT_MULTIUSER ) && !(sbflags &CIFS_MOUNT_CIFS_ACL ) && - !tcon->unix_ext) { + !tcon->unix_ext && !tcon->posix_extensions) {if (!(sbflags &CIFS_MOUNT_OVERR_UID )) stat->uid =current_fsuid ();if (!(sbflags &CIFS_MOUNT_OVERR_GID ))
Signature · 1 line
2.53.0