This is the merge of the upstream LTS release of 5.10.177 into the android12-5.10 branch. It contains the following commits: 289d29ddbfdb Merge tag 'android12-5.10.177_r00' into android12-5.100334ff98b9Revert "net: mdio: fix owner field for mdio buses registered using device-tree"f3670bd0ffMerge 5.10.177 into android12-5.10-lts387078f903Linux 5.10.17734a02011c5hsr: ratelimit only when errors are printed7c414f6f06gfs2: Always check inode size of inline inodes3392d67af0ext4: fix kernel BUG in 'ext4_write_inline_data_end()'b4781477f3libbpf: Fix btf_dump's packed struct determination7ad30ad8c6selftests/bpf: Add few corner cases to test padding handling of btf_dumpe5a16bcb13libbpf: Fix BTF-to-C converter's padding logicb9f7422dd9selftests/bpf: Test btf dump for struct with padding only fieldsf1c17475a9zonefs: Fix error message in zonefs_file_dio_append()b51e442295btrfs: scan device in non-exclusive mode3eeff8d26cs390/uaccess: add missing earlyclobber annotations to __clear_user()7051d51f12drm/amd/display: Add DSC Support for Synaptics Cascaded MST Hub79815326a5drm/etnaviv: fix reference leak when mmaping imported buffera484f8bec8rcu: Fix rcu_torture_read ftrace event08bfd05987xtensa: fix KASAN report for show_stack8ada1b5c8bALSA: hda/realtek: Add quirk for Lenovo ZhaoYang CF4620Z3b6992bdf0ALSA: usb-audio: Fix regression on detection of Roland VS-1000044721f4fALSA: hda/conexant: Partial revert of a quirk for Lenovo3d328a17c8NFSv4: Fix hangs when recovering open state after a server reboot80a4200d51powerpc: Don't try to copy PPR for task with NULL pt_regs12c2612e18pinctrl: at91-pio4: fix domain name assignment25065ed83bpinctrl: amd: Disable and mask interrupts on resumefbf3fe7f7bnet: phy: dp83869: fix default value for tx-/rx-internal-delayb3d7a4478cxen/netback: don't do grant copy across page boundary5f63470343btrfs: fix race between quota disable and quota assign ioctlsba5deb64ddInput: goodix - add Lenovo Yoga Book X90F to nine_bytes_report DMI table26a32a212bcifs: fix DFS traversal oops without CONFIG_CIFS_DFS_UPCALL63bbe24b99cifs: prevent infinite recursion in CIFSGetDFSRefer()8b3d7ad3e8Input: focaltech - use explicitly signed char type449a1a61f7Input: alps - fix compatibility with -funsigned-char988061d099pinctrl: ocelot: Fix alt mode for oceloted3439a8c4net: dsa: mv88e6xxx: Enable IGMP snooping on user ports only8104c79551bnxt_en: Add missing 200G link speed reporting62850a0763bnxt_en: Fix typo in PCI id to device description string mappingf524d1e550i40e: fix registers dump after run ethtool adapter self testfa7fafedc9net: ipa: compute DMA pool size properly96e34c8800ALSA: ymfpci: Fix BUG_ON in probe function688b1178c4ALSA: ymfpci: Fix assignment in if conditionee17dea307s390/vfio-ap: fix memory leak in vfio_ap device driverab2a559078can: bcm: bcm_tx_setup(): fix KMSAN uninit-value in vfs_write9b22e0cfc4net: stmmac: don't reject VLANs when IFF_PROMISC is setf032e12514net/net_failover: fix txq exceeding warning1025c47151regulator: Handle deferred clk69ed49a7b8r8169: fix RTL8168H and RTL8107E rx crc error3907fcb5a4ptp_qoriq: fix memory leak in probe()6ff4a54c02scsi: megaraid_sas: Fix crash after a double completion059c3a7a3dsfc: ef10: don't overwrite offload features at NIC reset4a81e2da72mtd: rawnand: meson: invalidate cache on polling ECC bit47a449ec09mips: bmips: BCM6358: disable RAC flush for TP1ac63f78d9aca8210: Fix unsigned mac_len comparison with zero in ca8210_skb_tx()8b1269b709tracing: Fix wrong return in kprobe_event_gen_test.c038765a095tools/power turbostat: Fix /dev/cpu_dma_latency warnings5ec5680dc6fbdev: au1200fb: Fix potential divide by zeroce5551db36fbdev: lxfb: Fix potential divide by zeroc2be7f8056fbdev: intelfb: Fix potential divide by zero78eb964805fbdev: nvidia: Fix potential divide by zero1f2a94baeesched_getaffinity: don't assume 'cpumask_size()' is fully initialized6eaa2254ccfbdev: tgafb: Fix potential divide by zerobaef27176eALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set()fcf80111a4ALSA: asihpi: check pao in control_message()b94ffa2874net: hsr: Don't log netdev_err message on unknown prp dst node74d6d33f36md: avoid signed overflow in slot_store()10941fd5c3fsverity: don't drop pagecache at end of FS_IOC_ENABLE_VERITY0b9493b504dm crypt: avoid accessing uninitialized taskletb2d1956547bus: imx-weim: fix branch condition evaluates to a garbage value1635a062fadrm/meson: fix missing component unbind on bind errors794a6cea22drm/meson: Fix error handling when afbcd.ops->init failsf7385e0886kcsan: avoid passing -g for test46ae204069kernel: kcsan: kcsan_test: build without structleak plugina5ce0a559busb: dwc3: gadget: Add 1ms delay after end transfer command without IOCddb1973e67usb: dwc3: gadget: move cmd_endtransfer to extra function01e4c9c03dNFSD: fix use-after-free in __nfs42_ssc_open()34ef9cd887KVM: fix memoryleak in kvm_init()a6d345c3a3xfs: don't reuse busy extents on extent trimcb61e1e36fxfs: shut down the filesystem if we screw up quota reservation91d7a4bd56ocfs2: fix data corruption after failed writed4a5181ba1sched/fair: Sanitize vruntime of entity being migrateddfdcda25fbsched/fair: sanitize vruntime of entity being placed66ff37993ddm crypt: add cond_resched() to dmcrypt_write()c68f08cc74dm stats: check for and propagate alloc_percpu failure1eaa2b7ae9i2c: xgene-slimpro: Fix out-of-bounds bug in xgene_slimpro_i2c_xfer()85b637feeefirmware: arm_scmi: Fix device node validation for mailbox transportf632a90f8etee: amdtee: fix race condition in amdtee_open_session4ede0da36cdrm/i915: Preserve crtc_state->inherited during state clearingd5329a06b4drm/i915/active: Fix missing debug object activationd18db946ccnilfs2: fix kernel-infoleak in nilfs_ioctl_wrap_copy()560437bba1wifi: mac80211: fix qos on mesh interfacesa6adfe9bbdusb: ucsi: Fix NULL pointer deref in ucsi_connector_change()09671cfc2busb: chipidea: core: fix possible concurrent when switch role073ce98aa3usb: chipdea: core: fix return -EINVAL if request role is the same with current role5a36b601afusb: cdns3: Fix issue with using incorrect PCI device functionaae6d1bf4ddm thin: fix deadlock when swapping to thin device4d2626e107igb: revert rtnl_lock() that causes deadlocke66f3039c7fsverity: Remove WQ_UNBOUND from fsverity read workqueue33f341c1fcusb: gadget: u_audio: don't let userspace block driver unbind1f01027c51usb: dwc2: fix a devres leak in hw_enable upon suspend resumedce1284215scsi: core: Add BLIST_SKIP_VPD_PAGES for SKhynix H28U74301AMRf7a4ce3514cifs: empty interface list when server doesn't support query interfaces8beb18c25bsh: sanitize the flags on sigreturn87e800e3dcnet: usb: qmi_wwan: add Telit 0x1080 composition27d4ce4aa3net: usb: cdc_mbim: avoid altsetting toggling for Telit FE990ddfc061793scsi: storvsc: Handle BlockSize change in Hyper-V VHD/VHDX file3e0a423a55scsi: lpfc: Avoid usage of list iterator variable after loopf9a937f75bscsi: ufs: core: Add soft dependency on governor_simpleondemand522314863fscsi: hisi_sas: Check devm_add_action() return value799d29a447scsi: target: iscsi: Fix an error message in iscsi_check_key()8c42442887selftests/bpf: check that modifier resolves after pointerdf1da53a7em68k: Only force 030 bus error if PC not in exception table7df72bedbdca8210: fix mac_len negative array access3d8fafc530HID: cp2112: Fix driver not registering GPIO IRQ chip as threaded082b8240a6riscv: Bump COMMAND_LINE_SIZE value to 10242d6c2dee59thunderbolt: Use const qualifier for `ring_interrupt_index`06e04b450bthunderbolt: Use scale field when allocating USB3 bandwidth32fa53c27euas: Add US_FL_NO_REPORT_OPCODES for JMicron JMS583Gen 2231cfa78ecscsi: qla2xxx: Perform lockless command completion in abort pathf73a88df19hwmon (it87): Fix voltage scaling for chips with 10.9mV ADCs33c2fa39fbhwmon: fix potential sensor registration fail if of_node is missingf86ff88a15platform/chrome: cros_ec_chardev: fix kernel data leak from ioctlda3d3fdfb4Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished workfce0e47e9eBluetooth: L2CAP: Fix responding with wrong PDU type77a61df0a0Bluetooth: L2CAP: Fix not checking for maximum number of DCID65ceb17074Bluetooth: btqcomsmd: Fix command timeout after setting BD address7aa3d03e1bnet: mdio: thunder: Add missing fwnode_handle_put()94ef1715d2gve: Cache link_speed value from device3c72445dadnvme-tcp: fix nvme_tcp_term_pdu to match spec73db80dcdcnet/sonic: use dma_mapping_error() for error checkf8cec30541erspan: do not use skb_mac_header() in ndo_start_xmit()19aa85b9dfatm: idt77252: fix kmemleak when rmmod idt772525eadc80328net/mlx5: E-Switch, Fix an Oops in error handling code265101aea4net/mlx5: Read the TC mapping of all priorities on ETS query18cead61e4net/mlx5: Fix steering rules cleanupa4bbab27c4bpf: Adjust insufficient default bpf_jit_limita44e98abcckeys: Do not cache key in task struct if key is requested from kernel threadec23a669debootconfig: Fix testcase to increase max node56e0bc4a72net/ps3_gelic_net: Use dma_mapping_error3d5a97283enet/ps3_gelic_net: Fix RX sk_buff lengthcb5879efdenet: qcom/emac: Fix use after free bug in emac_remove due to race conditiond04dac7faenet: mdio: fix owner field for mdio buses registered using device-tree1b333766eanet: phy: Ensure state transitions are processed from phy_stop()bfeeb3aaadxirc2ps_cs: Fix use after free bug in xirc2ps_detach39c3b9dd48qed/qed_sriov: guard against NULL derefs from qed_iov_get_vf_info33d1603a38net: usb: smsc95xx: Limit packet length to skb->lenc09cdf6eb8scsi: scsi_dh_alua: Fix memleak for 'qdata' in alua_activate()a3ada13f20i2c: imx-lpi2c: check only for enabled interrupt flagsbde2e73d52igc: fix the validation logic for taprio's gate listd3e4844c18igbvf: Regard vf reset nack as successfe3850c72aintel/igbvf: free irq on the error path in igbvf_request_msix()155d6d434fiavf: fix non-tunneled IPv6 UDP packet type and hashing15dcb57ebaiavf: fix inverted Rx hash condition leading to disabled hash580634b03axsk: Add missing overflow check in xdp_umem_reg7b5dffe048ARM: dts: imx6sl: tolino-shine2hd: fix usbotg1 pinctrl35a49d2758ARM: dts: imx6sll: e60k02: fix usbotg1 pinctrl75e2144291power: supply: da9150: Fix use after free bug in da9150_charger_remove due to race condition2b346876b9power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition18359b8e30power: supply: bq24190_charger: using pm_runtime_resume_and_get instead of pm_runtime_get_sync1fde5782f1net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf()cfeda9432cdrm/sun4i: fix missing component unbind on bind errorsb5131ed83cserial: 8250: ASPEED_VUART: select REGMAP instead of depending on it5fcb12f00aserial: 8250: SERIAL_8250_ASPEED_VUART should depend on ARCH_ASPEED19a98d56dftty: serial: fsl_lpuart: fix race on RX DMA shutdownae12308c7dserial: fsl_lpuart: Fix comment typoa43f7d0628KVM: Register /dev/kvm as the _very_ last thing during initialization7958663668KVM: Pre-allocate cpumasks for kvm_make_all_cpus_request_except()6100066358KVM: Optimize kvm_make_vcpus_request_mask() a bitad120bc869KVM: KVM: Use cpumask_available() to check for NULL cpumask when kicking vCPUs4cc54f6ae5KVM: Clean up benign vcpu->cpu data races when kicking vCPUs8f9ae017ddipmi:ssif: Add a timer between request retriesc94de7f85dipmi:ssif: resend_msg() cannot failcd35cbde00ipmi:ssif: Increase the message retry time4d57c90f24ipmi:ssif: make ssif_i2c_send() void18dd825b86perf: fix perf_event_context->timeddcf832000perf/core: Fix perf_output_begin parameter is incorrectly invoked in perf_event_bpf_output29ee1495e8interconnect: qcom: osm-l3: fix icc_onecell_data allocation90eb02302bRevert "HID: core: Provide new max_buffer_size attribute to over-ride the default"f1b6325b25Revert "HID: uhid: Over-ride the default maximum data buffer value with our own"df23049a96Merge 5.10.176 into android12-5.10-lts9b0fcb1986ANDROID: preserve CRC for __irq_domain_add()87cdb8101eMerge 5.10.175 into android12-5.10-lts1baa036104Merge 5.10.174 into android12-5.10-ltsfe51d37c6cMerge branch 'android12-5.10' into android12-5.10-lts04d892b616Revert "PCI: loongson: Prevent LS7A MRRS increases"1aaaa18b4aRevert "PCI: loongson: Add more devices that need MRRS quirk"a880d7ebc5ANDROID: remove CONFIG_NET_CLS_TCINDEX from gki_defconfigca9787bdecLinux 5.10.176e57f797e3fHID: uhid: Over-ride the default maximum data buffer value with our own9bc878756bHID: core: Provide new max_buffer_size attribute to over-ride the defaultdaa97e770exfs: remove xfs_setattr_time() declaration183ca91954fs: use consistent setgid checks in is_sxid()0e9dbde96cattr: use consistent sgid stripping checks240b96ffecattr: add setattr_should_drop_sgid()baea3ae425fs: move should_remove_suid()24378d6f74attr: add in_group_or_capable()94ac142c19fs: move S_ISGID stripping into the vfs_*() helpers347750e1b6fs: add mode_strip_sgid() helperf60b68c464xfs: use setattr_copy to set vfs inode attributes8cf9400f89xfs: set prealloc flag in xfs_alloc_file_space()308dfe49ebxfs: fallocate() should call file_modified()35f049abbaxfs: remove XFS_PREALLOC_SYNCc84fb29626xfs: don't leak btree cursor when insrec fails after a splitbe60f08c03xfs: purge dquots after inode walk fails during quotacheckd6f223cfefxfs: don't assert fail on perag references on teardownd0292124bbPCI/DPC: Await readiness of secondary bus after reset337aa99f76PCI: Unify delay handling for reset and resumeb5e0b3d742s390/ipl: add missing intersection check to ipl_report handling84e2e393bfio_uring: avoid null-ptr-deref in io_arm_poll_handler5e784a7d07drm/i915/active: Fix misuse of non-idle barriers as fence trackers8f27d43217drm/i915: Don't use stolen memory for ring buffers with LLCb4a798374fx86/mm: Fix use of uninitialized buffer in sme_enable()764217184fx86/mce: Make sure logged MCEs are processed after sysfs update15e926dfd8cpuidle: psci: Iterate backwards over list in psci_pd_remove()38742635edfbdev: stifb: Provide valid pixelclock and add fb_check_var() checks03fc29e75emmc: sdhci_am654: lower power-on failed message severityb2747b690cmm/userfaultfd: propagate uffd-wp bit when PTE-mapping the huge zeropage83c3b2f4e7ftrace: Fix invalid address access in lookup_rec() when index is 0f9a98b8ddemptcp: avoid setting TCP_CLOSE state twice684c7372bbdrm/shmem-helper: Remove another errant put in error pathfbc5ffcce7ALSA: hda/realtek: Fix the speaker output on Samsung Galaxy Book2 Pro9addf5e105ALSA: hda: intel-dsp-config: add MTL PCI idc54974ccafKVM: nVMX: add missing consistency checks for CR0 and CR47b18dea697cifs: Fix smb2_set_path_size()ec663c410ctracing: Make tracepoint lockdep check actually test something8ae86ef7a0tracing: Check field value in hist_field_name()de3170bd41tracing: Make splice_read available againefae80ca13interconnect: fix mem leak when freeing nodesb37d3ccbd5firmware: xilinx: don't make a sleepable memory allocation from an atomic context0c16c20b87serial: 8250_em: Fix UART port typef5a5150c70tty: serial: fsl_lpuart: skip waiting for transmission complete when UARTCTRL_SBK is asserted020166bc66ext4: fix possible double unlock when moving a directory7257070be7drm/amd/display: fix shift-out-of-bounds in CalculateVMAndRowBytesab7da8d93ash: intc: Avoid spurious sizeof-pointer-div warning6936525142drm/amdkfd: Fix an illegal memory accessa98160d8f3ext4: fix task hung in ext4_xattr_delete_inode0bf15bc393ext4: fail ext4_iget if special inode unallocated8e7f26b956jffs2: correct logic when creating a hole in jffs2_write_begin980d4e70c7mmc: atmel-mci: fix race between stop command and start of next command04eaeaa2f7media: m5mols: fix off-by-one loop termination errora4c048d502hwmon: (adm1266) Set `can_sleep` flag for GPIO chipa4c3e11324hwmon: tmp512: drop of_match_ptr for ID tablec5bd9719b5hwmon: (ucd90320) Add minimum delay between bus accesses663c3afee8hwmon: (ina3221) return prober error code0a73c8b3cchwmon: (xgene) Fix use after free bug in xgene_hwmon_remove due to race condition4a8c3ad12chwmon: (adt7475) Fix masking of hysteresis registersaff84fadbahwmon: (adt7475) Display smoothing attributes in correct orderd4dbd26f98ethernet: sun: add check for the mdesc_grab()eb80cb66a2qed/qed_mng_tlv: correctly zero out ->min instead of ->hour1c06d12237selftests: net: devlink_port_split.py: skip test if no suitable device availablebd2e78462anet/iucv: Fix size of interrupt data2cc46ed406net: usb: smsc75xx: Move packet length check to prevent kernel panic in skb_pull013fae04b8ipv4: Fix incorrect table ID in IOCTL path1f0586dcc0net: dsa: mv88e6xxx: fix max_mtu of 1492 on 6165, 6191, 6220, 6250, 6290cccba1ff07ice: xsk: disable txq irq before flushing hw2f28cb5c2ablock: sunvdc: add check for mdesc_grab() returning NULLa6317235danvmet: avoid potential UAF in nvmet_req_complete()9ebc344ce5nvme: fix handling single range discard request4cf15887a4block: null_blk: Fix handling of fake timeout requestd14d2574a5null_blk: Move driver into its own directoryd5e61a859adrm/bridge: Fix returned array size name for atomic_get_input_bus_fmts kdoce294f0aa47net: usb: smsc75xx: Limit packet length to skb->len9708efad9bnet/smc: fix deadlock triggered by cancel_delayed_work_syn()43aa468df2nfc: st-nci: Fix use after free bug in ndlc_remove due to race condition194248138fnet: phy: smsc: bail out in lan87xx_read_status if genphy_read_status failsbe59b87ee4net: tunnels: annotate lockless accesses to dev->needed_headroom281e86e3faqed/qed_dev: guard against a possible division by zero31817c5307net/smc: fix NULL sndbuf_desc in smc_cdc_tx_handler()3cbecb1c90i40e: Fix kernel crash during reboot when adapter is in recovery mode91eb592401ipvlan: Make skb->skb_iif track skb->dev for l3s mode2703da7884nfc: pn533: initialize struct pn533_out_arg properly77ad58bca0tcp: tcp_make_synack() can be called from process context68c665bb18scsi: core: Fix a procfs host directory removal regressionbe5aa25341scsi: core: Fix a comment in function scsi_host_dev_release()0fac20b180netfilter: nft_redir: correct value of inet type `.maxattrs`c144dff64enetfilter: nft_redir: correct length for loading protocol registers3a0f8ea35dnetfilter: nft_masq: correct length for loading protocol registerseff050d83enetfilter: nft_nat: correct length for loading protocol registers0c6c5abeb4ALSA: hda: Match only Intel devices with CONTROLLER_IN_GPU()6f0c2f70d9scsi: mpt3sas: Fix NULL pointer access in mpt3sas_transport_port_add()79fe786dabdocs: Correct missing "d_" prefix for dentry_operations member d_weak_revalidateea1e21d38aclk: HI655X: select REGMAP instead of depending on it081893e254drm/meson: fix 1px pink line on GXM when scaling video overlayed9ed2f58ccifs: Move the in_send statistic to __smb_send_rqst()a3c502218cdrm/panfrost: Don't sync rpm suspension after mmu flushing0da0b81697xfrm: Allow transport-mode states with AF_UNSPEC selector0847230e9bMerge 5.10.173 into android12-5.10-lts2b5ee1cbc1Merge 5.10.172 into android12-5.10-lts78985e3685Merge 5.10.171 into android12-5.10-lts45fa1d879aMerge 5.10.170 into android12-5.10-ltsde26e1b210Linux 5.10.175aa8579bc08s390/dasd: add missing discipline function6baebcecf0KVM: VMX: Fix crash due to uninitialized current_vmcs685ed0a277KVM: VMX: Introduce vmx_msr_bitmap_l01_changed() helper0ef55bafabKVM: nVMX: Don't use Enlightened MSR Bitmap for L39da269bee7UML: define RUNTIME_DISCARD_EXIT5c425eb9dash: define RUNTIME_DISCARD_EXITbfef72d2fcs390: define RUNTIME_DISCARD_EXIT to fix link error with GNU ld < 2.366af633e778powerpc/vmlinux.lds: Don't discard .rela* for relocatable buildsaf560685bapowerpc/vmlinux.lds: Define RUNTIME_DISCARD_EXITd367c5ebe9arch: fix broken BuildID for arm64 and riscv7550aade97ext4: block range must be validated before use in ext4_mb_clear_bb()c3fd717b58ext4: add strict range checks while freeing blocks65061f49a5ext4: add ext4_sb_block_valid() refactored out of ext4_inode_block_valid()9cd21f5babext4: refactor ext4_free_blocks() to pull out ext4_mb_clear_bb()b500560501drm/i915: Don't use BAR mappings for ring buffers with LLCc53d50d808skbuff: Fix nfct leak on napi stolena4932a2c54ipmi:watchdog: Set panic count to proper value on a panic7aa5a495cbipmi/watchdog: replace atomic_add() and atomic_sub()a5c140d88amedia: rc: gpio-ir-recv: add remove function13b04efb5bmedia: ov5640: Fix analogue gain control42bb1e6b7fscripts: handle BrokenPipeError for python scriptsbe658aa43aPCI: Add SolidRun vendor IDd47d364f66macintosh: windfarm: Use unsigned type for 1-bit bitfields9cff3f106aalpha: fix R_ALPHA_LITERAL reloc for large modules9a61a3a6ecpowerpc/kcsan: Exclude udelay to prevent recursive instrumentation5ddcb0a348MIPS: Fix a compilation issue7f77f3dab5block, bfq: fix uaf for bfqq in bic_set_bfqq()6291281f15block, bfq: replace 0/1 with false/true in bic apise6f03decf5block/bfq-iosched.c: use "false" rather than "BLK_RW_ASYNC"1425f1bb5dblock, bfq: fix uaf for bfqq in bfq_exit_icq_bfqq5533742c7cblock, bfq: fix possible uaf for 'bfqq->bic'c660e024bctpm/eventlog: Don't abort tpm_read_log on faulty ACPI addressb1fddddf58watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error pathsf2a5ec7f7biommu/amd: Add a length limitation for the ivrs_acpihid command-line parameterb113f90204ext4: Fix deadlock during directory renameab89b8a67fRISC-V: Don't check text_mutex during stop_machine3de277af48riscv: Use READ_ONCE_NOCHECK in imprecise unwinding stack modece7dd61e00SUNRPC: Fix a server shutdown leake1b8342a85net/smc: fix fallback failed while sendmsg with fastopen93367126f6platform: x86: MLX_PLATFORM: select REGMAP instead of depending on it0fe672336dscsi: megaraid_sas: Update max supported LD IDs to 240f4eae84f57net: ethernet: mtk_eth_soc: fix RX data corruption issue01a1e98109btf: fix resolving BTF_KIND_VAR after ARRAY, STRUCT, UNION, PTR065c1ed5c4netfilter: tproxy: fix deadlock due to missing BH disable26fa059cc9netfilter: ctnetlink: revert to dumping mark regardless of event typed16701a385bnxt_en: Avoid order-5 memory allocation for TPA datac0df4e5c24net: phylib: get rid of unnecessary lockingd2a5a9cdc5net: stmmac: add to set device wake up flag when stmmac init phyc3aaec463anet: caif: Fix use-after-free in cfusbl_device_notify()db16d65674net: lan78xx: fix accessing the LAN7800's internal phy specific registers from the MAC driverd5e8f7edc2net: usb: lan78xx: Remove lots of set but unused 'ret' variables374cbffe7dselftests: nft_nat: ensuring the listening side is up before starting the client42d9ed4e5dila: do not generate empty messages in ila_xlat_nl_cmd_get_mapping()6f0cc879c8powerpc: dts: t1040rdb: fix compatible string for Rev A boards80be62358fnfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_propertiescbf11ff370bgmac: fix *initial* chip reset to support BCM53584c43a0291fdrm/msm/a5xx: fix context faults during ring switch34e71ca0a0drm/msm/a5xx: fix the emptyness check in the preempt code8dde1d9d6fdrm/msm: Document and rename preempt_lock00c2020b8bdrm/msm/a5xx: fix setting of the CP_PREEMPT_ENABLE_LOCAL register08c0b54befdrm/msm: Fix potential invalid ptr free8b4a6dd157drm/nouveau/kms/nv50: fix nv50_wndw_new_ prototype9ca74e5e75drm/nouveau/kms/nv50-: remove unused functions0c440f1455ext4: Fix possible corruption when moving a directory6b223e32d6scsi: core: Remove the /proc/scsi/${proc_name} directory earliere993e3ea95riscv: Add header include guards to insn.h713c335e5ariscv: Avoid enabling interrupts in die()f9fdb3e7b0RISC-V: Avoid dereferening NULL regs in die()030b1c4217arm64: efi: Make efi_rt_lock a raw_spinlock7e00b52c8ciommu/vt-d: Fix PASID directory pointer coherencyc424b18191iommu/vt-d: Fix lockdep splat in intel_pasid_get_entry()aeab1f1a60irqdomain: Fix domain registration racebb7597777cirqdomain: Change the type of 'size' in __irq_domain_add() to be consistent4ab311d51cirqdomain: Fix mapping-creation race8617599c64irqdomain: Refactor __irq_domain_alloc_irqs()ff762cdbf0irqdomain: Look for existing mapping only once6414597815irq: Fix typos in commentsfe80a53eabudf: Fix off-by-one error when discarding preallocation7786bfd8f7nfc: change order inside nfc_se_io error path3f00c476daext4: zero i_disksize when initializing the bootloader inodea9bd94f67bext4: fix WARNING in ext4_update_inline_datad72a6c3139ext4: move where set the MAY_INLINE_DATA flag is set1d2366624bext4: fix another off-by-one fsmap error on 1k block filesystems8706c972fcext4: fix RENAME_WHITEOUT handling for inline directoriesd0632ff49bext4: fix cgroup writeback accounting with fs-layer encryption3106cb47cddrm/connector: print max_requested_bpc in state debugfs4279e87da6drm/amdgpu: fix error checking in amdgpu_read_mm_registers for soc155462843dc4x86/CPU/AMD: Disable XSAVES on AMD family 0x17a1eb8bf1e3fork: allow CLONE_NEWTIME in clone3 flagsa759905de9fs: prevent out-of-bounds array speculation when closing a file descriptor955623617fLinux 5.10.174c036dae036staging: rtl8192e: Remove call_usermodehelper starting RadioPower.sh1afff6203astaging: rtl8192e: Remove function ..dm_check_ac_dc_power calling a scriptdecf73066fwifi: cfg80211: Partial revert "wifi: cfg80211: Fix use after free for wext"e5f315b55fLinux 5.10.1738ecd5dabddusb: gadget: uvc: fix missing mutex_unlock() if kstrtou8() failsa5bbea50d6malidp: Fix NULL vs IS_ERR() checking1dfc0a52f7scsi: mpt3sas: Remove usage of dma_get_required_mask() API747652f9c5scsi: mpt3sas: re-do lost mpt3sas DMA mask fix2392303df2scsi: mpt3sas: Don't change DMA mask while reallocating poolsf73bbfb47fRevert "scsi: mpt3sas: Fix return value check of dma_get_required_mask()"331c18e8acmedia: uvcvideo: Fix race condition with usb_kill_urb9d83b69e93media: uvcvideo: Provide sync and async uvc_ctrl_status_eventc5fe3fba1bdrm/virtio: Fix error code in virtio_gpu_object_shmem_init()0a1d0c79eatcp: Fix listen() regression in 5.10.1637474be26b0Bluetooth: hci_sock: purge socket queues in the destruct() callbackd90967f850drm/display/dp_mst: Fix down message handling after a packet reception erroree4a4282d7drm/display/dp_mst: Fix down/up message handling after sink disconnect411b8ad505x86/resctl: fix scheduler confusion with 'current'9554af9801x86/resctrl: Apply READ_ONCE/WRITE_ONCE to task_struct.{rmid,closid}7123a4337bnet: tls: avoid hanging tasks on the tx_locka6549336f5soundwire: cadence: Drain the RX FIFO after an IO timeoute5ca5b7136soundwire: cadence: Remove wasted space in response_buf4d2423f15bphy: rockchip-typec: Fix unsigned comparison with less than zero01923e3196PCI: Add ACS quirk for Wangxun NICsfaa050d2ffPCI: loongson: Add more devices that need MRRS quirkdd9981a11dkernel/fail_function: fix memory leak with using debugfs_lookup()b2301851e7PCI: Take other bus devices into account when distributing resourcesfdca189e52PCI: Align extra resources for hotplug bridges properly877aacda14usb: gadget: uvc: Make bSourceID read/write56495e8d3cusb: uvc: Enumerate valid values for color matching961f93d63dUSB: ene_usb6250: Allocate enough memory for full object426cbe9a0ausb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math654ae53925PCI: loongson: Prevent LS7A MRRS increases09ca779ac0iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word()3357e90d3ciio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word()8db64cea47tools/iio/iio_utils:fix memory leak160494b66fmei: bus-fixup:upon error print return values of send and receive17b96b5c19serial: sc16is7xx: setup GPIO controller later in probe0cb1f78d88tty: serial: fsl_lpuart: disable the CTS when send break signal84ea44dc3etty: fix out-of-bounds access in tty_driver_lookup_tty()e8a5efd5aestaging: emxx_udc: Add checks for dma_alloc_coherent()c4d96503d6media: uvcvideo: Silence memcpy() run-time false positive warnings78b1fdc47emedia: uvcvideo: Quirk for autosuspend in Logitech B910 and C91023f9bead35media: uvcvideo: Handle errors from calls to usb_stringd8aa2e1ae6media: uvcvideo: Handle cameras with invalid descriptors76752888edIB/hfi1: Update RMT size calculation754e81ff44mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak903b91cea7bootconfig: Increase max nodes of bootconfig from 1024 to 8192 for DCC support07fb565336firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 325c9fba724tracing: Add NULL checks for buffer in ring_buffer_free_read_page()e30b26e746thermal: intel: BXT_PMIC: select REGMAP instead of depending on itf73134231fthermal: intel: quark_dts: fix error pointer dereference01829cb870ASoC: zl38060 add gpiolib dependency2bc1f260edASoC: zl38060: Remove spurious gpiolib selectc8e7c0ec45ASoC: adau7118: don't disable regulators on device unbindc79a924ed6loop: loop_set_status_from_info() check before assignmentaf5f9a4761scsi: ipr: Work around fortify-string warning555f315832rtc: sun6i: Always export the internal oscillator3e734e6941vc_screen: modify vcs_size() handling in vcs_read()ac73d8f6a6tcp: tcp_check_req() can be called from process context4d08ed4651ARM: dts: spear320-hmi: correct STMPE GPIO compatible2f935409cdnet/sched: act_sample: fix action bind logic8978315cb4nfc: fix memory leak of se_io context in nfc_genl_se_io8817602cffnet/mlx5: Geneve, Fix handling of Geneve object id as error code0ac65fab2b9p/rdma: unmap receive dma buffer in rdma_request()/post_recv()3e0359f1519p/xen: fix connection sequencec959a53b629p/xen: fix version parsing82a0c1fe1fnet: fix __dev_kfree_skb_any() vs drop monitor8ee401f89csctp: add a refcnt in sctp_stream_priorities to avoid a nested loopda26369377ipv6: Add lwtunnel encap size of all siblings in nexthop calculation9060abce33netfilter: ebtables: fix table blob use-after-free1ff0b87df9netfilter: ctnetlink: fix possible refcount leak in ctnetlink_create_conntrack()9f7abdd500watchdog: pcwd_usb: Fix attempting to access uninitialized memoryc5a21a5501watchdog: Fix kmemleak in watchdog_cdev_register273559f58fwatchdog: at91sam9_wdt: use devm_request_irq to avoid missing free_irq() in error path7cb46fa16bx86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list8a18856e07ubi: ubi_wl_put_peb: Fix infinite loop when wear-leveling work failed9d448dd6bcubi: Fix UAF wear-leveling entry in eraseblk_count_seq_show()0aa0253f6cubi: fastmap: Fix missed fm_anchor PEB in wear-leveling after disabling fastmapf09a84548cubifs: ubifs_writepage: Mark page dirty after writing inode failed9d4768523bubifs: dirty_cow_znode: Fix memleak in error handling path343d273d5fubifs: Re-statistic cleaned znode count if commit failedfcbc795abeubi: Fix possible null-ptr-deref in ubi_free_volume()bf50229494ubifs: Fix memory leak in alloc_wbufs()31d60afe2cubi: Fix unreferenced object reported by kmemleak in ubi_resize_volume()35f8d4064eubi: Fix use-after-free when volume resizing failed38fd7acdc1ubifs: Reserve one leb for each journal head while doing budget38a097dce1ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1495ea59a24ubifs: Fix wrong dirty space budget for dirty inode9e07ee28c2ubifs: Rectify space budget for ubifs_xrename()ffebd804c7ubifs: Rectify space budget for ubifs_symlink() if symlink is encrypted93e748ba51ubifs: Fix build errors as symbol undefined846bfba341ubi: ensure that VID header offset + VID header size <= alloc, sizef2b9c4544eum: vector: Fix memory leak in vector_config6be349d738fs: f2fs: initialize fsdata in pagecache_write()33909b1a64f2fs: use memcpy_{to,from}_page() where possible9d4a4a9ee9pwm: stm32-lp: fix the check on arr and cmp registers updatec2677c49b7pwm: sifive: Always let the first pwm_apply_state succeed8b98e7a45epwm: sifive: Reduce time the controller lock is helda1368eaea0objtool: Fix memory leak in create_static_call_sections()5d03a19ac7fs/jfs: fix shift exponent db_agl2size negative18c3fa7a7fnet/sched: Retire tcindex classifier322df540bakbuild: Port silent mode detection to future gnu make.f8ac5467e1pinctrl: rockchip: fix reading pull type on rk356850afcd5316pinctrl: rockchip: fix mux route data for rk3568844da39013wifi: ath9k: use proper statements in conditionalsa2a1e3f4edarm64: dts: qcom: ipq8074: fix Gen2 PCIe QMP PHY64a99c0ac6drm/edid: fix AVI infoframe aspect ratio handling1f064aaa81drm/radeon: Fix eDP for single-display iMac11,2266864c1e0drm/i915/quirks: Add inverted backlight quirk for HP 14-r206nv5a27124271vfio/type1: prevent underflow of locked_vm via exec()691a8e26dePCI: Avoid FLR for AMD FCH AHCI adapters88b51c6a6dPCI: hotplug: Allow marking devices as disconnected during bind/unbindd219b19e1fPCI/PM: Observe reset delay irrespective of bridge_d3285d8390d9riscv: jump_label: Fixup unaligned arch_static_branch function8f9542cad6scsi: ses: Fix slab-out-of-bounds in ses_intf_remove()c315560e3escsi: ses: Fix possible desc_ptr out-of-bounds accesses2ecd344173scsi: ses: Fix possible addl_desc_ptr out-of-bounds accessese4dd25da78scsi: ses: Fix slab-out-of-bounds in ses_enclosure_data_process()d68937dfc7scsi: ses: Don't attach if enclosure has no components0d14ace68dscsi: qla2xxx: Fix erroneous link downe596253113scsi: qla2xxx: Fix DMA-API call trace on NVMe LS requests40bedbf10dscsi: qla2xxx: Fix link failure in NPIV environment6e02a43acdring-buffer: Handle race between rb_move_tail and rb_check_pages1693f3bc1fktest.pl: Add RUN_TIMEOUT option with default unlimited39255e4788ktest.pl: Fix missing "end_monitor" when machine check fails0dfb3f4588ktest.pl: Give back console on Ctrt^C on monitored77831e69mm/thp: check and bail out if page in deferred queue alreadye6d20325f4mm: memcontrol: deprecate charge movingf1f6c87d82docs: gdbmacros: print newest record6814e8e420remoteproc/mtk_scp: Move clk ops outside send_lock3b78c2482bmedia: ipu3-cio2: Fix PM runtime usage_count in driver unbind6c96c0b2e3mips: fix syscall_get_nrcd4d3eab23dax/kmem: Fix leak of memory-hotplug resources241e893df4alpha: fix FEN fault handlingae16346078rbd: avoid use-after-free in do_rbd_add() when rbd_dev_create() fails0f2fd21b5bARM: dts: exynos: correct TMU phandle in Odroid HC17dd9de2e2fARM: dts: exynos: correct TMU phandle in Odroid XUd1887cca65ARM: dts: exynos: correct TMU phandle in Exynos5250136d6f3c5dARM: dts: exynos: correct TMU phandle in Odroid XU3 family135e968d6aARM: dts: exynos: correct TMU phandle in Exynos4aaa2d2249cARM: dts: exynos: correct TMU phandle in Exynos4210f2b478228bdm flakey: don't corrupt the zero page07e375c18adm flakey: fix logic when corrupting a bio17f81b1277thermal: intel: powerclamp: Fix cur_state for multi package system2cfe78619bwifi: cfg80211: Fix use after free for wext73090cebe3wifi: rtl8xxxu: Use a longer retry limit of 483383f79d6bdm: add cond_resched() to dm_wq_work()e6409208c1mtd: spi-nor: Fix shift-out-of-bounds in spi_nor_set_erase_type0dc0fa313bext4: refuse to create ea block when umountedd738789ae9ext4: optimize ea_inode block expansionab22799f11jbd2: fix data missing when reusing bh which is ready to be checkpointeda9cd89463eALSA: hda/realtek: Add quirk for HP EliteDesk 800 G6 Tower PCae2340769eALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls()246f26664bio_uring/poll: allow some retries for poll triggering spuriously7f3d132415io_uring: remove MSG_NOSIGNAL from recvmsg72783d2af8io_uring/rsrc: disallow multi-source reg buffersa442f12e47io_uring: add a conditional reschedule to the IOPOLL cancelation loop3d1f9533a3io_uring: mark task TASK_RUNNING before handling resume/task work3f32f8492eio_uring: handle TIF_NOTIFY_RESUME when checking for task_work306c8b49b5irqdomain: Drop bogus fwspec-mapping error handlinge0538aa7e0irqdomain: Fix disassociation race6b24bd85aeirqdomain: Fix association race8c64acd24aima: Align ima_file_mmap() parameters with mmap_file LSM hookc1aa96927bbrd: return 0/-error from brd_insert_page()3326ef84cdDocumentation/hw-vuln: Document the interaction between IBRS and STIBPabfed855f0x86/speculation: Allow enabling STIBP with legacy IBRS44a44b57e8x86/microcode/AMD: Fix mixed steppings support87cf9bc78cx86/microcode/AMD: Add a @cpu parameter to the reloading functions0a89768b85x86/microcode/amd: Remove load_microcode_amd()'s bsp parameter5255fd8dfbx86/kprobes: Fix arch_check_optimized_kprobe check within optimized_kprobe rangec16e4610d5x86/kprobes: Fix __recover_optprobed_insn check optimizing logicf75ee95196x86/reboot: Disable SVM, not just VMX, when stopping CPUs051f991c57x86/reboot: Disable virtualization in an emergency if SVM is supported8ff2cc2f87x86/crash: Disable virt in core NMI crash handler to avoid double shootdown537be939a8x86/virt: Force GIF=1 prior to disabling SVM (for reboot flows)edd7f5bc6fKVM: s390: disable migration mode when dirty tracking is disabled018798c6fbKVM: x86: Inject #GP if WRMSR sets reserved bits in APIC Self-IPI76a9886e1bKVM: Destroy target device if coalesced MMIO unregistration failsbacfce056eudf: Fix file corruption when appending just after end of preallocated extenta44ec34b90udf: Detect system inodes linked into directory hierarchy63478c3ce2udf: Preserve link count of system fileseb2133900cudf: Do not update file length for failed writes to inline files965982feb3udf: Do not bother merging very long extents9c792a59e0udf: Truncate added extents on failed expansion6bf9caa585ocfs2: fix non-auto defrag path not working issue2c559b3ba8ocfs2: fix defrag path triggering jbd2 ASSERTe9f20138b5f2fs: fix cgroup writeback accounting with fs-layer encryption00b5587326f2fs: fix information leak in f2fs_move_inline_dirents()f9dbc35ecbexfat: fix inode->i_blocks for non-512 byte sector size device4017209e08exfat: redefine DIR_DELETED as the bad cluster numberc2d1997074exfat: fix unexpected EOF while reading dir34b0588341exfat: fix reporting fs error when reading dir beyond EOFef7d71d7bdfs: hfsplus: fix UAF issue in hfsplus_put_superdc9f78b6d2hfs: fix missing hfs_bnode_get() in __hfs_bnode_create300b6404e6ARM: dts: exynos: correct HDMI phy compatible in Exynos469493675fdcifs: Fix uninitialized memory read in smb3_qfs_tcon()59102ded74s390/kprobes: fix current_kprobe never cleared after kprobes reenterd8724dc0ces390/kprobes: fix irq mask clobbering on kprobe reenter from post_handlerd43abcf91cs390: discard .interp section6cf48403c4s390/extmem: return correct segment type in __segment_load()be2dad7bc9ipmi_ssif: Rename idle state and check66b40f8756rtc: pm8xxx: fix set-alarm racee5b643645afirmware: coreboot: framebuffer: Ignore reserved pixel color bitsbf990eebeawifi: rtl8xxxu: fixing transmisison failure for rtl8192eu759f6a72bcnfsd: zero out pointers after putting nfsd_files on COPY setup error9b8047b210dm cache: add cond_resched() to various workqueue loops52206dd1c7dm thin: add cond_resched() to various workqueue loops861229a52bdrm: panel-orientation-quirks: Add quirk for Lenovo IdeaPad Duet 3 10IGL57df5da8e6bHID: logitech-hidpp: Don't restart communication if not necessaryca64ebcb45pinctrl: at91: use devm_kasprintf() to avoid potential leaks5735878a7bhwmon: (coretemp) Simplify platform device handling2f8623377fgfs2: Improve gfs2_make_fs_rw error handlingbfa4ffd815regulator: s5m8767: Bounds check id indexing into arraysb4ff71c6f0regulator: max77802: Bounds check regulator id against opmode0adacf6d6bASoC: kirkwood: Iterate over array indexes instead of using pointer mathfcfc774022docs/scripts/gdb: add necessary make scripts_gdb step540c66180adrm/msm/dsi: Add missing check for alloc_ordered_workqueued473c55ce1drm: amd: display: Fix memory leakagece9e9d3dcbdrm/radeon: free iio for atombios when driver shutdown819d8dba03drm/tiny: ili9486: Do not assume 8-bit only SPI controllersbc919c866dHID: Add Mapping for System Microphone Mutef4cb425252drm/omap: dsi: Fix excessive stack usage9f73793b81drm/amd/display: Fix potential null-deref in dm_resume348cc9ab33Bluetooth: btusb: Add VID:PID 13d3:3529 for Realtek RTL8821CEe974e8f1e3PM: EM: fix memory leak with using debugfs_lookup()0c2b778edduaccess: Add minimum bounds check on kernel buffer sized80f947bb3coda: Avoid partial allocation of sig_inputArgs206c511e42net/mlx5: fw_tracer: Fix debug print1ef724fed3ACPI: video: Fix Lenovo Ideapad Z570 DMI match46ce77b07cwifi: mt76: dma: free rx_head in mt76_dma_rx_cleanup7873def499m68k: Check syscall_trace_enter() return code8418813205net: bcmgenet: Add a check for oversized packets1fc9760afdcrypto: hisilicon: Wipe entire pool on error2fc7748d48clocksource: Suspend the watchdog temporarily when high read latency detected94933dab75ACPI: Don't build ACPICA with '-Os'9f1865ebfaice: add missing checks for PF vsi typeb33091fc28inet: fix fast path in __inet_hash_connect()47dc1f425awifi: mt7601u: fix an integer underflow0ca2efea4fwifi: brcmfmac: ensure CLM version is null-terminated to prevent stack-out-of-bounds4707c94f7fx86/bugs: Reset speculation control settings on init6ef02cdb5atimers: Prevent union confusion from unexpected restart_syscall()781bff0a53thermal: intel: Fix unsigned comparison with less than zero744e538dcfwifi: ath11k: debugfs: fix to work with multiple PCI devicesd99d194e2frcu-tasks: Make rude RCU-Tasks work well with CPU hotplug2bf501f1bcrcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait()f5657f3306rcu: Make RCU_LOCKDEP_WARN() avoid early lockdep checksd6ef66194bwifi: brcmfmac: Fix potential stack-out-of-bounds in brcmf_c_preinit_dcmds()99ff971b62wifi: ath9k: Fix use-after-free in ath9k_hif_usb_disconnect()6e291810feblk-iocost: fix divide by 0 error in calc_lcoefs()199624f314ARM: dts: exynos: Use Exynos5420 compatible for the MIPI video phyf34cc701eaudf: Define EFSCORRUPTED error code91f9d70871rpmsg: glink: Avoid infinite loop on intent for missing channel2b72ceef17media: saa7134: Use video_unregister_device for radio_dev42f8ba8355media: usb: siano: Fix use after free bugs caused by do_submit_urbcc2f9c8eb1media: i2c: ov7670: 0 instead of -EINVAL was returned78da5a378bmedia: rc: Fix use-after-free bugs caused by ene_tx_irqsim()c6c3b4ae31media: i2c: imx219: Fix binning for RAW8 capturea34288e3a1media: i2c: imx219: Split common registers from mode tables09a0410886media: i2c: imx219: remove redundant writesdfaafeb8e9media: i2c: ov772x: Fix memleak in ov772x_probe()bcae9115a1media: ov5675: Fix memleak in ov5675_init_controls()a163ee1134media: ov2740: Fix memleak in ov2740_init_controls()505ff3a0c5media: max9286: Fix memleak in max9286_v4l2_register()f3e10a3437builddeb: clean generated package content55f3bca25dpowerpc: Remove linker flag from KBUILD_AFLAGSb74aaa314fmedia: platform: ti: Add missing check for devm_regulator_getc7a218cbf6media: ti: cal: fix possible memory leak in cal_ctx_create()0a2e2674f7remoteproc: qcom_q6v5_mss: Use a carveout to authenticate modem headers7e5bc675ebInput: iqs269a - do not poll during ATI65e39fdce1Input: iqs269a - do not poll during suspend or resumeb0b84fd32calpha/boot/tools/objstrip: fix the check for ELF header4cab7debf3vdpa/mlx5: Don't clear mr struct on destroy MRbccccd43a0MIPS: vpe-mt: drop physical_memsize132203ce40MIPS: SMP-CPS: fix build error when HOTPLUG_CPU not set6fc6d29be8powerpc/eeh: Set channel state after notifying the driversdfc41e3859powerpc/eeh: Small refactor of eeh_handle_normal_event()386cc2af90powerpc/rtas: ensure 4KB alignment for rtas_data_bufc9a299f2f4powerpc/rtas: make all exports GPL7afd768784powerpc/pseries/lparcfg: add missing RTAS retry status handlingdf995aef64powerpc/pseries/lpar: add missing RTAS retry status handling9626f83a6epowerpc/perf/hv-24x7: add missing RTAS retry status handling831a2d8de1clk: Honor CLK_OPS_PARENT_ENABLE in clk_core_is_enabled()4f060379aapowerpc/powernv/ioda: Skip unallocated resources when mapping to PE15fed9258bclk: qcom: gpucc-sdm845: fix clk_dis_wait being programmed for CX GDSC241048adcbclk: qcom: gpucc-sc7180: fix clk_dis_wait being programmed for CX GDSC1957c5b5ecInput: ads7846 - don't check penirq immediately for 78458d9b9e56c2Input: ads7846 - always set last command to PWRDOWNd247f3527bInput: ads7846 - convert to one messagea6c4384446Input: ads7846 - convert to full duplex7f2034b9b0Input: ads7846 - don't report pressure for ads7845092effd9f9clk: imx: avoid memory leak092f17eca8clk: renesas: cpg-mssr: Remove superfluous check in resume code7beb9b4538clk: renesas: cpg-mssr: Fix use after free if cpg_mssr_common_init() failed44a2a912c7linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h>9a6dca86cfInput: iqs269a - configure device with a single block writeb7afc359f6Input: iqs269a - increase interrupt handler return delaya6a70ab2bbInput: iqs269a - drop unused device node referencesb7fb5b5d2cmtd: rawnand: sunxi: Fix the size of the last OOB regionc90fa32bd4RISC-V: fix funct4 definition for c.jalr in parse_asm.hc7950aa872clk: qcom: gcc-qcs404: fix names of the DSI clocks used as parents7fd6fd898bclk: qcom: gcc-qcs404: disable gpll[04]_out_aux parents3ee13bdf0dmfd: pcf50633-adc: Fix potential memleak in pcf50633_adc_async_read()8a041377a4objtool: add UACCESS exceptions for __tsan_volatile_read/write455cf05161printf: fix errname.c listb18946a9ceselftests/ftrace: Fix bash specific "==" operatorb8dc9f6fdesparc: allow PM configs for sparc32 COMPILE_TEST93925ab9ddperf tools: Fix auto-complete on aarch641d6101d922leds: led-core: Fix refcount leak in of_led_get()071b7f5720perf llvm: Fix inadvertent file creationdeece7bd60gfs2: jdata writepage fixcfd85a0922cifs: Fix warning and UAF when destroy the MR listcaac205e0dcifs: Fix lost destroy smbd connection when MR allocate failed9e8ccaf4ffnfsd: fix race to check ls_layoutse73640184chid: bigben_probe(): validate report countfddde36316HID: bigben: use spinlock to safely schedule workersec8b79668eHID: bigben_worker() remove unneeded check on report_field2ca8ae5cf6HID: bigben: use spinlock to protect concurrent accessesf69065e1bdASoC: soc-dapm.h: fixup warning struct snd_pcm_substream not declaredc785a87d9aspi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()ac3a513d4fNFS: fix disabling of swap242df51a82nfs4trace: fix state manager flag printing6d434b4c49NFSv4: keep state manager thread active if swap is enabledd601f78282NFS: Fix up handling of outstanding layoutcommit in nfs_update_inode()c550f65a54dm: remove flush_scheduled_work() during local_exit()f23a4b9bf8ASoC: tlv320adcx140: fix 'ti,gpio-config' DT property init4c6d18ea71hwmon: (mlxreg-fan) Return zero speed for broken fana79f1e71e7spi: bcm63xx-hsspi: Fix multi-bit mode setting59b0ce292aspi: bcm63xx-hsspi: fix pm_runtimeca769960cbscsi: aic94xx: Add missing check for dma_map_single()30c7c72b6cscsi: mpt3sas: Fix a memory leak0cb8a92a88drm/amdgpu: fix enum odm_combine_mode mismatch859bdc96bahwmon: (ltc2945) Handle error case in ltc2945_value_stored9bcf67b8bASoC: dt-bindings: meson: fix gx-card codec node regexb4d74716daASoC: mchp-spdifrx: Fix uninitialized use of mr in mchp_spdifrx_hw_params()ce07bbe038ASoC: mchp-spdifrx: disable all interrupts in mchp_spdifrx_dai_remove()d8f5539b5eASoC: mchp-spdifrx: fix controls that works with completion mechanism45956f1764ASoC: mchp-spdifrx: fix return value in case completion times out426423ed55ASoC: atmel: fix spelling mistakes1983a70778ASoC: mchp-spdifrx: fix controls which rely on rsr registerb33ca7b7bbspi: dw_bt1: fix MUX_MMIO dependencies33033f392dgpio: vf610: connect GPIO label to dev namef2f6e683d9ASoC: soc-compress.c: fixup private_data on snd_soc_new_compress()6a89ddee16drm/mediatek: Clean dangling pointer on bind error pathb64b6dff15drm/mediatek: mtk_drm_crtc: Add checks for devm_kcalloc3a50d86696drm/mediatek: Drop unbalanced obj unref55bc7babc0drm/mediatek: Use NULL instead of 0 for NULL pointerda5fd53999drm/mediatek: dsi: Reduce the time of dsi from LP11 to sending cmdcfd710a7e5gpu: host1x: Don't skip assigning syncpoints to channels53f98ffcd8pinctrl: mediatek: Initialize variable *buf to zerod2eb2e7125pinctrl: mediatek: Initialize variable pullen and pullup to zeroa46d29437bpinctrl: bcm2835: Remove of_node_put() in bcm2835_of_gpio_ranges_fallback()49907c8873drm/msm/mdp5: Add check for kzalloce9743b3052drm/msm/dpu: Add check for pstates31f2f8de0edrm/msm/dpu: Add check for cstate70bc4db1fbdrm/msm: use strscpy instead of strncpy23770064a3drm/mipi-dsi: Fix byte order of 16-bit DCS set/get brightness10c58ca62adrm/bridge: lt9611: pass a pointer to the of nodeffd4cbd7eadrm/bridge: lt9611: fix clock calculationaa37ec52c1drm/bridge: lt9611: fix programming of video modesbffd007802drm/bridge: lt9611: fix polarity programming3c865a0146drm/bridge: lt9611: fix HPD reenablement88618e800adrm/bridge: lt9611: fix sleep mode setup8dbd54d679drm/msm/dpu: Disallow unallocated resources to be returned42fdae9f59ALSA: hda/ca0132: minor fix for allocation sizeb26bd7791fdrm/msm/adreno: Fix null ptr access in adreno_gpu_cleanup()a3bf72eab8ASoC: fsl_sai: initialize is_dsp_mode flagd4438cbd9cdrm/vc4: hdmi: Correct interlaced timings again15a6be1011drm/vc4: hvs: Fix colour order for xRGB1555 on HVS5bc65127ba4drm/vc4: hvs: Set AXI panic modesd562054a3apinctrl: rockchip: Fix refcount leak in rockchip_pinctrl_parse_groups3dd6f15938pinctrl: rockchip: do coding style for mux route struct6da121152apinctrl: rockchip: add support for rk35688ab860dd87pinctrl: stm32: Fix refcount leak in stm32_pctrl_get_irq_domain86704e50ffpinctrl: qcom: pinctrl-msm8976: Correct function names for wcss pins1bab31a096drm/msm/hdmi: Add missing check for alloc_ordered_workqueue8eb74bd9c9gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id()fdcacfd110drm: tidss: Fix pixel format definition2adbcf94ebdrm/vc4: dpi: Fix format mapping for RGB56509c6e21d6adrm/vc4: dpi: Add option for inverting pixel clock and output enable0b8f390e22drm/vkms: Fix null-ptr-deref in vkms_release()5b9bcb33cfdrm/bridge: megachips: Fix error handling in i2c_register_driver()181fb5efb6drm: mxsfb: DRM_MXSFB should depend on ARCH_MXS || ARCH_MXCa86bd12bd9drm/fourcc: Add missing big-endian XRGB1555 and RGB565 formats5ae70041a6drm: Fix potential null-ptr-deref due to drmm_mode_config_init()8f06907f9fsefltests: netdevsim: wait for devlink instance after netns removal6038e45879selftest: fib_tests: Always cleanup before exite1c848d9ddnet: bcmgenet: fix MoCA LED control4a413d3609l2tp: Avoid possible recursive deadlock in l2tp_tunnel_register()5663df2062selftests/net: Interpret UDP_GRO cmsg data as an int value7cefa69222irqchip/irq-bcm7120-l2: Set IRQ_LEVEL for level triggered interrupts27a601623dirqchip/irq-brcmstb-l2: Set IRQ_LEVEL for level triggered interrupts9f487d888ebpf: Fix global subprog context argument resolution logic3e8733949fcan: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case of a bus errore02bc49288thermal/drivers/hisi: Drop second sensor hi36603856f75597wifi: mac80211: make rate u32 in sta_set_rate_info_rx()f333346001crypto: crypto4xx - Call dma_unmap_page when doneb10827bce7selftests/bpf: Fix out-of-srctree buildd7c5ecbc49wifi: mwifiex: fix loop iterator in mwifiex_update_ampdu_txwinsize()3185d6cfc5wifi: iwl4965: Add missing check for create_singlethread_workqueue()2f80b3ff92wifi: iwl3945: Add missing check for create_singlethread_workqueue5da95a7eb9RISC-V: time: initialize hrtimer based broadcast clock event devicedabc22a30dm68k: /proc/hardware should depend on PROC_FSc9c8714226crypto: rsa-pkcs1pad - Use akcipher_request_completeeb209a35d3rds: rds_rm_zerocopy_callback() correct order for list_add_tail()b7aa7fbc16libbpf: Fix alen calculation in libbpf_nla_dump_errormsg()b8ed41cc04Bluetooth: L2CAP: Fix potential user-after-free4f4c970a05OPP: fix error checking in opp_migrate_dentry()4a9272a864tap: tap_open(): correctly initialize socket uid9a31af61f3tun: tun_chr_open(): correctly initialize socket uid2416abd6banet: add sock_init_data_uid()4a614a68d9s390/vmem: fix empty page tables cleanup under KASANdf8d3536b6irqchip/ti-sci: Fix refcount leak in ti_sci_intr_irq_domain_probecee12e8be8irqchip/irq-mvebu-gicp: Fix refcount leak in mvebu_gicp_probec9aaf4efe1irqchip/alpine-msi: Fix refcount leak in alpine_msix_init_domainsb00baffcc2irqchip: Fix refcount leak in platform_irqchip_probe9cc2a41c58net/mlx5: Enhance debug print in page allocation failure94c4eafbbdbpftool: profile online CPUs instead of possible627e140a5bcrypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware959bd9d42acrypto: ccp - Refactor out sev_fw_alloc()6952629bedleds: led-class: Add missing put_device() to led_put()92a07ba4f0crypto: xts - Handle EBUSY correctly1198484164net: ethernet: ti: add missing of_node_put before return80c81aafc9net: ethernet: ti: am65-cpsw: handle deferred probe with dev_err_probe()37f0ca73fenet: ethernet: ti: am65-cpsw: fix tx csum offload for multi mac mode8e83e1619fx86/microcode: Adjust late loading result reporting message511e27e5fdx86/microcode: Check CPU capabilities after late microcode update correctly89e848bb4ax86/microcode: Add a parameter to microcode_check() to store CPU capabilitiesf5e78fa916x86/microcode: Print previous version of microcode after reloade623080668x86/microcode: Default-disable late loading9e56938f20x86/microcode: Rip out the OLD_INTERFACE8078a170bax86: Mark stop_this_cpu() __noreturn3900b7de1dx86/microcode: Replace deprecated CPU-hotplug functions.2e3bd75f64x86/cpu: Init AP exception handling from cpu_init_secondary()0e7a569929powercap: fix possible name leak in powercap_register_zone()ae849d2f48crypto: seqiv - Handle EBUSY correctly796e02cca3crypto: essiv - Handle EBUSY correctly62d428c9fecrypto: ccp - Failure on re-initialization due to duplicate sysfs filename6fb7dead79ACPI: battery: Fix missing NUL-termination with large strings45a1ca6f3awifi: cfg80211: Fix extended KCK key length check in nl80211_set_rekey_data()137963e3b9wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup78b56b0a61wifi: ath9k: Fix potential stack-out-of-bounds write in ath9k_wmi_rsp_callback()f26dd69f61wifi: ath9k: hif_usb: clean up skbs if ath9k_hif_usb_rx_stream() fails5668e63e26ath9k: htc: clean up statistics macros221f9bd5ecath9k: hif_usb: simplify if-if to if-elseec246dfe00wifi: ath9k: htc_hst: free skb in ath9k_htc_rx_msg() if there is no callback functionb44178e718wifi: orinoco: check return value of hermes_write_wordrec()430f9f9becwifi: rtl8xxxu: Fix memory leaks with RTL8723BU, RTL8192EU695f1d9431thermal/drivers/tsens: Sort out msm8976 vs msm8956 data40f62ff0d7thermal/drivers/tsens: Add compat string for the qcom,msm8960a9f2002484thermal/drivers/qcom/tsens_v1: Enable sensor 3 on MSM8976e6ec7fa688thermal/drivers/tsens: Drop msm8976-specific defines5419cd28c8ACPICA: nsrepair: handle cases without a return value correctly4c33e01fe1crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID24c5300f6f5crypto: ccp - Use kzalloc for sev ioctl interfaces to prevent kernel memory leakdaaec051cdcrypto: ccp: Use the stack and common buffer for status commandsc997b509fdcrypto: ccp: Use the stack for small SEV command buffers318dd6f5b7lib/mpi: Fix buffer overrun when SG is too long1c37e86a78rcu-tasks: Fix synchronize_rcu_tasks() VS zap_pid_ns_processes()ad410f64f7rcu-tasks: Remove preemption disablement around srcu_read_[un]lock() callsb02b6bb83crcu-tasks: Improve comments explaining tasks_rcu_exit_srcu purposea4935bb734genirq: Fix the return type of kstat_cpu_irqs_sum()5562585c4aACPICA: Drop port I/O validation for some regions6e43b2d9d1crypto: x86/ghash - fix unaligned access in ghash_setkey()f6e429cde9wifi: wl3501_cs: don't call kfree_skb() under spin_lock_irqsave()93b8809be5wifi: libertas: cmdresp: don't call kfree_skb() under spin_lock_irqsave()2ddb1820bdwifi: libertas: main: don't call kfree_skb() under spin_lock_irqsave()647230e71ewifi: libertas: if_usb: don't call kfree_skb() under spin_lock_irqsave()0258757caawifi: libertas_tf: don't call kfree_skb() under spin_lock_irqsave()b4b4447481wifi: brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid()e08e6812efwifi: brcmfmac: fix potential memory leak in brcmf_netdev_start_xmit()a1e94fb4d0wifi: wilc1000: fix potential memory leak in wilc_mac_xmit()8a2eb9d9d0wifi: ipw2200: fix memory leak in ipw_wdev_init()841ae9b924wifi: ipw2x00: don't call dev_kfree_skb() under spin_lock_irqsave()3938f01405libbpf: Fix btf__align_of() by taking into account field offsets1e950b9a84wifi: rtlwifi: Fix global-out-of-bounds bug in _rtl8812ae_phy_set_txpower_limit()d4fddfd728rtlwifi: fix -Wpointer-sign warning75f4eed70awifi: rtl8xxxu: don't call dev_kfree_skb() under spin_lock_irqsave()9c8f50c743wifi: libertas: fix memory leak in lbs_init_adapter()e9ef5631ddwifi: iwlegacy: common: don't call dev_kfree_skb() under spin_lock_irqsave()0e5b782c1cwifi: rtlwifi: rtl8723be: don't call kfree_skb() under spin_lock_irqsave()97018e737bwifi: rtlwifi: rtl8188ee: don't call kfree_skb() under spin_lock_irqsave()d85d0b1a61wifi: rtlwifi: rtl8821ae: don't call kfree_skb() under spin_lock_irqsave()efc8df9705wifi: rsi: Fix memory leak in rsi_coex_attach()0a82c1e057block: bio-integrity: Copy flags when bio_integrity_payload is cloned895cb50196x86/perf/zhaoxin: Add stepping check for ZXC80a1751730sched/rt: pick_next_rt_entity(): check list_entry53dbbe3634sched/deadline,rt: Remove unused parameter from pick_next_[rt|dl]_entity()a50e28d433s390/dasd: Fix potential memleak in dasd_eckd_init()72aebdac39s390/dasd: Prepare for additional path event handlinga33c33593bblk-mq: correct stale comment of .get_budget2c58012d96blk-mq: remove stale comment for blk_mq_sched_mark_restart_hctx12bcc4ec54blk-mq: avoid sleep in blk_mq_alloc_request_hctxd7cf3864d7arm64: dts: mediatek: mt7622: Add missing pwm-cells to pwm nodee874629c5fARM: dts: imx7s: correct iomuxc gpr mux controller cellsbbddc7c708ARM: dts: sun8i: nanopi-duo2: Fix regulator GPIO referencea451c1377aarm64: dts: renesas: beacon-renesom: Fix gpio expander reference4c37a37743arm64: dts: amlogic: meson-gxbb-kii-pro: fix led node namec39c3ed4a3arm64: dts: amlogic: meson-gxl-s905d-phicomm-n1: fix led node name269fd2fb04arm64: dts: amlogic: meson-gx-libretech-pc: fix update button name373bb505ffarm64: dts: amlogic: meson-gxl: add missing unit address to eth-phy-mux node name1c30db46ddarm64: dts: amlogic: meson-gx: add missing unit address to rng node name436060c1b6arm64: dts: amlogic: meson-gxl-s905d-sml5442tw: drop invalid clock-names property6a46320f2aarm64: dts: amlogic: meson-gx: add missing SCPI sensors compatibleeb5f2c5657arm64: dts: amlogic: meson-axg: fix SCPI clock dvfs node namea7163b258aarm64: dts: amlogic: meson-gx: fix SCPI clock dvfs node name14736f2eaeARM: imx: Call ida_simple_remove() for ida_simple_get23134f7a54ARM: dts: exynos: correct wr-active property in Exynos3250 Rinato5325b8a120arm64: dts: ti: k3-j7200: Fix wakeup pinmux range4811cfd286ARM: s3c: fix s3c64xx_set_timer_source prototype66315db914ARM: OMAP1: call platform_device_put() in error case in omap1_dm_timer_init()1fa673af0aarm64: dts: meson: remove CPU opps below 1GHz for G12A boardsc56595b948arm64: dts: qcom: ipq8074: correct PCIe QMP PHY output clock names192cb335d8arm64: dts: qcom: ipq8074: fix Gen3 PCIe nodee839d027d7arm64: dts: qcom: ipq8074: correct Gen2 PCIe ranges77970cf389arm64: dts: qcom: ipq8074: fix Gen3 PCIe QMP PHY9b5b1652e3arm64: dts: qcom: ipq8074: fix PCIe PHY serdes size8f1cb871f9arm64: dts: qcom: Fix IPQ8074 PCIe PHY nodes7ee2ca51e3arm64: dts: qcom: ipq8074: correct USB3 QMP PHY-s clock output names5633e86ccearm64: dts: meson-gx: Fix the SCPI DVFS node name and unit addressbd55aa16bfarm64: dts: meson-g12a: Fix internal Ethernet PHY unit name8303a34fcearm64: dts: meson-gx: Fix Ethernet MAC address unit name2df155a114arm64: dts: qcom: sc7180: correct SPMI bus address cells64b69cb420arm64: dts: qcom: sdm845-db845c: fix audio codec interrupt pin name717aa39846arm64: dts: mediatek: mt8183: Fix systimer 13 MHz clock description227f8c1c5cARM: zynq: Fix refcount leak in zynq_early_slcr_init644688a921arm64: dts: qcom: qcs404: use symbol names for PCIe resets4862c41d5fARM: OMAP2+: Fix memory leak in realtime_counter_init()e1bb97947cpowerpc/mm: Rearrange if-else block to avoid clang warning21a2eec4a4HID: asus: use spinlock to safely schedule workers6a63a3334aHID: asus: use spinlock to protect concurrent accessescb8382c371HID: asus: Remove check for same LED brightness on set9fd42770b5Linux 5.10.172da24142b1eio_uring: ensure that io_init_req() passes in the right issue_flagsa02b4a8660Revert "nvmem: core: Fix a conflict between MTD and NVMEM on wp-gpios property"d480976b05Revert "nvmem: core: remove nvmem_config wp_gpio"a4160f76c7Revert "nvmem: core: fix cleanup after dev_set_name()"07d89b34a9Revert "nvmem: core: fix registration vs use race"365c551e77Revert "nvmem: core: fix return value"a25aa776b0Linux 5.10.17108681391b8io_uring: add missing lock in io_get_file_fixed218925bfd5USB: core: Don't hold device lock while reading the "descriptors" sysfs filec5360eec64usb: gadget: u_serial: Add null pointer check in gserial_resumecebcd4300aUSB: serial: option: add support for VW/Skoda "Carstick LTE"87c647def3drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling0a4181b23adrm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_inita401ef0557scripts/tags.sh: fix incompatibility with PCRE265c07e15f2scripts/tags.sh: Invoke 'realpath' via 'xargs'1c44109c30md: Flush workqueue md_rdev_misc_wq in md_alloc()80653a6e6evc_screen: don't clobber return value in vcs_read3e4bbd1f38net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues().a2957adbf3bpf: bpf_fib_lookup should not return neigh in NUD_FAILED state75fbe1e435HID: core: Fix deadloop in hid_apply_multiplier.2fd5059f4fneigh: make sure used and confirmed times are valid065f6a6633IB/hfi1: Assign npages earlier6195cea4c7btrfs: send: limit number of clones and allocated memory size8e833fe47fACPI: NFIT: fix a potential deadlock during NFIT teardownabbf52efadARM: dts: rockchip: add power-domains property to dp node on rk32881f3a209b2farm64: dts: rockchip: drop unused LED mode property from rk3328-roc-cc887975834dFix XFRM-I support for nested ESP tunnels0caf8151c2Merge 5.10.169 into android12-5.10-ltsbb0ae42d0bRevert "Revert "nvmem: core: Fix a conflict between MTD and NVMEM on wp-gpios property""22d269bb30Linux 5.10.17012e3119a87bpf: add missing header file includec44e96d6c3Revert "net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs"1ba10d3640ext4: Fix function prototype mismatch for ext4_feat_ktype01e652f03aaudit: update the mailing list in MAINTAINERSe1dc3f102awifi: mwifiex: Add missing compatible string for SD87874311ad1e76nbd: fix possible overflow on 'first_minor' in nbd_dev_add()2e0c3e43ebnbd: fix possible overflow for 'first_minor' in nbd_dev_add()fd8107206anbd: fix max value for 'first_minor'f3f6b33b77Revert "Revert "block: nbd: add sanity check for first_minor""3b6ce54cfauaccess: Add speculation barrier to copy_from_user()267f62b7f3mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh3d743415c6drm/i915/gvt: fix double free bug in split_2MB_gtt_entryb50f6fc9d7powerpc: dts: t208x: Disable 10G on MAC1 and MAC26a3fb887dacan: kvaser_usb: hydra: help gcc-13 to figure out cmd_len1b0cafaae8KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRSc41d856b70KVM: SVM: Skip WRMSR fastpath on VM-Exit if next RIP isn't valida7ef904b68KVM: x86: Fail emulation during EMULTYPE_SKIP on any exception119e75d8ferandom: always mix cycle counter in add_latent_entropy()2da1f95085clk: mxl: syscon_node_to_regmap() returns error pointers1423d88753powerpc: dts: t208x: Mark MAC1 and MAC2 as 10Gcaa47d9173clk: mxl: Fix a clk entry by adding relevant flags9dcf2ca5d3clk: mxl: Add option to override gate clks3789e905f4clk: mxl: Remove redundant spinlocks072eb5fbd6clk: mxl: Switch from direct readl/writel based IO to regmap based IO051d73eb9awifi: rtl8xxxu: gen2: Turn on the rate controleb9236d74cdrm/etnaviv: don't truncate physical page address2ae7379698Linux 5.10.169e953810345nvmem: core: fix return valuec00867afe4net: sched: sch: Fix off by one in htb_activate_prios()31167df7c2ASoC: SOF: Intel: hda-dai: fix possible stream_tag leak6af2872cc6alarmtimer: Prevent starvation by small intervals and SIG_IGN6416c2108bkvm: initialize all of the kvm_debugregs structure before sending it to userspace4fe9950815net/sched: tcindex: search key must be 16 bitsb452e20b95i40e: Add checking for null for nlmsg_find_attr()5dfa51dbfcnet/sched: act_ctinfo: use percpu stats015ea70d72flow_offload: fill flags to action structure1d76a84448drm/i915/gen11: Wa_1408615072/Wa_1407596294 should be on GT list210e601180drm/i915/gen11: Moving WAs to icl_gt_workarounds_init()0ee5ed0126nilfs2: fix underflow in second superblock position calculations7546fb3554ipv6: Fix tcp socket connection with DSCP.5337bb508bipv6: Fix datagram socket connection with DSCP.1a4a5fd652ixgbe: add double of VLAN header when computing the max MTU7ff0fdba82net: mpls: fix stale pointer if allocation fails during device rename2dd914105anet: stmmac: Restrict warning on disabling DMA store and fwd mode7eb8ebb5e8bnxt_en: Fix mqprio and XDP ring checking logiccc7ca4871anet: stmmac: fix order of dwmac5 FlexPPS parametrization sequencec0f65ee0a3net: openvswitch: fix possible memory leak in ovs_meter_cmd_set()525bdcb083net/usb: kalmia: Don't pass act_len in usb_bulk_msg error path9d68bfa220dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions.eb8e9d8572net/sched: tcindex: update imperfect hash filters respecting rcu747a17e25asctp: sctp_sock_filter(): avoid list_entry() on possibly empty lista5c51e0c32net: bgmac: fix BCM5358 support by setting correct flags23974088fdi40e: add double of VLAN header when computing the max MTU152a5f32acixgbe: allow to increase MTU to 3K with XDP enabled3a63392c19revert "squashfs: harden sanity check in squashfs_read_xattr_id_table"e2bf52ff15net: Fix unwanted sign extension in netdev_stats_to_stats64()1933be146cRevert "mm: Always release pages to the buddy allocator in memblock_free_late()."9662320238hugetlb: check for undefined shift on 32 bit architecturesec9c7aa088sched/psi: Fix use-after-free in ep_remove_wait_queue()7ed5c14722ALSA: hda/realtek - fixed wrong gpio assigned59d5c80ce5ALSA: hda/conexant: add a new hda codec SN61800b3edcb24bmmc: mmc_spi: fix error handling in mmc_spi_probe()30716d9f0fmmc: sdio: fix possible resource leaks in some error paths73ad25c50dmmc: jz4740: Work around bug on JZ4760(B)eaba3f9b67netfilter: nft_tproxy: restrict to prerouting hook6618b0dcf2ovl: remove privs in ovl_fallocate()f6f94837d9ovl: remove privs in ovl_copyfile()645df4047bs390/signal: fix endless loop in do_signalc261f798f7aio: fix mremap after fork null-deref2dcb474af1nvmem: core: fix registration vs use race23676ecd2envmem: core: fix cleanup after dev_set_name()89991ededcnvmem: core: remove nvmem_config wp_gpioa19a0f67dbnvmem: core: add error handling for dev_set_name25f65c83f5platform/x86: touchscreen_dmi: Add Chuwi Vi8 (CWI501) DMI matchecf5b49df3nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association55dbd6f4eas390/decompressor: specify __decompress() buf len to avoid overflow90fcf55d83net: sched: sch: Bounds check priority614a58e00dnet: stmmac: do not stop RX_CLK in Rx LPI state for qcs404 SoCaa84a8cc1bnet/rose: Fix to not accept on connected socket37bb61763dtools/virtio: fix the vringh test for virtio ring changes3ec44268e2ASoC: cs42l56: fix DT probe7fc4e7191eALSA: hda: Do not unset preset when cleaning up codec490fcbc7b5selftests/bpf: Verify copy_register_state() preserves parent/live fields7d3a5ec579ASoC: Intel: sof_rt5682: always set dpcm_capture for amplifiers Update the .xml file to handle the ABI update in the LTS branch: Leaf changes summary: 1 artifact changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 1 Changed, 0 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some sub-type change: [C] 'function irq_domain* __irq_domain_add(fwnode_handle*, int, irq_hw_number_t, int, const irq_domain_ops*, void*)' at irqdomain.c:229:1 has some sub-type changes: parameter 2 of type 'int' changed: type name changed from 'int' to 'unsigned int' type size hasn't changed Change-Id: I0a63ed2e6b2f1871671f8341f3c3b431592fcd64 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
3156 lines
82 KiB
C
3156 lines
82 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/fs/ext4/xattr.c
|
|
*
|
|
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
|
|
*
|
|
* Fix by Harrison Xing <harrison@mountainviewdata.com>.
|
|
* Ext4 code with a lot of help from Eric Jarman <ejarman@acm.org>.
|
|
* Extended attributes for symlinks and special files added per
|
|
* suggestion of Luka Renko <luka.renko@hermes.si>.
|
|
* xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
|
|
* Red Hat Inc.
|
|
* ea-in-inode support by Alex Tomas <alex@clusterfs.com> aka bzzz
|
|
* and Andreas Gruenbacher <agruen@suse.de>.
|
|
*/
|
|
|
|
/*
|
|
* Extended attributes are stored directly in inodes (on file systems with
|
|
* inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
|
|
* field contains the block number if an inode uses an additional block. All
|
|
* attributes must fit in the inode and one additional block. Blocks that
|
|
* contain the identical set of attributes may be shared among several inodes.
|
|
* Identical blocks are detected by keeping a cache of blocks that have
|
|
* recently been accessed.
|
|
*
|
|
* The attributes in inodes and on blocks have a different header; the entries
|
|
* are stored in the same format:
|
|
*
|
|
* +------------------+
|
|
* | header |
|
|
* | entry 1 | |
|
|
* | entry 2 | | growing downwards
|
|
* | entry 3 | v
|
|
* | four null bytes |
|
|
* | . . . |
|
|
* | value 1 | ^
|
|
* | value 3 | | growing upwards
|
|
* | value 2 | |
|
|
* +------------------+
|
|
*
|
|
* The header is followed by multiple entry descriptors. In disk blocks, the
|
|
* entry descriptors are kept sorted. In inodes, they are unsorted. The
|
|
* attribute values are aligned to the end of the block in no specific order.
|
|
*
|
|
* Locking strategy
|
|
* ----------------
|
|
* EXT4_I(inode)->i_file_acl is protected by EXT4_I(inode)->xattr_sem.
|
|
* EA blocks are only changed if they are exclusive to an inode, so
|
|
* holding xattr_sem also means that nothing but the EA block's reference
|
|
* count can change. Multiple writers to the same block are synchronized
|
|
* by the buffer lock.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/mbcache.h>
|
|
#include <linux/quotaops.h>
|
|
#include <linux/iversion.h>
|
|
#include "ext4_jbd2.h"
|
|
#include "ext4.h"
|
|
#include "xattr.h"
|
|
#include "acl.h"
|
|
|
|
#ifdef EXT4_XATTR_DEBUG
|
|
# define ea_idebug(inode, fmt, ...) \
|
|
printk(KERN_DEBUG "inode %s:%lu: " fmt "\n", \
|
|
inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
|
|
# define ea_bdebug(bh, fmt, ...) \
|
|
printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \
|
|
bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
|
|
#else
|
|
# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
|
|
# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
static void ext4_xattr_block_cache_insert(struct mb_cache *,
|
|
struct buffer_head *);
|
|
static struct buffer_head *
|
|
ext4_xattr_block_cache_find(struct inode *, struct ext4_xattr_header *,
|
|
struct mb_cache_entry **);
|
|
static __le32 ext4_xattr_hash_entry(char *name, size_t name_len, __le32 *value,
|
|
size_t value_count);
|
|
static void ext4_xattr_rehash(struct ext4_xattr_header *);
|
|
|
|
static const struct xattr_handler * const ext4_xattr_handler_map[] = {
|
|
[EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler,
|
|
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
|
[EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
|
|
[EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
|
|
#endif
|
|
[EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler,
|
|
#ifdef CONFIG_EXT4_FS_SECURITY
|
|
[EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler,
|
|
#endif
|
|
[EXT4_XATTR_INDEX_HURD] = &ext4_xattr_hurd_handler,
|
|
};
|
|
|
|
const struct xattr_handler *ext4_xattr_handlers[] = {
|
|
&ext4_xattr_user_handler,
|
|
&ext4_xattr_trusted_handler,
|
|
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
|
&posix_acl_access_xattr_handler,
|
|
&posix_acl_default_xattr_handler,
|
|
#endif
|
|
#ifdef CONFIG_EXT4_FS_SECURITY
|
|
&ext4_xattr_security_handler,
|
|
#endif
|
|
&ext4_xattr_hurd_handler,
|
|
NULL
|
|
};
|
|
|
|
#define EA_BLOCK_CACHE(inode) (((struct ext4_sb_info *) \
|
|
inode->i_sb->s_fs_info)->s_ea_block_cache)
|
|
|
|
#define EA_INODE_CACHE(inode) (((struct ext4_sb_info *) \
|
|
inode->i_sb->s_fs_info)->s_ea_inode_cache)
|
|
|
|
static int
|
|
ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
|
|
struct inode *inode);
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
void ext4_xattr_inode_set_class(struct inode *ea_inode)
|
|
{
|
|
lockdep_set_subclass(&ea_inode->i_rwsem, 1);
|
|
}
|
|
#endif
|
|
|
|
static __le32 ext4_xattr_block_csum(struct inode *inode,
|
|
sector_t block_nr,
|
|
struct ext4_xattr_header *hdr)
|
|
{
|
|
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
|
__u32 csum;
|
|
__le64 dsk_block_nr = cpu_to_le64(block_nr);
|
|
__u32 dummy_csum = 0;
|
|
int offset = offsetof(struct ext4_xattr_header, h_checksum);
|
|
|
|
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&dsk_block_nr,
|
|
sizeof(dsk_block_nr));
|
|
csum = ext4_chksum(sbi, csum, (__u8 *)hdr, offset);
|
|
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
|
|
offset += sizeof(dummy_csum);
|
|
csum = ext4_chksum(sbi, csum, (__u8 *)hdr + offset,
|
|
EXT4_BLOCK_SIZE(inode->i_sb) - offset);
|
|
|
|
return cpu_to_le32(csum);
|
|
}
|
|
|
|
static int ext4_xattr_block_csum_verify(struct inode *inode,
|
|
struct buffer_head *bh)
|
|
{
|
|
struct ext4_xattr_header *hdr = BHDR(bh);
|
|
int ret = 1;
|
|
|
|
if (ext4_has_metadata_csum(inode->i_sb)) {
|
|
lock_buffer(bh);
|
|
ret = (hdr->h_checksum == ext4_xattr_block_csum(inode,
|
|
bh->b_blocknr, hdr));
|
|
unlock_buffer(bh);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void ext4_xattr_block_csum_set(struct inode *inode,
|
|
struct buffer_head *bh)
|
|
{
|
|
if (ext4_has_metadata_csum(inode->i_sb))
|
|
BHDR(bh)->h_checksum = ext4_xattr_block_csum(inode,
|
|
bh->b_blocknr, BHDR(bh));
|
|
}
|
|
|
|
static inline const struct xattr_handler *
|
|
ext4_xattr_handler(int name_index)
|
|
{
|
|
const struct xattr_handler *handler = NULL;
|
|
|
|
if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map))
|
|
handler = ext4_xattr_handler_map[name_index];
|
|
return handler;
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_check_entries(struct ext4_xattr_entry *entry, void *end,
|
|
void *value_start)
|
|
{
|
|
struct ext4_xattr_entry *e = entry;
|
|
|
|
/* Find the end of the names list */
|
|
while (!IS_LAST_ENTRY(e)) {
|
|
struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(e);
|
|
if ((void *)next >= end)
|
|
return -EFSCORRUPTED;
|
|
if (strnlen(e->e_name, e->e_name_len) != e->e_name_len)
|
|
return -EFSCORRUPTED;
|
|
e = next;
|
|
}
|
|
|
|
/* Check the values */
|
|
while (!IS_LAST_ENTRY(entry)) {
|
|
u32 size = le32_to_cpu(entry->e_value_size);
|
|
|
|
if (size > EXT4_XATTR_SIZE_MAX)
|
|
return -EFSCORRUPTED;
|
|
|
|
if (size != 0 && entry->e_value_inum == 0) {
|
|
u16 offs = le16_to_cpu(entry->e_value_offs);
|
|
void *value;
|
|
|
|
/*
|
|
* The value cannot overlap the names, and the value
|
|
* with padding cannot extend beyond 'end'. Check both
|
|
* the padded and unpadded sizes, since the size may
|
|
* overflow to 0 when adding padding.
|
|
*/
|
|
if (offs > end - value_start)
|
|
return -EFSCORRUPTED;
|
|
value = value_start + offs;
|
|
if (value < (void *)e + sizeof(u32) ||
|
|
size > end - value ||
|
|
EXT4_XATTR_SIZE(size) > end - value)
|
|
return -EFSCORRUPTED;
|
|
}
|
|
entry = EXT4_XATTR_NEXT(entry);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static inline int
|
|
__ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh,
|
|
const char *function, unsigned int line)
|
|
{
|
|
int error = -EFSCORRUPTED;
|
|
|
|
if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
|
|
BHDR(bh)->h_blocks != cpu_to_le32(1))
|
|
goto errout;
|
|
if (buffer_verified(bh))
|
|
return 0;
|
|
|
|
error = -EFSBADCRC;
|
|
if (!ext4_xattr_block_csum_verify(inode, bh))
|
|
goto errout;
|
|
error = ext4_xattr_check_entries(BFIRST(bh), bh->b_data + bh->b_size,
|
|
bh->b_data);
|
|
errout:
|
|
if (error)
|
|
__ext4_error_inode(inode, function, line, 0, -error,
|
|
"corrupted xattr block %llu",
|
|
(unsigned long long) bh->b_blocknr);
|
|
else
|
|
set_buffer_verified(bh);
|
|
return error;
|
|
}
|
|
|
|
#define ext4_xattr_check_block(inode, bh) \
|
|
__ext4_xattr_check_block((inode), (bh), __func__, __LINE__)
|
|
|
|
|
|
static int
|
|
__xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header,
|
|
void *end, const char *function, unsigned int line)
|
|
{
|
|
int error = -EFSCORRUPTED;
|
|
|
|
if (end - (void *)header < sizeof(*header) + sizeof(u32) ||
|
|
(header->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC)))
|
|
goto errout;
|
|
error = ext4_xattr_check_entries(IFIRST(header), end, IFIRST(header));
|
|
errout:
|
|
if (error)
|
|
__ext4_error_inode(inode, function, line, 0, -error,
|
|
"corrupted in-inode xattr");
|
|
return error;
|
|
}
|
|
|
|
#define xattr_check_inode(inode, header, end) \
|
|
__xattr_check_inode((inode), (header), (end), __func__, __LINE__)
|
|
|
|
static int
|
|
xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry,
|
|
void *end, int name_index, const char *name, int sorted)
|
|
{
|
|
struct ext4_xattr_entry *entry, *next;
|
|
size_t name_len;
|
|
int cmp = 1;
|
|
|
|
if (name == NULL)
|
|
return -EINVAL;
|
|
name_len = strlen(name);
|
|
for (entry = *pentry; !IS_LAST_ENTRY(entry); entry = next) {
|
|
next = EXT4_XATTR_NEXT(entry);
|
|
if ((void *) next >= end) {
|
|
EXT4_ERROR_INODE(inode, "corrupted xattr entries");
|
|
return -EFSCORRUPTED;
|
|
}
|
|
cmp = name_index - entry->e_name_index;
|
|
if (!cmp)
|
|
cmp = name_len - entry->e_name_len;
|
|
if (!cmp)
|
|
cmp = memcmp(name, entry->e_name, name_len);
|
|
if (cmp <= 0 && (sorted || cmp == 0))
|
|
break;
|
|
}
|
|
*pentry = entry;
|
|
return cmp ? -ENODATA : 0;
|
|
}
|
|
|
|
static u32
|
|
ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size)
|
|
{
|
|
return ext4_chksum(sbi, sbi->s_csum_seed, buffer, size);
|
|
}
|
|
|
|
static u64 ext4_xattr_inode_get_ref(struct inode *ea_inode)
|
|
{
|
|
return ((u64)ea_inode->i_ctime.tv_sec << 32) |
|
|
(u32) inode_peek_iversion_raw(ea_inode);
|
|
}
|
|
|
|
static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
|
|
{
|
|
ea_inode->i_ctime.tv_sec = (u32)(ref_count >> 32);
|
|
inode_set_iversion_raw(ea_inode, ref_count & 0xffffffff);
|
|
}
|
|
|
|
static u32 ext4_xattr_inode_get_hash(struct inode *ea_inode)
|
|
{
|
|
return (u32)ea_inode->i_atime.tv_sec;
|
|
}
|
|
|
|
static void ext4_xattr_inode_set_hash(struct inode *ea_inode, u32 hash)
|
|
{
|
|
ea_inode->i_atime.tv_sec = hash;
|
|
}
|
|
|
|
/*
|
|
* Read the EA value from an inode.
|
|
*/
|
|
static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t size)
|
|
{
|
|
int blocksize = 1 << ea_inode->i_blkbits;
|
|
int bh_count = (size + blocksize - 1) >> ea_inode->i_blkbits;
|
|
int tail_size = (size % blocksize) ?: blocksize;
|
|
struct buffer_head *bhs_inline[8];
|
|
struct buffer_head **bhs = bhs_inline;
|
|
int i, ret;
|
|
|
|
if (bh_count > ARRAY_SIZE(bhs_inline)) {
|
|
bhs = kmalloc_array(bh_count, sizeof(*bhs), GFP_NOFS);
|
|
if (!bhs)
|
|
return -ENOMEM;
|
|
}
|
|
|
|
ret = ext4_bread_batch(ea_inode, 0 /* block */, bh_count,
|
|
true /* wait */, bhs);
|
|
if (ret)
|
|
goto free_bhs;
|
|
|
|
for (i = 0; i < bh_count; i++) {
|
|
/* There shouldn't be any holes in ea_inode. */
|
|
if (!bhs[i]) {
|
|
ret = -EFSCORRUPTED;
|
|
goto put_bhs;
|
|
}
|
|
memcpy((char *)buf + blocksize * i, bhs[i]->b_data,
|
|
i < bh_count - 1 ? blocksize : tail_size);
|
|
}
|
|
ret = 0;
|
|
put_bhs:
|
|
for (i = 0; i < bh_count; i++)
|
|
brelse(bhs[i]);
|
|
free_bhs:
|
|
if (bhs != bhs_inline)
|
|
kfree(bhs);
|
|
return ret;
|
|
}
|
|
|
|
#define EXT4_XATTR_INODE_GET_PARENT(inode) ((__u32)(inode)->i_mtime.tv_sec)
|
|
|
|
static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
|
|
u32 ea_inode_hash, struct inode **ea_inode)
|
|
{
|
|
struct inode *inode;
|
|
int err;
|
|
|
|
/*
|
|
* We have to check for this corruption early as otherwise
|
|
* iget_locked() could wait indefinitely for the state of our
|
|
* parent inode.
|
|
*/
|
|
if (parent->i_ino == ea_ino) {
|
|
ext4_error(parent->i_sb,
|
|
"Parent and EA inode have the same ino %lu", ea_ino);
|
|
return -EFSCORRUPTED;
|
|
}
|
|
|
|
inode = ext4_iget(parent->i_sb, ea_ino, EXT4_IGET_NORMAL);
|
|
if (IS_ERR(inode)) {
|
|
err = PTR_ERR(inode);
|
|
ext4_error(parent->i_sb,
|
|
"error while reading EA inode %lu err=%d", ea_ino,
|
|
err);
|
|
return err;
|
|
}
|
|
|
|
if (is_bad_inode(inode)) {
|
|
ext4_error(parent->i_sb,
|
|
"error while reading EA inode %lu is_bad_inode",
|
|
ea_ino);
|
|
err = -EIO;
|
|
goto error;
|
|
}
|
|
|
|
if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
|
|
ext4_error(parent->i_sb,
|
|
"EA inode %lu does not have EXT4_EA_INODE_FL flag",
|
|
ea_ino);
|
|
err = -EINVAL;
|
|
goto error;
|
|
}
|
|
|
|
ext4_xattr_inode_set_class(inode);
|
|
|
|
/*
|
|
* Check whether this is an old Lustre-style xattr inode. Lustre
|
|
* implementation does not have hash validation, rather it has a
|
|
* backpointer from ea_inode to the parent inode.
|
|
*/
|
|
if (ea_inode_hash != ext4_xattr_inode_get_hash(inode) &&
|
|
EXT4_XATTR_INODE_GET_PARENT(inode) == parent->i_ino &&
|
|
inode->i_generation == parent->i_generation) {
|
|
ext4_set_inode_state(inode, EXT4_STATE_LUSTRE_EA_INODE);
|
|
ext4_xattr_inode_set_ref(inode, 1);
|
|
} else {
|
|
inode_lock(inode);
|
|
inode->i_flags |= S_NOQUOTA;
|
|
inode_unlock(inode);
|
|
}
|
|
|
|
*ea_inode = inode;
|
|
return 0;
|
|
error:
|
|
iput(inode);
|
|
return err;
|
|
}
|
|
|
|
/* Remove entry from mbcache when EA inode is getting evicted */
|
|
void ext4_evict_ea_inode(struct inode *inode)
|
|
{
|
|
struct mb_cache_entry *oe;
|
|
|
|
if (!EA_INODE_CACHE(inode))
|
|
return;
|
|
/* Wait for entry to get unused so that we can remove it */
|
|
while ((oe = mb_cache_entry_delete_or_get(EA_INODE_CACHE(inode),
|
|
ext4_xattr_inode_get_hash(inode), inode->i_ino))) {
|
|
mb_cache_entry_wait_unused(oe);
|
|
mb_cache_entry_put(EA_INODE_CACHE(inode), oe);
|
|
}
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_inode_verify_hashes(struct inode *ea_inode,
|
|
struct ext4_xattr_entry *entry, void *buffer,
|
|
size_t size)
|
|
{
|
|
u32 hash;
|
|
|
|
/* Verify stored hash matches calculated hash. */
|
|
hash = ext4_xattr_inode_hash(EXT4_SB(ea_inode->i_sb), buffer, size);
|
|
if (hash != ext4_xattr_inode_get_hash(ea_inode))
|
|
return -EFSCORRUPTED;
|
|
|
|
if (entry) {
|
|
__le32 e_hash, tmp_data;
|
|
|
|
/* Verify entry hash. */
|
|
tmp_data = cpu_to_le32(hash);
|
|
e_hash = ext4_xattr_hash_entry(entry->e_name, entry->e_name_len,
|
|
&tmp_data, 1);
|
|
if (e_hash != entry->e_hash)
|
|
return -EFSCORRUPTED;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Read xattr value from the EA inode.
|
|
*/
|
|
static int
|
|
ext4_xattr_inode_get(struct inode *inode, struct ext4_xattr_entry *entry,
|
|
void *buffer, size_t size)
|
|
{
|
|
struct mb_cache *ea_inode_cache = EA_INODE_CACHE(inode);
|
|
struct inode *ea_inode;
|
|
int err;
|
|
|
|
err = ext4_xattr_inode_iget(inode, le32_to_cpu(entry->e_value_inum),
|
|
le32_to_cpu(entry->e_hash), &ea_inode);
|
|
if (err) {
|
|
ea_inode = NULL;
|
|
goto out;
|
|
}
|
|
|
|
if (i_size_read(ea_inode) != size) {
|
|
ext4_warning_inode(ea_inode,
|
|
"ea_inode file size=%llu entry size=%zu",
|
|
i_size_read(ea_inode), size);
|
|
err = -EFSCORRUPTED;
|
|
goto out;
|
|
}
|
|
|
|
err = ext4_xattr_inode_read(ea_inode, buffer, size);
|
|
if (err)
|
|
goto out;
|
|
|
|
if (!ext4_test_inode_state(ea_inode, EXT4_STATE_LUSTRE_EA_INODE)) {
|
|
err = ext4_xattr_inode_verify_hashes(ea_inode, entry, buffer,
|
|
size);
|
|
if (err) {
|
|
ext4_warning_inode(ea_inode,
|
|
"EA inode hash validation failed");
|
|
goto out;
|
|
}
|
|
|
|
if (ea_inode_cache)
|
|
mb_cache_entry_create(ea_inode_cache, GFP_NOFS,
|
|
ext4_xattr_inode_get_hash(ea_inode),
|
|
ea_inode->i_ino, true /* reusable */);
|
|
}
|
|
out:
|
|
iput(ea_inode);
|
|
return err;
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
|
|
void *buffer, size_t buffer_size)
|
|
{
|
|
struct buffer_head *bh = NULL;
|
|
struct ext4_xattr_entry *entry;
|
|
size_t size;
|
|
void *end;
|
|
int error;
|
|
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
|
|
|
|
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
|
|
name_index, name, buffer, (long)buffer_size);
|
|
|
|
if (!EXT4_I(inode)->i_file_acl)
|
|
return -ENODATA;
|
|
ea_idebug(inode, "reading block %llu",
|
|
(unsigned long long)EXT4_I(inode)->i_file_acl);
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh))
|
|
return PTR_ERR(bh);
|
|
ea_bdebug(bh, "b_count=%d, refcount=%d",
|
|
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
|
|
error = ext4_xattr_check_block(inode, bh);
|
|
if (error)
|
|
goto cleanup;
|
|
ext4_xattr_block_cache_insert(ea_block_cache, bh);
|
|
entry = BFIRST(bh);
|
|
end = bh->b_data + bh->b_size;
|
|
error = xattr_find_entry(inode, &entry, end, name_index, name, 1);
|
|
if (error)
|
|
goto cleanup;
|
|
size = le32_to_cpu(entry->e_value_size);
|
|
error = -ERANGE;
|
|
if (unlikely(size > EXT4_XATTR_SIZE_MAX))
|
|
goto cleanup;
|
|
if (buffer) {
|
|
if (size > buffer_size)
|
|
goto cleanup;
|
|
if (entry->e_value_inum) {
|
|
error = ext4_xattr_inode_get(inode, entry, buffer,
|
|
size);
|
|
if (error)
|
|
goto cleanup;
|
|
} else {
|
|
u16 offset = le16_to_cpu(entry->e_value_offs);
|
|
void *p = bh->b_data + offset;
|
|
|
|
if (unlikely(p + size > end))
|
|
goto cleanup;
|
|
memcpy(buffer, p, size);
|
|
}
|
|
}
|
|
error = size;
|
|
|
|
cleanup:
|
|
brelse(bh);
|
|
return error;
|
|
}
|
|
|
|
int
|
|
ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
|
|
void *buffer, size_t buffer_size)
|
|
{
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_xattr_entry *entry;
|
|
struct ext4_inode *raw_inode;
|
|
struct ext4_iloc iloc;
|
|
size_t size;
|
|
void *end;
|
|
int error;
|
|
|
|
if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR))
|
|
return -ENODATA;
|
|
error = ext4_get_inode_loc(inode, &iloc);
|
|
if (error)
|
|
return error;
|
|
raw_inode = ext4_raw_inode(&iloc);
|
|
header = IHDR(inode, raw_inode);
|
|
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
|
|
error = xattr_check_inode(inode, header, end);
|
|
if (error)
|
|
goto cleanup;
|
|
entry = IFIRST(header);
|
|
error = xattr_find_entry(inode, &entry, end, name_index, name, 0);
|
|
if (error)
|
|
goto cleanup;
|
|
size = le32_to_cpu(entry->e_value_size);
|
|
error = -ERANGE;
|
|
if (unlikely(size > EXT4_XATTR_SIZE_MAX))
|
|
goto cleanup;
|
|
if (buffer) {
|
|
if (size > buffer_size)
|
|
goto cleanup;
|
|
if (entry->e_value_inum) {
|
|
error = ext4_xattr_inode_get(inode, entry, buffer,
|
|
size);
|
|
if (error)
|
|
goto cleanup;
|
|
} else {
|
|
u16 offset = le16_to_cpu(entry->e_value_offs);
|
|
void *p = (void *)IFIRST(header) + offset;
|
|
|
|
if (unlikely(p + size > end))
|
|
goto cleanup;
|
|
memcpy(buffer, p, size);
|
|
}
|
|
}
|
|
error = size;
|
|
|
|
cleanup:
|
|
brelse(iloc.bh);
|
|
return error;
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_get()
|
|
*
|
|
* Copy an extended attribute into the buffer
|
|
* provided, or compute the buffer size required.
|
|
* Buffer is NULL to compute the size of the buffer required.
|
|
*
|
|
* Returns a negative error number on failure, or the number of bytes
|
|
* used / required on success.
|
|
*/
|
|
int
|
|
ext4_xattr_get(struct inode *inode, int name_index, const char *name,
|
|
void *buffer, size_t buffer_size)
|
|
{
|
|
int error;
|
|
|
|
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
|
|
return -EIO;
|
|
|
|
if (strlen(name) > 255)
|
|
return -ERANGE;
|
|
|
|
down_read(&EXT4_I(inode)->xattr_sem);
|
|
error = ext4_xattr_ibody_get(inode, name_index, name, buffer,
|
|
buffer_size);
|
|
if (error == -ENODATA)
|
|
error = ext4_xattr_block_get(inode, name_index, name, buffer,
|
|
buffer_size);
|
|
up_read(&EXT4_I(inode)->xattr_sem);
|
|
return error;
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
|
|
char *buffer, size_t buffer_size)
|
|
{
|
|
size_t rest = buffer_size;
|
|
|
|
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
|
|
const struct xattr_handler *handler =
|
|
ext4_xattr_handler(entry->e_name_index);
|
|
|
|
if (handler && (!handler->list || handler->list(dentry))) {
|
|
const char *prefix = handler->prefix ?: handler->name;
|
|
size_t prefix_len = strlen(prefix);
|
|
size_t size = prefix_len + entry->e_name_len + 1;
|
|
|
|
if (buffer) {
|
|
if (size > rest)
|
|
return -ERANGE;
|
|
memcpy(buffer, prefix, prefix_len);
|
|
buffer += prefix_len;
|
|
memcpy(buffer, entry->e_name, entry->e_name_len);
|
|
buffer += entry->e_name_len;
|
|
*buffer++ = 0;
|
|
}
|
|
rest -= size;
|
|
}
|
|
}
|
|
return buffer_size - rest; /* total size */
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
|
|
{
|
|
struct inode *inode = d_inode(dentry);
|
|
struct buffer_head *bh = NULL;
|
|
int error;
|
|
|
|
ea_idebug(inode, "buffer=%p, buffer_size=%ld",
|
|
buffer, (long)buffer_size);
|
|
|
|
if (!EXT4_I(inode)->i_file_acl)
|
|
return 0;
|
|
ea_idebug(inode, "reading block %llu",
|
|
(unsigned long long)EXT4_I(inode)->i_file_acl);
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh))
|
|
return PTR_ERR(bh);
|
|
ea_bdebug(bh, "b_count=%d, refcount=%d",
|
|
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
|
|
error = ext4_xattr_check_block(inode, bh);
|
|
if (error)
|
|
goto cleanup;
|
|
ext4_xattr_block_cache_insert(EA_BLOCK_CACHE(inode), bh);
|
|
error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer,
|
|
buffer_size);
|
|
cleanup:
|
|
brelse(bh);
|
|
return error;
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
|
|
{
|
|
struct inode *inode = d_inode(dentry);
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_inode *raw_inode;
|
|
struct ext4_iloc iloc;
|
|
void *end;
|
|
int error;
|
|
|
|
if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR))
|
|
return 0;
|
|
error = ext4_get_inode_loc(inode, &iloc);
|
|
if (error)
|
|
return error;
|
|
raw_inode = ext4_raw_inode(&iloc);
|
|
header = IHDR(inode, raw_inode);
|
|
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
|
|
error = xattr_check_inode(inode, header, end);
|
|
if (error)
|
|
goto cleanup;
|
|
error = ext4_xattr_list_entries(dentry, IFIRST(header),
|
|
buffer, buffer_size);
|
|
|
|
cleanup:
|
|
brelse(iloc.bh);
|
|
return error;
|
|
}
|
|
|
|
/*
|
|
* Inode operation listxattr()
|
|
*
|
|
* d_inode(dentry)->i_rwsem: don't care
|
|
*
|
|
* Copy a list of attribute names into the buffer
|
|
* provided, or compute the buffer size required.
|
|
* Buffer is NULL to compute the size of the buffer required.
|
|
*
|
|
* Returns a negative error number on failure, or the number of bytes
|
|
* used / required on success.
|
|
*/
|
|
ssize_t
|
|
ext4_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
|
|
{
|
|
int ret, ret2;
|
|
|
|
down_read(&EXT4_I(d_inode(dentry))->xattr_sem);
|
|
ret = ret2 = ext4_xattr_ibody_list(dentry, buffer, buffer_size);
|
|
if (ret < 0)
|
|
goto errout;
|
|
if (buffer) {
|
|
buffer += ret;
|
|
buffer_size -= ret;
|
|
}
|
|
ret = ext4_xattr_block_list(dentry, buffer, buffer_size);
|
|
if (ret < 0)
|
|
goto errout;
|
|
ret += ret2;
|
|
errout:
|
|
up_read(&EXT4_I(d_inode(dentry))->xattr_sem);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* If the EXT4_FEATURE_COMPAT_EXT_ATTR feature of this file system is
|
|
* not set, set it.
|
|
*/
|
|
static void ext4_xattr_update_super_block(handle_t *handle,
|
|
struct super_block *sb)
|
|
{
|
|
if (ext4_has_feature_xattr(sb))
|
|
return;
|
|
|
|
BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
|
|
if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
|
|
ext4_set_feature_xattr(sb);
|
|
ext4_handle_dirty_super(handle, sb);
|
|
}
|
|
}
|
|
|
|
int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
|
|
{
|
|
struct ext4_iloc iloc = { .bh = NULL };
|
|
struct buffer_head *bh = NULL;
|
|
struct ext4_inode *raw_inode;
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_xattr_entry *entry;
|
|
qsize_t ea_inode_refs = 0;
|
|
void *end;
|
|
int ret;
|
|
|
|
lockdep_assert_held_read(&EXT4_I(inode)->xattr_sem);
|
|
|
|
if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
|
|
ret = ext4_get_inode_loc(inode, &iloc);
|
|
if (ret)
|
|
goto out;
|
|
raw_inode = ext4_raw_inode(&iloc);
|
|
header = IHDR(inode, raw_inode);
|
|
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
|
|
ret = xattr_check_inode(inode, header, end);
|
|
if (ret)
|
|
goto out;
|
|
|
|
for (entry = IFIRST(header); !IS_LAST_ENTRY(entry);
|
|
entry = EXT4_XATTR_NEXT(entry))
|
|
if (entry->e_value_inum)
|
|
ea_inode_refs++;
|
|
}
|
|
|
|
if (EXT4_I(inode)->i_file_acl) {
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh)) {
|
|
ret = PTR_ERR(bh);
|
|
bh = NULL;
|
|
goto out;
|
|
}
|
|
|
|
ret = ext4_xattr_check_block(inode, bh);
|
|
if (ret)
|
|
goto out;
|
|
|
|
for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry);
|
|
entry = EXT4_XATTR_NEXT(entry))
|
|
if (entry->e_value_inum)
|
|
ea_inode_refs++;
|
|
}
|
|
*usage = ea_inode_refs + 1;
|
|
ret = 0;
|
|
out:
|
|
brelse(iloc.bh);
|
|
brelse(bh);
|
|
return ret;
|
|
}
|
|
|
|
static inline size_t round_up_cluster(struct inode *inode, size_t length)
|
|
{
|
|
struct super_block *sb = inode->i_sb;
|
|
size_t cluster_size = 1 << (EXT4_SB(sb)->s_cluster_bits +
|
|
inode->i_blkbits);
|
|
size_t mask = ~(cluster_size - 1);
|
|
|
|
return (length + cluster_size - 1) & mask;
|
|
}
|
|
|
|
static int ext4_xattr_inode_alloc_quota(struct inode *inode, size_t len)
|
|
{
|
|
int err;
|
|
|
|
err = dquot_alloc_inode(inode);
|
|
if (err)
|
|
return err;
|
|
err = dquot_alloc_space_nodirty(inode, round_up_cluster(inode, len));
|
|
if (err)
|
|
dquot_free_inode(inode);
|
|
return err;
|
|
}
|
|
|
|
static void ext4_xattr_inode_free_quota(struct inode *parent,
|
|
struct inode *ea_inode,
|
|
size_t len)
|
|
{
|
|
if (ea_inode &&
|
|
ext4_test_inode_state(ea_inode, EXT4_STATE_LUSTRE_EA_INODE))
|
|
return;
|
|
dquot_free_space_nodirty(parent, round_up_cluster(parent, len));
|
|
dquot_free_inode(parent);
|
|
}
|
|
|
|
int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
|
|
struct buffer_head *block_bh, size_t value_len,
|
|
bool is_create)
|
|
{
|
|
int credits;
|
|
int blocks;
|
|
|
|
/*
|
|
* 1) Owner inode update
|
|
* 2) Ref count update on old xattr block
|
|
* 3) new xattr block
|
|
* 4) block bitmap update for new xattr block
|
|
* 5) group descriptor for new xattr block
|
|
* 6) block bitmap update for old xattr block
|
|
* 7) group descriptor for old block
|
|
*
|
|
* 6 & 7 can happen if we have two racing threads T_a and T_b
|
|
* which are each trying to set an xattr on inodes I_a and I_b
|
|
* which were both initially sharing an xattr block.
|
|
*/
|
|
credits = 7;
|
|
|
|
/* Quota updates. */
|
|
credits += EXT4_MAXQUOTAS_TRANS_BLOCKS(sb);
|
|
|
|
/*
|
|
* In case of inline data, we may push out the data to a block,
|
|
* so we need to reserve credits for this eventuality
|
|
*/
|
|
if (inode && ext4_has_inline_data(inode))
|
|
credits += ext4_writepage_trans_blocks(inode) + 1;
|
|
|
|
/* We are done if ea_inode feature is not enabled. */
|
|
if (!ext4_has_feature_ea_inode(sb))
|
|
return credits;
|
|
|
|
/* New ea_inode, inode map, block bitmap, group descriptor. */
|
|
credits += 4;
|
|
|
|
/* Data blocks. */
|
|
blocks = (value_len + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
|
|
|
|
/* Indirection block or one level of extent tree. */
|
|
blocks += 1;
|
|
|
|
/* Block bitmap and group descriptor updates for each block. */
|
|
credits += blocks * 2;
|
|
|
|
/* Blocks themselves. */
|
|
credits += blocks;
|
|
|
|
if (!is_create) {
|
|
/* Dereference ea_inode holding old xattr value.
|
|
* Old ea_inode, inode map, block bitmap, group descriptor.
|
|
*/
|
|
credits += 4;
|
|
|
|
/* Data blocks for old ea_inode. */
|
|
blocks = XATTR_SIZE_MAX >> sb->s_blocksize_bits;
|
|
|
|
/* Indirection block or one level of extent tree for old
|
|
* ea_inode.
|
|
*/
|
|
blocks += 1;
|
|
|
|
/* Block bitmap and group descriptor updates for each block. */
|
|
credits += blocks * 2;
|
|
}
|
|
|
|
/* We may need to clone the existing xattr block in which case we need
|
|
* to increment ref counts for existing ea_inodes referenced by it.
|
|
*/
|
|
if (block_bh) {
|
|
struct ext4_xattr_entry *entry = BFIRST(block_bh);
|
|
|
|
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry))
|
|
if (entry->e_value_inum)
|
|
/* Ref count update on ea_inode. */
|
|
credits += 1;
|
|
}
|
|
return credits;
|
|
}
|
|
|
|
static int ext4_xattr_inode_update_ref(handle_t *handle, struct inode *ea_inode,
|
|
int ref_change)
|
|
{
|
|
struct ext4_iloc iloc;
|
|
s64 ref_count;
|
|
int ret;
|
|
|
|
inode_lock(ea_inode);
|
|
|
|
ret = ext4_reserve_inode_write(handle, ea_inode, &iloc);
|
|
if (ret)
|
|
goto out;
|
|
|
|
ref_count = ext4_xattr_inode_get_ref(ea_inode);
|
|
ref_count += ref_change;
|
|
ext4_xattr_inode_set_ref(ea_inode, ref_count);
|
|
|
|
if (ref_change > 0) {
|
|
WARN_ONCE(ref_count <= 0, "EA inode %lu ref_count=%lld",
|
|
ea_inode->i_ino, ref_count);
|
|
|
|
if (ref_count == 1) {
|
|
WARN_ONCE(ea_inode->i_nlink, "EA inode %lu i_nlink=%u",
|
|
ea_inode->i_ino, ea_inode->i_nlink);
|
|
|
|
set_nlink(ea_inode, 1);
|
|
ext4_orphan_del(handle, ea_inode);
|
|
}
|
|
} else {
|
|
WARN_ONCE(ref_count < 0, "EA inode %lu ref_count=%lld",
|
|
ea_inode->i_ino, ref_count);
|
|
|
|
if (ref_count == 0) {
|
|
WARN_ONCE(ea_inode->i_nlink != 1,
|
|
"EA inode %lu i_nlink=%u",
|
|
ea_inode->i_ino, ea_inode->i_nlink);
|
|
|
|
clear_nlink(ea_inode);
|
|
ext4_orphan_add(handle, ea_inode);
|
|
}
|
|
}
|
|
|
|
ret = ext4_mark_iloc_dirty(handle, ea_inode, &iloc);
|
|
if (ret)
|
|
ext4_warning_inode(ea_inode,
|
|
"ext4_mark_iloc_dirty() failed ret=%d", ret);
|
|
out:
|
|
inode_unlock(ea_inode);
|
|
return ret;
|
|
}
|
|
|
|
static int ext4_xattr_inode_inc_ref(handle_t *handle, struct inode *ea_inode)
|
|
{
|
|
return ext4_xattr_inode_update_ref(handle, ea_inode, 1);
|
|
}
|
|
|
|
static int ext4_xattr_inode_dec_ref(handle_t *handle, struct inode *ea_inode)
|
|
{
|
|
return ext4_xattr_inode_update_ref(handle, ea_inode, -1);
|
|
}
|
|
|
|
static int ext4_xattr_inode_inc_ref_all(handle_t *handle, struct inode *parent,
|
|
struct ext4_xattr_entry *first)
|
|
{
|
|
struct inode *ea_inode;
|
|
struct ext4_xattr_entry *entry;
|
|
struct ext4_xattr_entry *failed_entry;
|
|
unsigned int ea_ino;
|
|
int err, saved_err;
|
|
|
|
for (entry = first; !IS_LAST_ENTRY(entry);
|
|
entry = EXT4_XATTR_NEXT(entry)) {
|
|
if (!entry->e_value_inum)
|
|
continue;
|
|
ea_ino = le32_to_cpu(entry->e_value_inum);
|
|
err = ext4_xattr_inode_iget(parent, ea_ino,
|
|
le32_to_cpu(entry->e_hash),
|
|
&ea_inode);
|
|
if (err)
|
|
goto cleanup;
|
|
err = ext4_xattr_inode_inc_ref(handle, ea_inode);
|
|
if (err) {
|
|
ext4_warning_inode(ea_inode, "inc ref error %d", err);
|
|
iput(ea_inode);
|
|
goto cleanup;
|
|
}
|
|
iput(ea_inode);
|
|
}
|
|
return 0;
|
|
|
|
cleanup:
|
|
saved_err = err;
|
|
failed_entry = entry;
|
|
|
|
for (entry = first; entry != failed_entry;
|
|
entry = EXT4_XATTR_NEXT(entry)) {
|
|
if (!entry->e_value_inum)
|
|
continue;
|
|
ea_ino = le32_to_cpu(entry->e_value_inum);
|
|
err = ext4_xattr_inode_iget(parent, ea_ino,
|
|
le32_to_cpu(entry->e_hash),
|
|
&ea_inode);
|
|
if (err) {
|
|
ext4_warning(parent->i_sb,
|
|
"cleanup ea_ino %u iget error %d", ea_ino,
|
|
err);
|
|
continue;
|
|
}
|
|
err = ext4_xattr_inode_dec_ref(handle, ea_inode);
|
|
if (err)
|
|
ext4_warning_inode(ea_inode, "cleanup dec ref error %d",
|
|
err);
|
|
iput(ea_inode);
|
|
}
|
|
return saved_err;
|
|
}
|
|
|
|
static int ext4_xattr_restart_fn(handle_t *handle, struct inode *inode,
|
|
struct buffer_head *bh, bool block_csum, bool dirty)
|
|
{
|
|
int error;
|
|
|
|
if (bh && dirty) {
|
|
if (block_csum)
|
|
ext4_xattr_block_csum_set(inode, bh);
|
|
error = ext4_handle_dirty_metadata(handle, NULL, bh);
|
|
if (error) {
|
|
ext4_warning(inode->i_sb, "Handle metadata (error %d)",
|
|
error);
|
|
return error;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
ext4_xattr_inode_dec_ref_all(handle_t *handle, struct inode *parent,
|
|
struct buffer_head *bh,
|
|
struct ext4_xattr_entry *first, bool block_csum,
|
|
struct ext4_xattr_inode_array **ea_inode_array,
|
|
int extra_credits, bool skip_quota)
|
|
{
|
|
struct inode *ea_inode;
|
|
struct ext4_xattr_entry *entry;
|
|
bool dirty = false;
|
|
unsigned int ea_ino;
|
|
int err;
|
|
int credits;
|
|
|
|
/* One credit for dec ref on ea_inode, one for orphan list addition, */
|
|
credits = 2 + extra_credits;
|
|
|
|
for (entry = first; !IS_LAST_ENTRY(entry);
|
|
entry = EXT4_XATTR_NEXT(entry)) {
|
|
if (!entry->e_value_inum)
|
|
continue;
|
|
ea_ino = le32_to_cpu(entry->e_value_inum);
|
|
err = ext4_xattr_inode_iget(parent, ea_ino,
|
|
le32_to_cpu(entry->e_hash),
|
|
&ea_inode);
|
|
if (err)
|
|
continue;
|
|
|
|
err = ext4_expand_inode_array(ea_inode_array, ea_inode);
|
|
if (err) {
|
|
ext4_warning_inode(ea_inode,
|
|
"Expand inode array err=%d", err);
|
|
iput(ea_inode);
|
|
continue;
|
|
}
|
|
|
|
err = ext4_journal_ensure_credits_fn(handle, credits, credits,
|
|
ext4_free_metadata_revoke_credits(parent->i_sb, 1),
|
|
ext4_xattr_restart_fn(handle, parent, bh, block_csum,
|
|
dirty));
|
|
if (err < 0) {
|
|
ext4_warning_inode(ea_inode, "Ensure credits err=%d",
|
|
err);
|
|
continue;
|
|
}
|
|
if (err > 0) {
|
|
err = ext4_journal_get_write_access(handle, bh);
|
|
if (err) {
|
|
ext4_warning_inode(ea_inode,
|
|
"Re-get write access err=%d",
|
|
err);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
err = ext4_xattr_inode_dec_ref(handle, ea_inode);
|
|
if (err) {
|
|
ext4_warning_inode(ea_inode, "ea_inode dec ref err=%d",
|
|
err);
|
|
continue;
|
|
}
|
|
|
|
if (!skip_quota)
|
|
ext4_xattr_inode_free_quota(parent, ea_inode,
|
|
le32_to_cpu(entry->e_value_size));
|
|
|
|
/*
|
|
* Forget about ea_inode within the same transaction that
|
|
* decrements the ref count. This avoids duplicate decrements in
|
|
* case the rest of the work spills over to subsequent
|
|
* transactions.
|
|
*/
|
|
entry->e_value_inum = 0;
|
|
entry->e_value_size = 0;
|
|
|
|
dirty = true;
|
|
}
|
|
|
|
if (dirty) {
|
|
/*
|
|
* Note that we are deliberately skipping csum calculation for
|
|
* the final update because we do not expect any journal
|
|
* restarts until xattr block is freed.
|
|
*/
|
|
|
|
err = ext4_handle_dirty_metadata(handle, NULL, bh);
|
|
if (err)
|
|
ext4_warning_inode(parent,
|
|
"handle dirty metadata err=%d", err);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Release the xattr block BH: If the reference count is > 1, decrement it;
|
|
* otherwise free the block.
|
|
*/
|
|
static void
|
|
ext4_xattr_release_block(handle_t *handle, struct inode *inode,
|
|
struct buffer_head *bh,
|
|
struct ext4_xattr_inode_array **ea_inode_array,
|
|
int extra_credits)
|
|
{
|
|
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
|
|
u32 hash, ref;
|
|
int error = 0;
|
|
|
|
BUFFER_TRACE(bh, "get_write_access");
|
|
error = ext4_journal_get_write_access(handle, bh);
|
|
if (error)
|
|
goto out;
|
|
|
|
retry_ref:
|
|
lock_buffer(bh);
|
|
hash = le32_to_cpu(BHDR(bh)->h_hash);
|
|
ref = le32_to_cpu(BHDR(bh)->h_refcount);
|
|
if (ref == 1) {
|
|
ea_bdebug(bh, "refcount now=0; freeing");
|
|
/*
|
|
* This must happen under buffer lock for
|
|
* ext4_xattr_block_set() to reliably detect freed block
|
|
*/
|
|
if (ea_block_cache) {
|
|
struct mb_cache_entry *oe;
|
|
|
|
oe = mb_cache_entry_delete_or_get(ea_block_cache, hash,
|
|
bh->b_blocknr);
|
|
if (oe) {
|
|
unlock_buffer(bh);
|
|
mb_cache_entry_wait_unused(oe);
|
|
mb_cache_entry_put(ea_block_cache, oe);
|
|
goto retry_ref;
|
|
}
|
|
}
|
|
get_bh(bh);
|
|
unlock_buffer(bh);
|
|
|
|
if (ext4_has_feature_ea_inode(inode->i_sb))
|
|
ext4_xattr_inode_dec_ref_all(handle, inode, bh,
|
|
BFIRST(bh),
|
|
true /* block_csum */,
|
|
ea_inode_array,
|
|
extra_credits,
|
|
true /* skip_quota */);
|
|
ext4_free_blocks(handle, inode, bh, 0, 1,
|
|
EXT4_FREE_BLOCKS_METADATA |
|
|
EXT4_FREE_BLOCKS_FORGET);
|
|
} else {
|
|
ref--;
|
|
BHDR(bh)->h_refcount = cpu_to_le32(ref);
|
|
if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) {
|
|
struct mb_cache_entry *ce;
|
|
|
|
if (ea_block_cache) {
|
|
ce = mb_cache_entry_get(ea_block_cache, hash,
|
|
bh->b_blocknr);
|
|
if (ce) {
|
|
set_bit(MBE_REUSABLE_B, &ce->e_flags);
|
|
mb_cache_entry_put(ea_block_cache, ce);
|
|
}
|
|
}
|
|
}
|
|
|
|
ext4_xattr_block_csum_set(inode, bh);
|
|
/*
|
|
* Beware of this ugliness: Releasing of xattr block references
|
|
* from different inodes can race and so we have to protect
|
|
* from a race where someone else frees the block (and releases
|
|
* its journal_head) before we are done dirtying the buffer. In
|
|
* nojournal mode this race is harmless and we actually cannot
|
|
* call ext4_handle_dirty_metadata() with locked buffer as
|
|
* that function can call sync_dirty_buffer() so for that case
|
|
* we handle the dirtying after unlocking the buffer.
|
|
*/
|
|
if (ext4_handle_valid(handle))
|
|
error = ext4_handle_dirty_metadata(handle, inode, bh);
|
|
unlock_buffer(bh);
|
|
if (!ext4_handle_valid(handle))
|
|
error = ext4_handle_dirty_metadata(handle, inode, bh);
|
|
if (IS_SYNC(inode))
|
|
ext4_handle_sync(handle);
|
|
dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
|
|
ea_bdebug(bh, "refcount now=%d; releasing",
|
|
le32_to_cpu(BHDR(bh)->h_refcount));
|
|
}
|
|
out:
|
|
ext4_std_error(inode->i_sb, error);
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* Find the available free space for EAs. This also returns the total number of
|
|
* bytes used by EA entries.
|
|
*/
|
|
static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
|
|
size_t *min_offs, void *base, int *total)
|
|
{
|
|
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
|
|
if (!last->e_value_inum && last->e_value_size) {
|
|
size_t offs = le16_to_cpu(last->e_value_offs);
|
|
if (offs < *min_offs)
|
|
*min_offs = offs;
|
|
}
|
|
if (total)
|
|
*total += EXT4_XATTR_LEN(last->e_name_len);
|
|
}
|
|
return (*min_offs - ((void *)last - base) - sizeof(__u32));
|
|
}
|
|
|
|
/*
|
|
* Write the value of the EA in an inode.
|
|
*/
|
|
static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
|
|
const void *buf, int bufsize)
|
|
{
|
|
struct buffer_head *bh = NULL;
|
|
unsigned long block = 0;
|
|
int blocksize = ea_inode->i_sb->s_blocksize;
|
|
int max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits;
|
|
int csize, wsize = 0;
|
|
int ret = 0, ret2 = 0;
|
|
int retries = 0;
|
|
|
|
retry:
|
|
while (ret >= 0 && ret < max_blocks) {
|
|
struct ext4_map_blocks map;
|
|
map.m_lblk = block += ret;
|
|
map.m_len = max_blocks -= ret;
|
|
|
|
ret = ext4_map_blocks(handle, ea_inode, &map,
|
|
EXT4_GET_BLOCKS_CREATE);
|
|
if (ret <= 0) {
|
|
ext4_mark_inode_dirty(handle, ea_inode);
|
|
if (ret == -ENOSPC &&
|
|
ext4_should_retry_alloc(ea_inode->i_sb, &retries)) {
|
|
ret = 0;
|
|
goto retry;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
block = 0;
|
|
while (wsize < bufsize) {
|
|
brelse(bh);
|
|
csize = (bufsize - wsize) > blocksize ? blocksize :
|
|
bufsize - wsize;
|
|
bh = ext4_getblk(handle, ea_inode, block, 0);
|
|
if (IS_ERR(bh))
|
|
return PTR_ERR(bh);
|
|
if (!bh) {
|
|
WARN_ON_ONCE(1);
|
|
EXT4_ERROR_INODE(ea_inode,
|
|
"ext4_getblk() return bh = NULL");
|
|
return -EFSCORRUPTED;
|
|
}
|
|
ret = ext4_journal_get_write_access(handle, bh);
|
|
if (ret)
|
|
goto out;
|
|
|
|
memcpy(bh->b_data, buf, csize);
|
|
set_buffer_uptodate(bh);
|
|
ext4_handle_dirty_metadata(handle, ea_inode, bh);
|
|
|
|
buf += csize;
|
|
wsize += csize;
|
|
block += 1;
|
|
}
|
|
|
|
inode_lock(ea_inode);
|
|
i_size_write(ea_inode, wsize);
|
|
ext4_update_i_disksize(ea_inode, wsize);
|
|
inode_unlock(ea_inode);
|
|
|
|
ret2 = ext4_mark_inode_dirty(handle, ea_inode);
|
|
if (unlikely(ret2 && !ret))
|
|
ret = ret2;
|
|
|
|
out:
|
|
brelse(bh);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Create an inode to store the value of a large EA.
|
|
*/
|
|
static struct inode *ext4_xattr_inode_create(handle_t *handle,
|
|
struct inode *inode, u32 hash)
|
|
{
|
|
struct inode *ea_inode = NULL;
|
|
uid_t owner[2] = { i_uid_read(inode), i_gid_read(inode) };
|
|
int err;
|
|
|
|
if (inode->i_sb->s_root == NULL) {
|
|
ext4_warning(inode->i_sb,
|
|
"refuse to create EA inode when umounting");
|
|
WARN_ON(1);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
/*
|
|
* Let the next inode be the goal, so we try and allocate the EA inode
|
|
* in the same group, or nearby one.
|
|
*/
|
|
ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
|
|
S_IFREG | 0600, NULL, inode->i_ino + 1, owner,
|
|
EXT4_EA_INODE_FL);
|
|
if (!IS_ERR(ea_inode)) {
|
|
ea_inode->i_op = &ext4_file_inode_operations;
|
|
ea_inode->i_fop = &ext4_file_operations;
|
|
ext4_set_aops(ea_inode);
|
|
ext4_xattr_inode_set_class(ea_inode);
|
|
unlock_new_inode(ea_inode);
|
|
ext4_xattr_inode_set_ref(ea_inode, 1);
|
|
ext4_xattr_inode_set_hash(ea_inode, hash);
|
|
err = ext4_mark_inode_dirty(handle, ea_inode);
|
|
if (!err)
|
|
err = ext4_inode_attach_jinode(ea_inode);
|
|
if (err) {
|
|
if (ext4_xattr_inode_dec_ref(handle, ea_inode))
|
|
ext4_warning_inode(ea_inode,
|
|
"cleanup dec ref error %d", err);
|
|
iput(ea_inode);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
/*
|
|
* Xattr inodes are shared therefore quota charging is performed
|
|
* at a higher level.
|
|
*/
|
|
dquot_free_inode(ea_inode);
|
|
dquot_drop(ea_inode);
|
|
inode_lock(ea_inode);
|
|
ea_inode->i_flags |= S_NOQUOTA;
|
|
inode_unlock(ea_inode);
|
|
}
|
|
|
|
return ea_inode;
|
|
}
|
|
|
|
static struct inode *
|
|
ext4_xattr_inode_cache_find(struct inode *inode, const void *value,
|
|
size_t value_len, u32 hash)
|
|
{
|
|
struct inode *ea_inode;
|
|
struct mb_cache_entry *ce;
|
|
struct mb_cache *ea_inode_cache = EA_INODE_CACHE(inode);
|
|
void *ea_data;
|
|
|
|
if (!ea_inode_cache)
|
|
return NULL;
|
|
|
|
ce = mb_cache_entry_find_first(ea_inode_cache, hash);
|
|
if (!ce)
|
|
return NULL;
|
|
|
|
WARN_ON_ONCE(ext4_handle_valid(journal_current_handle()) &&
|
|
!(current->flags & PF_MEMALLOC_NOFS));
|
|
|
|
ea_data = kvmalloc(value_len, GFP_KERNEL);
|
|
if (!ea_data) {
|
|
mb_cache_entry_put(ea_inode_cache, ce);
|
|
return NULL;
|
|
}
|
|
|
|
while (ce) {
|
|
ea_inode = ext4_iget(inode->i_sb, ce->e_value,
|
|
EXT4_IGET_NORMAL);
|
|
if (!IS_ERR(ea_inode) &&
|
|
!is_bad_inode(ea_inode) &&
|
|
(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL) &&
|
|
i_size_read(ea_inode) == value_len &&
|
|
!ext4_xattr_inode_read(ea_inode, ea_data, value_len) &&
|
|
!ext4_xattr_inode_verify_hashes(ea_inode, NULL, ea_data,
|
|
value_len) &&
|
|
!memcmp(value, ea_data, value_len)) {
|
|
mb_cache_entry_touch(ea_inode_cache, ce);
|
|
mb_cache_entry_put(ea_inode_cache, ce);
|
|
kvfree(ea_data);
|
|
return ea_inode;
|
|
}
|
|
|
|
if (!IS_ERR(ea_inode))
|
|
iput(ea_inode);
|
|
ce = mb_cache_entry_find_next(ea_inode_cache, ce);
|
|
}
|
|
kvfree(ea_data);
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* Add value of the EA in an inode.
|
|
*/
|
|
static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
|
|
const void *value, size_t value_len,
|
|
struct inode **ret_inode)
|
|
{
|
|
struct inode *ea_inode;
|
|
u32 hash;
|
|
int err;
|
|
|
|
hash = ext4_xattr_inode_hash(EXT4_SB(inode->i_sb), value, value_len);
|
|
ea_inode = ext4_xattr_inode_cache_find(inode, value, value_len, hash);
|
|
if (ea_inode) {
|
|
err = ext4_xattr_inode_inc_ref(handle, ea_inode);
|
|
if (err) {
|
|
iput(ea_inode);
|
|
return err;
|
|
}
|
|
|
|
*ret_inode = ea_inode;
|
|
return 0;
|
|
}
|
|
|
|
/* Create an inode for the EA value */
|
|
ea_inode = ext4_xattr_inode_create(handle, inode, hash);
|
|
if (IS_ERR(ea_inode))
|
|
return PTR_ERR(ea_inode);
|
|
|
|
err = ext4_xattr_inode_write(handle, ea_inode, value, value_len);
|
|
if (err) {
|
|
ext4_xattr_inode_dec_ref(handle, ea_inode);
|
|
iput(ea_inode);
|
|
return err;
|
|
}
|
|
|
|
if (EA_INODE_CACHE(inode))
|
|
mb_cache_entry_create(EA_INODE_CACHE(inode), GFP_NOFS, hash,
|
|
ea_inode->i_ino, true /* reusable */);
|
|
|
|
*ret_inode = ea_inode;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Reserve min(block_size/8, 1024) bytes for xattr entries/names if ea_inode
|
|
* feature is enabled.
|
|
*/
|
|
#define EXT4_XATTR_BLOCK_RESERVE(inode) min(i_blocksize(inode)/8, 1024U)
|
|
|
|
static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
|
|
struct ext4_xattr_search *s,
|
|
handle_t *handle, struct inode *inode,
|
|
bool is_block)
|
|
{
|
|
struct ext4_xattr_entry *last, *next;
|
|
struct ext4_xattr_entry *here = s->here;
|
|
size_t min_offs = s->end - s->base, name_len = strlen(i->name);
|
|
int in_inode = i->in_inode;
|
|
struct inode *old_ea_inode = NULL;
|
|
struct inode *new_ea_inode = NULL;
|
|
size_t old_size, new_size;
|
|
int ret;
|
|
|
|
/* Space used by old and new values. */
|
|
old_size = (!s->not_found && !here->e_value_inum) ?
|
|
EXT4_XATTR_SIZE(le32_to_cpu(here->e_value_size)) : 0;
|
|
new_size = (i->value && !in_inode) ? EXT4_XATTR_SIZE(i->value_len) : 0;
|
|
|
|
/*
|
|
* Optimization for the simple case when old and new values have the
|
|
* same padded sizes. Not applicable if external inodes are involved.
|
|
*/
|
|
if (new_size && new_size == old_size) {
|
|
size_t offs = le16_to_cpu(here->e_value_offs);
|
|
void *val = s->base + offs;
|
|
|
|
here->e_value_size = cpu_to_le32(i->value_len);
|
|
if (i->value == EXT4_ZERO_XATTR_VALUE) {
|
|
memset(val, 0, new_size);
|
|
} else {
|
|
memcpy(val, i->value, i->value_len);
|
|
/* Clear padding bytes. */
|
|
memset(val + i->value_len, 0, new_size - i->value_len);
|
|
}
|
|
goto update_hash;
|
|
}
|
|
|
|
/* Compute min_offs and last. */
|
|
last = s->first;
|
|
for (; !IS_LAST_ENTRY(last); last = next) {
|
|
next = EXT4_XATTR_NEXT(last);
|
|
if ((void *)next >= s->end) {
|
|
EXT4_ERROR_INODE(inode, "corrupted xattr entries");
|
|
ret = -EFSCORRUPTED;
|
|
goto out;
|
|
}
|
|
if (!last->e_value_inum && last->e_value_size) {
|
|
size_t offs = le16_to_cpu(last->e_value_offs);
|
|
if (offs < min_offs)
|
|
min_offs = offs;
|
|
}
|
|
}
|
|
|
|
/* Check whether we have enough space. */
|
|
if (i->value) {
|
|
size_t free;
|
|
|
|
free = min_offs - ((void *)last - s->base) - sizeof(__u32);
|
|
if (!s->not_found)
|
|
free += EXT4_XATTR_LEN(name_len) + old_size;
|
|
|
|
if (free < EXT4_XATTR_LEN(name_len) + new_size) {
|
|
ret = -ENOSPC;
|
|
goto out;
|
|
}
|
|
|
|
/*
|
|
* If storing the value in an external inode is an option,
|
|
* reserve space for xattr entries/names in the external
|
|
* attribute block so that a long value does not occupy the
|
|
* whole space and prevent further entries being added.
|
|
*/
|
|
if (ext4_has_feature_ea_inode(inode->i_sb) &&
|
|
new_size && is_block &&
|
|
(min_offs + old_size - new_size) <
|
|
EXT4_XATTR_BLOCK_RESERVE(inode)) {
|
|
ret = -ENOSPC;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Getting access to old and new ea inodes is subject to failures.
|
|
* Finish that work before doing any modifications to the xattr data.
|
|
*/
|
|
if (!s->not_found && here->e_value_inum) {
|
|
ret = ext4_xattr_inode_iget(inode,
|
|
le32_to_cpu(here->e_value_inum),
|
|
le32_to_cpu(here->e_hash),
|
|
&old_ea_inode);
|
|
if (ret) {
|
|
old_ea_inode = NULL;
|
|
goto out;
|
|
}
|
|
}
|
|
if (i->value && in_inode) {
|
|
WARN_ON_ONCE(!i->value_len);
|
|
|
|
ret = ext4_xattr_inode_alloc_quota(inode, i->value_len);
|
|
if (ret)
|
|
goto out;
|
|
|
|
ret = ext4_xattr_inode_lookup_create(handle, inode, i->value,
|
|
i->value_len,
|
|
&new_ea_inode);
|
|
if (ret) {
|
|
new_ea_inode = NULL;
|
|
ext4_xattr_inode_free_quota(inode, NULL, i->value_len);
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
if (old_ea_inode) {
|
|
/* We are ready to release ref count on the old_ea_inode. */
|
|
ret = ext4_xattr_inode_dec_ref(handle, old_ea_inode);
|
|
if (ret) {
|
|
/* Release newly required ref count on new_ea_inode. */
|
|
if (new_ea_inode) {
|
|
int err;
|
|
|
|
err = ext4_xattr_inode_dec_ref(handle,
|
|
new_ea_inode);
|
|
if (err)
|
|
ext4_warning_inode(new_ea_inode,
|
|
"dec ref new_ea_inode err=%d",
|
|
err);
|
|
ext4_xattr_inode_free_quota(inode, new_ea_inode,
|
|
i->value_len);
|
|
}
|
|
goto out;
|
|
}
|
|
|
|
ext4_xattr_inode_free_quota(inode, old_ea_inode,
|
|
le32_to_cpu(here->e_value_size));
|
|
}
|
|
|
|
/* No failures allowed past this point. */
|
|
|
|
if (!s->not_found && here->e_value_size && !here->e_value_inum) {
|
|
/* Remove the old value. */
|
|
void *first_val = s->base + min_offs;
|
|
size_t offs = le16_to_cpu(here->e_value_offs);
|
|
void *val = s->base + offs;
|
|
|
|
memmove(first_val + old_size, first_val, val - first_val);
|
|
memset(first_val, 0, old_size);
|
|
min_offs += old_size;
|
|
|
|
/* Adjust all value offsets. */
|
|
last = s->first;
|
|
while (!IS_LAST_ENTRY(last)) {
|
|
size_t o = le16_to_cpu(last->e_value_offs);
|
|
|
|
if (!last->e_value_inum &&
|
|
last->e_value_size && o < offs)
|
|
last->e_value_offs = cpu_to_le16(o + old_size);
|
|
last = EXT4_XATTR_NEXT(last);
|
|
}
|
|
}
|
|
|
|
if (!i->value) {
|
|
/* Remove old name. */
|
|
size_t size = EXT4_XATTR_LEN(name_len);
|
|
|
|
last = ENTRY((void *)last - size);
|
|
memmove(here, (void *)here + size,
|
|
(void *)last - (void *)here + sizeof(__u32));
|
|
memset(last, 0, size);
|
|
} else if (s->not_found) {
|
|
/* Insert new name. */
|
|
size_t size = EXT4_XATTR_LEN(name_len);
|
|
size_t rest = (void *)last - (void *)here + sizeof(__u32);
|
|
|
|
memmove((void *)here + size, here, rest);
|
|
memset(here, 0, size);
|
|
here->e_name_index = i->name_index;
|
|
here->e_name_len = name_len;
|
|
memcpy(here->e_name, i->name, name_len);
|
|
} else {
|
|
/* This is an update, reset value info. */
|
|
here->e_value_inum = 0;
|
|
here->e_value_offs = 0;
|
|
here->e_value_size = 0;
|
|
}
|
|
|
|
if (i->value) {
|
|
/* Insert new value. */
|
|
if (in_inode) {
|
|
here->e_value_inum = cpu_to_le32(new_ea_inode->i_ino);
|
|
} else if (i->value_len) {
|
|
void *val = s->base + min_offs - new_size;
|
|
|
|
here->e_value_offs = cpu_to_le16(min_offs - new_size);
|
|
if (i->value == EXT4_ZERO_XATTR_VALUE) {
|
|
memset(val, 0, new_size);
|
|
} else {
|
|
memcpy(val, i->value, i->value_len);
|
|
/* Clear padding bytes. */
|
|
memset(val + i->value_len, 0,
|
|
new_size - i->value_len);
|
|
}
|
|
}
|
|
here->e_value_size = cpu_to_le32(i->value_len);
|
|
}
|
|
|
|
update_hash:
|
|
if (i->value) {
|
|
__le32 hash = 0;
|
|
|
|
/* Entry hash calculation. */
|
|
if (in_inode) {
|
|
__le32 crc32c_hash;
|
|
|
|
/*
|
|
* Feed crc32c hash instead of the raw value for entry
|
|
* hash calculation. This is to avoid walking
|
|
* potentially long value buffer again.
|
|
*/
|
|
crc32c_hash = cpu_to_le32(
|
|
ext4_xattr_inode_get_hash(new_ea_inode));
|
|
hash = ext4_xattr_hash_entry(here->e_name,
|
|
here->e_name_len,
|
|
&crc32c_hash, 1);
|
|
} else if (is_block) {
|
|
__le32 *value = s->base + le16_to_cpu(
|
|
here->e_value_offs);
|
|
|
|
hash = ext4_xattr_hash_entry(here->e_name,
|
|
here->e_name_len, value,
|
|
new_size >> 2);
|
|
}
|
|
here->e_hash = hash;
|
|
}
|
|
|
|
if (is_block)
|
|
ext4_xattr_rehash((struct ext4_xattr_header *)s->base);
|
|
|
|
ret = 0;
|
|
out:
|
|
iput(old_ea_inode);
|
|
iput(new_ea_inode);
|
|
return ret;
|
|
}
|
|
|
|
struct ext4_xattr_block_find {
|
|
struct ext4_xattr_search s;
|
|
struct buffer_head *bh;
|
|
};
|
|
|
|
static int
|
|
ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
|
|
struct ext4_xattr_block_find *bs)
|
|
{
|
|
struct super_block *sb = inode->i_sb;
|
|
int error;
|
|
|
|
ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
|
|
i->name_index, i->name, i->value, (long)i->value_len);
|
|
|
|
if (EXT4_I(inode)->i_file_acl) {
|
|
/* The inode already has an extended attribute block. */
|
|
bs->bh = ext4_sb_bread(sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bs->bh)) {
|
|
error = PTR_ERR(bs->bh);
|
|
bs->bh = NULL;
|
|
return error;
|
|
}
|
|
ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
|
|
atomic_read(&(bs->bh->b_count)),
|
|
le32_to_cpu(BHDR(bs->bh)->h_refcount));
|
|
error = ext4_xattr_check_block(inode, bs->bh);
|
|
if (error)
|
|
return error;
|
|
/* Find the named attribute. */
|
|
bs->s.base = BHDR(bs->bh);
|
|
bs->s.first = BFIRST(bs->bh);
|
|
bs->s.end = bs->bh->b_data + bs->bh->b_size;
|
|
bs->s.here = bs->s.first;
|
|
error = xattr_find_entry(inode, &bs->s.here, bs->s.end,
|
|
i->name_index, i->name, 1);
|
|
if (error && error != -ENODATA)
|
|
return error;
|
|
bs->s.not_found = error;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
ext4_xattr_block_set(handle_t *handle, struct inode *inode,
|
|
struct ext4_xattr_info *i,
|
|
struct ext4_xattr_block_find *bs)
|
|
{
|
|
struct super_block *sb = inode->i_sb;
|
|
struct buffer_head *new_bh = NULL;
|
|
struct ext4_xattr_search s_copy = bs->s;
|
|
struct ext4_xattr_search *s = &s_copy;
|
|
struct mb_cache_entry *ce = NULL;
|
|
int error = 0;
|
|
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
|
|
struct inode *ea_inode = NULL, *tmp_inode;
|
|
size_t old_ea_inode_quota = 0;
|
|
unsigned int ea_ino;
|
|
|
|
|
|
#define header(x) ((struct ext4_xattr_header *)(x))
|
|
|
|
if (s->base) {
|
|
int offset = (char *)s->here - bs->bh->b_data;
|
|
|
|
BUFFER_TRACE(bs->bh, "get_write_access");
|
|
error = ext4_journal_get_write_access(handle, bs->bh);
|
|
if (error)
|
|
goto cleanup;
|
|
lock_buffer(bs->bh);
|
|
|
|
if (header(s->base)->h_refcount == cpu_to_le32(1)) {
|
|
__u32 hash = le32_to_cpu(BHDR(bs->bh)->h_hash);
|
|
|
|
/*
|
|
* This must happen under buffer lock for
|
|
* ext4_xattr_block_set() to reliably detect modified
|
|
* block
|
|
*/
|
|
if (ea_block_cache) {
|
|
struct mb_cache_entry *oe;
|
|
|
|
oe = mb_cache_entry_delete_or_get(ea_block_cache,
|
|
hash, bs->bh->b_blocknr);
|
|
if (oe) {
|
|
/*
|
|
* Xattr block is getting reused. Leave
|
|
* it alone.
|
|
*/
|
|
mb_cache_entry_put(ea_block_cache, oe);
|
|
goto clone_block;
|
|
}
|
|
}
|
|
ea_bdebug(bs->bh, "modifying in-place");
|
|
error = ext4_xattr_set_entry(i, s, handle, inode,
|
|
true /* is_block */);
|
|
ext4_xattr_block_csum_set(inode, bs->bh);
|
|
unlock_buffer(bs->bh);
|
|
if (error == -EFSCORRUPTED)
|
|
goto bad_block;
|
|
if (!error)
|
|
error = ext4_handle_dirty_metadata(handle,
|
|
inode,
|
|
bs->bh);
|
|
if (error)
|
|
goto cleanup;
|
|
goto inserted;
|
|
}
|
|
clone_block:
|
|
unlock_buffer(bs->bh);
|
|
ea_bdebug(bs->bh, "cloning");
|
|
s->base = kmemdup(BHDR(bs->bh), bs->bh->b_size, GFP_NOFS);
|
|
error = -ENOMEM;
|
|
if (s->base == NULL)
|
|
goto cleanup;
|
|
s->first = ENTRY(header(s->base)+1);
|
|
header(s->base)->h_refcount = cpu_to_le32(1);
|
|
s->here = ENTRY(s->base + offset);
|
|
s->end = s->base + bs->bh->b_size;
|
|
|
|
/*
|
|
* If existing entry points to an xattr inode, we need
|
|
* to prevent ext4_xattr_set_entry() from decrementing
|
|
* ref count on it because the reference belongs to the
|
|
* original block. In this case, make the entry look
|
|
* like it has an empty value.
|
|
*/
|
|
if (!s->not_found && s->here->e_value_inum) {
|
|
ea_ino = le32_to_cpu(s->here->e_value_inum);
|
|
error = ext4_xattr_inode_iget(inode, ea_ino,
|
|
le32_to_cpu(s->here->e_hash),
|
|
&tmp_inode);
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
if (!ext4_test_inode_state(tmp_inode,
|
|
EXT4_STATE_LUSTRE_EA_INODE)) {
|
|
/*
|
|
* Defer quota free call for previous
|
|
* inode until success is guaranteed.
|
|
*/
|
|
old_ea_inode_quota = le32_to_cpu(
|
|
s->here->e_value_size);
|
|
}
|
|
iput(tmp_inode);
|
|
|
|
s->here->e_value_inum = 0;
|
|
s->here->e_value_size = 0;
|
|
}
|
|
} else {
|
|
/* Allocate a buffer where we construct the new block. */
|
|
s->base = kzalloc(sb->s_blocksize, GFP_NOFS);
|
|
/* assert(header == s->base) */
|
|
error = -ENOMEM;
|
|
if (s->base == NULL)
|
|
goto cleanup;
|
|
header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
|
|
header(s->base)->h_blocks = cpu_to_le32(1);
|
|
header(s->base)->h_refcount = cpu_to_le32(1);
|
|
s->first = ENTRY(header(s->base)+1);
|
|
s->here = ENTRY(header(s->base)+1);
|
|
s->end = s->base + sb->s_blocksize;
|
|
}
|
|
|
|
error = ext4_xattr_set_entry(i, s, handle, inode, true /* is_block */);
|
|
if (error == -EFSCORRUPTED)
|
|
goto bad_block;
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
if (i->value && s->here->e_value_inum) {
|
|
/*
|
|
* A ref count on ea_inode has been taken as part of the call to
|
|
* ext4_xattr_set_entry() above. We would like to drop this
|
|
* extra ref but we have to wait until the xattr block is
|
|
* initialized and has its own ref count on the ea_inode.
|
|
*/
|
|
ea_ino = le32_to_cpu(s->here->e_value_inum);
|
|
error = ext4_xattr_inode_iget(inode, ea_ino,
|
|
le32_to_cpu(s->here->e_hash),
|
|
&ea_inode);
|
|
if (error) {
|
|
ea_inode = NULL;
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
inserted:
|
|
if (!IS_LAST_ENTRY(s->first)) {
|
|
new_bh = ext4_xattr_block_cache_find(inode, header(s->base),
|
|
&ce);
|
|
if (new_bh) {
|
|
/* We found an identical block in the cache. */
|
|
if (new_bh == bs->bh)
|
|
ea_bdebug(new_bh, "keeping");
|
|
else {
|
|
u32 ref;
|
|
|
|
WARN_ON_ONCE(dquot_initialize_needed(inode));
|
|
|
|
/* The old block is released after updating
|
|
the inode. */
|
|
error = dquot_alloc_block(inode,
|
|
EXT4_C2B(EXT4_SB(sb), 1));
|
|
if (error)
|
|
goto cleanup;
|
|
BUFFER_TRACE(new_bh, "get_write_access");
|
|
error = ext4_journal_get_write_access(handle,
|
|
new_bh);
|
|
if (error)
|
|
goto cleanup_dquot;
|
|
lock_buffer(new_bh);
|
|
/*
|
|
* We have to be careful about races with
|
|
* adding references to xattr block. Once we
|
|
* hold buffer lock xattr block's state is
|
|
* stable so we can check the additional
|
|
* reference fits.
|
|
*/
|
|
ref = le32_to_cpu(BHDR(new_bh)->h_refcount) + 1;
|
|
if (ref > EXT4_XATTR_REFCOUNT_MAX) {
|
|
/*
|
|
* Undo everything and check mbcache
|
|
* again.
|
|
*/
|
|
unlock_buffer(new_bh);
|
|
dquot_free_block(inode,
|
|
EXT4_C2B(EXT4_SB(sb),
|
|
1));
|
|
brelse(new_bh);
|
|
mb_cache_entry_put(ea_block_cache, ce);
|
|
ce = NULL;
|
|
new_bh = NULL;
|
|
goto inserted;
|
|
}
|
|
BHDR(new_bh)->h_refcount = cpu_to_le32(ref);
|
|
if (ref == EXT4_XATTR_REFCOUNT_MAX)
|
|
clear_bit(MBE_REUSABLE_B, &ce->e_flags);
|
|
ea_bdebug(new_bh, "reusing; refcount now=%d",
|
|
ref);
|
|
ext4_xattr_block_csum_set(inode, new_bh);
|
|
unlock_buffer(new_bh);
|
|
error = ext4_handle_dirty_metadata(handle,
|
|
inode,
|
|
new_bh);
|
|
if (error)
|
|
goto cleanup_dquot;
|
|
}
|
|
mb_cache_entry_touch(ea_block_cache, ce);
|
|
mb_cache_entry_put(ea_block_cache, ce);
|
|
ce = NULL;
|
|
} else if (bs->bh && s->base == bs->bh->b_data) {
|
|
/* We were modifying this block in-place. */
|
|
ea_bdebug(bs->bh, "keeping this block");
|
|
ext4_xattr_block_cache_insert(ea_block_cache, bs->bh);
|
|
new_bh = bs->bh;
|
|
get_bh(new_bh);
|
|
} else {
|
|
/* We need to allocate a new block */
|
|
ext4_fsblk_t goal, block;
|
|
|
|
WARN_ON_ONCE(dquot_initialize_needed(inode));
|
|
|
|
goal = ext4_group_first_block_no(sb,
|
|
EXT4_I(inode)->i_block_group);
|
|
block = ext4_new_meta_blocks(handle, inode, goal, 0,
|
|
NULL, &error);
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
ea_idebug(inode, "creating block %llu",
|
|
(unsigned long long)block);
|
|
|
|
new_bh = sb_getblk(sb, block);
|
|
if (unlikely(!new_bh)) {
|
|
error = -ENOMEM;
|
|
getblk_failed:
|
|
ext4_free_blocks(handle, inode, NULL, block, 1,
|
|
EXT4_FREE_BLOCKS_METADATA);
|
|
goto cleanup;
|
|
}
|
|
error = ext4_xattr_inode_inc_ref_all(handle, inode,
|
|
ENTRY(header(s->base)+1));
|
|
if (error)
|
|
goto getblk_failed;
|
|
if (ea_inode) {
|
|
/* Drop the extra ref on ea_inode. */
|
|
error = ext4_xattr_inode_dec_ref(handle,
|
|
ea_inode);
|
|
if (error)
|
|
ext4_warning_inode(ea_inode,
|
|
"dec ref error=%d",
|
|
error);
|
|
iput(ea_inode);
|
|
ea_inode = NULL;
|
|
}
|
|
|
|
lock_buffer(new_bh);
|
|
error = ext4_journal_get_create_access(handle, new_bh);
|
|
if (error) {
|
|
unlock_buffer(new_bh);
|
|
error = -EIO;
|
|
goto getblk_failed;
|
|
}
|
|
memcpy(new_bh->b_data, s->base, new_bh->b_size);
|
|
ext4_xattr_block_csum_set(inode, new_bh);
|
|
set_buffer_uptodate(new_bh);
|
|
unlock_buffer(new_bh);
|
|
ext4_xattr_block_cache_insert(ea_block_cache, new_bh);
|
|
error = ext4_handle_dirty_metadata(handle, inode,
|
|
new_bh);
|
|
if (error)
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
if (old_ea_inode_quota)
|
|
ext4_xattr_inode_free_quota(inode, NULL, old_ea_inode_quota);
|
|
|
|
/* Update the inode. */
|
|
EXT4_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
|
|
|
|
/* Drop the previous xattr block. */
|
|
if (bs->bh && bs->bh != new_bh) {
|
|
struct ext4_xattr_inode_array *ea_inode_array = NULL;
|
|
|
|
ext4_xattr_release_block(handle, inode, bs->bh,
|
|
&ea_inode_array,
|
|
0 /* extra_credits */);
|
|
ext4_xattr_inode_array_free(ea_inode_array);
|
|
}
|
|
error = 0;
|
|
|
|
cleanup:
|
|
if (ea_inode) {
|
|
int error2;
|
|
|
|
error2 = ext4_xattr_inode_dec_ref(handle, ea_inode);
|
|
if (error2)
|
|
ext4_warning_inode(ea_inode, "dec ref error=%d",
|
|
error2);
|
|
|
|
/* If there was an error, revert the quota charge. */
|
|
if (error)
|
|
ext4_xattr_inode_free_quota(inode, ea_inode,
|
|
i_size_read(ea_inode));
|
|
iput(ea_inode);
|
|
}
|
|
if (ce)
|
|
mb_cache_entry_put(ea_block_cache, ce);
|
|
brelse(new_bh);
|
|
if (!(bs->bh && s->base == bs->bh->b_data))
|
|
kfree(s->base);
|
|
|
|
return error;
|
|
|
|
cleanup_dquot:
|
|
dquot_free_block(inode, EXT4_C2B(EXT4_SB(sb), 1));
|
|
goto cleanup;
|
|
|
|
bad_block:
|
|
EXT4_ERROR_INODE(inode, "bad block %llu",
|
|
EXT4_I(inode)->i_file_acl);
|
|
goto cleanup;
|
|
|
|
#undef header
|
|
}
|
|
|
|
int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
|
|
struct ext4_xattr_ibody_find *is)
|
|
{
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_inode *raw_inode;
|
|
int error;
|
|
|
|
if (!EXT4_INODE_HAS_XATTR_SPACE(inode))
|
|
return 0;
|
|
|
|
raw_inode = ext4_raw_inode(&is->iloc);
|
|
header = IHDR(inode, raw_inode);
|
|
is->s.base = is->s.first = IFIRST(header);
|
|
is->s.here = is->s.first;
|
|
is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
|
|
if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
|
|
error = xattr_check_inode(inode, header, is->s.end);
|
|
if (error)
|
|
return error;
|
|
/* Find the named attribute. */
|
|
error = xattr_find_entry(inode, &is->s.here, is->s.end,
|
|
i->name_index, i->name, 0);
|
|
if (error && error != -ENODATA)
|
|
return error;
|
|
is->s.not_found = error;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,
|
|
struct ext4_xattr_info *i,
|
|
struct ext4_xattr_ibody_find *is)
|
|
{
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_xattr_search *s = &is->s;
|
|
int error;
|
|
|
|
if (!EXT4_INODE_HAS_XATTR_SPACE(inode))
|
|
return -ENOSPC;
|
|
|
|
error = ext4_xattr_set_entry(i, s, handle, inode, false /* is_block */);
|
|
if (error)
|
|
return error;
|
|
header = IHDR(inode, ext4_raw_inode(&is->iloc));
|
|
if (!IS_LAST_ENTRY(s->first)) {
|
|
header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
|
|
ext4_set_inode_state(inode, EXT4_STATE_XATTR);
|
|
} else {
|
|
header->h_magic = cpu_to_le32(0);
|
|
ext4_clear_inode_state(inode, EXT4_STATE_XATTR);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int ext4_xattr_value_same(struct ext4_xattr_search *s,
|
|
struct ext4_xattr_info *i)
|
|
{
|
|
void *value;
|
|
|
|
/* When e_value_inum is set the value is stored externally. */
|
|
if (s->here->e_value_inum)
|
|
return 0;
|
|
if (le32_to_cpu(s->here->e_value_size) != i->value_len)
|
|
return 0;
|
|
value = ((void *)s->base) + le16_to_cpu(s->here->e_value_offs);
|
|
return !memcmp(value, i->value, i->value_len);
|
|
}
|
|
|
|
static struct buffer_head *ext4_xattr_get_block(struct inode *inode)
|
|
{
|
|
struct buffer_head *bh;
|
|
int error;
|
|
|
|
if (!EXT4_I(inode)->i_file_acl)
|
|
return NULL;
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh))
|
|
return bh;
|
|
error = ext4_xattr_check_block(inode, bh);
|
|
if (error) {
|
|
brelse(bh);
|
|
return ERR_PTR(error);
|
|
}
|
|
return bh;
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_set_handle()
|
|
*
|
|
* Create, replace or remove an extended attribute for this inode. Value
|
|
* is NULL to remove an existing extended attribute, and non-NULL to
|
|
* either replace an existing extended attribute, or create a new extended
|
|
* attribute. The flags XATTR_REPLACE and XATTR_CREATE
|
|
* specify that an extended attribute must exist and must not exist
|
|
* previous to the call, respectively.
|
|
*
|
|
* Returns 0, or a negative error number on failure.
|
|
*/
|
|
int
|
|
ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
|
|
const char *name, const void *value, size_t value_len,
|
|
int flags)
|
|
{
|
|
struct ext4_xattr_info i = {
|
|
.name_index = name_index,
|
|
.name = name,
|
|
.value = value,
|
|
.value_len = value_len,
|
|
.in_inode = 0,
|
|
};
|
|
struct ext4_xattr_ibody_find is = {
|
|
.s = { .not_found = -ENODATA, },
|
|
};
|
|
struct ext4_xattr_block_find bs = {
|
|
.s = { .not_found = -ENODATA, },
|
|
};
|
|
int no_expand;
|
|
int error;
|
|
|
|
if (!name)
|
|
return -EINVAL;
|
|
if (strlen(name) > 255)
|
|
return -ERANGE;
|
|
|
|
ext4_write_lock_xattr(inode, &no_expand);
|
|
|
|
/* Check journal credits under write lock. */
|
|
if (ext4_handle_valid(handle)) {
|
|
struct buffer_head *bh;
|
|
int credits;
|
|
|
|
bh = ext4_xattr_get_block(inode);
|
|
if (IS_ERR(bh)) {
|
|
error = PTR_ERR(bh);
|
|
goto cleanup;
|
|
}
|
|
|
|
credits = __ext4_xattr_set_credits(inode->i_sb, inode, bh,
|
|
value_len,
|
|
flags & XATTR_CREATE);
|
|
brelse(bh);
|
|
|
|
if (jbd2_handle_buffer_credits(handle) < credits) {
|
|
error = -ENOSPC;
|
|
goto cleanup;
|
|
}
|
|
WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
|
|
}
|
|
|
|
error = ext4_reserve_inode_write(handle, inode, &is.iloc);
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) {
|
|
struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc);
|
|
memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
|
|
ext4_clear_inode_state(inode, EXT4_STATE_NEW);
|
|
}
|
|
|
|
error = ext4_xattr_ibody_find(inode, &i, &is);
|
|
if (error)
|
|
goto cleanup;
|
|
if (is.s.not_found)
|
|
error = ext4_xattr_block_find(inode, &i, &bs);
|
|
if (error)
|
|
goto cleanup;
|
|
if (is.s.not_found && bs.s.not_found) {
|
|
error = -ENODATA;
|
|
if (flags & XATTR_REPLACE)
|
|
goto cleanup;
|
|
error = 0;
|
|
if (!value)
|
|
goto cleanup;
|
|
} else {
|
|
error = -EEXIST;
|
|
if (flags & XATTR_CREATE)
|
|
goto cleanup;
|
|
}
|
|
|
|
if (!value) {
|
|
if (!is.s.not_found)
|
|
error = ext4_xattr_ibody_set(handle, inode, &i, &is);
|
|
else if (!bs.s.not_found)
|
|
error = ext4_xattr_block_set(handle, inode, &i, &bs);
|
|
} else {
|
|
error = 0;
|
|
/* Xattr value did not change? Save us some work and bail out */
|
|
if (!is.s.not_found && ext4_xattr_value_same(&is.s, &i))
|
|
goto cleanup;
|
|
if (!bs.s.not_found && ext4_xattr_value_same(&bs.s, &i))
|
|
goto cleanup;
|
|
|
|
if (ext4_has_feature_ea_inode(inode->i_sb) &&
|
|
(EXT4_XATTR_SIZE(i.value_len) >
|
|
EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
|
|
i.in_inode = 1;
|
|
retry_inode:
|
|
error = ext4_xattr_ibody_set(handle, inode, &i, &is);
|
|
if (!error && !bs.s.not_found) {
|
|
i.value = NULL;
|
|
error = ext4_xattr_block_set(handle, inode, &i, &bs);
|
|
} else if (error == -ENOSPC) {
|
|
if (EXT4_I(inode)->i_file_acl && !bs.s.base) {
|
|
brelse(bs.bh);
|
|
bs.bh = NULL;
|
|
error = ext4_xattr_block_find(inode, &i, &bs);
|
|
if (error)
|
|
goto cleanup;
|
|
}
|
|
error = ext4_xattr_block_set(handle, inode, &i, &bs);
|
|
if (!error && !is.s.not_found) {
|
|
i.value = NULL;
|
|
error = ext4_xattr_ibody_set(handle, inode, &i,
|
|
&is);
|
|
} else if (error == -ENOSPC) {
|
|
/*
|
|
* Xattr does not fit in the block, store at
|
|
* external inode if possible.
|
|
*/
|
|
if (ext4_has_feature_ea_inode(inode->i_sb) &&
|
|
i.value_len && !i.in_inode) {
|
|
i.in_inode = 1;
|
|
goto retry_inode;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!error) {
|
|
ext4_xattr_update_super_block(handle, inode->i_sb);
|
|
inode->i_ctime = current_time(inode);
|
|
if (!value)
|
|
no_expand = 0;
|
|
error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
|
|
/*
|
|
* The bh is consumed by ext4_mark_iloc_dirty, even with
|
|
* error != 0.
|
|
*/
|
|
is.iloc.bh = NULL;
|
|
if (IS_SYNC(inode))
|
|
ext4_handle_sync(handle);
|
|
}
|
|
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR);
|
|
|
|
cleanup:
|
|
brelse(is.iloc.bh);
|
|
brelse(bs.bh);
|
|
ext4_write_unlock_xattr(inode, &no_expand);
|
|
return error;
|
|
}
|
|
|
|
int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
|
|
bool is_create, int *credits)
|
|
{
|
|
struct buffer_head *bh;
|
|
int err;
|
|
|
|
*credits = 0;
|
|
|
|
if (!EXT4_SB(inode->i_sb)->s_journal)
|
|
return 0;
|
|
|
|
down_read(&EXT4_I(inode)->xattr_sem);
|
|
|
|
bh = ext4_xattr_get_block(inode);
|
|
if (IS_ERR(bh)) {
|
|
err = PTR_ERR(bh);
|
|
} else {
|
|
*credits = __ext4_xattr_set_credits(inode->i_sb, inode, bh,
|
|
value_len, is_create);
|
|
brelse(bh);
|
|
err = 0;
|
|
}
|
|
|
|
up_read(&EXT4_I(inode)->xattr_sem);
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_set()
|
|
*
|
|
* Like ext4_xattr_set_handle, but start from an inode. This extended
|
|
* attribute modification is a filesystem transaction by itself.
|
|
*
|
|
* Returns 0, or a negative error number on failure.
|
|
*/
|
|
int
|
|
ext4_xattr_set(struct inode *inode, int name_index, const char *name,
|
|
const void *value, size_t value_len, int flags)
|
|
{
|
|
handle_t *handle;
|
|
struct super_block *sb = inode->i_sb;
|
|
int error, retries = 0;
|
|
int credits;
|
|
|
|
error = dquot_initialize(inode);
|
|
if (error)
|
|
return error;
|
|
|
|
retry:
|
|
error = ext4_xattr_set_credits(inode, value_len, flags & XATTR_CREATE,
|
|
&credits);
|
|
if (error)
|
|
return error;
|
|
|
|
handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
|
|
if (IS_ERR(handle)) {
|
|
error = PTR_ERR(handle);
|
|
} else {
|
|
int error2;
|
|
|
|
error = ext4_xattr_set_handle(handle, inode, name_index, name,
|
|
value, value_len, flags);
|
|
error2 = ext4_journal_stop(handle);
|
|
if (error == -ENOSPC &&
|
|
ext4_should_retry_alloc(sb, &retries))
|
|
goto retry;
|
|
if (error == 0)
|
|
error = error2;
|
|
}
|
|
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR);
|
|
|
|
return error;
|
|
}
|
|
|
|
/*
|
|
* Shift the EA entries in the inode to create space for the increased
|
|
* i_extra_isize.
|
|
*/
|
|
static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,
|
|
int value_offs_shift, void *to,
|
|
void *from, size_t n)
|
|
{
|
|
struct ext4_xattr_entry *last = entry;
|
|
int new_offs;
|
|
|
|
/* We always shift xattr headers further thus offsets get lower */
|
|
BUG_ON(value_offs_shift > 0);
|
|
|
|
/* Adjust the value offsets of the entries */
|
|
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
|
|
if (!last->e_value_inum && last->e_value_size) {
|
|
new_offs = le16_to_cpu(last->e_value_offs) +
|
|
value_offs_shift;
|
|
last->e_value_offs = cpu_to_le16(new_offs);
|
|
}
|
|
}
|
|
/* Shift the entries by n bytes */
|
|
memmove(to, from, n);
|
|
}
|
|
|
|
/*
|
|
* Move xattr pointed to by 'entry' from inode into external xattr block
|
|
*/
|
|
static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
|
|
struct ext4_inode *raw_inode,
|
|
struct ext4_xattr_entry *entry)
|
|
{
|
|
struct ext4_xattr_ibody_find *is = NULL;
|
|
struct ext4_xattr_block_find *bs = NULL;
|
|
char *buffer = NULL, *b_entry_name = NULL;
|
|
size_t value_size = le32_to_cpu(entry->e_value_size);
|
|
struct ext4_xattr_info i = {
|
|
.value = NULL,
|
|
.value_len = 0,
|
|
.name_index = entry->e_name_index,
|
|
.in_inode = !!entry->e_value_inum,
|
|
};
|
|
struct ext4_xattr_ibody_header *header = IHDR(inode, raw_inode);
|
|
int needs_kvfree = 0;
|
|
int error;
|
|
|
|
is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
|
|
bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
|
|
b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS);
|
|
if (!is || !bs || !b_entry_name) {
|
|
error = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
is->s.not_found = -ENODATA;
|
|
bs->s.not_found = -ENODATA;
|
|
is->iloc.bh = NULL;
|
|
bs->bh = NULL;
|
|
|
|
/* Save the entry name and the entry value */
|
|
if (entry->e_value_inum) {
|
|
buffer = kvmalloc(value_size, GFP_NOFS);
|
|
if (!buffer) {
|
|
error = -ENOMEM;
|
|
goto out;
|
|
}
|
|
needs_kvfree = 1;
|
|
error = ext4_xattr_inode_get(inode, entry, buffer, value_size);
|
|
if (error)
|
|
goto out;
|
|
} else {
|
|
size_t value_offs = le16_to_cpu(entry->e_value_offs);
|
|
buffer = (void *)IFIRST(header) + value_offs;
|
|
}
|
|
|
|
memcpy(b_entry_name, entry->e_name, entry->e_name_len);
|
|
b_entry_name[entry->e_name_len] = '\0';
|
|
i.name = b_entry_name;
|
|
|
|
error = ext4_get_inode_loc(inode, &is->iloc);
|
|
if (error)
|
|
goto out;
|
|
|
|
error = ext4_xattr_ibody_find(inode, &i, is);
|
|
if (error)
|
|
goto out;
|
|
|
|
i.value = buffer;
|
|
i.value_len = value_size;
|
|
error = ext4_xattr_block_find(inode, &i, bs);
|
|
if (error)
|
|
goto out;
|
|
|
|
/* Move ea entry from the inode into the block */
|
|
error = ext4_xattr_block_set(handle, inode, &i, bs);
|
|
if (error)
|
|
goto out;
|
|
|
|
/* Remove the chosen entry from the inode */
|
|
i.value = NULL;
|
|
i.value_len = 0;
|
|
error = ext4_xattr_ibody_set(handle, inode, &i, is);
|
|
|
|
out:
|
|
kfree(b_entry_name);
|
|
if (needs_kvfree && buffer)
|
|
kvfree(buffer);
|
|
if (is)
|
|
brelse(is->iloc.bh);
|
|
if (bs)
|
|
brelse(bs->bh);
|
|
kfree(is);
|
|
kfree(bs);
|
|
|
|
return error;
|
|
}
|
|
|
|
static int ext4_xattr_make_inode_space(handle_t *handle, struct inode *inode,
|
|
struct ext4_inode *raw_inode,
|
|
int isize_diff, size_t ifree,
|
|
size_t bfree, int *total_ino)
|
|
{
|
|
struct ext4_xattr_ibody_header *header = IHDR(inode, raw_inode);
|
|
struct ext4_xattr_entry *small_entry;
|
|
struct ext4_xattr_entry *entry;
|
|
struct ext4_xattr_entry *last;
|
|
unsigned int entry_size; /* EA entry size */
|
|
unsigned int total_size; /* EA entry size + value size */
|
|
unsigned int min_total_size;
|
|
int error;
|
|
|
|
while (isize_diff > ifree) {
|
|
entry = NULL;
|
|
small_entry = NULL;
|
|
min_total_size = ~0U;
|
|
last = IFIRST(header);
|
|
/* Find the entry best suited to be pushed into EA block */
|
|
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
|
|
/* never move system.data out of the inode */
|
|
if ((last->e_name_len == 4) &&
|
|
(last->e_name_index == EXT4_XATTR_INDEX_SYSTEM) &&
|
|
!memcmp(last->e_name, "data", 4))
|
|
continue;
|
|
total_size = EXT4_XATTR_LEN(last->e_name_len);
|
|
if (!last->e_value_inum)
|
|
total_size += EXT4_XATTR_SIZE(
|
|
le32_to_cpu(last->e_value_size));
|
|
if (total_size <= bfree &&
|
|
total_size < min_total_size) {
|
|
if (total_size + ifree < isize_diff) {
|
|
small_entry = last;
|
|
} else {
|
|
entry = last;
|
|
min_total_size = total_size;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (entry == NULL) {
|
|
if (small_entry == NULL)
|
|
return -ENOSPC;
|
|
entry = small_entry;
|
|
}
|
|
|
|
entry_size = EXT4_XATTR_LEN(entry->e_name_len);
|
|
total_size = entry_size;
|
|
if (!entry->e_value_inum)
|
|
total_size += EXT4_XATTR_SIZE(
|
|
le32_to_cpu(entry->e_value_size));
|
|
error = ext4_xattr_move_to_block(handle, inode, raw_inode,
|
|
entry);
|
|
if (error)
|
|
return error;
|
|
|
|
*total_ino -= entry_size;
|
|
ifree += total_size;
|
|
bfree -= total_size;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Expand an inode by new_extra_isize bytes when EAs are present.
|
|
* Returns 0 on success or negative error number on failure.
|
|
*/
|
|
int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
|
|
struct ext4_inode *raw_inode, handle_t *handle)
|
|
{
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
|
static unsigned int mnt_count;
|
|
size_t min_offs;
|
|
size_t ifree, bfree;
|
|
int total_ino;
|
|
void *base, *end;
|
|
int error = 0, tried_min_extra_isize = 0;
|
|
int s_min_extra_isize = le16_to_cpu(sbi->s_es->s_min_extra_isize);
|
|
int isize_diff; /* How much do we need to grow i_extra_isize */
|
|
|
|
retry:
|
|
isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize;
|
|
if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
|
|
return 0;
|
|
|
|
header = IHDR(inode, raw_inode);
|
|
|
|
/*
|
|
* Check if enough free space is available in the inode to shift the
|
|
* entries ahead by new_extra_isize.
|
|
*/
|
|
|
|
base = IFIRST(header);
|
|
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
|
|
min_offs = end - base;
|
|
total_ino = sizeof(struct ext4_xattr_ibody_header) + sizeof(u32);
|
|
|
|
error = xattr_check_inode(inode, header, end);
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
ifree = ext4_xattr_free_space(base, &min_offs, base, &total_ino);
|
|
if (ifree >= isize_diff)
|
|
goto shift;
|
|
|
|
/*
|
|
* Enough free space isn't available in the inode, check if
|
|
* EA block can hold new_extra_isize bytes.
|
|
*/
|
|
if (EXT4_I(inode)->i_file_acl) {
|
|
struct buffer_head *bh;
|
|
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh)) {
|
|
error = PTR_ERR(bh);
|
|
goto cleanup;
|
|
}
|
|
error = ext4_xattr_check_block(inode, bh);
|
|
if (error) {
|
|
brelse(bh);
|
|
goto cleanup;
|
|
}
|
|
base = BHDR(bh);
|
|
end = bh->b_data + bh->b_size;
|
|
min_offs = end - base;
|
|
bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
|
|
NULL);
|
|
brelse(bh);
|
|
if (bfree + ifree < isize_diff) {
|
|
if (!tried_min_extra_isize && s_min_extra_isize) {
|
|
tried_min_extra_isize++;
|
|
new_extra_isize = s_min_extra_isize;
|
|
goto retry;
|
|
}
|
|
error = -ENOSPC;
|
|
goto cleanup;
|
|
}
|
|
} else {
|
|
bfree = inode->i_sb->s_blocksize;
|
|
}
|
|
|
|
error = ext4_xattr_make_inode_space(handle, inode, raw_inode,
|
|
isize_diff, ifree, bfree,
|
|
&total_ino);
|
|
if (error) {
|
|
if (error == -ENOSPC && !tried_min_extra_isize &&
|
|
s_min_extra_isize) {
|
|
tried_min_extra_isize++;
|
|
new_extra_isize = s_min_extra_isize;
|
|
goto retry;
|
|
}
|
|
goto cleanup;
|
|
}
|
|
shift:
|
|
/* Adjust the offsets and shift the remaining entries ahead */
|
|
ext4_xattr_shift_entries(IFIRST(header), EXT4_I(inode)->i_extra_isize
|
|
- new_extra_isize, (void *)raw_inode +
|
|
EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
|
|
(void *)header, total_ino);
|
|
EXT4_I(inode)->i_extra_isize = new_extra_isize;
|
|
|
|
if (ext4_has_inline_data(inode))
|
|
error = ext4_find_inline_data_nolock(inode);
|
|
|
|
cleanup:
|
|
if (error && (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count))) {
|
|
ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
|
|
inode->i_ino);
|
|
mnt_count = le16_to_cpu(sbi->s_es->s_mnt_count);
|
|
}
|
|
return error;
|
|
}
|
|
|
|
#define EIA_INCR 16 /* must be 2^n */
|
|
#define EIA_MASK (EIA_INCR - 1)
|
|
|
|
/* Add the large xattr @inode into @ea_inode_array for deferred iput().
|
|
* If @ea_inode_array is new or full it will be grown and the old
|
|
* contents copied over.
|
|
*/
|
|
static int
|
|
ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
|
|
struct inode *inode)
|
|
{
|
|
if (*ea_inode_array == NULL) {
|
|
/*
|
|
* Start with 15 inodes, so it fits into a power-of-two size.
|
|
* If *ea_inode_array is NULL, this is essentially offsetof()
|
|
*/
|
|
(*ea_inode_array) =
|
|
kmalloc(offsetof(struct ext4_xattr_inode_array,
|
|
inodes[EIA_MASK]),
|
|
GFP_NOFS);
|
|
if (*ea_inode_array == NULL)
|
|
return -ENOMEM;
|
|
(*ea_inode_array)->count = 0;
|
|
} else if (((*ea_inode_array)->count & EIA_MASK) == EIA_MASK) {
|
|
/* expand the array once all 15 + n * 16 slots are full */
|
|
struct ext4_xattr_inode_array *new_array = NULL;
|
|
int count = (*ea_inode_array)->count;
|
|
|
|
/* if new_array is NULL, this is essentially offsetof() */
|
|
new_array = kmalloc(
|
|
offsetof(struct ext4_xattr_inode_array,
|
|
inodes[count + EIA_INCR]),
|
|
GFP_NOFS);
|
|
if (new_array == NULL)
|
|
return -ENOMEM;
|
|
memcpy(new_array, *ea_inode_array,
|
|
offsetof(struct ext4_xattr_inode_array, inodes[count]));
|
|
kfree(*ea_inode_array);
|
|
*ea_inode_array = new_array;
|
|
}
|
|
(*ea_inode_array)->inodes[(*ea_inode_array)->count++] = inode;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_delete_inode()
|
|
*
|
|
* Free extended attribute resources associated with this inode. Traverse
|
|
* all entries and decrement reference on any xattr inodes associated with this
|
|
* inode. This is called immediately before an inode is freed. We have exclusive
|
|
* access to the inode. If an orphan inode is deleted it will also release its
|
|
* references on xattr block and xattr inodes.
|
|
*/
|
|
int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
|
|
struct ext4_xattr_inode_array **ea_inode_array,
|
|
int extra_credits)
|
|
{
|
|
struct buffer_head *bh = NULL;
|
|
struct ext4_xattr_ibody_header *header;
|
|
struct ext4_iloc iloc = { .bh = NULL };
|
|
struct ext4_xattr_entry *entry;
|
|
struct inode *ea_inode;
|
|
int error;
|
|
|
|
error = ext4_journal_ensure_credits(handle, extra_credits,
|
|
ext4_free_metadata_revoke_credits(inode->i_sb, 1));
|
|
if (error < 0) {
|
|
EXT4_ERROR_INODE(inode, "ensure credits (error %d)", error);
|
|
goto cleanup;
|
|
}
|
|
|
|
if (ext4_has_feature_ea_inode(inode->i_sb) &&
|
|
ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
|
|
|
|
error = ext4_get_inode_loc(inode, &iloc);
|
|
if (error) {
|
|
EXT4_ERROR_INODE(inode, "inode loc (error %d)", error);
|
|
goto cleanup;
|
|
}
|
|
|
|
error = ext4_journal_get_write_access(handle, iloc.bh);
|
|
if (error) {
|
|
EXT4_ERROR_INODE(inode, "write access (error %d)",
|
|
error);
|
|
goto cleanup;
|
|
}
|
|
|
|
header = IHDR(inode, ext4_raw_inode(&iloc));
|
|
if (header->h_magic == cpu_to_le32(EXT4_XATTR_MAGIC))
|
|
ext4_xattr_inode_dec_ref_all(handle, inode, iloc.bh,
|
|
IFIRST(header),
|
|
false /* block_csum */,
|
|
ea_inode_array,
|
|
extra_credits,
|
|
false /* skip_quota */);
|
|
}
|
|
|
|
if (EXT4_I(inode)->i_file_acl) {
|
|
bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
|
|
if (IS_ERR(bh)) {
|
|
error = PTR_ERR(bh);
|
|
if (error == -EIO) {
|
|
EXT4_ERROR_INODE_ERR(inode, EIO,
|
|
"block %llu read error",
|
|
EXT4_I(inode)->i_file_acl);
|
|
}
|
|
bh = NULL;
|
|
goto cleanup;
|
|
}
|
|
error = ext4_xattr_check_block(inode, bh);
|
|
if (error)
|
|
goto cleanup;
|
|
|
|
if (ext4_has_feature_ea_inode(inode->i_sb)) {
|
|
for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry);
|
|
entry = EXT4_XATTR_NEXT(entry)) {
|
|
if (!entry->e_value_inum)
|
|
continue;
|
|
error = ext4_xattr_inode_iget(inode,
|
|
le32_to_cpu(entry->e_value_inum),
|
|
le32_to_cpu(entry->e_hash),
|
|
&ea_inode);
|
|
if (error)
|
|
continue;
|
|
ext4_xattr_inode_free_quota(inode, ea_inode,
|
|
le32_to_cpu(entry->e_value_size));
|
|
iput(ea_inode);
|
|
}
|
|
|
|
}
|
|
|
|
ext4_xattr_release_block(handle, inode, bh, ea_inode_array,
|
|
extra_credits);
|
|
/*
|
|
* Update i_file_acl value in the same transaction that releases
|
|
* block.
|
|
*/
|
|
EXT4_I(inode)->i_file_acl = 0;
|
|
error = ext4_mark_inode_dirty(handle, inode);
|
|
if (error) {
|
|
EXT4_ERROR_INODE(inode, "mark inode dirty (error %d)",
|
|
error);
|
|
goto cleanup;
|
|
}
|
|
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR);
|
|
}
|
|
error = 0;
|
|
cleanup:
|
|
brelse(iloc.bh);
|
|
brelse(bh);
|
|
return error;
|
|
}
|
|
|
|
void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *ea_inode_array)
|
|
{
|
|
int idx;
|
|
|
|
if (ea_inode_array == NULL)
|
|
return;
|
|
|
|
for (idx = 0; idx < ea_inode_array->count; ++idx)
|
|
iput(ea_inode_array->inodes[idx]);
|
|
kfree(ea_inode_array);
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_block_cache_insert()
|
|
*
|
|
* Create a new entry in the extended attribute block cache, and insert
|
|
* it unless such an entry is already in the cache.
|
|
*
|
|
* Returns 0, or a negative error number on failure.
|
|
*/
|
|
static void
|
|
ext4_xattr_block_cache_insert(struct mb_cache *ea_block_cache,
|
|
struct buffer_head *bh)
|
|
{
|
|
struct ext4_xattr_header *header = BHDR(bh);
|
|
__u32 hash = le32_to_cpu(header->h_hash);
|
|
int reusable = le32_to_cpu(header->h_refcount) <
|
|
EXT4_XATTR_REFCOUNT_MAX;
|
|
int error;
|
|
|
|
if (!ea_block_cache)
|
|
return;
|
|
error = mb_cache_entry_create(ea_block_cache, GFP_NOFS, hash,
|
|
bh->b_blocknr, reusable);
|
|
if (error) {
|
|
if (error == -EBUSY)
|
|
ea_bdebug(bh, "already in cache");
|
|
} else
|
|
ea_bdebug(bh, "inserting [%x]", (int)hash);
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_cmp()
|
|
*
|
|
* Compare two extended attribute blocks for equality.
|
|
*
|
|
* Returns 0 if the blocks are equal, 1 if they differ, and
|
|
* a negative error number on errors.
|
|
*/
|
|
static int
|
|
ext4_xattr_cmp(struct ext4_xattr_header *header1,
|
|
struct ext4_xattr_header *header2)
|
|
{
|
|
struct ext4_xattr_entry *entry1, *entry2;
|
|
|
|
entry1 = ENTRY(header1+1);
|
|
entry2 = ENTRY(header2+1);
|
|
while (!IS_LAST_ENTRY(entry1)) {
|
|
if (IS_LAST_ENTRY(entry2))
|
|
return 1;
|
|
if (entry1->e_hash != entry2->e_hash ||
|
|
entry1->e_name_index != entry2->e_name_index ||
|
|
entry1->e_name_len != entry2->e_name_len ||
|
|
entry1->e_value_size != entry2->e_value_size ||
|
|
entry1->e_value_inum != entry2->e_value_inum ||
|
|
memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
|
|
return 1;
|
|
if (!entry1->e_value_inum &&
|
|
memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
|
|
(char *)header2 + le16_to_cpu(entry2->e_value_offs),
|
|
le32_to_cpu(entry1->e_value_size)))
|
|
return 1;
|
|
|
|
entry1 = EXT4_XATTR_NEXT(entry1);
|
|
entry2 = EXT4_XATTR_NEXT(entry2);
|
|
}
|
|
if (!IS_LAST_ENTRY(entry2))
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* ext4_xattr_block_cache_find()
|
|
*
|
|
* Find an identical extended attribute block.
|
|
*
|
|
* Returns a pointer to the block found, or NULL if such a block was
|
|
* not found or an error occurred.
|
|
*/
|
|
static struct buffer_head *
|
|
ext4_xattr_block_cache_find(struct inode *inode,
|
|
struct ext4_xattr_header *header,
|
|
struct mb_cache_entry **pce)
|
|
{
|
|
__u32 hash = le32_to_cpu(header->h_hash);
|
|
struct mb_cache_entry *ce;
|
|
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
|
|
|
|
if (!ea_block_cache)
|
|
return NULL;
|
|
if (!header->h_hash)
|
|
return NULL; /* never share */
|
|
ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
|
|
ce = mb_cache_entry_find_first(ea_block_cache, hash);
|
|
while (ce) {
|
|
struct buffer_head *bh;
|
|
|
|
bh = ext4_sb_bread(inode->i_sb, ce->e_value, REQ_PRIO);
|
|
if (IS_ERR(bh)) {
|
|
if (PTR_ERR(bh) == -ENOMEM)
|
|
return NULL;
|
|
bh = NULL;
|
|
EXT4_ERROR_INODE(inode, "block %lu read error",
|
|
(unsigned long)ce->e_value);
|
|
} else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
|
|
*pce = ce;
|
|
return bh;
|
|
}
|
|
brelse(bh);
|
|
ce = mb_cache_entry_find_next(ea_block_cache, ce);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
#define NAME_HASH_SHIFT 5
|
|
#define VALUE_HASH_SHIFT 16
|
|
|
|
/*
|
|
* ext4_xattr_hash_entry()
|
|
*
|
|
* Compute the hash of an extended attribute.
|
|
*/
|
|
static __le32 ext4_xattr_hash_entry(char *name, size_t name_len, __le32 *value,
|
|
size_t value_count)
|
|
{
|
|
__u32 hash = 0;
|
|
|
|
while (name_len--) {
|
|
hash = (hash << NAME_HASH_SHIFT) ^
|
|
(hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
|
|
*name++;
|
|
}
|
|
while (value_count--) {
|
|
hash = (hash << VALUE_HASH_SHIFT) ^
|
|
(hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
|
|
le32_to_cpu(*value++);
|
|
}
|
|
return cpu_to_le32(hash);
|
|
}
|
|
|
|
#undef NAME_HASH_SHIFT
|
|
#undef VALUE_HASH_SHIFT
|
|
|
|
#define BLOCK_HASH_SHIFT 16
|
|
|
|
/*
|
|
* ext4_xattr_rehash()
|
|
*
|
|
* Re-compute the extended attribute hash value after an entry has changed.
|
|
*/
|
|
static void ext4_xattr_rehash(struct ext4_xattr_header *header)
|
|
{
|
|
struct ext4_xattr_entry *here;
|
|
__u32 hash = 0;
|
|
|
|
here = ENTRY(header+1);
|
|
while (!IS_LAST_ENTRY(here)) {
|
|
if (!here->e_hash) {
|
|
/* Block is not shared if an entry's hash value == 0 */
|
|
hash = 0;
|
|
break;
|
|
}
|
|
hash = (hash << BLOCK_HASH_SHIFT) ^
|
|
(hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
|
|
le32_to_cpu(here->e_hash);
|
|
here = EXT4_XATTR_NEXT(here);
|
|
}
|
|
header->h_hash = cpu_to_le32(hash);
|
|
}
|
|
|
|
#undef BLOCK_HASH_SHIFT
|
|
|
|
#define HASH_BUCKET_BITS 10
|
|
|
|
struct mb_cache *
|
|
ext4_xattr_create_cache(void)
|
|
{
|
|
return mb_cache_create(HASH_BUCKET_BITS);
|
|
}
|
|
|
|
void ext4_xattr_destroy_cache(struct mb_cache *cache)
|
|
{
|
|
if (cache)
|
|
mb_cache_destroy(cache);
|
|
}
|
|
|