Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *   fs/cifs/xattr.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *   Copyright (c) International Business Machines  Corp., 2003, 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *   Author(s): Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *   This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *   by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *   (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *   This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *   the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *   You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *   along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/posix_acl_xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "cifsfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include "cifspdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include "cifsglob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include "cifsproto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "cifs_debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "cifs_fs_sb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "cifs_unicode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define MAX_EA_VALUE_SIZE CIFSMaxBufSize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define CIFS_XATTR_CIFS_ACL "system.cifs_acl" /* DACL only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define CIFS_XATTR_CIFS_NTSD "system.cifs_ntsd" /* owner plus DACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define CIFS_XATTR_ATTRIB "cifs.dosattrib"  /* full name: user.cifs.dosattrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define CIFS_XATTR_CREATETIME "cifs.creationtime"  /* user.cifs.creationtime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * Although these three are just aliases for the above, need to move away from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * confusing users and using the 20+ year old term 'cifs' when it is no longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define SMB3_XATTR_ATTRIB "smb3.dosattrib"  /* full name: user.smb3.dosattrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define SMB3_XATTR_CREATETIME "smb3.creationtime"  /* user.smb3.creationtime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /* BB need to add server (Samba e.g) support for security and trusted prefix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	XATTR_CIFS_NTSD };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int cifs_attrib_set(unsigned int xid, struct cifs_tcon *pTcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 			   struct inode *inode, char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			   const void *value, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	ssize_t rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	__u32 *pattrib = (__u32 *)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	__u32 attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	FILE_BASIC_INFO info_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if ((value == NULL) || (size != sizeof(__u32)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	memset(&info_buf, 0, sizeof(info_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	attrib = *pattrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	info_buf.Attributes = cpu_to_le32(attrib);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (pTcon->ses->server->ops->set_file_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				&info_buf, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (rc == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		CIFS_I(inode)->cifsAttrs = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static int cifs_creation_time_set(unsigned int xid, struct cifs_tcon *pTcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				  struct inode *inode, char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				  const void *value, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	ssize_t rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	__u64 *pcreation_time = (__u64 *)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	__u64 creation_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	FILE_BASIC_INFO info_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if ((value == NULL) || (size != sizeof(__u64)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	memset(&info_buf, 0, sizeof(info_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	creation_time = *pcreation_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	info_buf.CreationTime = cpu_to_le64(creation_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (pTcon->ses->server->ops->set_file_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				&info_buf, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (rc == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		CIFS_I(inode)->createtime = creation_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int cifs_xattr_set(const struct xattr_handler *handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			  struct dentry *dentry, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			  const char *name, const void *value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			  size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	int rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	unsigned int xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct super_block *sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct cifs_tcon *pTcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	char *full_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	tlink = cifs_sb_tlink(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (IS_ERR(tlink))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		return PTR_ERR(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	pTcon = tlink_tcon(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	full_path = build_path_from_dentry(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	if (full_path == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/* return dos attributes as pseudo xattr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	/* return alt name if available as pseudo attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	/* if proc/fs/cifs/streamstoxattr is set then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		search server for EAs or streams to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		returns as xattrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (size > MAX_EA_VALUE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		cifs_dbg(FYI, "size of EA value too large\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	switch (handler->flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	case XATTR_USER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		cifs_dbg(FYI, "%s:setting user xattr %s\n", __func__, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		    (strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			rc = cifs_attrib_set(xid, pTcon, inode, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 					value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			if (rc == 0) /* force revalidate of the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 				CIFS_I(inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		} else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			   (strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			rc = cifs_creation_time_set(xid, pTcon, inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 					full_path, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			if (rc == 0) /* force revalidate of the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				CIFS_I(inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		if (pTcon->ses->server->ops->set_EA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				full_path, name, value, (__u16)size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				cifs_sb->local_nls, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	case XATTR_CIFS_ACL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	case XATTR_CIFS_NTSD: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		struct cifs_ntsd *pacl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		if (!value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		pacl = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		if (!pacl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			memcpy(pacl, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			if (value &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			    pTcon->ses->server->ops->set_acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 				rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				if (handler->flags == XATTR_CIFS_NTSD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 					/* set owner and DACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 					rc = pTcon->ses->server->ops->set_acl(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 							pacl, size, inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 							full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 							CIFS_ACL_OWNER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				if (rc == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 					/* set DACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 					rc = pTcon->ses->server->ops->set_acl(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 							pacl, size, inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 							full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 							CIFS_ACL_DACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			if (rc == 0) /* force revalidate of the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				CIFS_I(inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			kfree(pacl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	case XATTR_ACL_ACCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #ifdef CONFIG_CIFS_POSIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		if (!value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		if (sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				value, (const int)size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				ACL_TYPE_ACCESS, cifs_sb->local_nls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 				cifs_remap(cifs_sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #endif  /* CONFIG_CIFS_POSIX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	case XATTR_ACL_DEFAULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #ifdef CONFIG_CIFS_POSIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		if (!value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		if (sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				value, (const int)size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				ACL_TYPE_DEFAULT, cifs_sb->local_nls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				cifs_remap(cifs_sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) #endif  /* CONFIG_CIFS_POSIX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	kfree(full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	cifs_put_tlink(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static int cifs_attrib_get(struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			   struct inode *inode, void *value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			   size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	__u32 *pattribute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	rc = cifs_revalidate_dentry_attr(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	if ((value == NULL) || (size == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		return sizeof(__u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	else if (size < sizeof(__u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	/* return dos attributes as pseudo xattr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	pattribute = (__u32 *)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	*pattribute = CIFS_I(inode)->cifsAttrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	return sizeof(__u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static int cifs_creation_time_get(struct dentry *dentry, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 				  void *value, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	__u64 *pcreatetime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	rc = cifs_revalidate_dentry_attr(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if ((value == NULL) || (size == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		return sizeof(__u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	else if (size < sizeof(__u64))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/* return dos attributes as pseudo xattr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	pcreatetime = (__u64 *)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	*pcreatetime = CIFS_I(inode)->createtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	return sizeof(__u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) static int cifs_xattr_get(const struct xattr_handler *handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			  struct dentry *dentry, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			  const char *name, void *value, size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	ssize_t rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	unsigned int xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct super_block *sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	struct cifs_tcon *pTcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	char *full_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	tlink = cifs_sb_tlink(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	if (IS_ERR(tlink))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		return PTR_ERR(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	pTcon = tlink_tcon(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	full_path = build_path_from_dentry(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (full_path == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	/* return alt name if available as pseudo attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	switch (handler->flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	case XATTR_USER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		    (strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			rc = cifs_attrib_get(dentry, inode, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		} else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		    (strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			rc = cifs_creation_time_get(dentry, inode, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		if (pTcon->ses->server->ops->query_all_EAs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 			rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 				full_path, name, value, size, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	case XATTR_CIFS_ACL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	case XATTR_CIFS_NTSD: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		/* the whole ntsd is fetched regardless */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		u32 acllen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		struct cifs_ntsd *pacl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		if (pTcon->ses->server->ops->get_acl == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 			goto out; /* rc already EOPNOTSUPP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 				inode, full_path, &acllen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		if (IS_ERR(pacl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 			rc = PTR_ERR(pacl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 			cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 				 __func__, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			if (value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 				if (acllen > size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 					acllen = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 					memcpy(value, pacl, acllen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 			rc = acllen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 			kfree(pacl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	case XATTR_ACL_ACCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) #ifdef CONFIG_CIFS_POSIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		if (sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 				value, size, ACL_TYPE_ACCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 				cifs_sb->local_nls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 				cifs_remap(cifs_sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #endif  /* CONFIG_CIFS_POSIX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	case XATTR_ACL_DEFAULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #ifdef CONFIG_CIFS_POSIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		if (sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 				value, size, ACL_TYPE_DEFAULT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				cifs_sb->local_nls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				cifs_remap(cifs_sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) #endif  /* CONFIG_CIFS_POSIX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	/* We could add an additional check for streams ie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	    if proc/fs/cifs/streamstoxattr is set then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		search server for EAs or streams to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		returns as xattrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	if (rc == -EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	kfree(full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	cifs_put_tlink(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	ssize_t rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	unsigned int xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	struct cifs_tcon *pTcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	char *full_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	tlink = cifs_sb_tlink(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	if (IS_ERR(tlink))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		return PTR_ERR(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	pTcon = tlink_tcon(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	full_path = build_path_from_dentry(direntry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (full_path == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		goto list_ea_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	/* return dos attributes as pseudo xattr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	/* return alt name if available as pseudo attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	/* if proc/fs/cifs/streamstoxattr is set then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		search server for EAs or streams to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		returns as xattrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	if (pTcon->ses->server->ops->query_all_EAs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 				full_path, NULL, data, buf_size, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) list_ea_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	kfree(full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	cifs_put_tlink(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) static const struct xattr_handler cifs_user_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	.prefix = XATTR_USER_PREFIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	.flags = XATTR_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) /* os2.* attributes are treated like user.* attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static const struct xattr_handler cifs_os2_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	.prefix = XATTR_OS2_PREFIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	.flags = XATTR_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	.name = CIFS_XATTR_CIFS_ACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	.flags = XATTR_CIFS_ACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  * Although this is just an alias for the above, need to move away from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  * confusing users and using the 20 year old term 'cifs' when it is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)  * longer secure and was replaced by SMB2/SMB3 a long time ago, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)  * SMB3 and later are highly secure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static const struct xattr_handler smb3_acl_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	.name = SMB3_XATTR_CIFS_ACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	.flags = XATTR_CIFS_ACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) static const struct xattr_handler cifs_cifs_ntsd_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	.name = CIFS_XATTR_CIFS_NTSD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	.flags = XATTR_CIFS_NTSD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  * Although this is just an alias for the above, need to move away from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  * confusing users and using the 20 year old term 'cifs' when it is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)  * longer secure and was replaced by SMB2/SMB3 a long time ago, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)  * SMB3 and later are highly secure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) static const struct xattr_handler smb3_ntsd_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	.name = SMB3_XATTR_CIFS_NTSD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	.flags = XATTR_CIFS_NTSD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	.name = XATTR_NAME_POSIX_ACL_ACCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	.flags = XATTR_ACL_ACCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) static const struct xattr_handler cifs_posix_acl_default_xattr_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	.name = XATTR_NAME_POSIX_ACL_DEFAULT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	.flags = XATTR_ACL_DEFAULT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	.get = cifs_xattr_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	.set = cifs_xattr_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) const struct xattr_handler *cifs_xattr_handlers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	&cifs_user_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	&cifs_os2_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	&cifs_cifs_acl_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	&cifs_cifs_ntsd_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	&smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	&cifs_posix_acl_access_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	&cifs_posix_acl_default_xattr_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) };