bdd8d64f36
Changes in 5.10.203 RDMA/irdma: Prevent zero-length STAG registration PCI: keystone: Drop __init from ks_pcie_add_pcie_{ep,port}() afs: Fix afs_server_list to be cleaned up with RCU afs: Make error on cell lookup failure consistent with OpenAFS drm/panel: boe-tv101wum-nl6: Fine tune the panel power sequence drm/panel: auo,b101uan08.3: Fine tune the panel power sequence drm/panel: simple: Fix Innolux G101ICE-L01 bus flags drm/panel: simple: Fix Innolux G101ICE-L01 timings wireguard: use DEV_STATS_INC() ata: pata_isapnp: Add missing error check for devm_ioport_map() drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full HID: core: store the unique system identifier in hid_device HID: fix HID device resource race between HID core and debugging support ipv4: Correct/silence an endian warning in __ip_do_redirect net: usb: ax88179_178a: fix failed operations during ax88179_reset net/smc: avoid data corruption caused by decline arm/xen: fix xen_vcpu_info allocation alignment amd-xgbe: handle corner-case during sfp hotplug amd-xgbe: handle the corner-case during tx completion amd-xgbe: propagate the correct speed and duplex status net: axienet: Fix check for partial TX checksum afs: Return ENOENT if no cell DNS record can be found afs: Fix file locking on R/O volumes to operate in local mode nvmet: remove unnecessary ctrl parameter nvmet: nul-terminate the NQNs passed in the connect command USB: dwc3: qcom: fix resource leaks on probe deferral USB: dwc3: qcom: fix ACPI platform device leak lockdep: Fix block chain corruption media: ccs: Correctly initialise try compose rectangle MIPS: KVM: Fix a build warning about variable set but not used ext4: add a new helper to check if es must be kept ext4: factor out __es_alloc_extent() and __es_free_extent() ext4: use pre-allocated es in __es_insert_extent() ext4: use pre-allocated es in __es_remove_extent() ext4: using nofail preallocation in ext4_es_remove_extent() ext4: using nofail preallocation in ext4_es_insert_delayed_block() ext4: using nofail preallocation in ext4_es_insert_extent() ext4: fix slab-use-after-free in ext4_es_insert_extent() ext4: make sure allocate pending entry not fail nfsd: lock_rename() needs both directories to live on the same fs ASoC: simple-card: fixup asoc_simple_probe() error handling ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CVA swiotlb-xen: provide the "max_mapping_size" method bcache: replace a mistaken IS_ERR() by IS_ERR_OR_NULL() in btree_gc_coalesce() bcache: fixup multi-threaded bch_sectors_dirty_init() wake-up race s390/dasd: protect device queue against concurrent access USB: serial: option: add Luat Air72*U series products hv_netvsc: Fix race of register_netdevice_notifier and VF register hv_netvsc: Mark VF as slave before exposing it to user-mode dm-delay: fix a race between delay_presuspend and delay_bio bcache: check return value from btree_node_alloc_replacement() bcache: prevent potential division by zero error bcache: fixup init dirty data errors bcache: fixup lock c->root error USB: serial: option: add Fibocom L7xx modules USB: serial: option: fix FM101R-GL defines USB: serial: option: don't claim interface 4 for ZTE MF290 USB: dwc2: write HCINT with INTMASK applied usb: dwc3: Fix default mode initialization usb: dwc3: set the dma max_seg_size USB: dwc3: qcom: fix wakeup after probe deferral io_uring: fix off-by one bvec index pinctrl: avoid reload of p state in list iteration firewire: core: fix possible memory leak in create_units() mmc: block: Do not lose cache flush during CQE error recovery ALSA: hda: Disable power-save on KONTRON SinglePC ALSA: hda/realtek: Headset Mic VREF to 100% ALSA: hda/realtek: Add supported ALC257 for ChromeOS dm-verity: align struct dm_verity_fec_io properly dm verity: don't perform FEC for failed readahead IO bcache: revert replacing IS_ERR_OR_NULL with IS_ERR iommu/vt-d: Add MTL to quirk list to skip TE disabling powerpc: Don't clobber f0/vs0 during fp|altivec register save parisc: Drop the HP-UX ENOSYM and EREMOTERELEASE error codes btrfs: add dmesg output for first mount and last unmount of a filesystem btrfs: ref-verify: fix memory leaks in btrfs_ref_tree_mod() btrfs: fix off-by-one when checking chunk map includes logical address btrfs: send: ensure send_fd is writable btrfs: make error messages more clear when getting a chunk map Input: xpad - add HyperX Clutch Gladiate Support hv_netvsc: fix race of netvsc and VF register_netdevice USB: core: Change configuration warnings to notices usb: config: fix iteration issue in 'usb_get_bos_descriptor()' ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet dpaa2-eth: increase the needed headroom to account for alignment selftests/net: ipsec: fix constant out of range selftests/net: mptcp: fix uninitialized variable warnings net: stmmac: xgmac: Disable FPE MMC interrupts octeontx2-pf: Fix adding mbox work queue entry when num_vfs > 64 Revert "workqueue: remove unused cancel_work()" r8169: prevent potential deadlock in rtl8169_close ravb: Fix races between ravb_tx_timeout_work() and net related ops net: ravb: Use pm_runtime_resume_and_get() net: ravb: Start TX queues after HW initialization succeeded smb3: fix touch -h of symlink ASoC: Intel: Move soc_intel_is_foo() helpers to a generic header ASoC: SOF: sof-pci-dev: use community key on all Up boards ASoC: SOF: sof-pci-dev: add parameter to override topology filename ASoC: SOF: sof-pci-dev: don't use the community key on APL Chromebooks ASoC: SOF: sof-pci-dev: Fix community key quirk detection s390/mm: fix phys vs virt confusion in mark_kernel_pXd() functions family s390/cmma: fix detection of DAT pages misc: pci_endpoint_test: Add deviceID for AM64 and J7200 misc: pci_endpoint_test: Add deviceID for J721S2 PCIe EP device support fbdev: stifb: Make the STI next font pointer a 32-bit signed offset ima: annotate iint mutex to avoid lockdep false positive warnings driver core: Move the "removable" attribute from USB to core drm/amdgpu: don't use ATRM for external devices fs: add ctime accessors infrastructure smb3: fix caching of ctime on setxattr scsi: core: Introduce the scsi_cmd_to_rq() function scsi: qla2xxx: Use scsi_cmd_to_rq() instead of scsi_cmnd.request scsi: qla2xxx: Fix system crash due to bad pointer access cpufreq: imx6q: don't warn for disabling a non-existing frequency cpufreq: imx6q: Don't disable 792 Mhz OPP unnecessarily mmc: cqhci: Increase recovery halt timeout mmc: cqhci: Warn of halt or task clear failure mmc: cqhci: Fix task clearing in CQE error recovery mmc: core: convert comma to semicolon mmc: block: Retry commands in CQE error recovery mmc: core: add helpers mmc_regulator_enable/disable_vqmmc mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled r8169: disable ASPM in case of tx timeout r8169: fix deadlock on RTL8125 in jumbo mtu mode driver core: Release all resources during unbind before updating device links Linux 5.10.203 Change-Id: I7feccd8526f0286020be24411be0e6113129ff65 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
517 lines
14 KiB
C
517 lines
14 KiB
C
/*
|
|
* fs/cifs/xattr.c
|
|
*
|
|
* Copyright (c) International Business Machines Corp., 2003, 2007
|
|
* Author(s): Steve French (sfrench@us.ibm.com)
|
|
*
|
|
* This library is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation; either version 2.1 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
* the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/posix_acl_xattr.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/xattr.h>
|
|
#include "cifsfs.h"
|
|
#include "cifspdu.h"
|
|
#include "cifsglob.h"
|
|
#include "cifsproto.h"
|
|
#include "cifs_debug.h"
|
|
#include "cifs_fs_sb.h"
|
|
#include "cifs_unicode.h"
|
|
|
|
#define MAX_EA_VALUE_SIZE CIFSMaxBufSize
|
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl" /* DACL only */
|
|
#define CIFS_XATTR_CIFS_NTSD "system.cifs_ntsd" /* owner plus DACL */
|
|
#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
|
|
#define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */
|
|
/*
|
|
* Although these three are just aliases for the above, need to move away from
|
|
* confusing users and using the 20+ year old term 'cifs' when it is no longer
|
|
* secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
|
|
*/
|
|
#define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
|
|
#define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
|
|
#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
|
|
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
|
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
|
|
|
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
|
|
XATTR_CIFS_NTSD };
|
|
|
|
static int cifs_attrib_set(unsigned int xid, struct cifs_tcon *pTcon,
|
|
struct inode *inode, char *full_path,
|
|
const void *value, size_t size)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
__u32 *pattrib = (__u32 *)value;
|
|
__u32 attrib;
|
|
FILE_BASIC_INFO info_buf;
|
|
|
|
if ((value == NULL) || (size != sizeof(__u32)))
|
|
return -ERANGE;
|
|
|
|
memset(&info_buf, 0, sizeof(info_buf));
|
|
attrib = *pattrib;
|
|
info_buf.Attributes = cpu_to_le32(attrib);
|
|
if (pTcon->ses->server->ops->set_file_info)
|
|
rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
|
|
&info_buf, xid);
|
|
if (rc == 0)
|
|
CIFS_I(inode)->cifsAttrs = attrib;
|
|
|
|
return rc;
|
|
}
|
|
|
|
static int cifs_creation_time_set(unsigned int xid, struct cifs_tcon *pTcon,
|
|
struct inode *inode, char *full_path,
|
|
const void *value, size_t size)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
__u64 *pcreation_time = (__u64 *)value;
|
|
__u64 creation_time;
|
|
FILE_BASIC_INFO info_buf;
|
|
|
|
if ((value == NULL) || (size != sizeof(__u64)))
|
|
return -ERANGE;
|
|
|
|
memset(&info_buf, 0, sizeof(info_buf));
|
|
creation_time = *pcreation_time;
|
|
info_buf.CreationTime = cpu_to_le64(creation_time);
|
|
if (pTcon->ses->server->ops->set_file_info)
|
|
rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
|
|
&info_buf, xid);
|
|
if (rc == 0)
|
|
CIFS_I(inode)->createtime = creation_time;
|
|
|
|
return rc;
|
|
}
|
|
|
|
static int cifs_xattr_set(const struct xattr_handler *handler,
|
|
struct dentry *dentry, struct inode *inode,
|
|
const char *name, const void *value,
|
|
size_t size, int flags)
|
|
{
|
|
int rc = -EOPNOTSUPP;
|
|
unsigned int xid;
|
|
struct super_block *sb = dentry->d_sb;
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
|
struct tcon_link *tlink;
|
|
struct cifs_tcon *pTcon;
|
|
char *full_path;
|
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
if (IS_ERR(tlink))
|
|
return PTR_ERR(tlink);
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
xid = get_xid();
|
|
|
|
full_path = build_path_from_dentry(dentry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
goto out;
|
|
}
|
|
/* return dos attributes as pseudo xattr */
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
if (size > MAX_EA_VALUE_SIZE) {
|
|
cifs_dbg(FYI, "size of EA value too large\n");
|
|
rc = -EOPNOTSUPP;
|
|
goto out;
|
|
}
|
|
|
|
switch (handler->flags) {
|
|
case XATTR_USER:
|
|
cifs_dbg(FYI, "%s:setting user xattr %s\n", __func__, name);
|
|
if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
|
|
(strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
|
|
rc = cifs_attrib_set(xid, pTcon, inode, full_path,
|
|
value, size);
|
|
if (rc == 0) /* force revalidate of the inode */
|
|
CIFS_I(inode)->time = 0;
|
|
break;
|
|
} else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
|
|
(strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
|
|
rc = cifs_creation_time_set(xid, pTcon, inode,
|
|
full_path, value, size);
|
|
if (rc == 0) /* force revalidate of the inode */
|
|
CIFS_I(inode)->time = 0;
|
|
break;
|
|
}
|
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto out;
|
|
|
|
if (pTcon->ses->server->ops->set_EA) {
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
|
full_path, name, value, (__u16)size,
|
|
cifs_sb->local_nls, cifs_sb);
|
|
if (rc == 0)
|
|
inode_set_ctime_current(inode);
|
|
}
|
|
break;
|
|
|
|
case XATTR_CIFS_ACL:
|
|
case XATTR_CIFS_NTSD: {
|
|
struct cifs_ntsd *pacl;
|
|
|
|
if (!value)
|
|
goto out;
|
|
pacl = kmalloc(size, GFP_KERNEL);
|
|
if (!pacl) {
|
|
rc = -ENOMEM;
|
|
} else {
|
|
memcpy(pacl, value, size);
|
|
if (value &&
|
|
pTcon->ses->server->ops->set_acl) {
|
|
rc = 0;
|
|
if (handler->flags == XATTR_CIFS_NTSD) {
|
|
/* set owner and DACL */
|
|
rc = pTcon->ses->server->ops->set_acl(
|
|
pacl, size, inode,
|
|
full_path,
|
|
CIFS_ACL_OWNER);
|
|
}
|
|
if (rc == 0) {
|
|
/* set DACL */
|
|
rc = pTcon->ses->server->ops->set_acl(
|
|
pacl, size, inode,
|
|
full_path,
|
|
CIFS_ACL_DACL);
|
|
}
|
|
} else {
|
|
rc = -EOPNOTSUPP;
|
|
}
|
|
if (rc == 0) /* force revalidate of the inode */
|
|
CIFS_I(inode)->time = 0;
|
|
kfree(pacl);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case XATTR_ACL_ACCESS:
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (!value)
|
|
goto out;
|
|
if (sb->s_flags & SB_POSIXACL)
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
value, (const int)size,
|
|
ACL_TYPE_ACCESS, cifs_sb->local_nls,
|
|
cifs_remap(cifs_sb));
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
break;
|
|
|
|
case XATTR_ACL_DEFAULT:
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (!value)
|
|
goto out;
|
|
if (sb->s_flags & SB_POSIXACL)
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
value, (const int)size,
|
|
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
|
|
cifs_remap(cifs_sb));
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
break;
|
|
}
|
|
|
|
out:
|
|
kfree(full_path);
|
|
free_xid(xid);
|
|
cifs_put_tlink(tlink);
|
|
return rc;
|
|
}
|
|
|
|
static int cifs_attrib_get(struct dentry *dentry,
|
|
struct inode *inode, void *value,
|
|
size_t size)
|
|
{
|
|
ssize_t rc;
|
|
__u32 *pattribute;
|
|
|
|
rc = cifs_revalidate_dentry_attr(dentry);
|
|
|
|
if (rc)
|
|
return rc;
|
|
|
|
if ((value == NULL) || (size == 0))
|
|
return sizeof(__u32);
|
|
else if (size < sizeof(__u32))
|
|
return -ERANGE;
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
pattribute = (__u32 *)value;
|
|
*pattribute = CIFS_I(inode)->cifsAttrs;
|
|
|
|
return sizeof(__u32);
|
|
}
|
|
|
|
static int cifs_creation_time_get(struct dentry *dentry, struct inode *inode,
|
|
void *value, size_t size)
|
|
{
|
|
ssize_t rc;
|
|
__u64 *pcreatetime;
|
|
|
|
rc = cifs_revalidate_dentry_attr(dentry);
|
|
if (rc)
|
|
return rc;
|
|
|
|
if ((value == NULL) || (size == 0))
|
|
return sizeof(__u64);
|
|
else if (size < sizeof(__u64))
|
|
return -ERANGE;
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
pcreatetime = (__u64 *)value;
|
|
*pcreatetime = CIFS_I(inode)->createtime;
|
|
return sizeof(__u64);
|
|
}
|
|
|
|
|
|
static int cifs_xattr_get(const struct xattr_handler *handler,
|
|
struct dentry *dentry, struct inode *inode,
|
|
const char *name, void *value, size_t size, int flags)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
unsigned int xid;
|
|
struct super_block *sb = dentry->d_sb;
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
|
struct tcon_link *tlink;
|
|
struct cifs_tcon *pTcon;
|
|
char *full_path;
|
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
if (IS_ERR(tlink))
|
|
return PTR_ERR(tlink);
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
xid = get_xid();
|
|
|
|
full_path = build_path_from_dentry(dentry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
/* return alt name if available as pseudo attr */
|
|
switch (handler->flags) {
|
|
case XATTR_USER:
|
|
cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name);
|
|
if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
|
|
(strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
|
|
rc = cifs_attrib_get(dentry, inode, value, size);
|
|
break;
|
|
} else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
|
|
(strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
|
|
rc = cifs_creation_time_get(dentry, inode, value, size);
|
|
break;
|
|
}
|
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto out;
|
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
|
full_path, name, value, size, cifs_sb);
|
|
break;
|
|
|
|
case XATTR_CIFS_ACL:
|
|
case XATTR_CIFS_NTSD: {
|
|
/* the whole ntsd is fetched regardless */
|
|
u32 acllen;
|
|
struct cifs_ntsd *pacl;
|
|
|
|
if (pTcon->ses->server->ops->get_acl == NULL)
|
|
goto out; /* rc already EOPNOTSUPP */
|
|
|
|
pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
|
|
inode, full_path, &acllen);
|
|
if (IS_ERR(pacl)) {
|
|
rc = PTR_ERR(pacl);
|
|
cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
|
|
__func__, rc);
|
|
} else {
|
|
if (value) {
|
|
if (acllen > size)
|
|
acllen = -ERANGE;
|
|
else
|
|
memcpy(value, pacl, acllen);
|
|
}
|
|
rc = acllen;
|
|
kfree(pacl);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case XATTR_ACL_ACCESS:
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (sb->s_flags & SB_POSIXACL)
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
|
value, size, ACL_TYPE_ACCESS,
|
|
cifs_sb->local_nls,
|
|
cifs_remap(cifs_sb));
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
break;
|
|
|
|
case XATTR_ACL_DEFAULT:
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (sb->s_flags & SB_POSIXACL)
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
|
value, size, ACL_TYPE_DEFAULT,
|
|
cifs_sb->local_nls,
|
|
cifs_remap(cifs_sb));
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
break;
|
|
}
|
|
|
|
/* We could add an additional check for streams ie
|
|
if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
|
|
if (rc == -EINVAL)
|
|
rc = -EOPNOTSUPP;
|
|
|
|
out:
|
|
kfree(full_path);
|
|
free_xid(xid);
|
|
cifs_put_tlink(tlink);
|
|
return rc;
|
|
}
|
|
|
|
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
unsigned int xid;
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
|
|
struct tcon_link *tlink;
|
|
struct cifs_tcon *pTcon;
|
|
char *full_path;
|
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
return -EOPNOTSUPP;
|
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
if (IS_ERR(tlink))
|
|
return PTR_ERR(tlink);
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
xid = get_xid();
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
goto list_ea_exit;
|
|
}
|
|
/* return dos attributes as pseudo xattr */
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
|
full_path, NULL, data, buf_size, cifs_sb);
|
|
list_ea_exit:
|
|
kfree(full_path);
|
|
free_xid(xid);
|
|
cifs_put_tlink(tlink);
|
|
return rc;
|
|
}
|
|
|
|
static const struct xattr_handler cifs_user_xattr_handler = {
|
|
.prefix = XATTR_USER_PREFIX,
|
|
.flags = XATTR_USER,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
/* os2.* attributes are treated like user.* attributes */
|
|
static const struct xattr_handler cifs_os2_xattr_handler = {
|
|
.prefix = XATTR_OS2_PREFIX,
|
|
.flags = XATTR_USER,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
|
|
.name = CIFS_XATTR_CIFS_ACL,
|
|
.flags = XATTR_CIFS_ACL,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
/*
|
|
* Although this is just an alias for the above, need to move away from
|
|
* confusing users and using the 20 year old term 'cifs' when it is no
|
|
* longer secure and was replaced by SMB2/SMB3 a long time ago, and
|
|
* SMB3 and later are highly secure.
|
|
*/
|
|
static const struct xattr_handler smb3_acl_xattr_handler = {
|
|
.name = SMB3_XATTR_CIFS_ACL,
|
|
.flags = XATTR_CIFS_ACL,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
static const struct xattr_handler cifs_cifs_ntsd_xattr_handler = {
|
|
.name = CIFS_XATTR_CIFS_NTSD,
|
|
.flags = XATTR_CIFS_NTSD,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
/*
|
|
* Although this is just an alias for the above, need to move away from
|
|
* confusing users and using the 20 year old term 'cifs' when it is no
|
|
* longer secure and was replaced by SMB2/SMB3 a long time ago, and
|
|
* SMB3 and later are highly secure.
|
|
*/
|
|
static const struct xattr_handler smb3_ntsd_xattr_handler = {
|
|
.name = SMB3_XATTR_CIFS_NTSD,
|
|
.flags = XATTR_CIFS_NTSD,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
|
|
.name = XATTR_NAME_POSIX_ACL_ACCESS,
|
|
.flags = XATTR_ACL_ACCESS,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
static const struct xattr_handler cifs_posix_acl_default_xattr_handler = {
|
|
.name = XATTR_NAME_POSIX_ACL_DEFAULT,
|
|
.flags = XATTR_ACL_DEFAULT,
|
|
.get = cifs_xattr_get,
|
|
.set = cifs_xattr_set,
|
|
};
|
|
|
|
const struct xattr_handler *cifs_xattr_handlers[] = {
|
|
&cifs_user_xattr_handler,
|
|
&cifs_os2_xattr_handler,
|
|
&cifs_cifs_acl_xattr_handler,
|
|
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
|
|
&cifs_cifs_ntsd_xattr_handler,
|
|
&smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
|
|
&cifs_posix_acl_access_xattr_handler,
|
|
&cifs_posix_acl_default_xattr_handler,
|
|
NULL
|
|
};
|