57b60a3a15
Changes in 5.10.26 ASoC: ak4458: Add MODULE_DEVICE_TABLE ASoC: ak5558: Add MODULE_DEVICE_TABLE spi: cadence: set cqspi to the driver_data field of struct device ALSA: dice: fix null pointer dereference when node is disconnected ALSA: hda/realtek: apply pin quirk for XiaomiNotebook Pro ALSA: hda: generic: Fix the micmute led init state ALSA: hda/realtek: Apply headset-mic quirks for Xiaomi Redmibook Air ALSA: hda/realtek: fix mute/micmute LEDs for HP 840 G8 ALSA: hda/realtek: fix mute/micmute LEDs for HP 440 G8 ALSA: hda/realtek: fix mute/micmute LEDs for HP 850 G8 Revert "PM: runtime: Update device status before letting suppliers suspend" s390/vtime: fix increased steal time accounting s390/pci: refactor zpci_create_device() s390/pci: remove superfluous zdev->zbus check s390/pci: fix leak of PCI device structure zonefs: Fix O_APPEND async write handling zonefs: prevent use of seq files as swap file zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() btrfs: fix race when cloning extent buffer during rewind of an old root btrfs: fix slab cache flags for free space tree bitmap vhost-vdpa: fix use-after-free of v->config_ctx vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails drm/amd/display: Correct algorithm for reversed gamma ASoC: fsl_ssi: Fix TDM slot setup for I2S mode ASoC: Intel: bytcr_rt5640: Fix HP Pavilion x2 10-p0XX OVCD current threshold ASoC: SOF: Intel: unregister DMIC device on probe error ASoC: SOF: intel: fix wrong poll bits in dsp power down ASoC: qcom: sdm845: Fix array out of bounds access ASoC: qcom: sdm845: Fix array out of range on rx slim channels ASoC: codecs: wcd934x: add a sanity check in set channel map ASoC: qcom: lpass-cpu: Fix lpass dai ids parse ASoC: simple-card-utils: Do not handle device clock afs: Fix accessing YFS xattrs on a non-YFS server afs: Stop listxattr() from listing "afs.*" attributes ALSA: usb-audio: Fix unintentional sign extension issue nvme: fix Write Zeroes limitations nvme-tcp: fix misuse of __smp_processor_id with preemption enabled nvme-tcp: fix possible hang when failing to set io queues nvme-tcp: fix a NULL deref when receiving a 0-length r2t PDU nvmet: don't check iosqes,iocqes for discovery controllers nfsd: Don't keep looking up unhashed files in the nfsd file cache nfsd: don't abort copies early NFSD: Repair misuse of sv_lock in 5.10.16-rt30. NFSD: fix dest to src mount in inter-server COPY svcrdma: disable timeouts on rdma backchannel vfio: IOMMU_API should be selected vhost_vdpa: fix the missing irq_bypass_unregister_producer() invocation sunrpc: fix refcount leak for rpc auth modules i915/perf: Start hrtimer only if sampling the OA buffer pstore: Fix warning in pstore_kill_sb() io_uring: ensure that SQPOLL thread is started for exit net/qrtr: fix __netdev_alloc_skb call kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again cifs: fix allocation size on newly created files riscv: Correct SPARSEMEM configuration scsi: lpfc: Fix some error codes in debugfs scsi: myrs: Fix a double free in myrs_cleanup() scsi: ufs: ufs-mediatek: Correct operator & -> && RISC-V: correct enum sbi_ext_rfence_fid counter: stm32-timer-cnt: Report count function when SLAVE_MODE_DISABLED gpiolib: Assign fwnode to parent's if no primary one provided nvme-rdma: fix possible hang when failing to set io queues ibmvnic: add some debugs ibmvnic: serialize access to work queue on remove tty: serial: stm32-usart: Remove set but unused 'cookie' variables serial: stm32: fix DMA initialization error handling bpf: Declare __bpf_free_used_maps() unconditionally RDMA/rtrs: Remove unnecessary argument dir of rtrs_iu_free RDMA/rtrs-srv: Jump to dereg_mr label if allocate iu fails RDMA/rtrs: Introduce rtrs_post_send RDMA/rtrs: Fix KASAN: stack-out-of-bounds bug module: merge repetitive strings in module_sig_check() module: avoid *goto*s in module_sig_check() module: harden ELF info handling scsi: pm80xx: Make mpi_build_cmd locking consistent scsi: pm80xx: Make running_req atomic scsi: pm80xx: Fix pm8001_mpi_get_nvmd_resp() race condition scsi: pm8001: Neaten debug logging macros and uses scsi: libsas: Remove notifier indirection scsi: libsas: Introduce a _gfp() variant of event notifiers scsi: mvsas: Pass gfp_t flags to libsas event notifiers scsi: isci: Pass gfp_t flags in isci_port_link_down() scsi: isci: Pass gfp_t flags in isci_port_link_up() scsi: isci: Pass gfp_t flags in isci_port_bc_change_received() RDMA/mlx5: Allow creating all QPs even when non RDMA profile is used powerpc/sstep: Fix load-store and update emulation powerpc/sstep: Fix darn emulation i40e: Fix endianness conversions net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ8081 MIPS: compressed: fix build with enabled UBSAN drm/amd/display: turn DPMS off on connector unplug iwlwifi: Add a new card for MA family io_uring: fix inconsistent lock state media: cedrus: h264: Support profile controls ibmvnic: remove excessive irqsave s390/qeth: schedule TX NAPI on QAOB completion drm/amd/pm: fulfill the Polaris implementation for get_clock_by_type_with_latency() io_uring: don't attempt IO reissue from the ring exit path io_uring: clear IOCB_WAITQ for non -EIOCBQUEUED return net: bonding: fix error return code of bond_neigh_init() regulator: pca9450: Add SD_VSEL GPIO for LDO5 regulator: pca9450: Enable system reset on WDOG_B assertion regulator: pca9450: Clear PRESET_EN bit to fix BUCK1/2/3 voltage setting gfs2: Add common helper for holding and releasing the freeze glock gfs2: move freeze glock outside the make_fs_rw and _ro functions gfs2: bypass signal_our_withdraw if no journal powerpc: Force inlining of cpu_has_feature() to avoid build failure usb-storage: Add quirk to defeat Kindle's automatic unload usbip: Fix incorrect double assignment to udc->ud.tcp_rx usb: gadget: configfs: Fix KASAN use-after-free usb: typec: Remove vdo[3] part of tps6598x_rx_identity_reg struct usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- usb: dwc3: gadget: Allow runtime suspend if UDC unbinded usb: dwc3: gadget: Prevent EP queuing while stopping transfers thunderbolt: Initialize HopID IDAs in tb_switch_alloc() thunderbolt: Increase runtime PM reference count on DP tunnel discovery iio:adc:stm32-adc: Add HAS_IOMEM dependency iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel iio: adis16400: Fix an error code in adis16400_initial_setup() iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler iio: adc: ab8500-gpadc: Fix off by 10 to 3 iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask iio: adc: adi-axi-adc: add proper Kconfig dependencies iio: hid-sensor-humidity: Fix alignment issue of timestamp channel iio: hid-sensor-prox: Fix scale not correct issue iio: hid-sensor-temperature: Fix issues of timestamp channel counter: stm32-timer-cnt: fix ceiling write max value counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register PCI: rpadlpar: Fix potential drc_name corruption in store functions perf/x86/intel: Fix a crash caused by zero PEBS status perf/x86/intel: Fix unchecked MSR access error caused by VLBR_EVENT x86/ioapic: Ignore IRQ2 again kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data() x86: Move TS_COMPAT back to asm/thread_info.h x86: Introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall() efivars: respect EFI_UNSUPPORTED return from firmware ext4: fix error handling in ext4_end_enable_verity() ext4: find old entry again if failed to rename whiteout ext4: stop inode update before return ext4: do not try to set xattr into ea_inode if value is empty ext4: fix potential error in ext4_do_update_inode ext4: fix rename whiteout with fast commit MAINTAINERS: move some real subsystems off of the staging mailing list MAINTAINERS: move the staging subsystem to lists.linux.dev static_call: Fix static_call_update() sanity check efi: use 32-bit alignment for efi_guid_t literals firmware/efi: Fix a use after bug in efi_mem_reserve_persistent genirq: Disable interrupts for force threaded handlers x86/apic/of: Fix CPU devicetree-node lookups cifs: Fix preauth hash corruption Linux 5.10.26 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I6f6bdd1dc46dc744c848e778f9edd0be558b46ac
362 lines
8.3 KiB
C
362 lines
8.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/* Extended attribute handling for AFS. We use xattrs to get and set metadata
|
|
* instead of providing pioctl().
|
|
*
|
|
* Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*/
|
|
|
|
#include <linux/slab.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/xattr.h>
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* Deal with the result of a successful fetch ACL operation.
|
|
*/
|
|
static void afs_acl_success(struct afs_operation *op)
|
|
{
|
|
afs_vnode_commit_status(op, &op->file[0]);
|
|
}
|
|
|
|
static void afs_acl_put(struct afs_operation *op)
|
|
{
|
|
kfree(op->acl);
|
|
}
|
|
|
|
static const struct afs_operation_ops afs_fetch_acl_operation = {
|
|
.issue_afs_rpc = afs_fs_fetch_acl,
|
|
.success = afs_acl_success,
|
|
.put = afs_acl_put,
|
|
};
|
|
|
|
/*
|
|
* Get a file's ACL.
|
|
*/
|
|
static int afs_xattr_get_acl(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_operation *op;
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
struct afs_acl *acl = NULL;
|
|
int ret;
|
|
|
|
op = afs_alloc_operation(NULL, vnode->volume);
|
|
if (IS_ERR(op))
|
|
return -ENOMEM;
|
|
|
|
afs_op_set_vnode(op, 0, vnode);
|
|
op->ops = &afs_fetch_acl_operation;
|
|
|
|
afs_begin_vnode_operation(op);
|
|
afs_wait_for_operation(op);
|
|
acl = op->acl;
|
|
op->acl = NULL;
|
|
ret = afs_put_operation(op);
|
|
|
|
if (ret == 0) {
|
|
ret = acl->size;
|
|
if (size > 0) {
|
|
if (acl->size <= size)
|
|
memcpy(buffer, acl->data, acl->size);
|
|
else
|
|
ret = -ERANGE;
|
|
}
|
|
}
|
|
|
|
kfree(acl);
|
|
return ret;
|
|
}
|
|
|
|
static bool afs_make_acl(struct afs_operation *op,
|
|
const void *buffer, size_t size)
|
|
{
|
|
struct afs_acl *acl;
|
|
|
|
acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
|
|
if (!acl) {
|
|
afs_op_nomem(op);
|
|
return false;
|
|
}
|
|
|
|
acl->size = size;
|
|
memcpy(acl->data, buffer, size);
|
|
op->acl = acl;
|
|
return true;
|
|
}
|
|
|
|
static const struct afs_operation_ops afs_store_acl_operation = {
|
|
.issue_afs_rpc = afs_fs_store_acl,
|
|
.success = afs_acl_success,
|
|
.put = afs_acl_put,
|
|
};
|
|
|
|
/*
|
|
* Set a file's AFS3 ACL.
|
|
*/
|
|
static int afs_xattr_set_acl(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
const void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_operation *op;
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
|
|
if (flags == XATTR_CREATE)
|
|
return -EINVAL;
|
|
|
|
op = afs_alloc_operation(NULL, vnode->volume);
|
|
if (IS_ERR(op))
|
|
return -ENOMEM;
|
|
|
|
afs_op_set_vnode(op, 0, vnode);
|
|
if (!afs_make_acl(op, buffer, size))
|
|
return afs_put_operation(op);
|
|
|
|
op->ops = &afs_store_acl_operation;
|
|
return afs_do_sync_operation(op);
|
|
}
|
|
|
|
static const struct xattr_handler afs_xattr_afs_acl_handler = {
|
|
.name = "afs.acl",
|
|
.get = afs_xattr_get_acl,
|
|
.set = afs_xattr_set_acl,
|
|
};
|
|
|
|
static const struct afs_operation_ops yfs_fetch_opaque_acl_operation = {
|
|
.issue_yfs_rpc = yfs_fs_fetch_opaque_acl,
|
|
.success = afs_acl_success,
|
|
/* Don't free op->yacl in .put here */
|
|
};
|
|
|
|
/*
|
|
* Get a file's YFS ACL.
|
|
*/
|
|
static int afs_xattr_get_yfs(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_operation *op;
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
struct yfs_acl *yacl = NULL;
|
|
char buf[16], *data;
|
|
int which = 0, dsize, ret = -ENOMEM;
|
|
|
|
if (strcmp(name, "acl") == 0)
|
|
which = 0;
|
|
else if (strcmp(name, "acl_inherited") == 0)
|
|
which = 1;
|
|
else if (strcmp(name, "acl_num_cleaned") == 0)
|
|
which = 2;
|
|
else if (strcmp(name, "vol_acl") == 0)
|
|
which = 3;
|
|
else
|
|
return -EOPNOTSUPP;
|
|
|
|
yacl = kzalloc(sizeof(struct yfs_acl), GFP_KERNEL);
|
|
if (!yacl)
|
|
goto error;
|
|
|
|
if (which == 0)
|
|
yacl->flags |= YFS_ACL_WANT_ACL;
|
|
else if (which == 3)
|
|
yacl->flags |= YFS_ACL_WANT_VOL_ACL;
|
|
|
|
op = afs_alloc_operation(NULL, vnode->volume);
|
|
if (IS_ERR(op))
|
|
goto error_yacl;
|
|
|
|
afs_op_set_vnode(op, 0, vnode);
|
|
op->yacl = yacl;
|
|
op->ops = &yfs_fetch_opaque_acl_operation;
|
|
|
|
afs_begin_vnode_operation(op);
|
|
afs_wait_for_operation(op);
|
|
ret = afs_put_operation(op);
|
|
|
|
if (ret == 0) {
|
|
switch (which) {
|
|
case 0:
|
|
data = yacl->acl->data;
|
|
dsize = yacl->acl->size;
|
|
break;
|
|
case 1:
|
|
data = buf;
|
|
dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag);
|
|
break;
|
|
case 2:
|
|
data = buf;
|
|
dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned);
|
|
break;
|
|
case 3:
|
|
data = yacl->vol_acl->data;
|
|
dsize = yacl->vol_acl->size;
|
|
break;
|
|
default:
|
|
ret = -EOPNOTSUPP;
|
|
goto error_yacl;
|
|
}
|
|
|
|
ret = dsize;
|
|
if (size > 0) {
|
|
if (dsize <= size)
|
|
memcpy(buffer, data, dsize);
|
|
else
|
|
ret = -ERANGE;
|
|
}
|
|
} else if (ret == -ENOTSUPP) {
|
|
ret = -ENODATA;
|
|
}
|
|
|
|
error_yacl:
|
|
yfs_free_opaque_acl(yacl);
|
|
error:
|
|
return ret;
|
|
}
|
|
|
|
static const struct afs_operation_ops yfs_store_opaque_acl2_operation = {
|
|
.issue_yfs_rpc = yfs_fs_store_opaque_acl2,
|
|
.success = afs_acl_success,
|
|
.put = afs_acl_put,
|
|
};
|
|
|
|
/*
|
|
* Set a file's YFS ACL.
|
|
*/
|
|
static int afs_xattr_set_yfs(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
const void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_operation *op;
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
int ret;
|
|
|
|
if (flags == XATTR_CREATE ||
|
|
strcmp(name, "acl") != 0)
|
|
return -EINVAL;
|
|
|
|
op = afs_alloc_operation(NULL, vnode->volume);
|
|
if (IS_ERR(op))
|
|
return -ENOMEM;
|
|
|
|
afs_op_set_vnode(op, 0, vnode);
|
|
if (!afs_make_acl(op, buffer, size))
|
|
return afs_put_operation(op);
|
|
|
|
op->ops = &yfs_store_opaque_acl2_operation;
|
|
ret = afs_do_sync_operation(op);
|
|
if (ret == -ENOTSUPP)
|
|
ret = -ENODATA;
|
|
return ret;
|
|
}
|
|
|
|
static const struct xattr_handler afs_xattr_yfs_handler = {
|
|
.prefix = "afs.yfs.",
|
|
.get = afs_xattr_get_yfs,
|
|
.set = afs_xattr_set_yfs,
|
|
};
|
|
|
|
/*
|
|
* Get the name of the cell on which a file resides.
|
|
*/
|
|
static int afs_xattr_get_cell(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
struct afs_cell *cell = vnode->volume->cell;
|
|
size_t namelen;
|
|
|
|
namelen = cell->name_len;
|
|
if (size == 0)
|
|
return namelen;
|
|
if (namelen > size)
|
|
return -ERANGE;
|
|
memcpy(buffer, cell->name, namelen);
|
|
return namelen;
|
|
}
|
|
|
|
static const struct xattr_handler afs_xattr_afs_cell_handler = {
|
|
.name = "afs.cell",
|
|
.get = afs_xattr_get_cell,
|
|
};
|
|
|
|
/*
|
|
* Get the volume ID, vnode ID and vnode uniquifier of a file as a sequence of
|
|
* hex numbers separated by colons.
|
|
*/
|
|
static int afs_xattr_get_fid(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
char text[16 + 1 + 24 + 1 + 8 + 1];
|
|
size_t len;
|
|
|
|
/* The volume ID is 64-bit, the vnode ID is 96-bit and the
|
|
* uniquifier is 32-bit.
|
|
*/
|
|
len = scnprintf(text, sizeof(text), "%llx:", vnode->fid.vid);
|
|
if (vnode->fid.vnode_hi)
|
|
len += scnprintf(text + len, sizeof(text) - len, "%x%016llx",
|
|
vnode->fid.vnode_hi, vnode->fid.vnode);
|
|
else
|
|
len += scnprintf(text + len, sizeof(text) - len, "%llx",
|
|
vnode->fid.vnode);
|
|
len += scnprintf(text + len, sizeof(text) - len, ":%x",
|
|
vnode->fid.unique);
|
|
|
|
if (size == 0)
|
|
return len;
|
|
if (len > size)
|
|
return -ERANGE;
|
|
memcpy(buffer, text, len);
|
|
return len;
|
|
}
|
|
|
|
static const struct xattr_handler afs_xattr_afs_fid_handler = {
|
|
.name = "afs.fid",
|
|
.get = afs_xattr_get_fid,
|
|
};
|
|
|
|
/*
|
|
* Get the name of the volume on which a file resides.
|
|
*/
|
|
static int afs_xattr_get_volume(const struct xattr_handler *handler,
|
|
struct dentry *dentry,
|
|
struct inode *inode, const char *name,
|
|
void *buffer, size_t size, int flags)
|
|
{
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
const char *volname = vnode->volume->name;
|
|
size_t namelen;
|
|
|
|
namelen = strlen(volname);
|
|
if (size == 0)
|
|
return namelen;
|
|
if (namelen > size)
|
|
return -ERANGE;
|
|
memcpy(buffer, volname, namelen);
|
|
return namelen;
|
|
}
|
|
|
|
static const struct xattr_handler afs_xattr_afs_volume_handler = {
|
|
.name = "afs.volume",
|
|
.get = afs_xattr_get_volume,
|
|
};
|
|
|
|
const struct xattr_handler *afs_xattr_handlers[] = {
|
|
&afs_xattr_afs_acl_handler,
|
|
&afs_xattr_afs_cell_handler,
|
|
&afs_xattr_afs_fid_handler,
|
|
&afs_xattr_afs_volume_handler,
|
|
&afs_xattr_yfs_handler, /* afs.yfs. prefix */
|
|
NULL
|
|
};
|