aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/xattr.c
diff options
context:
space:
mode:
authorSteve French <smfrench@gmail.com>2014-01-27 00:53:43 -0500
committerSteve French <smfrench@gmail.com>2014-01-27 00:53:43 -0500
commit666753c3ef8fc88b0ddd5be4865d0aa66428ac35 (patch)
tree266c25b12cb879efe96cd1351ee13fb8aca041a9 /fs/cifs/xattr.c
parentd81b8a40e2ece0a9ab57b1fe1798e291e75bf8fc (diff)
[CIFS] Fix SMB2 mounts so they don't try to set or get xattrs via cifs
When mounting with smb2 (or smb2.1 or smb3) we need to check to make sure that attempts to query or set extended attributes do not attempt to send the request with the older cifs protocol instead (eventually we also need to add the support in SMB2 to query/set extended attributes but this patch prevents us from using the wrong protocol for extended attribute operations). Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/xattr.c')
-rw-r--r--fs/cifs/xattr.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 09afda4cc58e..95c43bb20335 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -82,9 +82,11 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name)
82 goto remove_ea_exit; 82 goto remove_ea_exit;
83 83
84 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ 84 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
85 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL, 85 if (pTcon->ses->server->ops->set_EA)
86 (__u16)0, cifs_sb->local_nls, 86 rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
87 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 87 full_path, ea_name, NULL, (__u16)0,
88 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
89 CIFS_MOUNT_MAP_SPECIAL_CHR);
88 } 90 }
89remove_ea_exit: 91remove_ea_exit:
90 kfree(full_path); 92 kfree(full_path);
@@ -149,18 +151,22 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
149 cifs_dbg(FYI, "attempt to set cifs inode metadata\n"); 151 cifs_dbg(FYI, "attempt to set cifs inode metadata\n");
150 152
151 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ 153 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
152 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, 154 if (pTcon->ses->server->ops->set_EA)
153 (__u16)value_size, cifs_sb->local_nls, 155 rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
154 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 156 full_path, ea_name, ea_value, (__u16)value_size,
157 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
158 CIFS_MOUNT_MAP_SPECIAL_CHR);
155 } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) 159 } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)
156 == 0) { 160 == 0) {
157 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 161 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
158 goto set_ea_exit; 162 goto set_ea_exit;
159 163
160 ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ 164 ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
161 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, 165 if (pTcon->ses->server->ops->set_EA)
162 (__u16)value_size, cifs_sb->local_nls, 166 rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
163 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 167 full_path, ea_name, ea_value, (__u16)value_size,
168 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
169 CIFS_MOUNT_MAP_SPECIAL_CHR);
164 } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, 170 } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
165 strlen(CIFS_XATTR_CIFS_ACL)) == 0) { 171 strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
166#ifdef CONFIG_CIFS_ACL 172#ifdef CONFIG_CIFS_ACL
@@ -272,17 +278,21 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
272 /* revalidate/getattr then populate from inode */ 278 /* revalidate/getattr then populate from inode */
273 } /* BB add else when above is implemented */ 279 } /* BB add else when above is implemented */
274 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ 280 ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
275 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, 281 if (pTcon->ses->server->ops->query_all_EAs)
276 buf_size, cifs_sb->local_nls, 282 rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
277 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 283 full_path, ea_name, ea_value, buf_size,
284 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
285 CIFS_MOUNT_MAP_SPECIAL_CHR);
278 } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { 286 } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
279 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 287 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
280 goto get_ea_exit; 288 goto get_ea_exit;
281 289
282 ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ 290 ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
283 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, 291 if (pTcon->ses->server->ops->query_all_EAs)
284 buf_size, cifs_sb->local_nls, 292 rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
285 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 293 full_path, ea_name, ea_value, buf_size,
294 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
295 CIFS_MOUNT_MAP_SPECIAL_CHR);
286 } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS, 296 } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
287 strlen(POSIX_ACL_XATTR_ACCESS)) == 0) { 297 strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
288#ifdef CONFIG_CIFS_POSIX 298#ifdef CONFIG_CIFS_POSIX
@@ -400,11 +410,12 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
400 /* if proc/fs/cifs/streamstoxattr is set then 410 /* if proc/fs/cifs/streamstoxattr is set then
401 search server for EAs or streams to 411 search server for EAs or streams to
402 returns as xattrs */ 412 returns as xattrs */
403 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
404 buf_size, cifs_sb->local_nls,
405 cifs_sb->mnt_cifs_flags &
406 CIFS_MOUNT_MAP_SPECIAL_CHR);
407 413
414 if (pTcon->ses->server->ops->query_all_EAs)
415 rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
416 full_path, NULL, data, buf_size,
417 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
418 CIFS_MOUNT_MAP_SPECIAL_CHR);
408list_ea_exit: 419list_ea_exit:
409 kfree(full_path); 420 kfree(full_path);
410 free_xid(xid); 421 free_xid(xid);