5.4.263-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 5.4.263-rc1 review
This is the start of the stable review cycle for the 5.4.263 release. There are 94 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 07 Dec 2023 03:14:57 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.263-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.4.263-rc1
Adrian Hunter <[email protected]>
mmc: block: Retry commands in CQE error recovery
Zheng Yongjun <[email protected]>
mmc: core: convert comma to semicolon
Adrian Hunter <[email protected]>
mmc: cqhci: Fix task clearing in CQE error recovery
Adrian Hunter <[email protected]>
mmc: cqhci: Warn of halt or task clear failure
Adrian Hunter <[email protected]>
mmc: cqhci: Increase recovery halt timeout
Christoph Niedermaier <[email protected]>
cpufreq: imx6q: Don't disable 792 Mhz OPP unnecessarily
Christoph Niedermaier <[email protected]>
cpufreq: imx6q: don't warn for disabling a non-existing frequency
Quinn Tran <[email protected]>
scsi: qla2xxx: Fix system crash due to bad pointer access
Bart Van Assche <[email protected]>
scsi: qla2xxx: Use scsi_cmd_to_rq() instead of scsi_cmnd.request
Bart Van Assche <[email protected]>
scsi: core: Introduce the scsi_cmd_to_rq() function
Bart Van Assche <[email protected]>
scsi: qla2xxx: Simplify the code for aborting SCSI commands
Mimi Zohar <[email protected]>
ima: detect changes to the backing overlay file
Konstantin Khlebnikov <[email protected]>
ovl: skip overlayfs superblocks at global sync
Amir Goldstein <[email protected]>
ima: annotate iint mutex to avoid lockdep false positive warnings
Helge Deller <[email protected]>
fbdev: stifb: Make the STI next font pointer a 32-bit signed offset
Linus Walleij <[email protected]>
mtd: cfi_cmdset_0001: Byte swap OTP info
Jean-Philippe Brucker <[email protected]>
mtd: cfi_cmdset_0001: Support the absence of protection registers
Heiko Carstens <[email protected]>
s390/cmma: fix detection of DAT pages
Alexander Gordeev <[email protected]>
s390/mm: fix phys vs virt confusion in mark_kernel_pXd() functions family
Steve French <[email protected]>
smb3: fix touch -h of symlink
Adrian Hunter <[email protected]>
perf intel-pt: Fix async branch flags
Adrian Hunter <[email protected]>
perf intel-pt: Adjust sample flags for VM-Exit
Claudiu Beznea <[email protected]>
net: ravb: Start TX queues after HW initialization succeeded
Claudiu Beznea <[email protected]>
net: ravb: Use pm_runtime_resume_and_get()
Yoshihiro Shimoda <[email protected]>
ravb: Fix races between ravb_tx_timeout_work() and net related ops
Furong Xu <[email protected]>
net: stmmac: xgmac: Disable FPE MMC interrupts
Zhengchao Shao <[email protected]>
ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet
Max Nguyen <[email protected]>
Input: xpad - add HyperX Clutch Gladiate Support
Filipe Manana <[email protected]>
btrfs: make error messages more clear when getting a chunk map
Jann Horn <[email protected]>
btrfs: send: ensure send_fd is writable
Filipe Manana <[email protected]>
btrfs: fix off-by-one when checking chunk map includes logical address
Qu Wenruo <[email protected]>
btrfs: add dmesg output for first mount and last unmount of a filesystem
Timothy Pearson <[email protected]>
powerpc: Don't clobber f0/vs0 during fp|altivec register save
Markus Weippert <[email protected]>
bcache: revert replacing IS_ERR_OR_NULL with IS_ERR
Wu Bo <[email protected]>
dm verity: don't perform FEC for failed readahead IO
Mikulas Patocka <[email protected]>
dm-verity: align struct dm_verity_fec_io properly
Kailang Yang <[email protected]>
ALSA: hda/realtek: Add supported ALC257 for ChromeOS
Kailang Yang <[email protected]>
ALSA: hda/realtek: Headset Mic VREF to 100%
Takashi Iwai <[email protected]>
ALSA: hda: Disable power-save on KONTRON SinglePC
Adrian Hunter <[email protected]>
mmc: block: Do not lose cache flush during CQE error recovery
Wenchao Chen <[email protected]>
mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled
Yang Yingliang <[email protected]>
firewire: core: fix possible memory leak in create_units()
Maria Yu <[email protected]>
pinctrl: avoid reload of p state in list iteration
Adrian Hunter <[email protected]>
perf inject: Fix GEN_ELF_TEXT_OFFSET for jit
Keith Busch <[email protected]>
io_uring: fix off-by one bvec index
Johan Hovold <[email protected]>
USB: dwc3: qcom: fix wakeup after probe deferral
Johan Hovold <[email protected]>
USB: dwc3: qcom: fix resource leaks on probe deferral
Ricardo Ribalda <[email protected]>
usb: dwc3: set the dma max_seg_size
Oliver Neukum <[email protected]>
USB: dwc2: write HCINT with INTMASK applied
Lech Perczak <[email protected]>
USB: serial: option: don't claim interface 4 for ZTE MF290
Puliang Lu <[email protected]>
USB: serial: option: fix FM101R-GL defines
Victor Fragoso <[email protected]>
USB: serial: option: add Fibocom L7xx modules
Rand Deeb <[email protected]>
bcache: prevent potential division by zero error
Coly Li <[email protected]>
bcache: check return value from btree_node_alloc_replacement()
Mikulas Patocka <[email protected]>
dm-delay: fix a race between delay_presuspend and delay_bio
Long Li <[email protected]>
hv_netvsc: Mark VF as slave before exposing it to user-mode
Haiyang Zhang <[email protected]>
hv_netvsc: Fix race of register_netdevice_notifier and VF register
Asuna Yang <[email protected]>
USB: serial: option: add Luat Air72*U series products
Jan Höppner <[email protected]>
s390/dasd: protect device queue against concurrent access
Coly Li <[email protected]>
bcache: replace a mistaken IS_ERR() by IS_ERR_OR_NULL() in btree_gc_coalesce()
Hans de Goede <[email protected]>
ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CVA
Andrew Murray <[email protected]>
KVM: arm64: limit PMU version to PMUv3 for ARMv8.1
Andrew Murray <[email protected]>
arm64: cpufeature: Extract capped perfmon fields
Zhang Yi <[email protected]>
ext4: make sure allocate pending entry not fail
Baokun Li <[email protected]>
ext4: fix slab-use-after-free in ext4_es_insert_extent()
Baokun Li <[email protected]>
ext4: using nofail preallocation in ext4_es_insert_extent()
Baokun Li <[email protected]>
ext4: using nofail preallocation in ext4_es_insert_delayed_block()
Baokun Li <[email protected]>
ext4: using nofail preallocation in ext4_es_remove_extent()
Baokun Li <[email protected]>
ext4: use pre-allocated es in __es_remove_extent()
Baokun Li <[email protected]>
ext4: use pre-allocated es in __es_insert_extent()
Baokun Li <[email protected]>
ext4: factor out __es_alloc_extent() and __es_free_extent()
Baokun Li <[email protected]>
ext4: add a new helper to check if es must be kept
Huacai Chen <[email protected]>
MIPS: KVM: Fix a build warning about variable set but not used
Christoph Hellwig <[email protected]>
nvmet: nul-terminate the NQNs passed in the connect command
Chaitanya Kulkarni <[email protected]>
nvmet: remove unnecessary ctrl parameter
David Howells <[email protected]>
afs: Fix file locking on R/O volumes to operate in local mode
David Howells <[email protected]>
afs: Return ENOENT if no cell DNS record can be found
Samuel Holland <[email protected]>
net: axienet: Fix check for partial TX checksum
Raju Rangoju <[email protected]>
amd-xgbe: propagate the correct speed and duplex status
Raju Rangoju <[email protected]>
amd-xgbe: handle the corner-case during tx completion
Raju Rangoju <[email protected]>
amd-xgbe: handle corner-case during sfp hotplug
Stefano Stabellini <[email protected]>
arm/xen: fix xen_vcpu_info allocation alignment
Jose Ignacio Tornos Martinez <[email protected]>
net: usb: ax88179_178a: fix failed operations during ax88179_reset
Kunwu Chan <[email protected]>
ipv4: Correct/silence an endian warning in __ip_do_redirect
Charles Yi <[email protected]>
HID: fix HID device resource race between HID core and debugging support
Benjamin Tissoires <[email protected]>
HID: core: store the unique system identifier in hid_device
Jonas Karlman <[email protected]>
drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full
Chen Ni <[email protected]>
ata: pata_isapnp: Add missing error check for devm_ioport_map()
Marek Vasut <[email protected]>
drm/panel: simple: Fix Innolux G101ICE-L01 timings
Marek Vasut <[email protected]>
drm/panel: simple: Fix Innolux G101ICE-L01 bus flags
David Howells <[email protected]>
afs: Make error on cell lookup failure consistent with OpenAFS
Nathan Chancellor <[email protected]>
PCI: keystone: Drop __init from ks_pcie_add_pcie_{ep,port}()
Christopher Bednarz <[email protected]>
RDMA/irdma: Prevent zero-length STAG registration
Saravana Kannan <[email protected]>
driver core: Release all resources during unbind before updating device links
-------------
Diffstat:
Makefile | 4 +- arch/arm/xen/enlighten.c | 3 +- arch/arm64/include/asm/cpufeature.h | 23 ++ arch/arm64/include/asm/sysreg.h | 6 + arch/arm64/kvm/sys_regs.c | 10 + arch/mips/kvm/mmu.c | 3 +- arch/powerpc/kernel/fpu.S | 13 + arch/powerpc/kernel/vector.S | 2 + arch/s390/mm/page-states.c | 14 +- drivers/acpi/resource.c | 7 + drivers/ata/pata_isapnp.c | 3 + drivers/base/dd.c | 4 +- drivers/cpufreq/imx6q-cpufreq.c | 32 +-- drivers/firewire/core-device.c | 11 +- drivers/gpu/drm/panel/panel-simple.c | 13 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 14 +- drivers/hid/hid-core.c | 16 +- drivers/hid/hid-debug.c | 3 + drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 6 + drivers/infiniband/hw/i40iw/i40iw_type.h | 2 + drivers/infiniband/hw/i40iw/i40iw_verbs.c | 10 +- drivers/input/joystick/xpad.c | 2 + drivers/md/bcache/btree.c | 6 +- drivers/md/bcache/sysfs.c | 2 +- drivers/md/dm-delay.c | 17 +- drivers/md/dm-verity-fec.c | 3 +- drivers/md/dm-verity-target.c | 4 +- drivers/md/dm-verity.h | 6 - drivers/mmc/core/block.c | 2 + drivers/mmc/core/core.c | 15 +- drivers/mmc/host/cqhci.c | 44 ++-- drivers/mmc/host/sdhci-sprd.c | 25 ++ drivers/mtd/chips/cfi_cmdset_0001.c | 29 +- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 14 + drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 11 +- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 14 +- drivers/net/ethernet/renesas/ravb_main.c | 20 +- drivers/net/ethernet/stmicro/stmmac/mmc_core.c | 4 + drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 41 ++- drivers/net/usb/ax88179_178a.c | 4 +- drivers/nvme/target/core.c | 21 +- drivers/nvme/target/fabrics-cmd.c | 15 +- drivers/nvme/target/nvmet.h | 5 +- drivers/pci/controller/dwc/pci-keystone.c | 8 +- drivers/pinctrl/core.c | 6 +- drivers/s390/block/dasd.c | 24 +- drivers/scsi/qla2xxx/qla_def.h | 3 - drivers/scsi/qla2xxx/qla_isr.c | 5 - drivers/scsi/qla2xxx/qla_os.c | 39 +-- drivers/usb/dwc2/hcd_intr.c | 15 +- drivers/usb/dwc3/core.c | 2 + drivers/usb/dwc3/dwc3-qcom.c | 17 +- drivers/usb/serial/option.c | 11 +- drivers/video/fbdev/sticore.h | 2 +- fs/afs/dynroot.c | 4 +- fs/afs/super.c | 2 + fs/afs/vl_rotate.c | 10 + fs/btrfs/disk-io.c | 1 + fs/btrfs/send.c | 2 +- fs/btrfs/super.c | 5 +- fs/btrfs/volumes.c | 9 +- fs/cifs/cifsfs.c | 1 + fs/ext4/extents_status.c | 306 +++++++++++++++------- fs/io_uring.c | 2 +- fs/overlayfs/super.c | 5 +- fs/sync.c | 3 +- include/linux/fs.h | 2 + include/linux/hid.h | 5 + include/scsi/scsi_cmnd.h | 6 + net/ipv4/igmp.c | 6 +- net/ipv4/route.c | 2 +- security/integrity/iint.c | 48 +++- security/integrity/ima/ima_api.c | 5 + security/integrity/ima/ima_main.c | 16 +- security/integrity/integrity.h | 2 + sound/pci/hda/hda_intel.c | 2 + sound/pci/hda/patch_realtek.c | 12 + tools/perf/util/genelf.h | 4 +- tools/perf/util/intel-pt.c | 13 +- 80 files changed, 790 insertions(+), 320 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/94 driver core: Release all resources during unbind before updating device links
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
commit 2e84dc37920012b458e9458b19fc4ed33f81bc74 upstream.
This commit fixes a bug in commit 9ed9895370ae ("driver core: Functional dependencies tracking support") where the device link status was incorrectly updated in the driver unbind path before all the device's resources were released.
--- drivers/base/dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/dd.c +2 -2
@@ -1162,8 +1162,6 @@ static void __device_release_driver(struelse if (drv->remove) drv->remove (dev); -device_links_driver_cleanup (dev); -devres_release_all (dev);arch_teardown_dma_ops (dev); dev->driver =NULL ;
@@ -1173,6 +1171,8 @@ static void __device_release_driver(strupm_runtime_reinit (dev);dev_pm_set_driver_flags (dev,0 ); +device_links_driver_cleanup (dev); +klist_remove (&dev->p->knode_driver);device_pm_check_callbacks (dev);if (dev->bus)
Greg Kroah-Hartman
maintainerPATCH 2/94 RDMA/irdma: Prevent zero-length STAG registration
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher Bednarz <[email protected]>
commit bb6d73d9add68ad270888db327514384dfa44958 upstream.
Currently irdma allows zero-length STAGs to be programmed in HW during the kernel mode fast register flow. Zero-length MR or STAG registration disable HW memory length checks.
Improve gaps in bounds checking in irdma by preventing zero-length STAG or MR registrations except if the IB_PD_UNSAFE_GLOBAL_RKEY is set.
This addresses the disclosure CVE-2023-25775.
--- drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 6 ++++++ drivers/infiniband/hw/i40iw/i40iw_type.h | 2 ++ drivers/infiniband/hw/i40iw/i40iw_verbs.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_ctrl.c +6 -0
@@ -2945,6 +2945,9 @@ static enum i40iw_status_code i40iw_sc_au64 header;enum i40iw_page_size page_size; +if (!info->total_len && !info->all_memory) +return -EINVAL ; + page_size = (info->page_size ==0x200000 ) ?I40IW_PAGE_SIZE_2M :I40IW_PAGE_SIZE_4K ; cqp = dev->cqp; wqe =i40iw_sc_cqp_get_next_send_wqe (cqp, scratch);
@@ -3003,6 +3006,9 @@ static enum i40iw_status_code i40iw_sc_mu8 addr_type;enum i40iw_page_size page_size; +if (!info->total_len && !info->all_memory) +return -EINVAL ; + page_size = (info->page_size ==0x200000 ) ?I40IW_PAGE_SIZE_2M :I40IW_PAGE_SIZE_4K ;if (info->access_rights & (I40IW_ACCESS_FLAGS_REMOTEREAD_ONLY |I40IW_ACCESS_FLAGS_REMOTEWRITE_ONLY ))
drivers/infiniband/hw/i40iw/i40iw_type.h +2 -0
@@ -779,6 +779,7 @@ struct i40iw_allocate_stag_info {bool use_hmc_fcn_index;u8 hmc_fcn_index;bool use_pf_rid; +bool all_memory; };struct i40iw_reg_ns_stag_info {
@@ -797,6 +798,7 @@ struct i40iw_reg_ns_stag_info {bool use_hmc_fcn_index;u8 hmc_fcn_index;bool use_pf_rid; +bool all_memory; };struct i40iw_fast_reg_stag_info {
drivers/infiniband/hw/i40iw/i40iw_verbs.c +8 -2
@@ -1500,7 +1500,8 @@ static int i40iw_handle_q_mem(struct i40static int i40iw_hw_alloc_stag (struct i40iw_device *iwdev,struct i40iw_mr *iwmr) {struct i40iw_allocate_stag_info *info; -struct i40iw_pd *iwpd =to_iwpd (iwmr->ibmr.pd); +struct ib_pd *pd = iwmr->ibmr.pd; +struct i40iw_pd *iwpd =to_iwpd (pd);enum i40iw_status_code status;int err =0 ;struct i40iw_cqp_request *cqp_request;
@@ -1517,6 +1518,7 @@ static int i40iw_hw_alloc_stag(struct i4 info->stag_idx = iwmr->stag >>I40IW_CQPSQ_STAG_IDX_SHIFT ; info->pd_id = iwpd->sc_pd.pd_id; info->total_len = iwmr->length; + info->all_memory = pd->flags &IB_PD_UNSAFE_GLOBAL_RKEY ; info->remote_access = true; cqp_info->cqp_cmd =OP_ALLOC_STAG ; cqp_info->post_sq =1 ;
@@ -1570,6 +1572,8 @@ static struct ib_mr *i40iw_alloc_mr(stru iwmr->type =IW_MEMREG_TYPE_MEM ; palloc = &iwpbl->pble_alloc; iwmr->page_cnt = max_num_sg; +/* Use system PAGE_SIZE as the sg page sizes are unknown at this point */ + iwmr->length = max_num_sg *PAGE_SIZE ;mutex_lock (&iwdev->pbl_mutex); status =i40iw_get_pble (&iwdev->sc_dev, iwdev->pble_rsrc, palloc, iwmr->page_cnt);mutex_unlock (&iwdev->pbl_mutex);
@@ -1666,7 +1670,8 @@ static int i40iw_hwreg_mr(struct i40iw_d {struct i40iw_pbl *iwpbl = &iwmr->iwpbl;struct i40iw_reg_ns_stag_info *stag_info; -struct i40iw_pd *iwpd =to_iwpd (iwmr->ibmr.pd); +struct ib_pd *pd = iwmr->ibmr.pd; +struct i40iw_pd *iwpd =to_iwpd (pd);struct i40iw_pble_alloc *palloc = &iwpbl->pble_alloc;enum i40iw_status_code status;int err =0 ;
@@ -1686,6 +1691,7 @@ static int i40iw_hwreg_mr(struct i40iw_d stag_info->total_len = iwmr->length; stag_info->access_rights = access; stag_info->pd_id = iwpd->sc_pd.pd_id; + stag_info->all_memory = pd->flags &IB_PD_UNSAFE_GLOBAL_RKEY ; stag_info->addr_type =I40IW_ADDR_TYPE_VA_BASED ; stag_info->page_size = iwmr->page_size;
Greg Kroah-Hartman
maintainerPATCH 3/94 PCI: keystone: Drop __init from ks_pcie_add_pcie_{ep,port}()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
This commit has no upstream equivalent.
After commit 012dba0ab814 ("PCI: keystone: Don't discard .probe() callback") in 5.4.262, there are two modpost warnings when building with clang:
WARNING: modpost: vmlinux.o(.text+0x5aa6dc): Section mismatch in reference from the function ks_pcie_probe() to the function .init.text:ks_pcie_add_pcie_port() The function ks_pcie_probe() references
the function __init ks_pcie_add_pcie_port().
This is often because ks_pcie_probe lacks a __init
annotation or the annotation of ks_pcie_add_pcie_port is wrong.
WARNING: modpost: vmlinux.o(.text+0x5aa6f4): Section mismatch in reference from the function ks_pcie_probe() to the function .init.text:ks_pcie_add_pcie_ep() The function ks_pcie_probe() references
the function __init ks_pcie_add_pcie_ep().
This is often because ks_pcie_probe lacks a __init
annotation or the annotation of ks_pcie_add_pcie_ep is wrong.
ks_pcie_add_pcie_ep() was removed in upstream commit a0fd361db8e5 ("PCI:
dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code") and ks_pcie_add_pcie_port() was removed in upstream commit 60f5b73fa0f2 ("PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init()"), both of which happened before upstream commit 7994db905c0f ("PCI: keystone: Don't discard .probe() callback").
As neither of these removal changes are really suitable for stable, just remove __init from these functions in stable, as it is no longer a correct annotation after dropping __init from ks_pcie_probe().
--- drivers/pci/controller/dwc/pci-keystone.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +4 -4
@@ -861,8 +861,8 @@ static irqreturn_t ks_pcie_err_irq_handlreturn ks_pcie_handle_error_irq (ks_pcie); } -static int __init ks_pcie_add_pcie_port (struct keystone_pcie *ks_pcie, -struct platform_device *pdev) +static int ks_pcie_add_pcie_port (struct keystone_pcie *ks_pcie, +struct platform_device *pdev) {struct dw_pcie *pci = ks_pcie->pci;struct pcie_port *pp = &pci->pp;
@@ -992,8 +992,8 @@ static const struct dw_pcie_ep_ops ks_pc .get_features = &ks_pcie_am654_get_features, }; -static int __init ks_pcie_add_pcie_ep (struct keystone_pcie *ks_pcie, -struct platform_device *pdev) +static int ks_pcie_add_pcie_ep (struct keystone_pcie *ks_pcie, +struct platform_device *pdev) {int ret;struct dw_pcie_ep *ep;
Greg Kroah-Hartman
maintainerPATCH 4/94 afs: Make error on cell lookup failure consistent with OpenAFS
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 2a4ca1b4b77850544408595e2433f5d7811a9daa ]
When kafs tries to look up a cell in the DNS or the local config, it will translate a lookup failure into EDESTADDRREQ whereas OpenAFS translates it into ENOENT. Applications such as West expect the latter behaviour and fail if they see the former.
This can be seen by trying to mount an unknown cell:
# mount -t afs %example.com:cell.root /mnt mount: /mnt: mount(2) system call failed: Destination address required.
--- fs/afs/dynroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/dynroot.c +2 -2
@@ -38,8 +38,8 @@ static int afs_probe_cell_name(struct dentry *dentry) ret =dns_query (net->net,"afsdb" , name, len,"srv=1" ,NULL ,NULL , false); -if (ret == -ENODATA ) - ret = -EDESTADDRREQ ; +if (ret == -ENODATA || ret == -ENOKEY ) + ret = -ENOENT ;return ret; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 5/94 drm/panel: simple: Fix Innolux G101ICE-L01 bus flags
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 06fc41b09cfbc02977acd9189473593a37d82d9b ]
Add missing .bus_flags = DRM_BUS_FLAG_DE_HIGH to this panel description, ones which match both the datasheet and the panel display_timing flags .
--- drivers/gpu/drm/panel/panel-simple.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-simple.c +1 -0
@@ -1670,6 +1670,7 @@ static const struct panel_desc innolux_g101ice_l01 = { .disable = 200, }, .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, + .bus_flags = DRM_BUS_FLAG_DE_HIGH, .connector_type = DRM_MODE_CONNECTOR_LVDS, };
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 6/94 drm/panel: simple: Fix Innolux G101ICE-L01 timings
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 3f9a91b6c00e655d27bd785dcda1742dbdc31bda ]
The Innolux G101ICE-L01 datasheet [1] page 17 table 6.1 INPUT SIGNAL TIMING SPECIFICATIONS
indicates that maximum vertical blanking time is 40 lines. Currently the driver uses 29 lines.
Fix it, and since this panel is a DE panel, adjust the timings to make them less hostile to controllers which cannot do 1 px HSA/VSA, distribute the delays evenly between all three parts.
[1] https://www.data-modul.com/sites/default/files/products/G101ICE-L01-C2-specification-12042389.pdf
--- drivers/gpu/drm/panel/panel-simple.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +6 -6
@@ -1647,13 +1647,13 @@ static const struct panel_desc innolux_g070y2_l01 = {static const struct display_timing innolux_g101ice_l01_timing = { .pixelclock = {60400000 ,71100000 ,74700000 }, .hactive = {1280 ,1280 ,1280 }, - .hfront_porch = {41 ,80 ,100 }, - .hback_porch = {40 ,79 ,99 }, - .hsync_len = {1 ,1 ,1 }, + .hfront_porch = {30 ,60 ,70 }, + .hback_porch = {30 ,60 ,70 }, + .hsync_len = {22 ,40 ,60 }, .vactive = {800 ,800 ,800 }, - .vfront_porch = {5 ,11 ,14 }, - .vback_porch = {4 ,11 ,14 }, - .vsync_len = {1 ,1 ,1 }, + .vfront_porch = {3 ,8 ,14 }, + .vback_porch = {3 ,8 ,14 }, + .vsync_len = {4 ,7 ,12 }, .flags =DISPLAY_FLAGS_DE_HIGH , };
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 7/94 ata: pata_isapnp: Add missing error check for devm_ioport_map()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit a6925165ea82b7765269ddd8dcad57c731aa00de ]
Add missing error return check for devm_ioport_map() and return the error if this function call fails.
--- drivers/ata/pata_isapnp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ata/pata_isapnp.c +3 -0
@@ -82,6 +82,9 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *devif (pnp_port_valid (idev,1 )) { ctl_addr =devm_ioport_map (&idev->dev,pnp_port_start (idev,1 ),1 ); +if (!ctl_addr) +return -ENOMEM ; + ap->ioaddr.altstatus_addr = ctl_addr; ap->ioaddr.ctl_addr = ctl_addr; ap->ops = &isapnp_port_ops;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 8/94 drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit bb0a05acd6121ff0e810b44fdc24dbdfaa46b642 ]
Use of DRM_FORMAT_RGB888 and DRM_FORMAT_BGR888 on e.g. RK3288, RK3328 and RK3399 result in wrong colors being displayed.
The issue can be observed using modetest:
modetest -s <connector_id>@<crtc_id>:1920x1080-60@RG24 modetest -s <connector_id>@<crtc_id>:1920x1080-60@BG24
Vendor 4.4 kernel apply an inverted rb swap for these formats on VOP full framework (IP version 3.x) compared to VOP little framework (2.x).
Fix colors by applying different rb swap for VOP full framework (3.x) and VOP little framework (2.x) similar to vendor 4.4 kernel.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +11 -3
@@ -234,14 +234,22 @@ static inline void vop_cfg_done(struct vop *vop)VOP_REG_SET (vop, common, cfg_done,1 ); } -static bool has_rb_swapped (uint32_t format) +static bool has_rb_swapped (uint32_t version,uint32_t format) {switch (format) {case DRM_FORMAT_XBGR8888 :case DRM_FORMAT_ABGR8888 : -case DRM_FORMAT_BGR888 :case DRM_FORMAT_BGR565 :return true; +/* +* full framework (IP version 3.x) only need rb swapped for RGB888 and +* little framework (IP version 2.x) only need rb swapped for BGR888, +* check for 3.x to also only rb swap BGR888 for unknown vop version +*/ +case DRM_FORMAT_RGB888 : +return VOP_MAJOR (version) ==3 ; +case DRM_FORMAT_BGR888 : +return VOP_MAJOR (version) !=3 ;default :return false; }
@@ -886,7 +894,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,VOP_WIN_SET (vop, win, dsp_info, dsp_info);VOP_WIN_SET (vop, win, dsp_st, dsp_st); - rb_swap =has_rb_swapped (fb->format->format); + rb_swap =has_rb_swapped (vop->data->version, fb->format->format);VOP_WIN_SET (vop, win, rb_swap, rb_swap);/*
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 9/94 HID: core: store the unique system identifier in hid_device
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Tissoires <[email protected]>
[ Upstream commit 1e839143d674603b0bbbc4c513bca35404967dbc ]
This unique identifier is currently used only for ensuring uniqueness in sysfs. However, this could be handful for userspace to refer to a specific hid_device by this id.
2 use cases are in my mind: LEDs (and their naming convention), and HID-BPF.
Stable-dep-of: fc43e9c857b7 ("HID: fix HID device resource race between HID core and debugging support")
--- drivers/hid/hid-core.c | 4 +++- include/linux/hid.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/hid/hid-core.c +3 -1
@@ -2437,10 +2437,12 @@ int hid_add_device(struct hid_device *hdev)hid_warn (hdev,"bad device descriptor (%d)\n" , ret); } + hdev->id =atomic_inc_return (&id); +/* XXX hack, any other cleaner solution after the driver core * is converted to allow more than 20 bytes as the device name? */ dev_set_name (&hdev->dev,"%04X:%04X:%04X.%04X" , hdev->bus, - hdev->vendor, hdev->product,atomic_inc_return (&id)); + hdev->vendor, hdev->product, hdev->id);hid_debug_register (hdev,dev_name (&hdev->dev)); ret =device_add (&hdev->dev);
include/linux/hid.h +2 -0
@@ -622,6 +622,8 @@ struct hid_device { /* device report descriptor */struct list_head debug_list;spinlock_t debug_list_lock;wait_queue_head_t debug_wait; + +unsigned int id;/* system unique id */ };#define to_hid_device (pdev) \
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 10/94 HID: fix HID device resource race between HID core and debugging support
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Yi <[email protected]>
[ Upstream commit fc43e9c857b7aa55efba9398419b14d9e35dcc7d ]
hid_debug_events_release releases resources bound to the HID device instance. hid_device_release releases the underlying HID device instance potentially before hid_debug_events_release has completed releasing debug resources bound to the same HID device instance.
Reference count to prevent the HID device instance from being torn down preemptively when HID debugging support is used. When count reaches zero, release core resources of HID device instance using hiddev_free.
The crash:
[ 120.728477][ T4396] kernel BUG at lib/list_debug.c:53! [ 120.728505][ T4396] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 120.739806][ T4396] Modules linked in: bcmdhd dhd_static_buf 8822cu pcie_mhi r8168 [ 120.747386][ T4396] CPU: 1 PID: 4396 Comm: hidt_bridge Not tainted 5.10.110 #257 [ 120.754771][ T4396] Hardware name: Rockchip RK3588 EVB4 LP4 V10 Board (DT) [ 120.761643][ T4396] pstate: 60400089 (nZCv daIf +PAN -UAO -TCO BTYPE=--) [ 120.768338][ T4396] pc : __list_del_entry_valid+0x98/0xac [ 120.773730][ T4396] lr : __list_del_entry_valid+0x98/0xac [ 120.779120][ T4396] sp : ffffffc01e62bb60 [ 120.783126][ T4396] x29: ffffffc01e62bb60 x28: ffffff818ce3a200 [ 120.789126][ T4396] x27: 0000000000000009 x26: 0000000000980000 [ 120.795126][ T4396] x25: ffffffc012431000 x24: ffffff802c6d4e00 [ 120.801125][ T4396] x23: ffffff8005c66f00 x22: ffffffc01183b5b8 [ 120.807125][ T4396] x21: ffffff819df2f100 x20: 0000000000000000 [ 120.813124][ T4396] x19: ffffff802c3f0700 x18: ffffffc01d2cd058 [ 120.819124][ T4396] x17: 0000000000000000 x16: 0000000000000000 [ 120.825124][ T4396] x15: 0000000000000004 x14: 0000000000003fff [ 120.831123][ T4396] x13: ffffffc012085588 x12: 0000000000000003 [ 120.837123][ T4396] x11: 00000000ffffbfff x10: 0000000000000003 [ 120.843123][ T4396] x9 : 455103d46b329300 x8 : 455103d46b329300 [ 120.849124][ T4396] x7 : 74707572726f6320 x6 : ffffffc0124b8cb5 [ 120.855124][ T4396] x5 : ffffffffffffffff x4 : 0000000000000000 [ 120.861123][ T4396] x3 : ffffffc011cf4f90 x2 : ffffff81fee7b948 [ 120.867122][ T4396] x1 : ffffffc011cf4f90 x0 : 0000000000000054 [ 120.873122][ T4396] Call trace: [ 120.876259][ T4396] __list_del_entry_valid+0x98/0xac [ 120.881304][ T4396] hid_debug_events_release+0x48/0x12c [ 120.886617][ T4396] full_proxy_release+0x50/0xbc [ 120.891323][ T4396] __fput+0xdc/0x238 [ 120.895075][ T4396] ____fput+0x14/0x24 [ 120.898911][ T4396] task_work_run+0x90/0x148 [ 120.903268][ T4396] do_exit+0x1bc/0x8a4 [ 120.907193][ T4396] do_group_exit+0x8c/0xa4 [ 120.911458][ T4396] get_signal+0x468/0x744 [ 120.915643][ T4396] do_signal+0x84/0x280 [ 120.919650][ T4396] do_notify_resume+0xd0/0x218 [ 120.924262][ T4396] work_pending+0xc/0x3f0
--- drivers/hid/hid-core.c | 12 ++++++++++-- drivers/hid/hid-debug.c | 3 +++ include/linux/hid.h | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/hid/hid-core.c +10 -2
@@ -702,15 +702,22 @@ static void hid_close_report(struct hid_device *device)* Free a device structure, all reports, and all fields. */ -static void hid_device_release (struct device *dev) +void hiddev_free (struct kref *ref) { -struct hid_device *hid =to_hid_device (dev); + struct hid_device *hid = container_of(ref, struct hid_device, ref);hid_close_report (hid);kfree (hid->dev_rdesc);kfree (hid); } +static void hid_device_release (struct device *dev) +{ +struct hid_device *hid =to_hid_device (dev); + +kref_put (&hid->ref, hiddev_free); +} +/* * Fetch a report description item from the data stream. We support long * items, though they are not used yet.
@@ -2485,6 +2492,7 @@ struct hid_device *hid_allocate_device(void)spin_lock_init (&hdev->debug_list_lock);sema_init (&hdev->driver_input_lock,1 );mutex_init (&hdev->ll_open_lock); +kref_init (&hdev->ref);return hdev; }
drivers/hid/hid-debug.c +3 -0
@@ -1082,6 +1082,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file) goto out; } list->hdev = (struct hid_device *) inode->i_private; +kref_get (&list->hdev->ref); file->private_data = list;mutex_init (&list->read_mutex);
@@ -1174,6 +1175,8 @@ static int hid_debug_events_release(struct inode *inode, struct file *file)list_del (&list->node);spin_unlock_irqrestore (&list->hdev->debug_list_lock, flags);kfifo_free (&list->hid_debug_fifo); + +kref_put (&list->hdev->ref, hiddev_free);kfree (list);return 0 ;
include/linux/hid.h +3 -0
@@ -622,10 +622,13 @@ struct hid_device { /* device report descriptor */struct list_head debug_list;spinlock_t debug_list_lock;wait_queue_head_t debug_wait; +struct kref ref;unsigned int id;/* system unique id */ }; +void hiddev_free (struct kref *ref); +#define to_hid_device (pdev) \ container_of(pdev, struct hid_device, dev)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 11/94 ipv4: Correct/silence an endian warning in __ip_do_redirect
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
[ Upstream commit c0e2926266af3b5acf28df0a8fc6e4d90effe0bb ]
net/ipv4/route.c:783:46: warning: incorrect type in argument 2 (different base types)net/ipv4/route.c:783:46: expected unsigned int [usertype] keynet/ipv4/route.c:783:46: got restricted __be32 [usertype] new_gw
--- net/ipv4/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
@@ -799,7 +799,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow goto reject_redirect; } - n =__ipv4_neigh_lookup (rt->dst.dev, new_gw); + n =__ipv4_neigh_lookup (rt->dst.dev, (__force u32 )new_gw);if (!n) n =neigh_create (&arp_tbl, &new_gw, rt->dst.dev);if (!IS_ERR (n)) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 12/94 net: usb: ax88179_178a: fix failed operations during ax88179_reset
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jose Ignacio Tornos Martinez <[email protected]>
[ Upstream commit 0739af07d1d947af27c877f797cb82ceee702515 ]
Using generic ASIX Electronics Corp. AX88179 Gigabit Ethernet device, the following test cycle has been implemented:
- power on
- check logs
- shutdown
- after detecting the system shutdown, disconnect power
- after approximately 60 seconds of sleep, power is restored
Running some cycles, sometimes error logs like this appear:
kernel: ax88179_178a 2-9:1.0 (unnamed net_device) (uninitialized): Failed to write reg index 0x0001: -19
kernel: ax88179_178a 2-9:1.0 (unnamed net_device) (uninitialized): Failed to read reg index 0x0001: -19
...These failed operation are happening during ax88179_reset execution, so the initialization could not be correct.
In order to avoid this, we need to increase the delay after reset and clock initial operations. By using these larger values, many cycles have been run and no failed operations appear.
It would be better to check some status register to verify when the operation has finished, but I do not have found any available information (neither in the public datasheets nor in the manufacturer's driver). The only available information for the necessary delays is the maufacturer's driver (original values) but the proposed values are not enough for the tested devices.
--- drivers/net/usb/ax88179_178a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/usb/ax88179_178a.c +2 -2
@@ -1594,11 +1594,11 @@ static int ax88179_reset(struct usbnet *dev) *tmp16 =AX_PHYPWR_RSTCTL_IPRL ;ax88179_write_cmd (dev,AX_ACCESS_MAC ,AX_PHYPWR_RSTCTL ,2 ,2 , tmp16); -msleep (200 ); +msleep (500 ); *tmp =AX_CLK_SELECT_ACS |AX_CLK_SELECT_BCS ;ax88179_write_cmd (dev,AX_ACCESS_MAC ,AX_CLK_SELECT ,1 ,1 , tmp); -msleep (100 ); +msleep (200 );/* Ethernet PHY Auto Detach*/ ax88179_auto_detach (dev,0 );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 13/94 arm/xen: fix xen_vcpu_info allocation alignment
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Stabellini <[email protected]>
[ Upstream commit 7bf9a6b46549852a37e6d07e52c601c3c706b562 ]
xen_vcpu_info is a percpu area than needs to be mapped by Xen. Currently, it could cross a page boundary resulting in Xen being unable to map it:
[ 0.567318] kernel BUG at arch/arm64/xen/../../arm/xen/enlighten.c:164! [ 0.574002] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
Fix the issue by using __alloc_percpu and requesting alignment for the memory allocation.
--- arch/arm/xen/enlighten.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/xen/enlighten.c +2 -1
@@ -354,7 +354,8 @@ static int __init xen_guest_init(void)* for secondary CPUs as they are brought up. * For uniformity we use VCPUOP_register_vcpu_info even on cpu0. */ - xen_vcpu_info = alloc_percpu(struct vcpu_info); + xen_vcpu_info =__alloc_percpu (sizeof (struct vcpu_info ), +1 <<fls (sizeof (struct vcpu_info ) -1 ));if (xen_vcpu_info ==NULL )return -ENOMEM ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 14/94 amd-xgbe: handle corner-case during sfp hotplug
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raju Rangoju <[email protected]>
[ Upstream commit 676ec53844cbdf2f47e68a076cdff7f0ec6cbe3f ]
Force the mode change for SFI in Fixed PHY configurations. Fixed PHY configurations needs PLL to be enabled while doing mode set. When the SFP module isn't connected during boot, driver assumes AN is ON and attempts auto-negotiation. However, if the connected SFP comes up in Fixed PHY configuration the link will not come up as PLL isn't enabled while the initial mode set command is issued. So, force the mode change for SFI in Fixed PHY configuration to fix link issues.
--- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +13 -1
@@ -1178,7 +1178,19 @@ static int xgbe_phy_config_fixed(struct xgbe_prv_data *pdata)if (pdata->phy.duplex !=DUPLEX_FULL )return -EINVAL ; -xgbe_set_mode (pdata, mode); +/* Force the mode change for SFI in Fixed PHY config. +* Fixed PHY configs needs PLL to be enabled while doing mode set. +* When the SFP module isn't connected during boot, driver assumes +* AN is ON and attempts autonegotiation. However, if the connected +* SFP comes up in Fixed PHY config, the link will not come up as +* PLL isn't enabled while the initial mode set command is issued. +* So, force the mode change for SFI in Fixed PHY configuration to +* fix link issues. +*/ +if (mode ==XGBE_MODE_SFI ) +xgbe_change_mode (pdata, mode); +else +xgbe_set_mode (pdata, mode);return 0 ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 15/94 amd-xgbe: handle the corner-case during tx completion
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raju Rangoju <[email protected]>
[ Upstream commit 7121205d5330c6a3cb3379348886d47c77b78d06 ]
The existing implementation uses software logic to accumulate tx completions until the specified time (1ms) is met and then poll them. However, there exists a tiny gap which leads to a race between resetting and checking the tx_activate flag. Due to this the tx completions are not reported to upper layer and tx queue timeout kicks-in restarting the device.
To address this, introduce a tx cleanup mechanism as part of the periodic maintenance process.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +14 -0
@@ -682,10 +682,24 @@ static void xgbe_service(struct work_struct *work)static void xgbe_service_timer (struct timer_list *t) {struct xgbe_prv_data *pdata =from_timer (pdata, t, service_timer); +struct xgbe_channel *channel; +unsigned int i;queue_work (pdata->dev_workqueue, &pdata->service_work);mod_timer (&pdata->service_timer, jiffies +HZ ); + +if (!pdata->tx_usecs) +return ; + +for (i =0 ; i < pdata->channel_count; i++) { + channel = pdata->channel[i]; +if (!channel->tx_ring || channel->tx_timer_active) +break ; + channel->tx_timer_active =1 ; +mod_timer (&channel->tx_timer, + jiffies +usecs_to_jiffies (pdata->tx_usecs)); + } }static void xgbe_init_timers (struct xgbe_prv_data *pdata)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 16/94 amd-xgbe: propagate the correct speed and duplex status
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raju Rangoju <[email protected]>
[ Upstream commit 7a2323ac24a50311f64a3a9b54ed5bef5821ecae ]
xgbe_get_link_ksettings() does not propagate correct speed and duplex information to ethtool during cable unplug. Due to which ethtool reports incorrect values for speed and duplex.
Address this by propagating correct information.
--- drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +8 -3
@@ -314,10 +314,15 @@ static int xgbe_get_link_ksettings(struct net_device *netdev, cmd->base.phy_address = pdata->phy.address; - cmd->base.autoneg = pdata->phy.autoneg; - cmd->base.speed = pdata->phy.speed; - cmd->base.duplex = pdata->phy.duplex; +if (netif_carrier_ok (netdev)) { + cmd->base.speed = pdata->phy.speed; + cmd->base.duplex = pdata->phy.duplex; + }else { + cmd->base.speed =SPEED_UNKNOWN ; + cmd->base.duplex =DUPLEX_UNKNOWN ; + } + cmd->base.autoneg = pdata->phy.autoneg; cmd->base.port =PORT_NONE ;XGBE_LM_COPY (cmd, supported, lks, supported);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 17/94 net: axienet: Fix check for partial TX checksum
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Holland <[email protected]>
[ Upstream commit fd0413bbf8b11f56e8aa842783b0deda0dfe2926 ]
Due to a typo, the code checked the RX checksum feature in the TX path.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -1
@@ -656,7 +656,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)if (lp->features &XAE_FEATURE_FULL_TX_CSUM ) {/* Tx Full Checksum Offload Enabled */ cur_p->app0 |=2 ; - }else if (lp->features &XAE_FEATURE_PARTIAL_RX_CSUM ) { + }else if (lp->features &XAE_FEATURE_PARTIAL_TX_CSUM ) { csum_start_off =skb_transport_offset (skb); csum_index_off = csum_start_off + skb->csum_offset;/* Tx Partial Checksum Offload Enabled */
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 18/94 afs: Return ENOENT if no cell DNS record can be found
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 0167236e7d66c5e1e85d902a6abc2529b7544539 ]
Make AFS return error ENOENT if no cell SRV or AFSDB DNS record (or cellservdb config file record) can be found rather than returning EDESTADDRREQ.
Also add cell name lookup info to the cursor dump.
--- fs/afs/vl_rotate.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/afs/vl_rotate.c +10 -0
@@ -58,6 +58,12 @@ static bool afs_start_vl_iteration(struct afs_vl_cursor *vc) }/* Status load is ordered after lookup counter load */ +if (cell->dns_status ==DNS_LOOKUP_GOT_NOT_FOUND ) { +pr_warn ("No record of cell %s\n" , cell->name); + vc->error = -ENOENT ; +return false; + } +if (cell->dns_source ==DNS_RECORD_UNAVAILABLE ) { vc->error = -EDESTADDRREQ ;return false;
@@ -276,6 +282,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)*/ static void afs_vl_dump_edestaddrreq (const struct afs_vl_cursor *vc) { +struct afs_cell *cell = vc->cell;static int count;int i;
@@ -285,6 +292,9 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)rcu_read_lock ();pr_notice ("EDESTADDR occurred\n" ); +pr_notice ("CELL: %s err=%d\n" , cell->name, cell->error); +pr_notice ("DNS: src=%u st=%u lc=%x\n" , + cell->dns_source, cell->dns_status, cell->dns_lookup_count);pr_notice ("VC: ut=%lx ix=%u ni=%hu fl=%hx err=%hd\n" , vc->untried, vc->index, vc->nr_iterations, vc->flags, vc->error);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 19/94 afs: Fix file locking on R/O volumes to operate in local mode
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit b590eb41be766c5a63acc7e8896a042f7a4e8293 ]
AFS doesn't really do locking on R/O volumes as fileservers don't maintain state with each other and thus a lock on a R/O volume file on one fileserver will not be be visible to someone looking at the same file on another fileserver.
Further, the server may return an error if you try it.
Fix this by doing what other AFS clients do and handle filelocking on R/O volume files entirely within the client and don't touch the server.
--- fs/afs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/afs/super.c +2 -0
@@ -391,6 +391,8 @@ static int afs_validate_fc(struct fs_context *fc)return PTR_ERR (volume); ctx->volume = volume; +if (volume->type !=AFSVL_RWVOL ) + ctx->flock_mode = afs_flock_mode_local; }return 0 ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 20/94 nvmet: remove unnecessary ctrl parameter
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kulkarni <[email protected]>
[ Upstream commit de5878048e11f1ec44164ebb8994de132074367a ]
The function nvmet_ctrl_find_get() accepts out pointer to nvmet_ctrl structure. This function returns the same error value from two places that is :- NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR.
Move this to the caller so we can change the return type to nvmet_ctrl.
Now that we can changed the return type, instead of taking out pointer to the nvmet_ctrl structure remove that function parameter and return the valid nvmet_ctrl pointer on success and NULL on failure.
Also, add and rename the goto labels for more readability with comments.
Stable-dep-of: 1c22e0295a5e ("nvmet: nul-terminate the NQNs passed in the connect command")
--- drivers/nvme/target/core.c | 21 +++++++++++---------- drivers/nvme/target/fabrics-cmd.c | 11 ++++++----- drivers/nvme/target/nvmet.h | 5 +++-- 3 files changed, 20 insertions(+), 17 deletions(-)
drivers/nvme/target/core.c +11 -10
@@ -1107,19 +1107,19 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) ctrl->cap |=NVMET_QUEUE_SIZE -1 ; } -u16 nvmet_ctrl_find_get (const char *subsysnqn,const char *hostnqn,u16 cntlid, -struct nvmet_req *req,struct nvmet_ctrl **ret) +struct nvmet_ctrl *nvmet_ctrl_find_get (const char *subsysnqn, +const char *hostnqn,u16 cntlid, +struct nvmet_req *req) { +struct nvmet_ctrl *ctrl =NULL ;struct nvmet_subsys *subsys; -struct nvmet_ctrl *ctrl; -u16 status =0 ; subsys =nvmet_find_get_subsys (req->port, subsysnqn);if (!subsys) {pr_warn ("connect request for invalid subsystem %s!\n" , subsysnqn); req->cqe->result.u32 =IPO_IATTR_CONNECT_DATA (subsysnqn); -return NVME_SC_CONNECT_INVALID_PARAM |NVME_SC_DNR ; + goto out; }mutex_lock (&subsys->lock);
@@ -1132,20 +1132,21 @@ u16 nvmet_ctrl_find_get(const char *subsysnqn, const char *hostnqn, u16 cntlid,if (!kref_get_unless_zero (&ctrl->ref))continue ; - *ret = ctrl; - goto out; +/* ctrl found */ + goto found; } } + ctrl =NULL ;/* ctrl not found */ pr_warn ("could not find controller %d for subsys %s / host %s\n" , cntlid, subsysnqn, hostnqn); req->cqe->result.u32 =IPO_IATTR_CONNECT_DATA (cntlid); - status =NVME_SC_CONNECT_INVALID_PARAM |NVME_SC_DNR ; -out: +found:mutex_unlock (&subsys->lock);nvmet_subsys_put (subsys); -return status; +out: +return ctrl; }u16 nvmet_check_ctrl_status (struct nvmet_req *req,struct nvme_command *cmd)
drivers/nvme/target/fabrics-cmd.c +6 -5
@@ -213,7 +213,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req) {struct nvmf_connect_command *c = &req->cmd->connect;struct nvmf_connect_data *d; -struct nvmet_ctrl *ctrl =NULL ; +struct nvmet_ctrl *ctrl;u16 qid =le16_to_cpu (c->qid);u16 status =0 ;
@@ -237,11 +237,12 @@ static void nvmet_execute_io_connect(struct nvmet_req *req) goto out; } - status =nvmet_ctrl_find_get (d->subsysnqn, d->hostnqn, -le16_to_cpu (d->cntlid), - req, &ctrl); -if (status) + ctrl =nvmet_ctrl_find_get (d->subsysnqn, d->hostnqn, +le16_to_cpu (d->cntlid), req); +if (!ctrl) { + status =NVME_SC_CONNECT_INVALID_PARAM |NVME_SC_DNR ; goto out; + }if (unlikely (qid > ctrl->subsys->max_qid)) {pr_warn ("invalid queue id (%d)\n" , qid);
drivers/nvme/target/nvmet.h +3 -2
@@ -394,8 +394,9 @@ void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl);void nvmet_update_cc (struct nvmet_ctrl *ctrl,u32 new);u16 nvmet_alloc_ctrl (const char *subsysnqn,const char *hostnqn,struct nvmet_req *req,u32 kato,struct nvmet_ctrl **ctrlp); -u16 nvmet_ctrl_find_get (const char *subsysnqn,const char *hostnqn,u16 cntlid, -struct nvmet_req *req,struct nvmet_ctrl **ret); +struct nvmet_ctrl *nvmet_ctrl_find_get (const char *subsysnqn, +const char *hostnqn,u16 cntlid, +struct nvmet_req *req);void nvmet_ctrl_put (struct nvmet_ctrl *ctrl);u16 nvmet_check_ctrl_status (struct nvmet_req *req,struct nvme_command *cmd);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 21/94 nvmet: nul-terminate the NQNs passed in the connect command
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 1c22e0295a5eb571c27b53c7371f95699ef705ff ]
The host and subsystem NQNs are passed in the connect command payload and interpreted as nul-terminated strings. Ensure they actually are nul-terminated before using them.
--- drivers/nvme/target/fabrics-cmd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvme/target/fabrics-cmd.c +4 -0
@@ -182,6 +182,8 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) goto out; } + d->subsysnqn[NVMF_NQN_FIELD_LEN -1 ] ='\0' ; + d->hostnqn[NVMF_NQN_FIELD_LEN -1 ] ='\0' ; status =nvmet_alloc_ctrl (d->subsysnqn, d->hostnqn, req,le32_to_cpu (c->kato), &ctrl);if (status) {
@@ -237,6 +239,8 @@ static void nvmet_execute_io_connect(struct nvmet_req *req) goto out; } + d->subsysnqn[NVMF_NQN_FIELD_LEN -1 ] ='\0' ; + d->hostnqn[NVMF_NQN_FIELD_LEN -1 ] ='\0' ; ctrl =nvmet_ctrl_find_get (d->subsysnqn, d->hostnqn,le16_to_cpu (d->cntlid), req);if (!ctrl) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 22/94 MIPS: KVM: Fix a build warning about variable set but not used
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 83767a67e7b6a0291cde5681ec7e3708f3f8f877 ]
After commit 411740f5422a ("KVM: MIPS/MMU: Implement KVM_CAP_SYNC_MMU") old_pte is no longer used in kvm_mips_map_page(). So remove it to fix a build warning about variable set but not used:
arch/mips/kvm/mmu.c: In function 'kvm_mips_map_page':
Quoted 1 line
Quoted 1 line
arch/mips/kvm/mmu.c:701:29: warning: variable 'old_pte' set but not used [-Wunused-but-set-variable]
701 | pte_t *ptep, entry, old_pte;
| ^~~~~~~--- arch/mips/kvm/mmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/kvm/mmu.c +1 -2
@@ -693,7 +693,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,gfn_t gfn = gpa >>PAGE_SHIFT ;int srcu_idx, err;kvm_pfn_t pfn; -pte_t *ptep, entry, old_pte; +pte_t *ptep, entry;bool writeable;unsigned long prot_bits;unsigned long mmu_seq;
@@ -766,7 +766,6 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, entry =pfn_pte (pfn,__pgprot (prot_bits));/* Write the PTE */ - old_pte = *ptep;set_pte (ptep, entry); err =0 ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 23/94 ext4: add a new helper to check if es must be kept
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 9649eb18c6288f514cacffdd699d5cd999c2f8f6 ]
In the extent status tree, we have extents which we can just drop without issues and extents we must not drop - this depends on the extent's status
- currently ext4_es_is_delayed() extents must stay, others may be dropped.
A helper function is added to help determine if the current extent can be dropped, although only ext4_es_is_delayed() extents cannot be dropped currently.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
fs/ext4/extents_status.c +21 -13
@@ -439,6 +439,19 @@ static void ext4_es_list_del(struct inode *inode)spin_unlock (&sbi->s_es_lock); } +/* +* Returns true if we cannot fail to allocate memory for this extent_status +* entry and cannot reclaim it until its status changes. +*/ +static inline bool ext4_es_must_keep (struct extent_status *es) +{ +/* fiemap, bigalloc, and seek_data/hole need to use it. */ +if (ext4_es_is_delayed (es)) +return true; + +return false; +} +static struct extent_status *ext4_es_alloc_extent (struct inode *inode,ext4_lblk_t lblk,ext4_lblk_t len,ext4_fsblk_t pblk)
@@ -451,10 +464,8 @@ ext4_es_alloc_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len, es->es_len = len; es->es_pblk = pblk; -/* -* We don't count delayed extent because we never try to reclaim them -*/ - if (!ext4_es_is_delayed(es)) { +/* We never try to reclaim a must kept extent, so we don't count it. */ + if (!ext4_es_must_keep(es)) { if (!EXT4_I(inode)->i_es_shk_nr++) ext4_es_list_add(inode); percpu_counter_inc(&EXT4_SB(inode->i_sb)->
@@ -472,8 +483,8 @@ static void ext4_es_free_extent(struct inode *inode, struct extent_status *es)EXT4_I (inode)->i_es_all_nr--;percpu_counter_dec (&EXT4_SB (inode->i_sb)->s_es_stats.es_stats_all_cnt); -/* Decrease the shrink counter when this es is not delayed */ -if (!ext4_es_is_delayed (es)) { +/* Decrease the shrink counter when we can reclaim the extent. */ +if (!ext4_es_must_keep (es)) {BUG_ON (EXT4_I (inode)->i_es_shk_nr ==0 );if (!--EXT4_I (inode)->i_es_shk_nr)ext4_es_list_del (inode);
@@ -842,7 +853,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,if (err == -ENOMEM &&__es_shrink (EXT4_SB (inode->i_sb),128 ,EXT4_I (inode))) goto retry; -if (err == -ENOMEM && !ext4_es_is_delayed (&newes)) +if (err == -ENOMEM && !ext4_es_must_keep (&newes)) err =0 ; if (sbi->s_cluster_ratio > 1 && test_opt(inode->i_sb, DELALLOC) &&
@@ -1683,11 +1694,8 @@ static int es_do_reclaim_extents(struct ext4_inode_info *ei, ext4_lblk_t end, (*nr_to_scan)--; node =rb_next (&es->rb_node); -/* -* We can't reclaim delayed extent from status tree because -* fiemap, bigallic, and seek_data/hole need to use it. -*/ -if (ext4_es_is_delayed (es)) + +if (ext4_es_must_keep (es)) goto next;if (ext4_es_is_referenced (es)) {ext4_es_clear_referenced (es);
@@ -1751,7 +1759,7 @@ void ext4_clear_inode_es(struct inode *inode)while (node) { es = rb_entry(node, struct extent_status, rb_node); node =rb_next (node); -if (!ext4_es_is_delayed (es)) { +if (!ext4_es_must_keep (es)) {rb_erase (&es->rb_node, &tree->root);ext4_es_free_extent (inode, es); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 24/94 ext4: factor out __es_alloc_extent() and __es_free_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 73a2f033656be11298912201ad50615307b4477a ]
Factor out __es_alloc_extent() and __es_free_extent(), which only allocate and free extent_status in these two helpers.
The ext4_es_alloc_extent() function is split into __es_alloc_extent() and ext4_es_init_extent(). In __es_alloc_extent() we allocate memory using GFP_KERNEL | __GFP_NOFAIL | __GFP_ZERO if the memory allocation cannot fail, otherwise we use GFP_ATOMIC. and the ext4_es_init_extent() is used to initialize extent_status and update related variables after a successful allocation.
This is to prepare for the use of pre-allocated extent_status later.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
fs/ext4/extents_status.c +19 -11
@@ -452,14 +452,17 @@ static inline bool ext4_es_must_keep(struct extent_status *es)return false; } -static struct extent_status * -ext4_es_alloc_extent (struct inode *inode,ext4_lblk_t lblk,ext4_lblk_t len, -ext4_fsblk_t pblk) +static inline struct extent_status *__es_alloc_extent (bool nofail) +{ +if (!nofail) +return kmem_cache_alloc (ext4_es_cachep,GFP_ATOMIC ); + +return kmem_cache_zalloc (ext4_es_cachep,GFP_KERNEL | __GFP_NOFAIL); +} + +static void ext4_es_init_extent (struct inode *inode,struct extent_status *es, +ext4_lblk_t lblk,ext4_lblk_t len,ext4_fsblk_t pblk) { -struct extent_status *es; - es =kmem_cache_alloc (ext4_es_cachep,GFP_ATOMIC ); -if (es ==NULL ) -return NULL ; es->es_lblk = lblk; es->es_len = len; es->es_pblk = pblk;
@@ -474,8 +477,11 @@ ext4_es_alloc_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len,EXT4_I (inode)->i_es_all_nr++;percpu_counter_inc (&EXT4_SB (inode->i_sb)->s_es_stats.es_stats_all_cnt); +} -return es; +static inline void __es_free_extent (struct extent_status *es) +{ +kmem_cache_free (ext4_es_cachep, es); }static void ext4_es_free_extent (struct inode *inode,struct extent_status *es)
@@ -492,7 +498,7 @@ static void ext4_es_free_extent(struct inode *inode, struct extent_status *es) s_es_stats.es_stats_shk_cnt); } -kmem_cache_free (ext4_es_cachep, es); +__es_free_extent (es); }/*
@@ -794,10 +800,12 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes) } } - es =ext4_es_alloc_extent (inode, newes->es_lblk, newes->es_len, - newes->es_pblk); + es =__es_alloc_extent (false);if (!es)return -ENOMEM ; +ext4_es_init_extent (inode, es, newes->es_lblk, newes->es_len, + newes->es_pblk); +rb_link_node (&es->rb_node, parent, p);rb_insert_color (&es->rb_node, &tree->root);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 25/94 ext4: use pre-allocated es in __es_insert_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 95f0b320339a977cf69872eac107122bf536775d ]
Pass a extent_status pointer prealloc to __es_insert_extent(). If the pointer is non-null, it is used directly when a new extent_status is needed to avoid memory allocation failures.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
fs/ext4/extents_status.c +12 -7
@@ -144,7 +144,8 @@static struct kmem_cache *ext4_es_cachep;static struct kmem_cache *ext4_pending_cachep; -static int __es_insert_extent (struct inode *inode,struct extent_status *newes); +static int __es_insert_extent (struct inode *inode,struct extent_status *newes, +struct extent_status *prealloc);static int __es_remove_extent (struct inode *inode,ext4_lblk_t lblk,ext4_lblk_t end,int *reserved);static int es_reclaim_extents (struct ext4_inode_info *ei,int *nr_to_scan);
@@ -760,7 +761,8 @@ static inline void ext4_es_insert_extent_check(struct inode *inode, }#endif -static int __es_insert_extent (struct inode *inode,struct extent_status *newes) +static int __es_insert_extent (struct inode *inode,struct extent_status *newes, +struct extent_status *prealloc) {struct ext4_es_tree *tree = &EXT4_I (inode)->i_es_tree;struct rb_node **p = &tree->root.rb_node;
@@ -800,7 +802,10 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes) } } - es =__es_alloc_extent (false); +if (prealloc) + es = prealloc; +else + es =__es_alloc_extent (false);if (!es)return -ENOMEM ; ext4_es_init_extent(inode, es, newes->es_lblk, newes->es_len,
@@ -857,7 +862,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,if (err !=0 ) goto error; retry: - err =__es_insert_extent (inode, &newes); + err =__es_insert_extent (inode, &newes,NULL );if (err == -ENOMEM &&__es_shrink (EXT4_SB (inode->i_sb),128 ,EXT4_I (inode))) goto retry;
@@ -904,7 +909,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk, es =__es_tree_search (&EXT4_I (inode)->i_es_tree.root, lblk);if (!es || es->es_lblk > end) -__es_insert_extent (inode, &newes); +__es_insert_extent (inode, &newes,NULL );write_unlock (&EXT4_I (inode)->i_es_lock); }
@@ -1347,7 +1352,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, orig_es.es_len - len2;ext4_es_store_pblock_status (&newes, block,ext4_es_status (&orig_es)); - err =__es_insert_extent (inode, &newes); + err =__es_insert_extent (inode, &newes,NULL );if (err) { es->es_lblk = orig_es.es_lblk; es->es_len = orig_es.es_len;
@@ -1996,7 +2001,7 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,if (err !=0 ) goto error; retry: - err =__es_insert_extent (inode, &newes); + err =__es_insert_extent (inode, &newes,NULL );if (err == -ENOMEM &&__es_shrink (EXT4_SB (inode->i_sb),128 ,EXT4_I (inode))) goto retry;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 26/94 ext4: use pre-allocated es in __es_remove_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit bda3efaf774fb687c2b7a555aaec3006b14a8857 ]
When splitting extent, if the second extent can not be dropped, we return -ENOMEM and use GFP_NOFAIL to preallocate an extent_status outside of i_es_lock and pass it to __es_remove_extent() to be used as the second extent. This ensures that __es_remove_extent() is executed successfully, thus ensuring consistency in the extent status tree. If the second extent is not undroppable, we simply drop it and return 0. Then retry is no longer necessary, remove it.
Now, __es_remove_extent() will always remove what it should, maybe more.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
fs/ext4/extents_status.c +13 -13
@@ -147,7 +147,8 @@ static struct kmem_cache *ext4_pending_cachep;static int __es_insert_extent (struct inode *inode,struct extent_status *newes,struct extent_status *prealloc);static int __es_remove_extent (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t end,int *reserved); +ext4_lblk_t end,int *reserved, +struct extent_status *prealloc);static int es_reclaim_extents (struct ext4_inode_info *ei,int *nr_to_scan);static int __es_shrink (struct ext4_sb_info *sbi,int nr_to_scan,struct ext4_inode_info *locked_ei);
@@ -858,7 +859,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,ext4_es_insert_extent_check (inode, &newes);write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, end,NULL ); + err =__es_remove_extent (inode, lblk, end,NULL ,NULL );if (err !=0 ) goto error; retry:
@@ -1296,6 +1297,7 @@ static unsigned int get_rsvd(struct inode *inode, ext4_lblk_t end,* @lblk - first block in range * @end - last block in range * @reserved - number of cluster reservations released +* @prealloc - pre-allocated es to avoid memory allocation failures * * If @reserved is not NULL and delayed allocation is enabled, counts * block/cluster reservations freed by removing range and if bigalloc
@@ -1303,7 +1305,8 @@ static unsigned int get_rsvd(struct inode *inode, ext4_lblk_t end,* error code on failure. */ static int __es_remove_extent (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t end,int *reserved) +ext4_lblk_t end,int *reserved, +struct extent_status *prealloc) {struct ext4_es_tree *tree = &EXT4_I (inode)->i_es_tree;struct rb_node *node;
@@ -1311,14 +1314,12 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,struct extent_status orig_es;ext4_lblk_t len1, len2;ext4_fsblk_t block; -int err; +int err =0 ;bool count_reserved = true;struct rsvd_count rc;if (reserved ==NULL || !test_opt (inode->i_sb,DELALLOC )) count_reserved = false; -retry: - err =0 ; es =__es_tree_search (&tree->root, lblk);if (!es)
@@ -1352,14 +1353,13 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, orig_es.es_len - len2;ext4_es_store_pblock_status (&newes, block,ext4_es_status (&orig_es)); - err =__es_insert_extent (inode, &newes,NULL ); + err =__es_insert_extent (inode, &newes, prealloc);if (err) { +if (!ext4_es_must_keep (&newes)) +return 0 ; + es->es_lblk = orig_es.es_lblk; es->es_len = orig_es.es_len; -if ((err == -ENOMEM ) && -__es_shrink (EXT4_SB (inode->i_sb), -128 ,EXT4_I (inode))) - goto retry; goto out; } }else {
@@ -1456,7 +1456,7 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,* is reclaimed. */ write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, end, &reserved); + err =__es_remove_extent (inode, lblk, end, &reserved,NULL );write_unlock (&EXT4_I (inode)->i_es_lock);ext4_es_print_tree (inode);ext4_da_release_space (inode, reserved);
@@ -1997,7 +1997,7 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, lblk,NULL ); + err =__es_remove_extent (inode, lblk, lblk,NULL ,NULL );if (err !=0 ) goto error; retry:
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 27/94 ext4: using nofail preallocation in ext4_es_remove_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit e9fe2b882bd5b26b987c9ba110c2222796f72af5 ]
If __es_remove_extent() returns an error it means that when splitting extent, allocating an extent that must be kept failed, where returning an error directly would cause the extent tree to be inconsistent. So we use GFP_NOFAIL to pre-allocate an extent_status and pass it to __es_remove_extent() to avoid this problem.
In addition, since the allocated memory is outside the i_es_lock, the extent_status tree may change and the pre-allocated extent_status is no longer needed, so we release the pre-allocated extent_status when es->es_len is not initialized.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/ext4/extents_status.c +11 -2
@@ -1439,6 +1439,7 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,ext4_lblk_t end;int err =0 ;int reserved =0 ; +struct extent_status *es =NULL ;trace_ext4_es_remove_extent (inode, lblk, len); es_debug("remove [%u/%u) from extent status tree of inode %lu\n",
@@ -1450,17 +1451,25 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, end = lblk + len -1 ;BUG_ON (end < lblk); +retry: +if (err && !es) + es =__es_alloc_extent (true);/* * ext4_clear_inode() depends on us taking i_es_lock unconditionally * so that we are sure __es_shrink() is done with the inode before it * is reclaimed. */ write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, end, &reserved,NULL ); + err =__es_remove_extent (inode, lblk, end, &reserved, es); +if (es && !es->es_len) +__es_free_extent (es);write_unlock (&EXT4_I (inode)->i_es_lock); +if (err) + goto retry; +ext4_es_print_tree (inode);ext4_da_release_space (inode, reserved); -return err; +return 0 ; } static int __es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 28/94 ext4: using nofail preallocation in ext4_es_insert_delayed_block()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 4a2d98447b37bcb68a7f06a1078edcb4f7e6ce7e ]
Similar to in ext4_es_remove_extent(), we use a no-fail preallocation to avoid inconsistencies, except that here we may have to preallocate two extent_status.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
fs/ext4/extents_status.c +22 -11
@@ -1992,7 +1992,10 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, bool allocated) {struct extent_status newes; -int err =0 ; +int err1 =0 ; +int err2 =0 ; +struct extent_status *es1 =NULL ; +struct extent_status *es2 =NULL ;es_debug ("add [%u/1) delayed to extent status tree of inode %lu\n" , lblk, inode->i_ino);
@@ -2004,29 +2007,37 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,ext4_es_insert_extent_check (inode, &newes); +retry: +if (err1 && !es1) + es1 =__es_alloc_extent (true); +if ((err1 || err2) && !es2) + es2 =__es_alloc_extent (true);write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, lblk,NULL ,NULL ); -if (err !=0 ) + err1 =__es_remove_extent (inode, lblk, lblk,NULL , es1); +if (err1 !=0 ) goto error; -retry: - err =__es_insert_extent (inode, &newes,NULL ); -if (err == -ENOMEM &&__es_shrink (EXT4_SB (inode->i_sb), -128 ,EXT4_I (inode))) - goto retry; -if (err !=0 ) + + err2 =__es_insert_extent (inode, &newes, es2); +if (err2 !=0 ) goto error;if (allocated)__insert_pending (inode, lblk); +/* es is pre-allocated but not used, free it. */ +if (es1 && !es1->es_len) +__es_free_extent (es1); +if (es2 && !es2->es_len) +__es_free_extent (es2); error:write_unlock (&EXT4_I (inode)->i_es_lock); +if (err1 || err2) + goto retry;ext4_es_print_tree (inode);ext4_print_pending_tree (inode); - -return err; +return 0 ; }/*
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 29/94 ext4: using nofail preallocation in ext4_es_insert_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 2a69c450083db164596c75c0f5b4d9c4c0e18eba ]
Similar to in ext4_es_insert_delayed_block(), we use preallocations that do not fail to avoid inconsistencies, but we do not care about es that are not must be kept, and we return 0 even if such es memory allocation fails.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
fs/ext4/extents_status.c +26 -12
@@ -832,8 +832,11 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, {struct extent_status newes;ext4_lblk_t end = lblk + len -1 ; -int err =0 ; +int err1 =0 ; +int err2 =0 ;struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb); +struct extent_status *es1 =NULL ; +struct extent_status *es2 =NULL ;es_debug ("add [%u/%u) %llu %x to extent status tree of inode %lu\n" , lblk, len, pblk, status, inode->i_ino);
@@ -858,29 +861,40 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,ext4_es_insert_extent_check (inode, &newes); +retry: +if (err1 && !es1) + es1 =__es_alloc_extent (true); +if ((err1 || err2) && !es2) + es2 =__es_alloc_extent (true);write_lock (&EXT4_I (inode)->i_es_lock); - err =__es_remove_extent (inode, lblk, end,NULL ,NULL ); -if (err !=0 ) + + err1 =__es_remove_extent (inode, lblk, end,NULL , es1); +if (err1 !=0 ) + goto error; + + err2 =__es_insert_extent (inode, &newes, es2); +if (err2 == -ENOMEM && !ext4_es_must_keep (&newes)) + err2 =0 ; +if (err2 !=0 ) goto error; -retry: - err =__es_insert_extent (inode, &newes,NULL ); -if (err == -ENOMEM &&__es_shrink (EXT4_SB (inode->i_sb), -128 ,EXT4_I (inode))) - goto retry; -if (err == -ENOMEM && !ext4_es_must_keep (&newes)) - err =0 ;if (sbi->s_cluster_ratio >1 &&test_opt (inode->i_sb,DELALLOC ) && (status &EXTENT_STATUS_WRITTEN || status &EXTENT_STATUS_UNWRITTEN ))__revise_pending (inode, lblk, len); +/* es is pre-allocated but not used, free it. */ +if (es1 && !es1->es_len) +__es_free_extent (es1); +if (es2 && !es2->es_len) +__es_free_extent (es2); error:write_unlock (&EXT4_I (inode)->i_es_lock); +if (err1 || err2) + goto retry;ext4_es_print_tree (inode); - -return err; +return 0 ; }/*
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 30/94 ext4: fix slab-use-after-free in ext4_es_insert_extent()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 768d612f79822d30a1e7d132a4d4b05337ce42ec ]
Yikebaer reported an issue:
==================================================================
BUG: KASAN: slab-use-after-free in ext4_es_insert_extent+0xc68/0xcb0 fs/ext4/extents_status.c:894 Read of size 4 at addr ffff888112ecc1a4 by task syz-executor/8438 CPU: 1 PID: 8438 Comm: syz-executor Not tainted 6.5.0-rc5 #1 Call Trace: [...] kasan_report+0xba/0xf0 mm/kasan/report.c:588 ext4_es_insert_extent+0xc68/0xcb0 fs/ext4/extents_status.c:894 ext4_map_blocks+0x92a/0x16f0 fs/ext4/inode.c:680 ext4_alloc_file_blocks.isra.0+0x2df/0xb70 fs/ext4/extents.c:4462 ext4_zero_range fs/ext4/extents.c:4622 [inline] ext4_fallocate+0x251c/0x3ce0 fs/ext4/extents.c:4721 [...] Allocated by task 8438: [...] kmem_cache_zalloc include/linux/slab.h:693 [inline] __es_alloc_extent fs/ext4/extents_status.c:469 [inline] ext4_es_insert_extent+0x672/0xcb0 fs/ext4/extents_status.c:873 ext4_map_blocks+0x92a/0x16f0 fs/ext4/inode.c:680 ext4_alloc_file_blocks.isra.0+0x2df/0xb70 fs/ext4/extents.c:4462 ext4_zero_range fs/ext4/extents.c:4622 [inline] ext4_fallocate+0x251c/0x3ce0 fs/ext4/extents.c:4721 [...] Freed by task 8438: [...] kmem_cache_free+0xec/0x490 mm/slub.c:3823 ext4_es_try_to_merge_right fs/ext4/extents_status.c:593 [inline] __es_insert_extent+0x9f4/0x1440 fs/ext4/extents_status.c:802 ext4_es_insert_extent+0x2ca/0xcb0 fs/ext4/extents_status.c:882 ext4_map_blocks+0x92a/0x16f0 fs/ext4/inode.c:680 ext4_alloc_file_blocks.isra.0+0x2df/0xb70 fs/ext4/extents.c:4462 ext4_zero_range fs/ext4/extents.c:4622 [inline] ext4_fallocate+0x251c/0x3ce0 fs/ext4/extents.c:4721 [...] ==================================================================
The flow of issue triggering is as follows:
1. remove es
raw es es removed es1
|-------------------| -> |----|.......|------|
2. insert es
es insert es1 merge with es es1 merge with es and free es1
|----|.......|------| -> |------------|------| -> |-------------------|
es merges with newes, then merges with es1, frees es1, then determines if es1->es_len is 0 and triggers a UAF.
The code flow is as follows:ext4_es_insert_extent
es1 = __es_alloc_extent(true);
es2 = __es_alloc_extent(true);
__es_remove_extent(inode, lblk, end, NULL, es1)
__es_insert_extent(inode, &newes, es1) ---> insert es1 to es tree
__es_insert_extent(inode, &newes, es2)
ext4_es_try_to_merge_right
ext4_es_free_extent(inode, es1) ---> es1 is freed
if (es1 && !es1->es_len)
// Trigger UAF by determining if es1 is used.We determine whether es1 or es2 is used immediately after calling __es_remove_extent() or __es_insert_extent() to avoid triggering a UAF if es1 or es2 is freed.
Stable-dep-of: 8e387c89e96b ("ext4: make sure allocate pending entry not fail")
--- fs/ext4/extents_status.c | 44 +++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-)
fs/ext4/extents_status.c +30 -14
@@ -871,23 +871,29 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, err1 =__es_remove_extent (inode, lblk, end,NULL , es1);if (err1 !=0 ) goto error; +/* Free preallocated extent if it didn't get used. */ +if (es1) { +if (!es1->es_len) +__es_free_extent (es1); + es1 =NULL ; + } err2 =__es_insert_extent (inode, &newes, es2);if (err2 == -ENOMEM && !ext4_es_must_keep (&newes)) err2 =0 ;if (err2 !=0 ) goto error; +/* Free preallocated extent if it didn't get used. */ +if (es2) { +if (!es2->es_len) +__es_free_extent (es2); + es2 =NULL ; + }if (sbi->s_cluster_ratio >1 &&test_opt (inode->i_sb,DELALLOC ) && (status &EXTENT_STATUS_WRITTEN || status &EXTENT_STATUS_UNWRITTEN ))__revise_pending (inode, lblk, len); - -/* es is pre-allocated but not used, free it. */ -if (es1 && !es1->es_len) -__es_free_extent (es1); -if (es2 && !es2->es_len) -__es_free_extent (es2); error:write_unlock (&EXT4_I (inode)->i_es_lock);if (err1 || err2)
@@ -1475,8 +1481,12 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,*/ write_lock (&EXT4_I (inode)->i_es_lock); err =__es_remove_extent (inode, lblk, end, &reserved, es); -if (es && !es->es_len) -__es_free_extent (es); +/* Free preallocated extent if it didn't get used. */ +if (es) { +if (!es->es_len) +__es_free_extent (es); + es =NULL ; + }write_unlock (&EXT4_I (inode)->i_es_lock);if (err) goto retry;
@@ -2031,19 +2041,25 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, err1 =__es_remove_extent (inode, lblk, lblk,NULL , es1);if (err1 !=0 ) goto error; +/* Free preallocated extent if it didn't get used. */ +if (es1) { +if (!es1->es_len) +__es_free_extent (es1); + es1 =NULL ; + } err2 =__es_insert_extent (inode, &newes, es2);if (err2 !=0 ) goto error; +/* Free preallocated extent if it didn't get used. */ +if (es2) { +if (!es2->es_len) +__es_free_extent (es2); + es2 =NULL ; + }if (allocated)__insert_pending (inode, lblk); - -/* es is pre-allocated but not used, free it. */ -if (es1 && !es1->es_len) -__es_free_extent (es1); -if (es2 && !es2->es_len) -__es_free_extent (es2); error:write_unlock (&EXT4_I (inode)->i_es_lock);if (err1 || err2)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 31/94 ext4: make sure allocate pending entry not fail
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 8e387c89e96b9543a339f84043cf9df15fed2632 ]
__insert_pending() allocate memory in atomic context, so the allocation could fail, but we are not handling that failure now. It could lead ext4_es_remove_extent() to get wrong reserved clusters, and the global data blocks reservation count will be incorrect. The same to extents_status entry preallocation, preallocate pending entry out of the i_es_lock with __GFP_NOFAIL, make sure __insert_pending() and __revise_pending() always succeeds.
--- fs/ext4/extents_status.c | 123 ++++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 34 deletions(-)
fs/ext4/extents_status.c +89 -34
@@ -152,8 +152,9 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,static int es_reclaim_extents (struct ext4_inode_info *ei,int *nr_to_scan);static int __es_shrink (struct ext4_sb_info *sbi,int nr_to_scan,struct ext4_inode_info *locked_ei); -static void __revise_pending (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t len); +static int __revise_pending (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t len, +struct pending_reservation **prealloc);int __init ext4_init_es (void ) {
@@ -441,6 +442,19 @@ static void ext4_es_list_del(struct inode *inode)spin_unlock (&sbi->s_es_lock); } +static inline struct pending_reservation *__alloc_pending (bool nofail) +{ +if (!nofail) +return kmem_cache_alloc (ext4_pending_cachep,GFP_ATOMIC ); + +return kmem_cache_zalloc (ext4_pending_cachep,GFP_KERNEL | __GFP_NOFAIL); +} + +static inline void __free_pending (struct pending_reservation *pr) +{ +kmem_cache_free (ext4_pending_cachep, pr); +} +/* * Returns true if we cannot fail to allocate memory for this extent_status * entry and cannot reclaim it until its status changes.
@@ -832,11 +846,12 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, {struct extent_status newes;ext4_lblk_t end = lblk + len -1 ; -int err1 =0 ; -int err2 =0 ; +int err1 =0 , err2 =0 , err3 =0 ;struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);struct extent_status *es1 =NULL ;struct extent_status *es2 =NULL ; +struct pending_reservation *pr =NULL ; +bool revise_pending = false;es_debug ("add [%u/%u) %llu %x to extent status tree of inode %lu\n" , lblk, len, pblk, status, inode->i_ino);
@@ -861,11 +876,17 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,ext4_es_insert_extent_check (inode, &newes); + revise_pending = sbi->s_cluster_ratio >1 && +test_opt (inode->i_sb,DELALLOC ) && + (status & (EXTENT_STATUS_WRITTEN | +EXTENT_STATUS_UNWRITTEN )); retry:if (err1 && !es1) es1 =__es_alloc_extent (true);if ((err1 || err2) && !es2) es2 =__es_alloc_extent (true); +if ((err1 || err2 || err3) && revise_pending && !pr) + pr =__alloc_pending (true);write_lock (&EXT4_I (inode)->i_es_lock); err1 =__es_remove_extent (inode, lblk, end,NULL , es1);
@@ -890,13 +911,18 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, es2 =NULL ; } -if (sbi->s_cluster_ratio >1 &&test_opt (inode->i_sb,DELALLOC ) && - (status &EXTENT_STATUS_WRITTEN || - status &EXTENT_STATUS_UNWRITTEN )) -__revise_pending (inode, lblk, len); +if (revise_pending) { + err3 =__revise_pending (inode, lblk, len, &pr); +if (err3 !=0 ) + goto error; +if (pr) { +__free_pending (pr); + pr =NULL ; + } + } error:write_unlock (&EXT4_I (inode)->i_es_lock); -if (err1 || err2) +if (err1 || err2 || err3) goto retry;ext4_es_print_tree (inode);
@@ -1298,7 +1324,7 @@ static unsigned int get_rsvd(struct inode *inode, ext4_lblk_t end, rc->ndelonly--; node =rb_next (&pr->rb_node);rb_erase (&pr->rb_node, &tree->root); -kmem_cache_free (ext4_pending_cachep, pr); +__free_pending (pr);if (!node)break ; pr = rb_entry(node, struct pending_reservation,
@@ -1892,11 +1918,13 @@ static struct pending_reservation *__get_pending(struct inode *inode,* * @inode - file containing the cluster * @lblk - logical block in the cluster to be added +* @prealloc - preallocated pending entry * * Returns 0 on successful insertion and -ENOMEM on failure. If the * pending reservation is already in the set, returns successfully. */ -static int __insert_pending (struct inode *inode,ext4_lblk_t lblk) +static int __insert_pending (struct inode *inode,ext4_lblk_t lblk, +struct pending_reservation **prealloc) {struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);struct ext4_pending_tree *tree = &EXT4_I (inode)->i_pending_tree;
@@ -1922,10 +1950,15 @@ static int __insert_pending(struct inode *inode, ext4_lblk_t lblk) } } - pr =kmem_cache_alloc (ext4_pending_cachep,GFP_ATOMIC ); -if (pr ==NULL ) { - ret = -ENOMEM ; - goto out; +if (likely (*prealloc ==NULL )) { + pr =__alloc_pending (false); +if (!pr) { + ret = -ENOMEM ; + goto out; + } + }else { + pr = *prealloc; + *prealloc =NULL ; } pr->lclu = lclu;
@@ -1955,7 +1988,7 @@ static void __remove_pending(struct inode *inode, ext4_lblk_t lblk)if (pr !=NULL ) { tree = &EXT4_I (inode)->i_pending_tree;rb_erase (&pr->rb_node, &tree->root); -kmem_cache_free (ext4_pending_cachep, pr); +__free_pending (pr); } }
@@ -2016,10 +2049,10 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, bool allocated) {struct extent_status newes; -int err1 =0 ; -int err2 =0 ; +int err1 =0 , err2 =0 , err3 =0 ;struct extent_status *es1 =NULL ;struct extent_status *es2 =NULL ; +struct pending_reservation *pr =NULL ;es_debug ("add [%u/1) delayed to extent status tree of inode %lu\n" , lblk, inode->i_ino);
@@ -2036,6 +2069,8 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, es1 =__es_alloc_extent (true);if ((err1 || err2) && !es2) es2 =__es_alloc_extent (true); +if ((err1 || err2 || err3) && allocated && !pr) + pr =__alloc_pending (true);write_lock (&EXT4_I (inode)->i_es_lock); err1 =__es_remove_extent (inode, lblk, lblk,NULL , es1);
@@ -2058,11 +2093,18 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, es2 =NULL ; } -if (allocated) -__insert_pending (inode, lblk); +if (allocated) { + err3 =__insert_pending (inode, lblk, &pr); +if (err3 !=0 ) + goto error; +if (pr) { +__free_pending (pr); + pr =NULL ; + } + } error:write_unlock (&EXT4_I (inode)->i_es_lock); -if (err1 || err2) +if (err1 || err2 || err3) goto retry;ext4_es_print_tree (inode);
@@ -2168,21 +2210,24 @@ unsigned int ext4_es_delayed_clu(struct inode *inode, ext4_lblk_t lblk,* @inode - file containing the range * @lblk - logical block defining the start of range * @len - length of range in blocks +* @prealloc - preallocated pending entry * * Used after a newly allocated extent is added to the extents status tree. * Requires that the extents in the range have either written or unwritten * status. Must be called while holding i_es_lock. */ -static void __revise_pending (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t len) +static int __revise_pending (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t len, +struct pending_reservation **prealloc) {struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);ext4_lblk_t end = lblk + len -1 ;ext4_lblk_t first, last;bool f_del = false, l_del = false; +int ret =0 ;if (len ==0 ) -return ; +return 0 ;/* * Two cases - block range within single cluster and block range
@@ -2203,7 +2248,9 @@ static void __revise_pending(struct inode *inode, ext4_lblk_t lblk, f_del =__es_scan_range (inode, &ext4_es_is_delonly, first, lblk -1 );if (f_del) { -__insert_pending (inode, first); + ret =__insert_pending (inode, first, prealloc); +if (ret <0 ) + goto out; }else { last =EXT4_LBLK_CMASK (sbi, end) + sbi->s_cluster_ratio -1 ;
@@ -2211,9 +2258,11 @@ static void __revise_pending(struct inode *inode, ext4_lblk_t lblk, l_del =__es_scan_range (inode, &ext4_es_is_delonly, end +1 , last); -if (l_del) -__insert_pending (inode, last); -else +if (l_del) { + ret =__insert_pending (inode, last, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, last); } }else {
@@ -2221,18 +2270,24 @@ static void __revise_pending(struct inode *inode, ext4_lblk_t lblk,if (first != lblk) f_del =__es_scan_range (inode, &ext4_es_is_delonly, first, lblk -1 ); -if (f_del) -__insert_pending (inode, first); -else +if (f_del) { + ret =__insert_pending (inode, first, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, first); last =EXT4_LBLK_CMASK (sbi, end) + sbi->s_cluster_ratio -1 ;if (last != end) l_del =__es_scan_range (inode, &ext4_es_is_delonly, end +1 , last); -if (l_del) -__insert_pending (inode, last); -else +if (l_del) { + ret =__insert_pending (inode, last, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, last); } +out: +return ret; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 32/94 arm64: cpufeature: Extract capped perfmon fields
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Murray <[email protected]>
commit 8e35aa642ee4dab01b16cc4b2df59d1936f3b3c2 upstream.
When emulating ID registers there is often a need to cap the version bits of a feature such that the guest will not use features that the host is not aware of. For example, when KVM mediates access to the PMU by emulating register accesses.
Let's add a helper that extracts a performance monitors ID field and caps the version to a given value.
Fields that identify the version of the Performance Monitors Extension do not follow the standard ID scheme, and instead follow the scheme described in ARM DDI 0487E.a page D13-2825 "Alternative ID scheme used for the Performance Monitors Extension version". The value 0xF means an IMPLEMENTATION DEFINED PMU is present, and values 0x0-OxE can be treated the same as an unsigned field with 0x0 meaning no PMU is present.
--- arch/arm64/include/asm/cpufeature.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm64/include/asm/cpufeature.h +23 -0
@@ -449,6 +449,29 @@ cpuid_feature_extract_unsigned_field(u64return cpuid_feature_extract_unsigned_field_width (features, field,4 ); } +/* +* Fields that identify the version of the Performance Monitors Extension do +* not follow the standard ID scheme. See ARM DDI 0487E.a page D13-2825, +* "Alternative ID scheme used for the Performance Monitors Extension version". +*/ +static inline u64 __attribute_const__ +cpuid_feature_cap_perfmon_field (u64 features,int field,u64 cap) +{ +u64 val =cpuid_feature_extract_unsigned_field (features, field); +u64 mask =GENMASK_ULL (field +3 , field); + +/* Treat IMPLEMENTATION DEFINED functionality as unimplemented */ +if (val ==0xf ) + val =0 ; + +if (val > cap) { + features &= ~mask; + features |= (cap << field) & mask; + } + +return features; +} +static inline u64 arm64_ftr_mask (const struct arm64_ftr_bits *ftrp) {return (u64 )GENMASK (ftrp->shift + ftrp->width -1 , ftrp->shift);
Greg Kroah-Hartman
maintainerPATCH 33/94 KVM: arm64: limit PMU version to PMUv3 for ARMv8.1
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Murray <[email protected]>
commit c854188ea01062f5a5fd7f05658feb1863774eaa upstream.
We currently expose the PMU version of the host to the guest via emulation of the DFR0_EL1 and AA64DFR0_EL1 debug feature registers. However many of the features offered beyond PMUv3 for 8.1 are not supported in KVM. Examples of this include support for the PMMIR registers (added in PMUv3 for ARMv8.4) and 64-bit event counters added in (PMUv3 for ARMv8.5).
Let's trap the Debug Feature Registers in order to limit PMUVer/PerfMon in the Debug Feature Registers to PMUv3 for ARMv8.1 to avoid unexpected behaviour.
Both ID_AA64DFR0.PMUVer and ID_DFR0.PerfMon follow the "Alternative ID scheme used for the Performance Monitors Extension version" where 0xF means an IMPLEMENTATION DEFINED PMU is implemented, and values 0x0-0xE are treated as with an unsigned field (with 0x0 meaning no PMU is present). As we don't expect to expose an IMPLEMENTATION DEFINED PMU, and our cap is below 0xF, we can treat these fields as unsigned when applying the cap.
--- arch/arm64/include/asm/sysreg.h | 6 ++++++ arch/arm64/kvm/sys_regs.c | 10 ++++++++++ 2 files changed, 16 insertions(+)
arch/arm64/include/asm/sysreg.h +6 -0
@@ -697,6 +697,12 @@#define ID_AA64DFR0_TRACEVER_SHIFT 4#define ID_AA64DFR0_DEBUGVER_SHIFT 0 +#define ID_AA64DFR0_PMUVER_8_1 0x4 + +#define ID_DFR0_PERFMON_SHIFT 24 + +#define ID_DFR0_PERFMON_8_1 0x4 +#define ID_ISAR5_RDM_SHIFT 24#define ID_ISAR5_CRC32_SHIFT 16#define ID_ISAR5_SHA2_SHIFT 12
arch/arm64/kvm/sys_regs.c +10 -0
@@ -1089,6 +1089,16 @@ static u64 read_id_reg(const struct kvm_ (0xfUL <<ID_AA64ISAR1_API_SHIFT ) | (0xfUL <<ID_AA64ISAR1_GPA_SHIFT ) | (0xfUL << ID_AA64ISAR1_GPI_SHIFT)); + }else if (id ==SYS_ID_AA64DFR0_EL1 ) { +/* Limit guests to PMUv3 for ARMv8.1 */ + val =cpuid_feature_cap_perfmon_field (val, +ID_AA64DFR0_PMUVER_SHIFT , +ID_AA64DFR0_PMUVER_8_1 ); + }else if (id ==SYS_ID_DFR0_EL1 ) { +/* Limit guests to PMUv3 for ARMv8.1 */ + val =cpuid_feature_cap_perfmon_field (val, +ID_DFR0_PERFMON_SHIFT , +ID_DFR0_PERFMON_8_1 ); }return val;
Greg Kroah-Hartman
maintainerPATCH 34/94 ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CVA
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit bd911485294a6f0596e4592ed442438015cffc8a upstream.
Like various other ASUS ExpertBook-s, the ASUS ExpertBook B1402CVA has an ACPI DSDT table that describes IRQ 1 as ActiveLow while the kernel overrides it to EdgeHigh.
This prevents the keyboard from working. To fix this issue, add this laptop to the skip_override_table so that the kernel does not override IRQ 1.
--- drivers/acpi/resource.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/resource.c +7 -0
@@ -449,6 +449,13 @@ static const struct dmi_system_id asus_l }, }, { +/* Asus ExpertBook B1402CVA */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), + DMI_MATCH(DMI_BOARD_NAME, "B1402CVA"), + }, + }, + {/* TongFang GM6XGxX/TUXEDO Stellaris 16 Gen5 AMD */ .matches = { DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"),
Greg Kroah-Hartman
maintainerPATCH 35/94 bcache: replace a mistaken IS_ERR() by IS_ERR_OR_NULL() in btree_gc_coalesce()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
commit f72f4312d4388376fc8a1f6cf37cb21a0d41758b upstream.
Commit 028ddcac477b ("bcache: Remove unnecessary NULL point check in node allocations") do the following change inside btree_gc_coalesce(),
31 @@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(
32 memset(new_nodes, 0, sizeof(new_nodes));
33 closure_init_stack(&cl);
34
35 - while (nodes < GC_MERGE_NODES && !IS_ERR_OR_NULL(r[nodes].b))
36 + while (nodes < GC_MERGE_NODES && !IS_ERR(r[nodes].b))
37 keys += r[nodes++].keys;
38
39 blocks = btree_default_blocks(b->c) * 2 / 3;
At line 35 the original r[nodes].b is not always allocatored from __bch_btree_node_alloc(), and possibly initialized as NULL pointer by caller of btree_gc_coalesce(). Therefore the change at line 36 is not correct.
This patch replaces the mistaken IS_ERR() by IS_ERR_OR_NULL() to avoid potential issue.
--- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/btree.c +1 -1
@@ -1391,7 +1391,7 @@ static int btree_gc_coalesce(struct btrememset (new_nodes,0 ,sizeof (new_nodes));closure_init_stack (&cl); -while (nodes <GC_MERGE_NODES && !IS_ERR (r[nodes].b)) +while (nodes <GC_MERGE_NODES && !IS_ERR_OR_NULL (r[nodes].b)) keys += r[nodes++].keys; blocks =btree_default_blocks (b->c) *2 /3 ;
Greg Kroah-Hartman
maintainerPATCH 36/94 s390/dasd: protect device queue against concurrent access
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Höppner <[email protected]>
commit db46cd1e0426f52999d50fa72cfa97fa39952885 upstream.
In dasd_profile_start() the amount of requests on the device queue are counted. The access to the device queue is unprotected against concurrent access. With a lot of parallel I/O, especially with alias devices enabled, the device queue can change while dasd_profile_start() is accessing the queue. In the worst case this leads to a kernel panic due to incorrect pointer accesses.
Fix this by taking the device lock before accessing the queue and counting the requests. Additionally the check for a valid profile data pointer can be done earlier to avoid unnecessary locking in a hot path.
--- drivers/s390/block/dasd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/s390/block/dasd.c +13 -11
@@ -737,18 +737,20 @@ static void dasd_profile_start(struct da* we count each request only once. */ device = cqr->startdev; -if (device->profile.data) { - counter =1 ;/* request is not yet queued on the start device */ -list_for_each (l, &device->ccw_queue) -if (++counter >=31 ) -break ; - } +if (!device->profile.data) +return ; + +spin_lock (get_ccwdev_lock (device->cdev)); + counter =1 ;/* request is not yet queued on the start device */ +list_for_each (l, &device->ccw_queue) +if (++counter >=31 ) +break ; +spin_unlock (get_ccwdev_lock (device->cdev)); +spin_lock (&device->profile.lock); -if (device->profile.data) { - device->profile.data->dasd_io_nr_req[counter]++; -if (rq_data_dir (req) ==READ ) - device->profile.data->dasd_read_nr_req[counter]++; - } + device->profile.data->dasd_io_nr_req[counter]++; +if (rq_data_dir (req) ==READ ) + device->profile.data->dasd_read_nr_req[counter]++;spin_unlock (&device->profile.lock); }
Greg Kroah-Hartman
maintainerPATCH 37/94 USB: serial: option: add Luat Air72*U series products
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Asuna Yang <[email protected]>
commit da90e45d5afc4da2de7cd3ea7943d0f1baa47cc2 upstream.
Update the USB serial option driver support for Luat Air72*U series products.
ID 1782:4e00 Spreadtrum Communications Inc. UNISOC-8910
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 13 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1782 ProdID=4e00 Rev=00.00
S: Manufacturer=UNISOC
S: Product=UNISOC-8910
C: #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=400mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=e0(wlcon) Sub=01 Prot=03 Driver=rndis_host
E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=4096ms
I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I: If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I: If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
If#= 2: AT
If#= 3: PPP + AT
If#= 4: Debug
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -609,6 +609,8 @@ static void option_instat_callback(struc#define UNISOC_VENDOR_ID 0x1782/* TOZED LT70-C based on UNISOC SL8563 uses UNISOC's vendor ID */ #define TOZED_PRODUCT_LT70C 0x4055 +/* Luat Air72*U series based on UNISOC UIS8910 uses UNISOC's vendor ID */ +#define LUAT_PRODUCT_AIR720U 0x4e00/* Device flags */
@@ -2271,6 +2273,7 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, LUAT_PRODUCT_AIR720U, 0xff, 0, 0) }, { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
Greg Kroah-Hartman
maintainerPATCH 38/94 hv_netvsc: Fix race of register_netdevice_notifier and VF register
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haiyang Zhang <[email protected]>
commit 85520856466ed6bc3b1ccb013cddac70ceb437db upstream.
If VF NIC is registered earlier, NETDEV_REGISTER event is replayed, but NETDEV_POST_INIT is not.
Move register_netdevice_notifier() earlier, so the call back function is set before probing.
--- drivers/net/hyperv/netvsc_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/hyperv/netvsc_drv.c +7 -2
@@ -2528,12 +2528,17 @@ static int __init netvsc_drv_init(void) } netvsc_ring_bytes = ring_size *PAGE_SIZE ; +register_netdevice_notifier (&netvsc_netdev_notifier); + ret =vmbus_driver_register (&netvsc_drv);if (ret) -return ret; + goto err_vmbus_reg; -register_netdevice_notifier (&netvsc_netdev_notifier);return 0 ; + +err_vmbus_reg: +unregister_netdevice_notifier (&netvsc_netdev_notifier); +return ret; }MODULE_LICENSE ("GPL" );
Greg Kroah-Hartman
maintainerPATCH 39/94 hv_netvsc: Mark VF as slave before exposing it to user-mode
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit c807d6cd089d2f4951baa838081ec5ae3e2360f8 upstream.
When a VF is being exposed form the kernel, it should be marked as "slave" before exposing to the user-mode. The VF is not usable without netvsc running as master. The user-mode should never see a VF without the "slave" flag.
This commit moves the code of setting the slave flag to the time before VF is exposed to user-mode.
--- drivers/net/hyperv/netvsc_drv.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
drivers/net/hyperv/netvsc_drv.c +23 -9
@@ -2060,9 +2060,6 @@ static int netvsc_vf_join(struct net_dev goto upper_link_failed; } -/* set slave flag before open to prevent IPv6 addrconf */ - vf_netdev->flags |=IFF_SLAVE ; -schedule_delayed_work (&ndev_ctx->vf_takeover,VF_TAKEOVER_INT );call_netdevice_notifiers (NETDEV_JOIN , vf_netdev);
@@ -2160,16 +2157,18 @@ static struct net_device *get_netvsc_bysreturn hv_get_drvdata (ndev_ctx->device_ctx); } -/* Fallback path to check synthetic vf with -* help of mac addr +/* Fallback path to check synthetic vf with help of mac addr. +* Because this function can be called before vf_netdev is +* initialized (NETDEV_POST_INIT) when its perm_addr has not been copied +* from dev_addr, also try to match to its dev_addr. +* Note: On Hyper-V and Azure, it's not possible to set a MAC address +* on a VF that matches to the MAC of a unrelated NETVSC device. */ list_for_each_entry (ndev_ctx, &netvsc_dev_list, list) { ndev =hv_get_drvdata (ndev_ctx->device_ctx); -if (ether_addr_equal (vf_netdev->perm_addr, ndev->perm_addr)) { -netdev_notice (vf_netdev, -"falling back to mac addr based matching\n" ); +if (ether_addr_equal (vf_netdev->perm_addr, ndev->perm_addr) || +ether_addr_equal (vf_netdev->dev_addr, ndev->perm_addr))return ndev; - } } netdev_notice(vf_netdev,
@@ -2177,6 +2176,19 @@ static struct net_device *get_netvsc_bysreturn NULL ; } +static int netvsc_prepare_bonding (struct net_device *vf_netdev) +{ +struct net_device *ndev; + + ndev =get_netvsc_byslot (vf_netdev); +if (!ndev) +return NOTIFY_DONE ; + +/* set slave flag before open to prevent IPv6 addrconf */ + vf_netdev->flags |=IFF_SLAVE ; +return NOTIFY_DONE ; +} +static int netvsc_register_vf (struct net_device *vf_netdev) {struct net_device_context *net_device_ctx;
@@ -2495,6 +2507,8 @@ static int netvsc_netdev_event(struct noreturn NOTIFY_DONE ;switch (event) { +case NETDEV_POST_INIT : +return netvsc_prepare_bonding (event_dev);case NETDEV_REGISTER :return netvsc_register_vf (event_dev);case NETDEV_UNREGISTER :
Greg Kroah-Hartman
maintainerPATCH 40/94 dm-delay: fix a race between delay_presuspend and delay_bio
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 6fc45b6ed921dc00dfb264dc08c7d67ee63d2656 ]
In delay_presuspend, we set the atomic variable may_delay and then stop the timer and flush pending bios. The intention here is to prevent the delay target from re-arming the timer again.
However, this test is racy. Suppose that one thread goes to delay_bio, sees that dc->may_delay is one and proceeds; now, another thread executes delay_presuspend, it sets dc->may_delay to zero, deletes the timer and flushes pending bios. Then, the first thread continues and adds the bio to delayed->list despite the fact that dc->may_delay is false.
Fix this bug by changing may_delay's type from atomic_t to bool and only access it while holding the delayed_bios_lock mutex. Note that we don't have to grab the mutex in delay_resume because there are no bios in flight at this point.
--- drivers/md/dm-delay.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/md/dm-delay.c +12 -5
@@ -30,7 +30,7 @@ struct delay_c {struct workqueue_struct *kdelayd_wq;struct work_struct flush_expired_bios;struct list_head delayed_bios; -atomic_t may_delay; +bool may_delay;struct delay_class read;struct delay_class write;
@@ -191,7 +191,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)INIT_WORK (&dc->flush_expired_bios, flush_expired_bios);INIT_LIST_HEAD (&dc->delayed_bios);mutex_init (&dc->timer_lock); -atomic_set (&dc->may_delay,1 ); + dc->may_delay = true; dc->argc = argc; ret =delay_class_ctr (ti, &dc->read, argv);
@@ -245,7 +245,7 @@ static int delay_bio(struct delay_c *dc, struct delay_class *c, struct bio *bio)struct dm_delay_info *delayed;unsigned long expires =0 ; -if (!c->delay || !atomic_read (&dc->may_delay)) +if (!c->delay)return DM_MAPIO_REMAPPED ; delayed =dm_per_bio_data (bio,sizeof (struct dm_delay_info ));
@@ -254,6 +254,10 @@ static int delay_bio(struct delay_c *dc, struct delay_class *c, struct bio *bio) delayed->expires = expires = jiffies +msecs_to_jiffies (c->delay);mutex_lock (&delayed_bios_lock); +if (unlikely (!dc->may_delay)) { +mutex_unlock (&delayed_bios_lock); +return DM_MAPIO_REMAPPED ; + } c->ops++;list_add_tail (&delayed->list, &dc->delayed_bios);mutex_unlock (&delayed_bios_lock);
@@ -267,7 +271,10 @@ static void delay_presuspend(struct dm_target *ti) {struct delay_c *dc = ti->private; -atomic_set (&dc->may_delay,0 ); +mutex_lock (&delayed_bios_lock); + dc->may_delay = false; +mutex_unlock (&delayed_bios_lock); +del_timer_sync (&dc->delay_timer);flush_bios (flush_delayed_bios (dc,1 )); }
@@ -276,7 +283,7 @@ static void delay_resume(struct dm_target *ti) {struct delay_c *dc = ti->private; -atomic_set (&dc->may_delay,1 ); + dc->may_delay = true; }static int delay_map (struct dm_target *ti,struct bio *bio)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 41/94 bcache: check return value from btree_node_alloc_replacement()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
commit 777967e7e9f6f5f3e153abffb562bffaf4430d26 upstream.
In btree_gc_rewrite_node(), pointer 'n' is not checked after it returns from btree_gc_rewrite_node(). There is potential possibility that 'n' is a non NULL ERR_PTR(), referencing such error code is not permitted in following code. Therefore a return value checking is necessary after 'n' is back from btree_node_alloc_replacement().
--- drivers/md/bcache/btree.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/bcache/btree.c +2 -0
@@ -1555,6 +1555,8 @@ static int btree_gc_rewrite_node(structreturn 0 ; n =btree_node_alloc_replacement (replace,NULL ); +if (IS_ERR (n)) +return 0 ;/* recheck reserve after allocating replacement node */ if (btree_check_reserve (b,NULL )) {
Greg Kroah-Hartman
maintainerPATCH 42/94 bcache: prevent potential division by zero error
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rand Deeb <[email protected]>
commit 2c7f497ac274a14330208b18f6f734000868ebf9 upstream.
In SHOW(), the variable 'n' is of type 'size_t.' While there is a conditional check to verify that 'n' is not equal to zero before executing the 'do_div' macro, concerns arise regarding potential division by zero error in 64-bit environments.
The concern arises when 'n' is 64 bits in size, greater than zero, and the lower 32 bits of it are zeros. In such cases, the conditional check passes because 'n' is non-zero, but the 'do_div' macro casts 'n' to 'uint32_t,' effectively truncating it to its lower 32 bits. Consequently, the 'n' value becomes zero.
To fix this potential division by zero error and ensure precise division handling, this commit replaces the 'do_div' macro with div64_u64(). div64_u64() is designed to work with 64-bit operands, guaranteeing that division is performed correctly.
This change enhances the robustness of the code, ensuring that division operations yield accurate results in all scenarios, eliminating the possibility of division by zero, and improving compatibility across different 64-bit environments.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/md/bcache/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/sysfs.c +1 -1
@@ -1057,7 +1057,7 @@ SHOW(__bch_cache) sum +=INITIAL_PRIO - cached[i];if (n) -do_div (sum, n); + sum =div64_u64 (sum, n);for (i =0 ; i <ARRAY_SIZE (q); i++) q[i] = INITIAL_PRIO - cached[n * (i + 1) /
Greg Kroah-Hartman
maintainerPATCH 43/94 USB: serial: option: add Fibocom L7xx modules
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Fragoso <[email protected]>
commit e389fe8b68137344562fb6e4d53d8a89ef6212dd upstream.
Add support for Fibocom L716-EU module series.
L716-EU is a Fibocom module based on ZTE's V3E/V3T chipset.
Device creates multiple interfaces when connected to PC as follows:
- Network Interface: ECM or RNDIS (set by FW or AT Command)
- ttyUSB0: AT port
- ttyUSB1: Modem port
- ttyUSB2: AT2 port
- ttyUSB3: Trace port for log information
- ADB: ADB port for debugging. ("Driver=usbfs" when ADB server enabled)
Here are the outputs of lsusb and usb-devices:
$ ls /dev/ttyUSB* /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
usb-devices:
L716-EU (ECM mode):
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 51 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=2cb7 ProdID=0001 Rev= 1.00 S: Manufacturer=Fibocom,Incorporated S: Product=Fibocom Mobile Boardband S: SerialNumber=1234567890ABCDEF C:* #Ifs= 7 Cfg#= 1 Atr=e0 MxPwr=500mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether E: Ad=87(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
L716-EU (RNDIS mode):
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 49 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=2cb7 ProdID=0001 Rev= 1.00 S: Manufacturer=Fibocom,Incorporated S: Product=Fibocom Mobile Boardband S: SerialNumber=1234567890ABCDEF
C:* #Ifs= 7 Cfg#= 1 Atr=e0 MxPwr=500mA
A: FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=03
I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=ff Driver=rndis_host
E: Ad=87(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/option.c +1 -0
@@ -2251,6 +2251,7 @@ static const struct usb_device_id option .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */ { USB_DEVICE_INTERFACE_CLASS(0x1782, 0x4d11, 0xff) }, /* Fibocom L610 (ECM/RNDIS mode) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x0001, 0xff, 0xff, 0xff) }, /* Fibocom L716-EU (ECM/RNDIS mode) */ { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */ .driver_info = RSVD(4) | RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */
Greg Kroah-Hartman
maintainerPATCH 44/94 USB: serial: option: fix FM101R-GL defines
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puliang Lu <[email protected]>
commit a1092619dd28ac0fcf23016160a2fdccd98ef935 upstream.
Modify the definition of the two Fibocom FM101R-GL PID macros, which had their PIDs switched.
The correct PIDs are:
- VID:PID 413C:8213, FM101R-GL ESIM are laptop M.2 cards (with MBIM interfaces for Linux)
- VID:PID 413C:8215, FM101R-GL are laptop M.2 cards (with MBIM interface for Linux)
0x8213: mbim, tty0x8215: mbim, tty
--- drivers/usb/serial/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/option.c +2 -2
@@ -203,8 +203,8 @@ static void option_instat_callback(struc#define DELL_PRODUCT_5829E_ESIM 0x81e4#define DELL_PRODUCT_5829E 0x81e6 -#define DELL_PRODUCT_FM101R 0x8213 -#define DELL_PRODUCT_FM101R_ESIM 0x8215 +#define DELL_PRODUCT_FM101R_ESIM 0x8213 +#define DELL_PRODUCT_FM101R 0x8215#define KYOCERA_VENDOR_ID 0x0c88#define KYOCERA_PRODUCT_KPC650 0x17da
Greg Kroah-Hartman
maintainerPATCH 45/94 USB: serial: option: dont claim interface 4 for ZTE MF290
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lech Perczak <[email protected]>
commit 8771127e25d6c20d458ad27cf32f7fcfc1755e05 upstream.
Interface 4 is used by for QMI interface in stock firmware of MF28D, the router which uses MF290 modem. Free the interface up, to rebind it to qmi_wwan driver.
The proper configuration is:
Interface mapping is:
0: QCDM, 1: (unknown), 2: AT (PCUI), 2: AT (Modem), 4: QMI
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 4 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=19d2 ProdID=0189 Rev= 0.00 S: Manufacturer=ZTE, Incorporated S: Product=ZTE LTE Technologies MSM C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 64 Ivl=2ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan E: Ad=86(I) Atr=03(Int.) MxPS= 64 Ivl=2ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
--- drivers/usb/serial/option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +2 -1
@@ -1548,7 +1548,8 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), .driver_info = RSVD(4) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff), + .driver_info = RSVD(4) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ .driver_info = RSVD(4) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) },
Greg Kroah-Hartman
maintainerPATCH 46/94 USB: dwc2: write HCINT with INTMASK applied
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 0583bc776ca5b5a3f5752869fc31cf7322df2b35 upstream.
dwc2_hc_n_intr() writes back INTMASK as read but evaluates it with intmask applied. In stress testing this causes spurious interrupts like this:
[Mon Aug 14 10:51:07 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 7 - ChHltd set, but reason is unknown [Mon Aug 14 10:51:07 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001 [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 0 - ChHltd set, but reason is unknown [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001 [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 4 - ChHltd set, but reason is unknown [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001 [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_update_urb_state_abn(): trimming xfer length
Applying INTMASK prevents this. The issue exists in all versions of the driver.
--- drivers/usb/dwc2/hcd_intr.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/usb/dwc2/hcd_intr.c +7 -8
@@ -2045,15 +2045,17 @@ static void dwc2_hc_n_intr(struct dwc2_h {struct dwc2_qtd *qtd;struct dwc2_host_chan *chan; -u32 hcint, hcintmsk; +u32 hcint, hcintraw, hcintmsk; chan = hsotg->hc_ptr_array[chnum]; - hcint =dwc2_readl (hsotg,HCINT (chnum)); + hcintraw =dwc2_readl (hsotg,HCINT (chnum)); hcintmsk =dwc2_readl (hsotg,HCINTMSK (chnum)); + hcint = hcintraw & hcintmsk; +dwc2_writel (hsotg, hcint,HCINT (chnum)); +if (!chan) {dev_err (hsotg->dev,"## hc_ptr_array for channel is NULL ##\n" ); -dwc2_writel (hsotg, hcint,HCINT (chnum));return ; }
@@ -2062,11 +2064,9 @@ static void dwc2_hc_n_intr(struct dwc2_h chnum);dev_vdbg (hsotg->dev," hcint 0x%08x, hcintmsk 0x%08x, hcint&hcintmsk 0x%08x\n" , - hcint, hcintmsk, hcint & hcintmsk); + hcintraw, hcintmsk, hcint); } -dwc2_writel (hsotg, hcint,HCINT (chnum)); -/* * If we got an interrupt after someone called * dwc2_hcd_endpoint_disable() we don't want to crash below
@@ -2076,8 +2076,7 @@ static void dwc2_hc_n_intr(struct dwc2_hreturn ; } - chan->hcint = hcint; - hcint &= hcintmsk; + chan->hcint = hcintraw;/* * If the channel was halted due to a dequeue, the qtd list might
Greg Kroah-Hartman
maintainerPATCH 47/94 usb: dwc3: set the dma max_seg_size
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit 8bbae288a85abed6a1cf7d185d8b9dc2f5dcb12c upstream.
Allow devices to have dma operations beyond 4K, and avoid warnings such as:
DMA-API: dwc3 a600000.usb: mapping sg segment longer than device claims to support [len=86016] [max=65536]
--- drivers/usb/dwc3/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/dwc3/core.c +2 -0
@@ -1556,6 +1556,8 @@ static int dwc3_probe(struct platform_depm_runtime_put (dev); +dma_set_max_seg_size (dev,UINT_MAX ); +return 0 ; err5:
Greg Kroah-Hartman
maintainerPATCH 48/94 USB: dwc3: qcom: fix resource leaks on probe deferral
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 51392a1879ff06dc21b68aef4825f6ef68a7be42 upstream.
The driver needs to deregister and free the newly allocated dwc3 core platform device on ACPI probe errors (e.g. probe deferral) and on driver unbind but instead it leaked those resources while erroneously dropping a reference to the parent platform device which is still in use.
For OF probing the driver takes a reference to the dwc3 core platform device which has also always been leaked.
Fix the broken ACPI tear down and make sure to drop the dwc3 core reference for both OF and ACPI.
--- drivers/usb/dwc3/dwc3-qcom.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -3
@@ -553,6 +553,7 @@ static int dwc3_qcom_of_register_core(stif (!qcom->dwc3) { ret = -ENODEV ;dev_err (dev,"failed to get dwc3 platform device\n" ); +of_platform_depopulate (dev); } node_put:
@@ -666,7 +667,7 @@ static int dwc3_qcom_probe(struct platfoif (ret) {dev_err (dev,"failed to register DWC3 Core, err=%d\n" , ret); - goto depopulate; + goto clk_disable; } qcom->mode =usb_get_dr_mode (&qcom->dwc3->dev);
@@ -692,7 +693,8 @@ depopulate:if (np)of_platform_depopulate (&pdev->dev);else -platform_device_put (pdev); +platform_device_del (qcom->dwc3); +platform_device_put (qcom->dwc3); clk_disable:for (i = qcom->num_clocks -1 ; i >=0 ; i--) {clk_disable_unprepare (qcom->clks[i]);
@@ -714,7 +716,8 @@ static int dwc3_qcom_remove(struct platfif (np)of_platform_depopulate (&pdev->dev);else -platform_device_put (pdev); +platform_device_del (qcom->dwc3); +platform_device_put (qcom->dwc3);for (i = qcom->num_clocks -1 ; i >=0 ; i--) {clk_disable_unprepare (qcom->clks[i]);
Greg Kroah-Hartman
maintainerPATCH 49/94 USB: dwc3: qcom: fix wakeup after probe deferral
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 41f5a0973259db9e4e3c9963d36505f80107d1a0 upstream.
The Qualcomm glue driver is overriding the interrupt trigger types defined by firmware when requesting the wakeup interrupts during probe.
This can lead to a failure to map the DP/DM wakeup interrupts after a probe deferral as the firmware defined trigger types do not match the type used for the initial mapping:
irq: type mismatch, failed to map hwirq-14 for interrupt-controller@b220000!
irq: type mismatch, failed to map hwirq-15 for interrupt-controller@b220000!
Fix this by not overriding the firmware provided trigger types when requesting the wakeup interrupts.
--- drivers/usb/dwc3/dwc3-qcom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +4 -4
@@ -361,7 +361,7 @@ static int dwc3_qcom_setup_irq(struct plirq_set_status_flags (irq,IRQ_NOAUTOEN ); ret =devm_request_threaded_irq (qcom->dev, irq,NULL , qcom_dwc3_resume_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +IRQF_ONESHOT ,"qcom_dwc3 HS" , qcom);if (ret) {dev_err (qcom->dev,"hs_phy_irq failed: %d\n" , ret);
@@ -376,7 +376,7 @@ static int dwc3_qcom_setup_irq(struct plirq_set_status_flags (irq,IRQ_NOAUTOEN ); ret =devm_request_threaded_irq (qcom->dev, irq,NULL , qcom_dwc3_resume_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +IRQF_ONESHOT ,"qcom_dwc3 DP_HS" , qcom);if (ret) {dev_err (qcom->dev,"dp_hs_phy_irq failed: %d\n" , ret);
@@ -391,7 +391,7 @@ static int dwc3_qcom_setup_irq(struct plirq_set_status_flags (irq,IRQ_NOAUTOEN ); ret =devm_request_threaded_irq (qcom->dev, irq,NULL , qcom_dwc3_resume_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +IRQF_ONESHOT ,"qcom_dwc3 DM_HS" , qcom);if (ret) {dev_err (qcom->dev,"dm_hs_phy_irq failed: %d\n" , ret);
@@ -406,7 +406,7 @@ static int dwc3_qcom_setup_irq(struct plirq_set_status_flags (irq,IRQ_NOAUTOEN ); ret =devm_request_threaded_irq (qcom->dev, irq,NULL , qcom_dwc3_resume_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +IRQF_ONESHOT ,"qcom_dwc3 SS" , qcom);if (ret) {dev_err (qcom->dev,"ss_phy_irq failed: %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 50/94 io_uring: fix off-by one bvec index
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
commit d6fef34ee4d102be448146f24caf96d7b4a05401 upstream.
If the offset equals the bv_len of the first registered bvec, then the request does not include any of that first bvec. Skip it so that drivers don't have to deal with a zero length bvec, which was observed to break NVMe's PRP list creation.
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -1256,7 +1256,7 @@ static int io_import_fixed(struct io_rin*/ const struct bio_vec *bvec = imu->bvec; -if (offset <= bvec->bv_len) { +if (offset < bvec->bv_len) {iov_iter_advance (iter, offset); }else {unsigned long seg_skip;
Greg Kroah-Hartman
maintainerPATCH 51/94 perf inject: Fix GEN_ELF_TEXT_OFFSET for jit
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 89b15d00527b7825ff19130ed83478e80e3fae99 upstream.
When a program header was added, it moved the text section but GEN_ELF_TEXT_OFFSET was not updated.
Fix by adding the program header size and aligning.
--- tools/perf/util/genelf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/genelf.h +3 -1
@@ -2,6 +2,8 @@#ifndef __GENELF_H__#define __GENELF_H__ +#include <linux/math.h> +/* genelf.c */ int jit_write_elf(int fd, uint64_t code_addr, const char *sym, const void *code, int csize, void *debug, int nr_debug_entries,
@@ -73,6 +75,6 @@ int jit_add_debug_info(Elf *e, uint64_t#endif /* The .text section is directly after the ELF header */ -#define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr) +#define GEN_ELF_TEXT_OFFSET round_up(sizeof(Elf_Ehdr) + sizeof(Elf_Phdr), 16)#endif
Greg Kroah-Hartman
maintainerPATCH 52/94 pinctrl: avoid reload of p state in list iteration
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maria Yu <[email protected]>
commit 4198a9b571065978632276264e01d71d68000ac5 upstream.
When in the list_for_each_entry iteration, reload of p->state->settings with a local setting from old_state will turn the list iteration into an infinite loop.
The typical symptom when the issue happens, will be a printk message like:
"not freeing pin xx (xxx) as part of deactivating group xxx - it is
already used for some other setting".
This is a compiler-dependent problem, one instance occurred using Clang version 10.0 on the arm64 architecture with linux version 4.19.
--- drivers/pinctrl/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/core.c +3 -3
@@ -1237,17 +1237,17 @@ static void pinctrl_link_add(struct pincstatic int pinctrl_commit_state (struct pinctrl *p,struct pinctrl_state *state) {struct pinctrl_setting *setting, *setting2; -struct pinctrl_state *old_state = p->state; +struct pinctrl_state *old_state =READ_ONCE (p->state);int ret; -if (p->state) { +if (old_state) {/* * For each pinmux setting in the old state, forget SW's record * of mux owner for that pingroup. Any pingroups which are * still owned by the new state will be re-acquired by the call * to pinmux_enable_setting() in the loop below. */ -list_for_each_entry (setting, &p->state->settings, node) { +list_for_each_entry (setting, &old_state->settings, node) {if (setting->type !=PIN_MAP_TYPE_MUX_GROUP )continue ;pinmux_disable_setting (setting);
Greg Kroah-Hartman
maintainerPATCH 53/94 firewire: core: fix possible memory leak in create_units()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yingliang <[email protected]>
commit 891e0eab32a57fca4d36c5162628eb0bcb1f0edf upstream.
If device_register() fails, the refcount of device is not 0, the name allocated in dev_set_name() is leaked. To fix this by calling put_device(), so that it will be freed in callback function kobject_cleanup().
unreferenced object 0xffff9d99035c7a90 (size 8):
comm "systemd-udevd", pid 168, jiffies 4294672386 (age 152.089s) hex dump (first 8 bytes):
66 77 30 2e 30 00 ff ff fw0.0...
backtrace:
[<00000000e1d62bac>] __kmem_cache_alloc_node+0x1e9/0x360
[<00000000bbeaff31>] __kmalloc_node_track_caller+0x44/0x1a0
[<00000000491f2fb4>] kvasprintf+0x67/0xd0
[<000000005b960ddc>] kobject_set_name_vargs+0x1e/0x90
[<00000000427ac591>] dev_set_name+0x4e/0x70
[<000000003b4e447d>] create_units+0xc5/0x110fw_unit_release() will be called in the error path, move fw_device_get() before calling device_register() to keep balanced with fw_device_put() in fw_unit_release().
--- drivers/firewire/core-device.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/firewire/core-device.c +4 -7
@@ -719,14 +719,11 @@ static void create_units(struct fw_devic fw_unit_attributes, &unit->attribute_group); -if (device_register (&unit->device) <0 ) - goto skip_unit; -fw_device_get (device); -continue ; - - skip_unit: -kfree (unit); +if (device_register (&unit->device) <0 ) { +put_device (&unit->device); +continue ; + } } }
Greg Kroah-Hartman
maintainerPATCH 54/94 mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenchao Chen <[email protected]>
commit 477865af60b2117ceaa1d558e03559108c15c78c upstream.
With cat regulator_summary, we found that vqmmc was not shutting down after the card was pulled.
cat /sys/kernel/debug/regulator/regulator_summary
1.before fix
1)Insert SD card
vddsdio 1 1 0 unknown 3500mV 0mA 1200mV 3750mV
71100000.mmc-vqmmc 1 0mA 3500mV 3600mV
2)Pull out the SD card
vddsdio 1 1 0 unknown 3500mV 0mA 1200mV 3750mV
71100000.mmc-vqmmc 1 0mA 3500mV 3600mV2.after fix
1)Insert SD cardt
vddsdio 1 1 0 unknown 3500mV 0mA 1200mV 3750mV
71100000.mmc-vqmmc 1 0mA 3500mV 3600mV2)Pull out the SD card
vddsdio 0 1 0 unknown 3500mV 0mA 1200mV 3750mV
71100000.mmc-vqmmc 0 0mA 3500mV 3600mV
--- drivers/mmc/host/sdhci-sprd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/mmc/host/sdhci-sprd.c +25 -0
@@ -381,12 +381,33 @@ static unsigned int sdhci_sprd_get_ro(streturn 0 ; } +static void sdhci_sprd_set_power (struct sdhci_host *host,unsigned char mode, +unsigned short vdd) +{ +struct mmc_host *mmc = host->mmc; + +switch (mode) { +case MMC_POWER_OFF : +mmc_regulator_set_ocr (host->mmc, mmc->supply.vmmc,0 ); + +mmc_regulator_disable_vqmmc (mmc); +break ; +case MMC_POWER_ON : +mmc_regulator_enable_vqmmc (mmc); +break ; +case MMC_POWER_UP : +mmc_regulator_set_ocr (host->mmc, mmc->supply.vmmc, vdd); +break ; + } +} +static struct sdhci_ops sdhci_sprd_ops = { .read_l = sdhci_sprd_readl, .write_l = sdhci_sprd_writel, .write_w = sdhci_sprd_writew, .write_b = sdhci_sprd_writeb, .set_clock = sdhci_sprd_set_clock, + .set_power = sdhci_sprd_set_power, .get_max_clock = sdhci_sprd_get_max_clock, .get_min_clock = sdhci_sprd_get_min_clock, .set_bus_width = sdhci_set_bus_width,
@@ -630,6 +651,10 @@ static int sdhci_sprd_probe(struct platf host->caps1 &= ~(SDHCI_SUPPORT_SDR50 |SDHCI_SUPPORT_SDR104 |SDHCI_SUPPORT_DDR50 ); + ret =mmc_regulator_get_supply (host->mmc); +if (ret) + goto pm_runtime_disable; + ret =sdhci_setup_host (host);if (ret) goto pm_runtime_disable;
Greg Kroah-Hartman
maintainerPATCH 55/94 mmc: block: Do not lose cache flush during CQE error recovery
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 174925d340aac55296318e43fd96c0e1d196e105 upstream.
During CQE error recovery, error-free data commands get requeued if there is any data left to transfer, but non-data commands are completed even though they have not been processed. Requeue them instead.
Note the only non-data command is cache flush, which would have resulted in a cache flush being lost if it was queued at the time of CQE recovery.
--- drivers/mmc/core/block.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mmc/core/block.c +2 -0
@@ -1463,6 +1463,8 @@ static void mmc_blk_cqe_complete_rq(strublk_mq_requeue_request (req, true); else__blk_mq_end_request (req ,BLK_STS_OK ); + }else if (mq->in_recovery) { +blk_mq_requeue_request (req, true); }else {blk_mq_end_request (req,BLK_STS_OK ); }
Greg Kroah-Hartman
maintainerPATCH 56/94 ALSA: hda: Disable power-save on KONTRON SinglePC
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit a337c355719c42a6c5b67e985ad753590ed844fb upstream.
It's been reported that the runtime PM on KONTRON SinglePC (PCI SSID 1734:1232) caused a stall of playback after a bunch of invocations. (FWIW, this looks like an timing issue, and the stall happens rather on the controller side.)
As a workaround, disable the default power-save on this platform.
--- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2244,6 +2244,8 @@ static struct snd_pci_quirk power_save_bSND_PCI_QUIRK (0x17aa ,0x36a7 ,"Lenovo C50 All in one" ,0 ),/* https://bugs.launchpad.net/bugs/1821663 */ SND_PCI_QUIRK (0x1631 ,0xe017 ,"Packard Bell NEC IMEDIA 5204" ,0 ), +/* KONTRON SinglePC may cause a stall at runtime resume */ + SND_PCI_QUIRK(0x1734, 0x1232, "KONTRON SinglePC", 0), {} };#endif /* CONFIG_PM */
Greg Kroah-Hartman
maintainerPATCH 57/94 ALSA: hda/realtek: Headset Mic VREF to 100%
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit baaacbff64d9f34b64f294431966d035aeadb81c upstream.
This platform need to set Mic VREF to 100%.
--- sound/pci/hda/patch_realtek.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/patch_realtek.c +9 -0
@@ -1935,6 +1935,7 @@ enum {ALC887_FIXUP_ASUS_AUDIO ,ALC887_FIXUP_ASUS_HMIC ,ALCS1200A_FIXUP_MIC_VREF , + ALC888VD_FIXUP_MIC_100VREF, }; static void alc889_fixup_coef(struct hda_codec *codec,
@@ -2488,6 +2489,13 @@ static const struct hda_fixup alc882_fix {} } }, + [ALC888VD_FIXUP_MIC_100VREF ] = { + .type =HDA_FIXUP_PINCTLS , + .v.pins = (const struct hda_pintbl []) { + {0x18 ,PIN_VREF100 },/* headset mic */ + {} + } + }, };static const struct snd_pci_quirk alc882_fixup_tbl[] = {
@@ -2557,6 +2565,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x106b ,0x4a00 ,"Macbook 5,2" ,ALC889_FIXUP_MBA11_VREF ),SND_PCI_QUIRK (0x1071 ,0x8258 ,"Evesham Voyaeger" ,ALC882_FIXUP_EAPD ), +SND_PCI_QUIRK (0x10ec ,0x12d8 ,"iBase Elo Touch" ,ALC888VD_FIXUP_MIC_100VREF ),SND_PCI_QUIRK (0x13fe ,0x1009 ,"Advantech MIT-W101" ,ALC886_FIXUP_EAPD ),SND_PCI_QUIRK (0x1458 ,0xa002 ,"Gigabyte EP45-DS3/Z87X-UD3H" ,ALC889_FIXUP_FRONT_HP_NO_PRESENCE ), SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
Greg Kroah-Hartman
maintainerPATCH 58/94 ALSA: hda/realtek: Add supported ALC257 for ChromeOS
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit cae2bdb579ecc9d4219c58a7d3fde1958118dc1d upstream.
ChromeOS want to support ALC257.
Add codec ID to some relation function.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -3207,6 +3207,7 @@ static void alc_disable_headset_jack_keycase 0x10ec0230 :case 0x10ec0236 :case 0x10ec0256 : +case 0x10ec0257 :case 0x19e58326 :alc_write_coef_idx (codec,0x48 ,0x0 );alc_update_coef_idx (codec,0x49 ,0x0045 ,0x0 );
@@ -3236,6 +3237,7 @@ static void alc_enable_headset_jack_key(case 0x10ec0230 :case 0x10ec0236 :case 0x10ec0256 : +case 0x10ec0257 :case 0x19e58326 :alc_write_coef_idx (codec,0x48 ,0xd011 );alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 );
@@ -6185,6 +6187,7 @@ static void alc_combo_jack_hp_jd_restartcase 0x10ec0236 :case 0x10ec0255 :case 0x10ec0256 : +case 0x10ec0257 :case 0x19e58326 :alc_update_coef_idx (codec,0x1b ,0x8000 ,1 <<15 );/* Reset HP JD */ alc_update_coef_idx (codec,0x1b ,0x8000 ,0 <<15 );
Greg Kroah-Hartman
maintainerPATCH 59/94 dm-verity: align struct dm_verity_fec_io properly
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 38bc1ab135db87577695816b190e7d6d8ec75879 upstream.
dm_verity_fec_io is placed after the end of two hash digests. If the hash digest has unaligned length, struct dm_verity_fec_io could be unaligned.
This commit fixes the placement of struct dm_verity_fec_io, so that it's aligned.
--- drivers/md/dm-verity-fec.c | 3 ++- drivers/md/dm-verity.h | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/md/dm-verity-fec.c +2 -1
@@ -24,7 +24,8 @@ bool verity_fec_is_enabled(struct dm_ver*/ static inline struct dm_verity_fec_io *fec_io (struct dm_verity_io *io) { -return (struct dm_verity_fec_io *)verity_io_digest_end (io->v, io); +return (struct dm_verity_fec_io *) + ((char *)io + io->v->ti->per_io_data_size -sizeof (struct dm_verity_fec_io )); }/*
drivers/md/dm-verity.h +0 -6
@@ -110,12 +110,6 @@ static inline u8 *verity_io_want_digest(return (u8 *)(io +1 ) + v->ahash_reqsize + v->digest_size; } -static inline u8 *verity_io_digest_end (struct dm_verity *v, -struct dm_verity_io *io) -{ -return verity_io_want_digest (v, io) + v->digest_size; -} - extern int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io, struct bvec_iter *iter, int (*process)(struct dm_verity *v,
Greg Kroah-Hartman
maintainerPATCH 60/94 dm verity: dont perform FEC for failed readahead IO
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wu Bo <[email protected]>
commit 0193e3966ceeeef69e235975918b287ab093082b upstream.
We found an issue under Android OTA scenario that many BIOs have to do FEC where the data under dm-verity is 100% complete and no corruption.
Android OTA has many dm-block layers, from upper to lower:
dm-verity
dm-snapshot
dm-origin & dm-cow
dm-linear
ufs
DM tables have to change 2 times during Android OTA merging process. When doing table change, the dm-snapshot will be suspended for a while. During this interval, many readahead IOs are submitted to dm_verity from filesystem. Then the kverity works are busy doing FEC process which cost too much time to finish dm-verity IO. This causes needless delay which feels like system is hung.
After adding debugging it was found that each readahead IO needed around 10s to finish when this situation occurred. This is due to IO amplification:
dm-snapshot suspenderofs_readahead // 300+ io is submitted
dm_submit_bio (dm_verity) dm_submit_bio (dm_snapshot) bio return EIO bio got nothing, it's empty verity_end_io verity_verify_io forloop range(0, io->n_blocks) // each io->nblocks ~= 20 verity_fec_decode fec_decode_rsb fec_read_bufs forloop range(0, v->fec->rsn) // v->fec->rsn = 253 new_read submit_bio (dm_snapshot) end loop end loop
dm-snapshot resume
Readahead BIOs get nothing while dm-snapshot is suspended, so all of them will cause verity's FEC.
Each readahead BIO needs to verify ~20 (io->nblocks) blocks. Each block needs to do FEC, and every block needs to do 253 (v->fec->rsn) reads.
So during the suspend interval(~200ms), 300 readahead BIOs trigger ~1518000 (300*20*253) IOs to dm-snapshot.
As readahead IO is not required by userspace, and to fix this issue, it is best to pass readahead errors to upper layer to handle it.
--- drivers/md/dm-verity-target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-verity-target.c +3 -1
@@ -579,7 +579,9 @@ static void verity_end_io(struct bio *bistruct dm_verity_io *io = bio->bi_private;if (bio->bi_status && - (!verity_fec_is_enabled (io->v) ||verity_is_system_shutting_down ())) { + (!verity_fec_is_enabled (io->v) || +verity_is_system_shutting_down () || + (bio->bi_opf &REQ_RAHEAD ))) {verity_finish_io (io, bio->bi_status);return ; }
Greg Kroah-Hartman
maintainerPATCH 61/94 bcache: revert replacing IS_ERR_OR_NULL with IS_ERR
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Weippert <[email protected]>
commit bb6cc253861bd5a7cf8439e2118659696df9619f upstream.
Commit 028ddcac477b ("bcache: Remove unnecessary NULL point check in node allocations") replaced IS_ERR_OR_NULL by IS_ERR. This leads to a NULL pointer dereference.
BUG: kernel NULL pointer dereference, address: 0000000000000080 Call Trace: ? __die_body.cold+0x1a/0x1f ? page_fault_oops+0xd2/0x2b0 ? exc_page_fault+0x70/0x170 ? asm_exc_page_fault+0x22/0x30 ? btree_node_free+0xf/0x160 [bcache] ? up_write+0x32/0x60 btree_gc_coalesce+0x2aa/0x890 [bcache] ? bch_extent_bad+0x70/0x170 [bcache] btree_gc_recurse+0x130/0x390 [bcache] ? btree_gc_mark_node+0x72/0x230 [bcache] bch_btree_gc+0x5da/0x600 [bcache] ? cpuusage_read+0x10/0x10 ? bch_btree_gc+0x600/0x600 [bcache] bch_gc_thread+0x135/0x180 [bcache]
The relevant code starts with:
new_nodes[0] = NULL;
for (i = 0; i < nodes; i++) {
if (__bch_keylist_realloc(&keylist, bkey_u64s(&r[i].b->key)))
goto out_nocoalesce;
// ...
out_nocoalesce:
// ...
for (i = 0; i < nodes; i++)
if (!IS_ERR(new_nodes[i])) { // IS_ERR_OR_NULL before
028ddcac477b
btree_node_free(new_nodes[i]); // new_nodes[0] is NULL
rw_unlock(true, new_nodes[i]);
}This patch replaces IS_ERR() by IS_ERR_OR_NULL() to fix this.
--- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/btree.c +1 -1
@@ -1538,7 +1538,7 @@ out_nocoalesce:bch_keylist_free (&keylist);for (i =0 ; i < nodes; i++) -if (!IS_ERR (new_nodes[i])) { +if (!IS_ERR_OR_NULL (new_nodes[i])) {btree_node_free (new_nodes[i]);rw_unlock (true, new_nodes[i]); }
Greg Kroah-Hartman
maintainerPATCH 62/94 powerpc: Dont clobber f0/vs0 during fp|altivec register save
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
commit 5e1d824f9a283cbf90f25241b66d1f69adb3835b upstream.
During floating point and vector save to thread data f0/vs0 are clobbered by the FPSCR/VSCR store routine. This has been obvserved to lead to userspace register corruption and application data corruption with io-uring.
Fix it by restoring f0/vs0 after FPSCR/VSCR store has completed for all the FP, altivec, VMX register save paths.
Tested under QEMU in kvm mode, running on a Talos II workstation with dual POWER9 DD2.2 CPUs.
Additional detail (mpe):
Typically save_fpu() is called from __giveup_fpu() which saves the FP regs and also *turns off FP* in the tasks MSR, meaning the kernel will reload the FP regs from the thread struct before letting the task use FP again. So in that case save_fpu() is free to clobber f0 because the FP regs no longer hold live values for the task.
There is another case though, which is the path via:
sys_clone()
...
copy_process()
dup_task_struct()
arch_dup_task_struct()
flush_all_to_thread()
save_all()That path saves the FP regs but leaves them live. That's meant as an optimisation for a process that's using FP/VSX and then calls fork(), leaving the regs live means the parent process doesn't have to take a fault after the fork to get its FP regs back. The optimisation was added in commit 8792468da5e1 ("powerpc: Add the ability to save FPU without giving it up").
That path does clobber f0, but f0 is volatile across function calls, and typically programs reach copy_process() from userspace via a syscall wrapper function. So in normal usage f0 being clobbered across a syscall doesn't cause visible data corruption.
But there is now a new path, because io-uring can call copy_process() via create_io_thread() from the signal handling path. That's OK if the signal is handled as part of syscall return, but it's not OK if the signal is handled due to some other interrupt.
That path is:
interrupt_return_srr_user()
interrupt_exit_user_prepare()
interrupt_exit_user_prepare_main()
do_notify_resume()
get_signal()
task_work_run()
create_worker_cb()
create_io_worker()
copy_process()
dup_task_struct()
arch_dup_task_struct()
flush_all_to_thread()
save_all()
if (tsk->thread.regs->msr & MSR_FP)
save_fpu()
# f0 is clobbered and potentially live in userspaceNote the above discussion applies equally to save_altivec().
--- arch/powerpc/kernel/fpu.S | 13 +++++++++++++ arch/powerpc/kernel/vector.S | 2 ++ 2 files changed, 15 insertions(+)
arch/powerpc/kernel/fpu.S +13 -0
@@ -24,6 +24,15 @@ #include <asm/feature-fixups.h> #ifdef CONFIG_VSX +#define __REST_1FPVSR(n,c,base) \ +BEGIN_FTR_SECTION \ + b 2f; \ +END_FTR_SECTION_IFSET(CPU_FTR_VSX); \ + REST_FPR(n,base); \ + b 3f; \ +2: REST_VSR(n,c,base); \ +3: + #define __REST_32FPVSRS(n,c,base) \ BEGIN_FTR_SECTION \ b 2f; \
@@ -42,9 +51,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); 2: SAVE_32VSRS(n,c,base); \ 3: #else +#define __REST_1FPVSR(n,b,base) REST_FPR(n, base) #define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base) #define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base) #endif +#define REST_1FPVSR(n,c,base) __REST_1FPVSR(n,__REG_##c,__REG_##base) #define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base) #define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
@@ -68,6 +79,7 @@ _GLOBAL(store_fp_state) SAVE_32FPVSRS(0, R4, R3) mffs fr0 stfd fr0,FPSTATE_FPSCR(r3) + REST_1FPVSR(0, R4, R3) blr EXPORT_SYMBOL(store_fp_state)
@@ -132,6 +144,7 @@ _GLOBAL(save_fpu) 2: SAVE_32FPVSRS(0, R4, R6) mffs fr0 stfd fr0,FPSTATE_FPSCR(r6) + REST_1FPVSR(0, R4, R6) blr /*
arch/powerpc/kernel/vector.S +2 -0
@@ -32,6 +32,7 @@ _GLOBAL(store_vr_state) mfvscr v0 li r4, VRSTATE_VSCR stvx v0, r4, r3 + lvx v0, 0, r3 blr EXPORT_SYMBOL(store_vr_state)
@@ -102,6 +103,7 @@ _GLOBAL(save_altivec) mfvscr v0 li r4,VRSTATE_VSCR stvx v0,r4,r7 + lvx v0,0,r7 blr #ifdef CONFIG_VSX
Greg Kroah-Hartman
maintainerPATCH 63/94 btrfs: add dmesg output for first mount and last unmount of a filesystem
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 2db313205f8b96eea467691917138d646bb50aef upstream.
There is a feature request to add dmesg output when unmounting a btrfs. There are several alternative methods to do the same thing, but with their own problems:
- Use eBPF to watch btrfs_put_super()/open_ctree()
Not end user friendly, they have to dip their head into the source code.
- Watch for directory /sys/fs/<uuid>/
This is way more simple, but still requires some simple device -> uuid lookups. And a script needs to use inotify to watch /sys/fs/.
Compared to all these, directly outputting the information into dmesg would be the most simple one, with both device and UUID included.
And since we're here, also add the output when mounting a filesystem for the first time for parity. A more fine grained monitoring of subvolume mounts should be done by another layer, like audit.
Now mounting a btrfs with all default mkfs options would look like this:
[81.906566] BTRFS info (device dm-8): first mount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2 [81.907494] BTRFS info (device dm-8): using crc32c (crc32c-intel) checksum algorithm [81.908258] BTRFS info (device dm-8): using free space tree [81.912644] BTRFS info (device dm-8): auto enabling async discard [81.913277] BTRFS info (device dm-8): checking UUID tree [91.668256] BTRFS info (device dm-8): last unmount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2
--- fs/btrfs/disk-io.c | 1 + fs/btrfs/super.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -0
@@ -2829,6 +2829,7 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } +btrfs_info (fs_info,"first mount of filesystem %pU" , disk_super->fsid);/* * Verify the type first, if that or the checksum value are * corrupted, we'll find out
fs/btrfs/super.c +4 -1
@@ -291,7 +291,10 @@ void __btrfs_panic(struct btrfs_fs_infostatic void btrfs_put_super (struct super_block *sb) { -close_ctree (btrfs_sb (sb)); +struct btrfs_fs_info *fs_info =btrfs_sb (sb); + +btrfs_info (fs_info,"last unmount of filesystem %pU" , fs_info->fs_devices->fsid); +close_ctree (fs_info); }enum {
Re: [PATCH 5.4 63/94] btrfs: add dmesg output for first mount and last unmount of a filesystem
Quoted 52 lines · Greg Kroah-Hartman
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit
2db313205f8b96eea467691917138d646bb50aefupstream.There is a feature request to add dmesg output when unmounting a btrfs. There are several alternative methods to do the same thing, but with their own problems:
- Use eBPF to watch btrfs_put_super()/open_ctree()
Not end user friendly, they have to dip their head into the source code.- Watch for directory /sys/fs/<uuid>/
This is way more simple, but still requires some simple device -> uuid lookups. And a script needs to use inotify to watch/sys/fs/.Compared to all these, directly outputting the information into dmesg would be the most simple one, with both device and UUID included.
And since we're here, also add the output when mounting a filesystem for the first time for parity. A more fine grained monitoring of subvolume mounts should be done by another layer, like audit.
Now mounting a btrfs with all default mkfs options would look like this:
[81.906566] BTRFS info (device dm-8): first mount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2 [81.907494] BTRFS info (device dm-8): using crc32c (crc32c-intel) checksum algorithm [81.908258] BTRFS info (device dm-8): using free space tree [81.912644] BTRFS info (device dm-8): auto enabling async discard [81.913277] BTRFS info (device dm-8): checking UUID tree [91.668256] BTRFS info (device dm-8): last unmount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2CC [email protected] # 5.4+Reviewed-by Anand Jain <[email protected]>Signed-off-by Qu Wenruo <[email protected]>Reviewed-by David Sterba <[email protected]>[ update changelog ]Signed-off-by David Sterba <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- fs/btrfs/disk-io.c | 1 + fs/btrfs/super.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c int open_ctree(struct super_block *sb, · line 2832
Quoted 4 lines
fs/btrfs/disk-io.c +1
-0@@ -2829,6 +2829,7 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } +btrfs_info (fs_info,"first mount of filesystem %pU" , disk_super->fsid);
clang tells me this backport does not appear to be correct and will likely introduce a null pointer deference:
fs/btrfs/disk-io.c:2832:55: warning: variable 'disk_super' is uninitialized when used here [-Wuninitialized]
2832 | btrfs_info(fs_info, "first mount of filesystem %pU", disk_super->fsid);
| ^~~~~~~~~~
fs/btrfs/ctree.h:3002:41: note: expanded from macro 'btrfs_info'
3002 | btrfs_printk(fs_info, KERN_INFO fmt, ##args)
| ^~~~
fs/btrfs/disk-io.c:2630:38: note: initialize the variable 'disk_super' to silence this warning
2630 | struct btrfs_super_block *disk_super;
| ^
| = NULL1 warning generated.
Quoted 19 lines
fs/btrfs/disk-io.c +0
-0/* * Verify the type first, if that or the checksum value are * corrupted, we'll find out fs/btrfs/super.c +4
-1@@ -291,7 +291,10 @@ void __btrfs_panic(struct btrfs_fs_infostatic void btrfs_put_super (struct super_block *sb) { -close_ctree (btrfs_sb (sb)); +struct btrfs_fs_info *fs_info =btrfs_sb (sb); + +btrfs_info (fs_info,"last unmount of filesystem %pU" , fs_info->fs_devices->fsid); +close_ctree (fs_info); }enum {
Greg Kroah-Hartman
maintainerRe: [PATCH 5.4 63/94] btrfs: add dmesg output for first mount and last unmount of a filesystem
Quoted 68 lines · Nathan Chancellor
Quoted 52 lines · Greg Kroah-Hartman
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit
2db313205f8b96eea467691917138d646bb50aefupstream.There is a feature request to add dmesg output when unmounting a btrfs. There are several alternative methods to do the same thing, but with their own problems:
- Use eBPF to watch btrfs_put_super()/open_ctree()
Not end user friendly, they have to dip their head into the source code.- Watch for directory /sys/fs/<uuid>/
This is way more simple, but still requires some simple device -> uuid lookups. And a script needs to use inotify to watch/sys/fs/.Compared to all these, directly outputting the information into dmesg would be the most simple one, with both device and UUID included.
And since we're here, also add the output when mounting a filesystem for the first time for parity. A more fine grained monitoring of subvolume mounts should be done by another layer, like audit.
Now mounting a btrfs with all default mkfs options would look like this:
[81.906566] BTRFS info (device dm-8): first mount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2 [81.907494] BTRFS info (device dm-8): using crc32c (crc32c-intel) checksum algorithm [81.908258] BTRFS info (device dm-8): using free space tree [81.912644] BTRFS info (device dm-8): auto enabling async discard [81.913277] BTRFS info (device dm-8): checking UUID tree [91.668256] BTRFS info (device dm-8): last unmount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2CC [email protected] # 5.4+Reviewed-by Anand Jain <[email protected]>Signed-off-by Qu Wenruo <[email protected]>Reviewed-by David Sterba <[email protected]>[ update changelog ]Signed-off-by David Sterba <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- fs/btrfs/disk-io.c | 1 + fs/btrfs/super.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)fs/btrfs/disk-io.c int open_ctree(struct super_block *sb, · line 2832
Quoted 4 lines
fs/btrfs/disk-io.c +1
-0@@ -2829,6 +2829,7 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } +btrfs_info (fs_info,"first mount of filesystem %pU" , disk_super->fsid);clang tells me this backport does not appear to be correct and will likely introduce a null pointer deference:
fs/btrfs/disk-io.c:2832:55: warning: variable 'disk_super' is uninitialized when used here [-Wuninitialized]
2832 |btrfs_info(fs_info, "first mount of filesystem %pU", disk_super->fsid);
| ^~~~~~~~~~
fs/btrfs/ctree.h:3002:41: note: expanded from macro 'btrfs_info'
3002 |btrfs_printk(fs_info, KERN_INFO fmt, ##args)
| ^~~~
fs/btrfs/disk-io.c:2630:38: note: initialize the variable 'disk_super' to silence this warning
Quoted 4 lines
2630 | struct btrfs_super_block *disk_super; | ^ | = NULL1 warning generated.
Thanks for the notice, I've now reverted this.
greg k-h
Re: [PATCH 5.4 63/94] btrfs: add dmesg output for first mount and last unmount of a filesystem
Quoted 74 lines · Greg Kroah-Hartman
Quoted 68 lines · Nathan Chancellor
Quoted 52 lines · Greg Kroah-Hartman
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit
2db313205f8b96eea467691917138d646bb50aefupstream.There is a feature request to add dmesg output when unmounting a btrfs. There are several alternative methods to do the same thing, but with their own problems:
- Use eBPF to watch btrfs_put_super()/open_ctree()
Not end user friendly, they have to dip their head into the source code.- Watch for directory /sys/fs/<uuid>/
This is way more simple, but still requires some simple device -> uuid lookups. And a script needs to use inotify to watch/sys/fs/.Compared to all these, directly outputting the information into dmesg would be the most simple one, with both device and UUID included.
And since we're here, also add the output when mounting a filesystem for the first time for parity. A more fine grained monitoring of subvolume mounts should be done by another layer, like audit.
Now mounting a btrfs with all default mkfs options would look like this:
[81.906566] BTRFS info (device dm-8): first mount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2 [81.907494] BTRFS info (device dm-8): using crc32c (crc32c-intel) checksum algorithm [81.908258] BTRFS info (device dm-8): using free space tree [81.912644] BTRFS info (device dm-8): auto enabling async discard [81.913277] BTRFS info (device dm-8): checking UUID tree [91.668256] BTRFS info (device dm-8): last unmount of filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2CC [email protected] # 5.4+Reviewed-by Anand Jain <[email protected]>Signed-off-by Qu Wenruo <[email protected]>Reviewed-by David Sterba <[email protected]>[ update changelog ]Signed-off-by David Sterba <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- fs/btrfs/disk-io.c | 1 + fs/btrfs/super.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)fs/btrfs/disk-io.c int open_ctree(struct super_block *sb, · line 2832
Quoted 4 lines
fs/btrfs/disk-io.c +1
-0@@ -2829,6 +2829,7 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } +btrfs_info (fs_info,"first mount of filesystem %pU" , disk_super->fsid);clang tells me this backport does not appear to be correct and will likely introduce a null pointer deference:
fs/btrfs/disk-io.c:2832:55: warning: variable 'disk_super' is uninitialized when used here [-Wuninitialized]
2832 |btrfs_info(fs_info, "first mount of filesystem %pU", disk_super->fsid);
| ^~~~~~~~~~
fs/btrfs/ctree.h:3002:41: note: expanded from macro 'btrfs_info'
3002 |btrfs_printk(fs_info, KERN_INFO fmt, ##args)
| ^~~~
fs/btrfs/disk-io.c:2630:38: note: initialize the variable 'disk_super' to silence this warningQuoted 4 lines
2630 | struct btrfs_super_block *disk_super; | ^ | = NULL1 warning generated.
Quoted 1 line
Thanks for the notice, I've now reverted this.
Thanks. I've verified that this only affects 5.4. The patch is still possible to apply there, the btrfs_info() call would have to be moved after 'disk_super' is initialized. The patch is not that important so reverting is OK for me.
Greg Kroah-Hartman
maintainerPATCH 64/94 btrfs: fix off-by-one when checking chunk map includes logical address
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 5fba5a571858ce2d787fdaf55814e42725bfa895 upstream.
At btrfs_get_chunk_map() we get the extent map for the chunk that contains the given logical address stored in the 'logical' argument. Then we do sanity checks to verify the extent map contains the logical address. One of these checks verifies if the extent map covers a range with an end offset behind the target logical address - however this check has an off-by-one error since it will consider an extent map whose start offset plus its length matches the target logical address as inclusive, while the fact is that the last byte it covers is behind the target logical address (by 1).
So fix this condition by using '<=' rather than '<' when comparing the extent map's "start + length" against the target logical address.
--- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
@@ -3095,7 +3095,7 @@ struct extent_map *btrfs_get_chunk_map(sreturn ERR_PTR (-EINVAL ); } -if (em->start > logical || em->start + em->len < logical) { +if (em->start > logical || em->start + em->len <= logical) {btrfs_crit (fs_info,"found a bad mapping, wanted %llu-%llu, found %llu-%llu" , logical, length, em->start, em->start + em->len);
Greg Kroah-Hartman
maintainerPATCH 65/94 btrfs: send: ensure send_fd is writable
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 0ac1d13a55eb37d398b63e6ff6db4a09a2c9128c upstream.
kernel_write() requires the caller to ensure that the file is writable. Let's do that directly after looking up the ->send_fd.
We don't need a separate bailout path because the "out" path already does fput() if ->send_filp is non-NULL.
This has no security impact for two reasons:
- the ioctl requires CAP_SYS_ADMIN
- __kernel_write() bails out on read-only files - but only since 5.8, see commit a01ac27be472 ("fs: check FMODE_WRITE in __kernel_write")
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -7381,7 +7381,7 @@ long btrfs_ioctl_send(struct file *mnt_f sctx->flags = arg->flags; sctx->send_filp =fget (arg->send_fd); -if (!sctx->send_filp) { +if (!sctx->send_filp || !(sctx->send_filp->f_mode &FMODE_WRITE )) { ret = -EBADF ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 66/94 btrfs: make error messages more clear when getting a chunk map
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 7d410d5efe04e42a6cd959bfe6d59d559fdf8b25 upstream.
When getting a chunk map, at btrfs_get_chunk_map(), we do some sanity checks to verify we found a chunk map and that map found covers the logical address the caller passed in. However the messages aren't very clear in the sense that don't mention the issue is with a chunk map and one of them prints the 'length' argument as if it were the end offset of the requested range (while the in the string format we use %llu-%llu which suggests a range, and the second %llu-%llu is actually a range for the chunk map). So improve these two details in the error messages.
--- fs/btrfs/volumes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/volumes.c +4 -3
@@ -3090,15 +3090,16 @@ struct extent_map *btrfs_get_chunk_map(sread_unlock (&em_tree->lock);if (!em) { -btrfs_crit (fs_info,"unable to find logical %llu length %llu" , +btrfs_crit (fs_info, +"unable to find chunk map for logical %llu length %llu" , logical, length);return ERR_PTR (-EINVAL ); }if (em->start > logical || em->start + em->len <= logical) {btrfs_crit (fs_info, -"found a bad mapping, wanted %llu-%llu, found %llu-%llu" , - logical, length, em->start, em->start + em->len); +"found a bad chunk map, wanted %llu-%llu, found %llu-%llu" , + logical, logical + length, em->start, em->start + em->len);free_extent_map (em);return ERR_PTR (-EINVAL ); }
Greg Kroah-Hartman
maintainerPATCH 67/94 Input: xpad - add HyperX Clutch Gladiate Support
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Nguyen <[email protected]>
commit e28a0974d749e5105d77233c0a84d35c37da047e upstream.
Add HyperX controller support to xpad_device and xpad_table.
--- drivers/input/joystick/xpad.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/joystick/xpad.c +2 -0
@@ -119,6 +119,7 @@ static const struct xpad_device { { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, { 0x044f, 0x0f10, "Thrustmaster Modena GT Wheel", 0, XTYPE_XBOX }, { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 }, + { 0x03f0, 0x0495, "HyperX Clutch Gladiate", 0, XTYPE_XBOXONE }, { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX }, { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
@@ -431,6 +432,7 @@ static const struct usb_device_id xpad_tXPAD_XBOX360_VENDOR (0x0079 ),/* GPD Win 2 Controller */ XPAD_XBOX360_VENDOR (0x03eb ),/* Wooting Keyboards (Legacy) */ XPAD_XBOX360_VENDOR (0x044f ),/* Thrustmaster X-Box 360 controllers */ +XPAD_XBOXONE_VENDOR (0x03f0 ),/* HP HyperX Xbox One Controllers */ XPAD_XBOX360_VENDOR (0x045e ),/* Microsoft X-Box 360 controllers */ XPAD_XBOXONE_VENDOR (0x045e ),/* Microsoft X-Box One controllers */ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
Greg Kroah-Hartman
maintainerPATCH 68/94 ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchao Shao <[email protected]>
[ Upstream commit e2b706c691905fe78468c361aaabc719d0a496f1 ]
When I perform the following test operations:
1.ip link add br0 type bridge
2.brctl addif br0 eth0
3.ip addr add 239.0.0.1/32 dev eth0
4.ip addr add 239.0.0.1/32 dev br0
5.ip addr add 224.0.0.1/32 dev br0
6.while ((1))
do
ifconfig br0 up
ifconfig br0 down
done
7.send IGMPv2 query packets to port eth0 continuously. For example, ./mausezahn ethX -c 0 "01 00 5e 00 00 01 00 72 19 88 aa 02 08 00 45 00 00 1c 00 01 00 00 01 02 0e 7f c0 a8 0a b7 e0 00 00 01 11 64 ee 9b 00 00 00 00"
The preceding tests may trigger the refcnt uaf issue of the mc list. The stack is as follows:
refcount_t: addition on 0; use-after-free. WARNING: CPU: 21 PID: 144 at lib/refcount.c:25 refcount_warn_saturate (lib/refcount.c:25) CPU: 21 PID: 144 Comm: ksoftirqd/21 Kdump: loaded Not tainted 6.7.0-rc1-next-20231117-dirty #80 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:refcount_warn_saturate (lib/refcount.c:25) RSP: 0018:ffffb68f00657910 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff8a00c3bf96c0 RCX: ffff8a07b6160908 RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff8a07b6160900 RBP: ffff8a00cba36862 R08: 0000000000000000 R09: 00000000ffff7fff R10: ffffb68f006577c0 R11: ffffffffb0fdcdc8 R12: ffff8a00c3bf9680 R13: ffff8a00c3bf96f0 R14: 0000000000000000 R15: ffff8a00d8766e00 FS: 0000000000000000(0000) GS:ffff8a07b6140000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055f10b520b28 CR3: 000000039741a000 CR4: 00000000000006f0 Call Trace: <TASK> igmp_heard_query (net/ipv4/igmp.c:1068) igmp_rcv (net/ipv4/igmp.c:1132) ip_protocol_deliver_rcu (net/ipv4/ip_input.c:205) ip_local_deliver_finish (net/ipv4/ip_input.c:234) __netif_receive_skb_one_core (net/core/dev.c:5529) netif_receive_skb_internal (net/core/dev.c:5729) netif_receive_skb (net/core/dev.c:5788) br_handle_frame_finish (net/bridge/br_input.c:216) nf_hook_bridge_pre (net/bridge/br_input.c:294) __netif_receive_skb_core (net/core/dev.c:5423) __netif_receive_skb_list_core (net/core/dev.c:5606) __netif_receive_skb_list (net/core/dev.c:5674) netif_receive_skb_list_internal (net/core/dev.c:5764) napi_gro_receive (net/core/gro.c:609) e1000_clean_rx_irq (drivers/net/ethernet/intel/e1000/e1000_main.c:4467) e1000_clean (drivers/net/ethernet/intel/e1000/e1000_main.c:3805) __napi_poll (net/core/dev.c:6533) net_rx_action (net/core/dev.c:6735) __do_softirq (kernel/softirq.c:554) run_ksoftirqd (kernel/softirq.c:913) smpboot_thread_fn (kernel/smpboot.c:164) kthread (kernel/kthread.c:388) ret_from_fork (arch/x86/kernel/process.c:153) ret_from_fork_asm (arch/x86/entry/entry_64.S:250) </TASK>
The root causes are as follows:
Thread A Thread B
... netif_receive_skbbr_dev_stop ...
br_multicast_leave_snoopers ...
__ip_mc_dec_group ...
__igmp_group_dropped igmp_rcv
igmp_stop_timer igmp_heard_query //ref = 1
ip_ma_put igmp_mod_timer
refcount_dec_and_test igmp_start_timer //ref = 0
... refcount_inc //ref increases from 0
When the device receives an IGMPv2 Query message, it starts the timer immediately, regardless of whether the device is running. If the device is down and has left the multicast group, it will cause the mc list refcount uaf issue.
--- net/ipv4/igmp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/igmp.c +4 -2
@@ -218,8 +218,10 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)int tv =prandom_u32 () % max_delay; im->tm_running =1 ; -if (!mod_timer (&im->timer, jiffies+tv+2 )) -refcount_inc (&im->refcnt); +if (refcount_inc_not_zero (&im->refcnt)) { +if (mod_timer (&im->timer, jiffies + tv +2 )) +ip_ma_put (im); + } }static void igmp_gq_start_timer (struct in_device *in_dev)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 69/94 net: stmmac: xgmac: Disable FPE MMC interrupts
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Furong Xu <[email protected]>
[ Upstream commit e54d628a2721bfbb002c19f6e8ca6746cec7640f ]
Commit aeb18dd07692 ("net: stmmac: xgmac: Disable MMC interrupts by default") tries to disable MMC interrupts to avoid a storm of unhandled interrupts, but leaves the FPE(Frame Preemption) MMC interrupts enabled, FPE MMC interrupts can cause the same problem. Now we mask FPE TX and RX interrupts to disable all MMC interrupts.
--- drivers/net/ethernet/stmicro/stmmac/mmc_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/mmc_core.c +4 -0
@@ -170,8 +170,10 @@#define MMC_XGMAC_RX_DISCARD_OCT_GB 0x1b4#define MMC_XGMAC_RX_ALIGN_ERR_PKT 0x1bc +#define MMC_XGMAC_TX_FPE_INTR_MASK 0x204#define MMC_XGMAC_TX_FPE_FRAG 0x208#define MMC_XGMAC_TX_HOLD_REQ 0x20c +#define MMC_XGMAC_RX_FPE_INTR_MASK 0x224#define MMC_XGMAC_RX_PKT_ASSEMBLY_ERR 0x228#define MMC_XGMAC_RX_PKT_SMD_ERR 0x22c#define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230
@@ -336,6 +338,8 @@ static void dwxgmac_mmc_intr_all_mask(void __iomem *mmcaddr) {writel (0x0 , mmcaddr +MMC_RX_INTR_MASK );writel (0x0 , mmcaddr +MMC_TX_INTR_MASK ); +writel (MMC_DEFAULT_MASK , mmcaddr +MMC_XGMAC_TX_FPE_INTR_MASK ); +writel (MMC_DEFAULT_MASK , mmcaddr +MMC_XGMAC_RX_FPE_INTR_MASK );writel (MMC_DEFAULT_MASK , mmcaddr +MMC_XGMAC_RX_IPC_INTR_MASK ); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 70/94 ravb: Fix races between ravb_tx_timeout_work() and net related ops
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
[ Upstream commit 9870257a0a338cd8d6c1cddab74e703f490f6779 ]
Fix races between ravb_tx_timeout_work() and functions of net_device_ops and ethtool_ops by using rtnl_trylock() and rtnl_unlock(). Note that since ravb_close() is under the rtnl lock and calls cancel_work_sync(), ravb_tx_timeout_work() should calls rtnl_trylock(). Otherwise, a deadlock may happen in ravb_tx_timeout_work() like below:
CPU0 CPU1
ravb_tx_timeout()
schedule_work()
...__dev_close_many()
// Under rtnl lockravb_close()cancel_work_sync()
// Waiting
ravb_tx_timeout_work() rtnl_lock() // This is possible to cause a deadlock
If rtnl_trylock() fails, rescheduling the work with sleep for 1 msec.
--- drivers/net/ethernet/renesas/ravb_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/renesas/ravb_main.c +10 -1
@@ -1435,6 +1435,12 @@ static void ravb_tx_timeout_work(struct work_struct *work)struct net_device *ndev = priv->ndev;int error; +if (!rtnl_trylock ()) { +usleep_range (1000 ,2000 ); +schedule_work (&priv->work); +return ; + } +netif_tx_stop_all_queues (ndev);/* Stop PTP Clock driver */
@@ -1467,7 +1473,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)*/ netdev_err (ndev,"%s: ravb_dmac_init() failed, error %d\n" , __func__, error); -return ; + goto out_unlock; }ravb_emac_init (ndev);
@@ -1477,6 +1483,9 @@ static void ravb_tx_timeout_work(struct work_struct *work)ravb_ptp_init (ndev, priv->pdev);netif_tx_start_all_queues (ndev); + +out_unlock: +rtnl_unlock (); }/* Packet transmit function for Ethernet AVB */
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 71/94 net: ravb: Use pm_runtime_resume_and_get()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 88b74831faaee455c2af380382d979fc38e79270 ]
pm_runtime_get_sync() may return an error. In case it returns with an error dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get() takes care of this. Thus use it.
--- drivers/net/ethernet/renesas/ravb_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/renesas/ravb_main.c +4 -1
@@ -2039,7 +2039,9 @@ static int ravb_probe(struct platform_device *pdev) ndev->hw_features =NETIF_F_RXCSUM ;pm_runtime_enable (&pdev->dev); -pm_runtime_get_sync (&pdev->dev); + error =pm_runtime_resume_and_get (&pdev->dev); +if (error <0 ) + goto out_rpm_disable;/* The Ether-specific entries in the device structure. */ ndev->base_addr = res->start;
@@ -2210,6 +2212,7 @@ static int ravb_probe(struct platform_device *pdev)free_netdev (ndev);pm_runtime_put (&pdev->dev); +out_rpm_disable:pm_runtime_disable (&pdev->dev);return error; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 72/94 net: ravb: Start TX queues after HW initialization succeeded
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 6f32c086602050fc11157adeafaa1c1eb393f0af ]
ravb_phy_start() may fail. If that happens, the TX queues will remain started. Thus, move the netif_tx_start_all_queues() after PHY is successfully initialized.
--- drivers/net/ethernet/renesas/ravb_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +2 -2
@@ -1380,13 +1380,13 @@ static int ravb_open(struct net_device *ndev)if (priv->chip_id ==RCAR_GEN2 )ravb_ptp_init (ndev, priv->pdev); -netif_tx_start_all_queues (ndev); -/* PHY control start */ error =ravb_phy_start (ndev);if (error) goto out_ptp_stop; +netif_tx_start_all_queues (ndev); +return 0 ; out_ptp_stop:
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 73/94 perf intel-pt: Adjust sample flags for VM-Exit
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 695fc4510615f8db40ebaf7a2c011f0a594b5f77 ]
Use the change of NR to detect whether an asynchronous branch is a VM-Exit.
Note VM-Entry is determined from the vmlaunch or vmresume instruction, in which case, sample flags will show "VMentry" even if the VM-Entry fails.
Stable-dep-of: f2d87895cbc4 ("perf intel-pt: Fix async branch flags")
--- tools/perf/util/intel-pt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/util/intel-pt.c +7 -4
@@ -997,13 +997,16 @@ static void intel_pt_sample_flags(struct intel_pt_queue *ptq)if (ptq->state->flags &INTEL_PT_ABORT_TX ) { ptq->flags =PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_TX_ABORT ; }else if (ptq->state->flags &INTEL_PT_ASYNC ) { -if (ptq->state->to_ip) +if (!ptq->state->to_ip) + ptq->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_TRACE_END ; +else if (ptq->state->from_nr && !ptq->state->to_nr) + ptq->flags =PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_CALL | +PERF_IP_FLAG_VMEXIT ; +else ptq->flags =PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_CALL |PERF_IP_FLAG_ASYNC |PERF_IP_FLAG_INTERRUPT ; -else - ptq->flags =PERF_IP_FLAG_BRANCH | -PERF_IP_FLAG_TRACE_END ; ptq->insn_len =0 ; }else {if (ptq->state->from_ip)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 74/94 perf intel-pt: Fix async branch flags
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit f2d87895cbc4af80649850dcf5da36de6b2ed3dd ]
Ensure PERF_IP_FLAG_ASYNC is set always for asynchronous branches (i.e. interrupts etc).
--- tools/perf/util/intel-pt.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/intel-pt.c +2 -0
@@ -999,9 +999,11 @@ static void intel_pt_sample_flags(struct intel_pt_queue *ptq) }else if (ptq->state->flags &INTEL_PT_ASYNC ) {if (!ptq->state->to_ip) ptq->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_ASYNC |PERF_IP_FLAG_TRACE_END ;else if (ptq->state->from_nr && !ptq->state->to_nr) ptq->flags =PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_CALL | +PERF_IP_FLAG_ASYNC |PERF_IP_FLAG_VMEXIT ;else ptq->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL |
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 75/94 smb3: fix touch -h of symlink
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
[ Upstream commit 475efd9808a3094944a56240b2711349e433fb66 ]
For example:
touch -h -t 02011200 testfile
where testfile is a symlink would not change the timestamp, but
touch -t 02011200 testfiledoes work to change the timestamp of the target
--- fs/cifs/cifsfs.c | 1 + 1 file changed, 1 insertion(+)
fs/cifs/cifsfs.c +1 -0
@@ -1062,6 +1062,7 @@ const struct inode_operations cifs_file_inode_ops = {const struct inode_operations cifs_symlink_inode_ops = { .get_link = cifs_get_link, + .setattr = cifs_setattr, .permission = cifs_permission, .listxattr = cifs_listxattr, };
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 76/94 s390/mm: fix phys vs virt confusion in mark_kernel_pXd() functions family
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Gordeev <[email protected]>
[ Upstream commit 3784231b1e091857bd129fd9658a8b3cedbdcd58 ]
Due to historical reasons mark_kernel_pXd() functions misuse the notion of physical vs virtual addresses difference.
Stable-dep-of: 44d930452476 ("s390/cmma: fix detection of DAT pages")
--- arch/s390/mm/page-states.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/s390/mm/page-states.c +4 -4
@@ -112,7 +112,7 @@ static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end) next =pmd_addr_end (addr, end);if (pmd_none (*pmd) ||pmd_large (*pmd))continue ; - page =virt_to_page (pmd_val (*pmd)); + page =phys_to_page (pmd_val (*pmd));set_bit (PG_arch_1, &page->flags); }while (pmd++, addr = next, addr != end); }
@@ -130,7 +130,7 @@ static void mark_kernel_pud(p4d_t *p4d, unsigned long addr, unsigned long end)if (pud_none (*pud) ||pud_large (*pud))continue ;if (!pud_folded (*pud)) { - page =virt_to_page (pud_val (*pud)); + page =phys_to_page (pud_val (*pud));for (i =0 ; i <3 ; i++)set_bit (PG_arch_1, &page[i].flags); }
@@ -151,7 +151,7 @@ static void mark_kernel_p4d(pgd_t *pgd, unsigned long addr, unsigned long end)if (p4d_none (*p4d))continue ;if (!p4d_folded (*p4d)) { - page =virt_to_page (p4d_val (*p4d)); + page =phys_to_page (p4d_val (*p4d));for (i =0 ; i <3 ; i++)set_bit (PG_arch_1, &page[i].flags); }
@@ -173,7 +173,7 @@ static void mark_kernel_pgd(void)if (pgd_none (*pgd))continue ;if (!pgd_folded (*pgd)) { - page =virt_to_page (pgd_val (*pgd)); + page =phys_to_page (pgd_val (*pgd));for (i =0 ; i <3 ; i++)set_bit (PG_arch_1, &page[i].flags); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 77/94 s390/cmma: fix detection of DAT pages
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 44d93045247661acbd50b1629e62f415f2747577 ]
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however is
incorrect: only the first three of the four pages which belong to segment and region tables will be marked as being used for DAT. The last page is incorrectly marked as no-dat.
This can result in incorrect guest TLB flushes.
Fix this by simply marking all four pages.
--- arch/s390/mm/page-states.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +3 -3
@@ -131,7 +131,7 @@ static void mark_kernel_pud(p4d_t *p4d, unsigned long addr, unsigned long end)continue ;if (!pud_folded (*pud)) { page =phys_to_page (pud_val (*pud)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pmd (pud, addr, next);
@@ -152,7 +152,7 @@ static void mark_kernel_p4d(pgd_t *pgd, unsigned long addr, unsigned long end)continue ;if (!p4d_folded (*p4d)) { page =phys_to_page (p4d_val (*p4d)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pud (p4d, addr, next);
@@ -174,7 +174,7 @@ static void mark_kernel_pgd(void)continue ;if (!pgd_folded (*pgd)) { page =phys_to_page (pgd_val (*pgd)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 78/94 mtd: cfi_cmdset_0001: Support the absence of protection registers
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Philippe Brucker <[email protected]>
[ Upstream commit b359ed5184aebf9d987e54abc5dae7ac03ed29ae ]
The flash controller implemented by the Arm Base platform behaves like the Intel StrataFlash J3 device, but omits several features. In particular it doesn't implement a protection register, so "Number of Protection register fields" in the Primary Vendor-Specific Extended Query, is 0.
The Intel StrataFlash J3 datasheet only lists 1 as a valid value for NumProtectionFields. It describes the field as:
"Number of Protection register fields in JEDEC ID space. “00h,” indicates that 256 protection bytes are available"
While a value of 0 may arguably not be architecturally valid, the driver's current behavior is certainly wrong: if NumProtectionFields is 0, read_pri_intelext() adds a negative value to the unsigned extra_size, and ends up in an infinite loop.
Fix it by ignoring a NumProtectionFields of 0.
Stable-dep-of: 565fe150624e ("mtd: cfi_cmdset_0001: Byte swap OTP info")
--- drivers/mtd/chips/cfi_cmdset_0001.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +8 -5
@@ -420,8 +420,9 @@ read_pri_intelext(struct map_info *map, __u16 adr) extra_size =0 ;/* Protection Register info */ - extra_size += (extp->NumProtectionFields -1 ) * -sizeof (struct cfi_intelext_otpinfo ); +if (extp->NumProtectionFields) + extra_size += (extp->NumProtectionFields -1 ) * +sizeof (struct cfi_intelext_otpinfo ); }if (extp->MinorVersion >='1' ) {
@@ -695,14 +696,16 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,*/ if (extp && extp->MajorVersion =='1' && extp->MinorVersion >='3' && extp->FeatureSupport & (1 <<9 )) { +int offs =0 ;struct cfi_private *newcfi;struct flchip *chip;struct flchip_shared *shared; -int offs, numregions, numparts, partshift, numvirtchips, i, j; +int numregions, numparts, partshift, numvirtchips, i, j;/* Protection Register info */ - offs = (extp->NumProtectionFields -1 ) * -sizeof (struct cfi_intelext_otpinfo ); +if (extp->NumProtectionFields) + offs = (extp->NumProtectionFields -1 ) * +sizeof (struct cfi_intelext_otpinfo );/* Burst Read info */ offs += extp->extra[offs+1 ]+2 ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 79/94 mtd: cfi_cmdset_0001: Byte swap OTP info
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 565fe150624ee77dc63a735cc1b3bff5101f38a3 ]
Currently the offset into the device when looking for OTP bits can go outside of the address of the MTD NOR devices, and if that memory isn't readable, bad things happen on the IXP4xx (added prints that illustrate the problem before the crash):
cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x00000100 ixp4xx_copy_from copy from 0x00000100 to 0xc880dd78 cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x12000000 ixp4xx_copy_from copy from 0x12000000 to 0xc880dd78
8<--- cut here ---
Unable to handle kernel paging request at virtual address db000000
[db000000] *pgd=00000000
(...)
This happens in this case because the IXP4xx is big endian and the 32- and 16-bit fields in the struct cfi_intelext_otpinfo are not properly byteswapped. Compare to how the code in read_pri_intelext() byteswaps the fields in struct cfi_pri_intelext.
Adding a small byte swapping loop for the OTP in read_pri_intelext() and the crash goes away.
The problem went unnoticed for many years until I enabled CONFIG_MTD_OTP on the IXP4xx as well, triggering the bug.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +18 -2
@@ -420,9 +420,25 @@ read_pri_intelext(struct map_info *map, __u16 adr) extra_size =0 ;/* Protection Register info */ -if (extp->NumProtectionFields) +if (extp->NumProtectionFields) { +struct cfi_intelext_otpinfo *otp = + (struct cfi_intelext_otpinfo *)&extp->extra[0 ]; + extra_size += (extp->NumProtectionFields -1 ) * -sizeof (struct cfi_intelext_otpinfo ); +sizeof (struct cfi_intelext_otpinfo ); + +if (extp_size >=sizeof (*extp) + extra_size) { +int i; + +/* Do some byteswapping if necessary */ +for (i =0 ; i < extp->NumProtectionFields -1 ; i++) { + otp->ProtRegAddr =le32_to_cpu (otp->ProtRegAddr); + otp->FactGroups =le16_to_cpu (otp->FactGroups); + otp->UserGroups =le16_to_cpu (otp->UserGroups); + otp++; + } + } + } }if (extp->MinorVersion >='1' ) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 80/94 fbdev: stifb: Make the STI next font pointer a 32-bit signed offset
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit 8a32aa17c1cd48df1ddaa78e45abcb8c7a2220d6 ]
The pointer to the next STI font is actually a signed 32-bit offset. With this change the 64-bit kernel will correctly subract the (signed 32-bit) offset instead of adding a (unsigned 32-bit) offset. It has no effect on 32-bit kernels.
This fixes the stifb driver with a 64-bit kernel on qemu.
--- drivers/video/fbdev/sticore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/sticore.h +1 -1
@@ -237,7 +237,7 @@ struct sti_rom_font {u8 height;u8 font_type;/* language type */ u8 bytes_per_char; -u32 next_font; +s32 next_font;/* note: signed int */ u8 underline_height;u8 underline_pos;u8 res008[2 ];
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 81/94 ima: annotate iint mutex to avoid lockdep false positive warnings
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
[ Upstream commit e044374a8a0a99e46f4e6d6751d3042b6d9cc12e ]
It is not clear that IMA should be nested at all, but as long is it measures files both on overlayfs and on underlying fs, we need to annotate the iint mutex to avoid lockdep false positives related to IMA + overlayfs, same as overlayfs annotates the inode mutex.
--- security/integrity/iint.c | 48 ++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-)
security/integrity/iint.c +37 -11
@@ -66,9 +66,32 @@ struct integrity_iint_cache *integrity_iint_find(struct inode *inode)return iint; } -static void iint_free (struct integrity_iint_cache *iint) +#define IMA_MAX_NESTING (FILESYSTEM_MAX_STACK_DEPTH+1) + +/* +* It is not clear that IMA should be nested at all, but as long is it measures +* files both on overlayfs and on underlying fs, we need to annotate the iint +* mutex to avoid lockdep false positives related to IMA + overlayfs. +* See ovl_lockdep_annotate_inode_mutex_key() for more details. +*/ +static inline void iint_lockdep_annotate (struct integrity_iint_cache *iint, +struct inode *inode) +{ +#ifdef CONFIG_LOCKDEP +static struct lock_class_key iint_mutex_key[IMA_MAX_NESTING ]; + +int depth = inode->i_sb->s_stack_depth; + +if (WARN_ON_ONCE (depth <0 || depth >=IMA_MAX_NESTING )) + depth =0 ; + +lockdep_set_class (&iint->mutex, &iint_mutex_key[depth]); +#endif +} + +static void iint_init_always (struct integrity_iint_cache *iint, +struct inode *inode) { -kfree (iint->ima_hash); iint->ima_hash =NULL ; iint->version =0 ; iint->flags =0UL ;
@@ -80,6 +103,14 @@ static void iint_free(struct integrity_iint_cache *iint) iint->ima_creds_status =INTEGRITY_UNKNOWN ; iint->evm_status =INTEGRITY_UNKNOWN ; iint->measured_pcrs =0 ; +mutex_init (&iint->mutex); +iint_lockdep_annotate (iint, inode); +} + +static void iint_free (struct integrity_iint_cache *iint) +{ +kfree (iint->ima_hash); +mutex_destroy (&iint->mutex);kmem_cache_free (iint_cache, iint); }
@@ -112,6 +143,8 @@ struct integrity_iint_cache *integrity_inode_get(struct inode *inode)if (!iint)return NULL ; +iint_init_always (iint, inode); +write_lock (&integrity_iint_lock); p = &integrity_iint_tree.rb_node;
@@ -161,25 +194,18 @@ void integrity_inode_free(struct inode *inode)iint_free (iint); } -static void init_once (void *foo) +static void iint_init_once (void *foo) {struct integrity_iint_cache *iint = foo;memset (iint,0 ,sizeof (*iint)); - iint->ima_file_status =INTEGRITY_UNKNOWN ; - iint->ima_mmap_status =INTEGRITY_UNKNOWN ; - iint->ima_bprm_status =INTEGRITY_UNKNOWN ; - iint->ima_read_status =INTEGRITY_UNKNOWN ; - iint->ima_creds_status =INTEGRITY_UNKNOWN ; - iint->evm_status =INTEGRITY_UNKNOWN ; -mutex_init (&iint->mutex); }static int __init integrity_iintcache_init (void ) { iint_cache =kmem_cache_create ("iint_cache" ,sizeof (struct integrity_iint_cache ), -0 ,SLAB_PANIC , init_once); +0 ,SLAB_PANIC , iint_init_once);return 0 ; }DEFINE_LSM (integrity) = {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 82/94 ovl: skip overlayfs superblocks at global sync
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khlebnikov <[email protected]>
[ Upstream commit 32b1924b210a70dcacdf65abd687c5ef86a67541 ]
Stacked filesystems like overlayfs has no own writeback, but they have to forward syncfs() requests to backend for keeping data integrity.
During global sync() each overlayfs instance calls method ->sync_fs() for backend although it itself is in global list of superblocks too. As a result one syscall sync() could write one superblock several times and send multiple disk barriers.
This patch adds flag SB_I_SKIP_SYNC into sb->sb_iflags to avoid that.
Stable-dep-of: b836c4d29f27 ("ima: detect changes to the backing overlay file")
--- fs/overlayfs/super.c | 5 +++-- fs/sync.c | 3 ++- include/linux/fs.h | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-)
fs/overlayfs/super.c +3 -2
@@ -263,8 +263,8 @@ static int ovl_sync_fs(struct super_block *sb, int wait)return 0 ;/* -* If this is a sync(2) call or an emergency sync, all the super blocks -* will be iterated, including upper_sb, so no need to do anything. +* Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC). +* All the super blocks will be iterated, including upper_sb. * * If this is a syncfs(2) call, then we do need to call * sync_filesystem() on upper_sb, but enough if we do it when being
@@ -1710,6 +1710,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) sb->s_xattr = ovl_xattr_handlers; sb->s_fs_info = ofs; sb->s_flags |=SB_POSIXACL ; + sb->s_iflags |=SB_I_SKIP_SYNC ; err = -ENOMEM ; root_dentry =d_make_root (ovl_new_inode (sb,S_IFDIR ,0 ));
fs/sync.c +2 -1
@@ -76,7 +76,8 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)static void sync_fs_one_sb (struct super_block *sb,void *arg) { -if (!sb_rdonly (sb) && sb->s_op->sync_fs) +if (!sb_rdonly (sb) && !(sb->s_iflags &SB_I_SKIP_SYNC ) && + sb->s_op->sync_fs) sb->s_op->sync_fs (sb, *(int *)arg); }
include/linux/fs.h +2 -0
@@ -1404,6 +1404,8 @@ extern int send_sigurg(struct fown_struct *fown);#define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020#define SB_I_UNTRUSTED_MOUNTER 0x00000040 +#define SB_I_SKIP_SYNC 0x00000100/* Skip superblock at global sync */ +/* Possible states of 'frozen' field */ enum {SB_UNFROZEN =0 ,/* FS is unfrozen */
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 83/94 ima: detect changes to the backing overlay file
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
[ Upstream commit b836c4d29f2744200b2af41e14bf50758dddc818 ]
Commit 18b44bc5a672 ("ovl: Always reevaluate the file signature for IMA") forced signature re-evaulation on every file access.
Instead of always re-evaluating the file's integrity, detect a change to the backing file, by comparing the cached file metadata with the backing file's metadata. Verifying just the i_version has not changed is insufficient. In addition save and compare the i_ino and s_dev as well.
--- security/integrity/ima/ima_api.c | 5 +++++ security/integrity/ima/ima_main.c | 16 +++++++++++++++- security/integrity/integrity.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)
security/integrity/ima/ima_api.c +5 -0
@@ -209,6 +209,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, {const char *audit_cause ="failed" ;struct inode *inode =file_inode (file); +struct inode *real_inode =d_real_inode (file_dentry (file));const char *filename = file->f_path.dentry->d_name.name;int result =0 ;int length;
@@ -259,6 +260,10 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, iint->ima_hash = tmpbuf;memcpy (iint->ima_hash, &hash, length); iint->version = i_version; +if (real_inode != inode) { + iint->real_ino = real_inode->i_ino; + iint->real_dev = real_inode->i_sb->s_dev; + }/* Possibly temporary failure due to type of read (eg. O_DIRECT) */ if (!result)
security/integrity/ima/ima_main.c +15 -1
@@ -27,6 +27,7 @@#include <linux/ima.h> #include <linux/iversion.h> #include <linux/fs.h> +#include <linux/iversion.h> #include "ima.h"
@@ -193,7 +194,7 @@ static int process_measurement(struct file *file, const struct cred *cred, u32 secid, char *buf, loff_t size, int mask, enum ima_hooks func) { - struct inode *inode = file_inode(file); + struct inode *backing_inode, *inode = file_inode(file);struct integrity_iint_cache *iint =NULL ;struct ima_template_desc *template_desc =NULL ;char *pathbuf =NULL ;
@@ -267,6 +268,19 @@ static int process_measurement(struct file *file, const struct cred *cred, iint->measured_pcrs =0 ; } +/* Detect and re-evaluate changes made to the backing file. */ + backing_inode =d_real_inode (file_dentry (file)); +if (backing_inode != inode && + (action &IMA_DO_MASK ) && (iint->flags &IMA_DONE_MASK )) { +if (!IS_I_VERSION (backing_inode) || + backing_inode->i_sb->s_dev != iint->real_dev || + backing_inode->i_ino != iint->real_ino || + !inode_eq_iversion (backing_inode, iint->version)) { + iint->flags &= ~IMA_DONE_MASK ; + iint->measured_pcrs =0 ; + } + } +/* Determine if already appraised/measured based on bitmask * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED, * IMA_AUDIT, IMA_AUDITED)
security/integrity/integrity.h +2 -0
@@ -124,6 +124,8 @@ struct integrity_iint_cache {unsigned long flags;unsigned long measured_pcrs;unsigned long atomic_flags; +unsigned long real_ino; +dev_t real_dev; enum integrity_status ima_file_status:4; enum integrity_status ima_mmap_status:4; enum integrity_status ima_bprm_status:4;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 84/94 scsi: qla2xxx: Simplify the code for aborting SCSI commands
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit c81ef0ed4477c637d1f1dd96ecd8e8fbe18b7283 ]
Since the SCSI core does not reuse the tag of the SCSI command that is being aborted by .eh_abort() before .eh_abort() has finished it is not necessary to check from inside that callback whether or not the SCSI command has already completed. Instead, rely on the firmware to return an error code when attempting to abort a command that has already completed. Additionally, rely on the firmware to return an error code when attempting to abort an already aborted command.
In qla2x00_abort_srb(), use blk_mq_request_started() instead of sp->completed and sp->aborted.
Stable-dep-of: 19597cad64d6 ("scsi: qla2xxx: Fix system crash due to bad pointer access")
--- drivers/scsi/qla2xxx/qla_def.h | 3 --- drivers/scsi/qla2xxx/qla_isr.c | 5 ----- drivers/scsi/qla2xxx/qla_os.c | 27 ++++++++++++++------------- 3 files changed, 14 insertions(+), 21 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -3
@@ -596,9 +596,6 @@ typedef struct srb {struct fc_port *fcport;struct scsi_qla_host *vha; unsigned int start_timer:1; - unsigned int abort:1; - unsigned int aborted:1; - unsigned int completed:1;uint32_t handle;uint16_t flags;
drivers/scsi/qla2xxx/qla_isr.c +0 -5
@@ -2479,11 +2479,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)return ; } -if (sp->abort) - sp->aborted =1 ; -else - sp->completed =1 ; -if (sp->cmd_type !=TYPE_SRB ) { req->outstanding_cmds[handle] =NULL ; ql_dbg(ql_dbg_io, vha, 0x3015,
drivers/scsi/qla2xxx/qla_os.c +14 -13
@@ -1243,17 +1243,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)return fast_fail_status !=SUCCESS ? fast_fail_status :FAILED ;spin_lock_irqsave (qpair->qp_lock_ptr, flags); -if (sp->completed) { -spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); -return SUCCESS ; - } - -if (sp->abort || sp->aborted) { -spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); -return FAILED ; - } - - sp->abort =1 ; sp->comp = ∁spin_unlock_irqrestore (qpair->qp_lock_ptr, flags);
@@ -1661,6 +1650,10 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)return QLA_SUCCESS ; } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, unsigned long *flags) __releases(qp->qp_lock_ptr)
@@ -1669,6 +1662,7 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,DECLARE_COMPLETION_ONSTACK (comp);scsi_qla_host_t *vha = qp->vha;struct qla_hw_data *ha = vha->hw; +struct scsi_cmnd *cmd =GET_CMD_SP (sp);int rval;bool ret_cmd;uint32_t ratov_j;
@@ -1688,7 +1682,6 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, } sp->comp = ∁ - sp->abort =1 ;spin_unlock_irqrestore (qp->qp_lock_ptr, *flags); rval = ha->isp_ops->abort_command (sp);
@@ -1712,13 +1705,17 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd && (!sp->completed || !sp->aborted)) +if (ret_cmd &&blk_mq_request_started (cmd->request)) sp->done (sp, res); }else { sp->done (sp, res); } } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ static void __qla2x00_abort_all_cmds (struct qla_qpair *qp,int res) {
@@ -1776,6 +1773,10 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)spin_unlock_irqrestore (qp->qp_lock_ptr, flags); } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ void qla2x00_abort_all_cmds (scsi_qla_host_t *vha,int res) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 85/94 scsi: core: Introduce the scsi_cmd_to_rq() function
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 51f3a478892873337c54068d1185bcd797000a52 ]
The 'request' member of struct scsi_cmnd is superfluous. The struct request and struct scsi_cmnd data structures are adjacent and hence the request pointer can be derived easily from a scsi_cmnd pointer. Introduce a helper function that performs that conversion in a type-safe way. This patch is the first step towards removing the request member from struct scsi_cmnd. Making that change has the following advantages:
- This is a performance optimization since adding an offset to a pointer takes less time than dereferencing a pointer.
- struct scsi_cmnd becomes smaller.
Stable-dep-of: 19597cad64d6 ("scsi: qla2xxx: Fix system crash due to bad pointer access")
--- include/scsi/scsi_cmnd.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/scsi/scsi_cmnd.h +6 -0
@@ -143,6 +143,12 @@ struct scsi_cmnd {unsigned char tag;/* SCSI-II queued command tag */ }; +/* Variant of blk_mq_rq_from_pdu() that verifies the type of its argument. */ +static inline struct request *scsi_cmd_to_rq (struct scsi_cmnd *scmd) +{ +return blk_mq_rq_from_pdu (scmd); +} +/* * Return the driver private allocation behind the command. * Only works if cmd_size is set in the host template.
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 86/94 scsi: qla2xxx: Use scsi_cmd_to_rq() instead of scsi_cmnd.request
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit c7d6b2c2cd5656b05849afb0de3f422da1742d0f ]
Prepare for removal of the request pointer by using scsi_cmd_to_rq() instead. This patch does not change any functionality.
Stable-dep-of: 19597cad64d6 ("scsi: qla2xxx: Fix system crash due to bad pointer access")
--- drivers/scsi/qla2xxx/qla_os.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +2 -2
@@ -814,7 +814,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)uint16_t hwq;struct qla_qpair *qpair =NULL ; - tag =blk_mq_unique_tag (cmd->request); + tag =blk_mq_unique_tag (scsi_cmd_to_rq (cmd)); hwq =blk_mq_unique_tag_to_hwq (tag); qpair = ha->queue_pair_map[hwq];
@@ -1705,7 +1705,7 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd &&blk_mq_request_started (cmd->request)) +if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) sp->done (sp, res); }else { sp->done (sp, res);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 87/94 scsi: qla2xxx: Fix system crash due to bad pointer access
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
[ Upstream commit 19597cad64d608aa8ac2f8aef50a50187a565223 ]
User experiences system crash when running AER error injection. The perturbation causes the abort-all-I/O path to trigger. The driver assumes all I/O on this path is FCP only. If there is both NVMe & FCP traffic, a system crash happens. Add additional check to see if I/O is FCP or not before access.
PID: 999019 TASK: ff35d769f24722c0 CPU: 53 COMMAND: "kworker/53:1"
0 [ff3f78b964847b58] machine_kexec at ffffffffae86973d
1 [ff3f78b964847ba8] __crash_kexec at ffffffffae9be29d
2 [ff3f78b964847c70] crash_kexec at ffffffffae9bf528
3 [ff3f78b964847c78] oops_end at ffffffffae8282ab
4 [ff3f78b964847c98] exc_page_fault at ffffffffaf2da502
5 [ff3f78b964847cc0] asm_exc_page_fault at ffffffffaf400b62
[exception RIP: qla2x00_abort_srb+444]
RIP: ffffffffc07b5f8c RSP: ff3f78b964847d78 RFLAGS: 00010046 RAX: 0000000000000282 RBX: ff35d74a0195a200 RCX: ff35d76886fd03a0 RDX: 0000000000000001 RSI: ffffffffc07c5ec8 RDI: ff35d74a0195a200 RBP: ff35d76913d22080 R8: ff35d7694d103200 R9: ff35d7694d103200 R10: 0000000100000000 R11: ffffffffb05d6630 R12: 0000000000010000 R13: ff3f78b964847df8 R14: ff35d768d8754000 R15: ff35d768877248e0 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 6 [ff3f78b964847d70] qla2x00_abort_srb at ffffffffc07b5f84 [qla2xxx] 7 [ff3f78b964847de0] __qla2x00_abort_all_cmds at ffffffffc07b6238 [qla2xxx] 8 [ff3f78b964847e38] qla2x00_abort_all_cmds at ffffffffc07ba635 [qla2xxx] 9 [ff3f78b964847e58] qla2x00_terminate_rport_io at ffffffffc08145eb [qla2xxx]
10 [ff3f78b964847e70] fc_terminate_rport_io at ffffffffc045987e [scsi_transport_fc] 11 [ff3f78b964847e88] process_one_work at ffffffffae914f15
12 [ff3f78b964847ed0] worker_thread at ffffffffae9154c0
13 [ff3f78b964847f10] kthread at ffffffffae91c456
14 [ff3f78b964847f50] ret_from_fork at ffffffffae8036ef
--- drivers/scsi/qla2xxx/qla_os.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +10 -2
@@ -1705,8 +1705,16 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) - sp->done (sp, res); +switch (sp->type) { +case SRB_SCSI_CMD : +if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) + sp->done (sp, res); +break ; +default : +if (ret_cmd) + sp->done (sp, res); +break ; + } }else { sp->done (sp, res); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 88/94 cpufreq: imx6q: dont warn for disabling a non-existing frequency
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Niedermaier <[email protected]>
[ Upstream commit 11a3b0ac33d95aa84be426e801f800997262a225 ]
It is confusing if a warning is given for disabling a non-existent frequency of the operating performance points (OPP). In this case the function dev_pm_opp_disable() returns -ENODEV. Check the return value and avoid the output of a warning in this case. Avoid code duplication by using a separate function.
Stable-dep-of: 2e4e0984c7d6 ("cpufreq: imx6q: Don't disable 792 Mhz OPP unnecessarily")
--- drivers/cpufreq/imx6q-cpufreq.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +16 -14
@@ -210,6 +210,14 @@ static struct cpufreq_driver imx6q_cpufreq_driver = { .suspend = cpufreq_generic_suspend, }; +static void imx6x_disable_freq_in_opp (struct device *dev,unsigned long freq) +{ +int ret =dev_pm_opp_disable (dev, freq); + +if (ret <0 && ret != -ENODEV ) +dev_warn (dev,"failed to disable %ldMHz OPP\n" , freq /1000000 ); +} +#define OCOTP_CFG3 0x440#define OCOTP_CFG3_SPEED_SHIFT 16#define OCOTP_CFG3_SPEED_1P2GHZ 0x3
@@ -245,17 +253,15 @@ static void imx6q_opp_check_speed_grading(struct device *dev) val &=0x3 ;if (val <OCOTP_CFG3_SPEED_996MHZ ) -if (dev_pm_opp_disable (dev,996000000 )) -dev_warn (dev,"failed to disable 996MHz OPP\n" ); +imx6x_disable_freq_in_opp (dev,996000000 );if (of_machine_is_compatible ("fsl,imx6q" ) ||of_machine_is_compatible ("fsl,imx6qp" )) {if (val !=OCOTP_CFG3_SPEED_852MHZ ) -if (dev_pm_opp_disable (dev,852000000 )) -dev_warn (dev,"failed to disable 852MHz OPP\n" ); +imx6x_disable_freq_in_opp (dev,852000000 ); +if (val !=OCOTP_CFG3_SPEED_1P2GHZ ) -if (dev_pm_opp_disable (dev,1200000000 )) -dev_warn (dev,"failed to disable 1.2GHz OPP\n" ); +imx6x_disable_freq_in_opp (dev,1200000000 ); }iounmap (base); put_node:
@@ -308,20 +314,16 @@ static int imx6ul_opp_check_speed_grading(struct device *dev) val >>=OCOTP_CFG3_SPEED_SHIFT ; val &=0x3 ; -if (of_machine_is_compatible ("fsl,imx6ul" )) { +if (of_machine_is_compatible ("fsl,imx6ul" ))if (val !=OCOTP_CFG3_6UL_SPEED_696MHZ ) -if (dev_pm_opp_disable (dev,696000000 )) -dev_warn (dev,"failed to disable 696MHz OPP\n" ); - } +imx6x_disable_freq_in_opp (dev,696000000 );if (of_machine_is_compatible ("fsl,imx6ull" )) {if (val !=OCOTP_CFG3_6ULL_SPEED_792MHZ ) -if (dev_pm_opp_disable (dev,792000000 )) -dev_warn (dev,"failed to disable 792MHz OPP\n" ); +imx6x_disable_freq_in_opp (dev,792000000 );if (val !=OCOTP_CFG3_6ULL_SPEED_900MHZ ) -if (dev_pm_opp_disable (dev,900000000 )) -dev_warn (dev,"failed to disable 900MHz OPP\n" ); +imx6x_disable_freq_in_opp (dev,900000000 ); }return ret;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 89/94 cpufreq: imx6q: Dont disable 792 Mhz OPP unnecessarily
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Niedermaier <[email protected]>
[ Upstream commit 2e4e0984c7d696cc74cf2fd7e7f62997f0e9ebe6 ]
For a 900MHz i.MX6ULL CPU the 792MHz OPP is disabled. There is no convincing reason to disable this OPP. If a CPU can run at 900MHz, it should also be able to cope with 792MHz. Looking at the voltage level of 792MHz in [1] (page 24, table 10. "Operating Ranges") the current defined OPP is above the minimum. So the voltage level shouldn't be a problem. However in [2] (page 24, table 10. "Operating Ranges"), it is not mentioned that 792MHz OPP isn't allowed. Change it to only disable 792MHz OPP for i.MX6ULL types below 792 MHz.
[1] https://www.nxp.com/docs/en/data-sheet/IMX6ULLIEC.pdf
[2] https://www.nxp.com/docs/en/data-sheet/IMX6ULLCEC.pdf
--- drivers/cpufreq/imx6q-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/imx6q-cpufreq.c +1 -1
@@ -319,7 +319,7 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)imx6x_disable_freq_in_opp (dev,696000000 );if (of_machine_is_compatible ("fsl,imx6ull" )) { -if (val !=OCOTP_CFG3_6ULL_SPEED_792MHZ ) +if (val <OCOTP_CFG3_6ULL_SPEED_792MHZ )imx6x_disable_freq_in_opp (dev,792000000 );if (val !=OCOTP_CFG3_6ULL_SPEED_900MHZ )
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 90/94 mmc: cqhci: Increase recovery halt timeout
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit b578d5d18e929aa7c007a98cce32657145dde219 ]
Failing to halt complicates the recovery. Additionally, unless the card or controller are stuck, which is expected to be very rare, then the halt should succeed, so it is better to wait. Set a large timeout.
--- drivers/mmc/host/cqhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/cqhci.c +3 -3
@@ -920,10 +920,10 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)/* * After halting we expect to be able to use the command line. We interpret the * failure to halt to mean the data lines might still be in use (and the upper -* layers will need to send a STOP command), so we set the timeout based on a -* generous command timeout. +* layers will need to send a STOP command), however failing to halt complicates +* the recovery, so set a timeout that would reasonably allow I/O to complete. */ -#define CQHCI_START_HALT_TIMEOUT 5 +#define CQHCI_START_HALT_TIMEOUT 500static void cqhci_recovery_start (struct mmc_host *mmc) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 91/94 mmc: cqhci: Warn of halt or task clear failure
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 35597bdb04ec27ef3b1cea007dc69f8ff5df75a5 ]
A correctly operating controller should successfully halt and clear tasks. Failure may result in errors elsewhere, so promote messages from debug to warnings.
--- drivers/mmc/host/cqhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/cqhci.c +3 -3
@@ -878,8 +878,8 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout) ret =cqhci_tasks_cleared (cq_host);if (!ret) -pr_debug ("%s: cqhci: Failed to clear tasks\n" , -mmc_hostname (mmc)); +pr_warn ("%s: cqhci: Failed to clear tasks\n" , +mmc_hostname (mmc));return ret; }
@@ -912,7 +912,7 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) ret =cqhci_halted (cq_host);if (!ret) -pr_debug ("%s: cqhci: Failed to halt\n" ,mmc_hostname (mmc)); +pr_warn ("%s: cqhci: Failed to halt\n" ,mmc_hostname (mmc));return ret; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 92/94 mmc: cqhci: Fix task clearing in CQE error recovery
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 1de1b77982e1a1df9707cb11f9b1789e6b8919d4 ]
If a task completion notification (TCN) is received when there is no outstanding task, the cqhci driver issues a "spurious TCN" warning. This was observed to happen right after CQE error recovery.
When an error interrupt is received the driver runs recovery logic. It halts the controller, clears all pending tasks, and then re-enables it. On some platforms, like Intel Jasper Lake, a stale task completion event was observed, regardless of the CQHCI_CLEAR_ALL_TASKS bit being set.
This results in either:
a) Spurious TC completion event for an empty slot.
b) Corrupted data being passed up the stack, as a result of premature completion for a newly added task.
Rather than add a quirk for affected controllers, ensure tasks are cleared by toggling CQHCI_ENABLE, which would happen anyway if cqhci_clear_all_tasks() timed out. This is simpler and should be safe and effective for all controllers.
--- drivers/mmc/host/cqhci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/mmc/host/cqhci.c +16 -16
@@ -1011,28 +1011,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc) ok =cqhci_halt (mmc,CQHCI_FINISH_HALT_TIMEOUT ); -if (!cqhci_clear_all_tasks (mmc,CQHCI_CLEAR_TIMEOUT )) - ok = false; -/* * The specification contradicts itself, by saying that tasks cannot be * cleared if CQHCI does not halt, but if CQHCI does not halt, it should * be disabled/re-enabled, but not to disable before clearing tasks. * Have a go anyway. */ -if (!ok) { -pr_debug ("%s: cqhci: disable / re-enable\n" ,mmc_hostname (mmc)); - cqcfg =cqhci_readl (cq_host,CQHCI_CFG ); - cqcfg &= ~CQHCI_ENABLE ; -cqhci_writel (cq_host, cqcfg,CQHCI_CFG ); - cqcfg |=CQHCI_ENABLE ; -cqhci_writel (cq_host, cqcfg,CQHCI_CFG ); -/* Be sure that there are no tasks */ - ok =cqhci_halt (mmc,CQHCI_FINISH_HALT_TIMEOUT ); -if (!cqhci_clear_all_tasks (mmc,CQHCI_CLEAR_TIMEOUT )) - ok = false; -WARN_ON (!ok); - } +if (!cqhci_clear_all_tasks (mmc,CQHCI_CLEAR_TIMEOUT )) + ok = false; + +/* Disable to make sure tasks really are cleared */ + cqcfg =cqhci_readl (cq_host,CQHCI_CFG ); + cqcfg &= ~CQHCI_ENABLE ; +cqhci_writel (cq_host, cqcfg,CQHCI_CFG ); + + cqcfg =cqhci_readl (cq_host,CQHCI_CFG ); + cqcfg |=CQHCI_ENABLE ; +cqhci_writel (cq_host, cqcfg,CQHCI_CFG ); + +cqhci_halt (mmc,CQHCI_FINISH_HALT_TIMEOUT ); + +if (!ok) +cqhci_clear_all_tasks (mmc,CQHCI_CLEAR_TIMEOUT );cqhci_recover_mrqs (cq_host);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 93/94 mmc: core: convert comma to semicolon
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yongjun <[email protected]>
[ Upstream commit 6b1dc6229aecbcb45e8901576684a8c09e25ad7b ]
Replace a comma between expression statements by a semicolon.
Stable-dep-of: 8155d1fa3a74 ("mmc: block: Retry commands in CQE error recovery")
--- drivers/mmc/core/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/core.c +4 -4
@@ -564,10 +564,10 @@ int mmc_cqe_recovery(struct mmc_host *host) host->cqe_ops->cqe_recovery_start (host);memset (&cmd,0 ,sizeof (cmd)); - cmd.opcode =MMC_STOP_TRANSMISSION , - cmd.flags =MMC_RSP_R1B |MMC_CMD_AC , + cmd.opcode =MMC_STOP_TRANSMISSION ; + cmd.flags =MMC_RSP_R1B |MMC_CMD_AC ; cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ - cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT , + cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT ;mmc_wait_for_cmd (host, &cmd,0 );memset (&cmd,0 ,sizeof (cmd));
@@ -575,7 +575,7 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.arg =1 ;/* Discard entire queue */ cmd.flags =MMC_RSP_R1B |MMC_CMD_AC ; cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ - cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT , + cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT ; err =mmc_wait_for_cmd (host, &cmd,0 ); host->cqe_ops->cqe_recovery_finish (host);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 94/94 mmc: block: Retry commands in CQE error recovery
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 8155d1fa3a747baad5caff5f8303321d68ddd48c ]
It is important that MMC_CMDQ_TASK_MGMT command to discard the queue is successful because otherwise a subsequent reset might fail to flush the cache first. Retry it and the previous STOP command.
--- drivers/mmc/core/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/core/core.c +5 -2
@@ -568,7 +568,7 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.flags =MMC_RSP_R1B |MMC_CMD_AC ; cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT ; -mmc_wait_for_cmd (host, &cmd,0 ); +mmc_wait_for_cmd (host, &cmd,MMC_CMD_RETRIES );memset (&cmd,0 ,sizeof (cmd)); cmd.opcode =MMC_CMDQ_TASK_MGMT ;
@@ -576,10 +576,13 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.flags =MMC_RSP_R1B |MMC_CMD_AC ; cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT ; - err =mmc_wait_for_cmd (host, &cmd,0 ); + err =mmc_wait_for_cmd (host, &cmd,MMC_CMD_RETRIES ); host->cqe_ops->cqe_recovery_finish (host); +if (err) + err =mmc_wait_for_cmd (host, &cmd,MMC_CMD_RETRIES ); +mmc_retune_release (host);return err;
Signature · 1 line
2.42.0
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.263 release. There are 94 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 07 Dec 2023 03:14:57 +0000. Anything received after that time might be too late.
Building arm64:allmodconfig ... failed
--------------
Error log:drivers/mmc/host/sdhci-sprd.c: In function 'sdhci_sprd_set_power':drivers/mmc/host/sdhci-sprd.c:393:17: error: implicit declaration of function 'mmc_regulator_disable_vqmmc'; did you mean 'mmc_regulator_set_vqmmc'? [-Werror=implicit-function-declaration]
393 | mmc_regulator_disable_vqmmc(mmc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| mmc_regulator_set_vqmmc
drivers/mmc/host/sdhci-sprd.c:396:17: error: implicit declaration of function 'mmc_regulator_enable_vqmmc'; did you mean 'mmc_regulator_set_vqmmc'? [-Werror=implicit-function-declaration]
396 | mmc_regulator_enable_vqmmc(mmc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| mmc_regulator_set_vqmmcCommit 2b11e5bd4ac0 ("mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled") calls those functions without introducing them.
Guenter
Greg Kroah-Hartman
maintainerQuoted 23 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.263 release. There are 94 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 07 Dec 2023 03:14:57 +0000. Anything received after that time might be too late.
Building arm64:allmodconfig ... failed
--------------
Error log:drivers/mmc/host/sdhci-sprd.c: In function 'sdhci_sprd_set_power':drivers/mmc/host/sdhci-sprd.c:393:17: error: implicit declaration of function 'mmc_regulator_disable_vqmmc'; did you mean 'mmc_regulator_set_vqmmc'? [-Werror=implicit-function-declaration]393 | mmc_regulator_disable_vqmmc(mmc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | mmc_regulator_set_vqmmc drivers/mmc/host/sdhci-sprd.c:396:17: error: implicit declaration of function 'mmc_regulator_enable_vqmmc'; did you mean 'mmc_regulator_set_vqmmc'? [-Werror=implicit-function-declaration] 396 | mmc_regulator_enable_vqmmc(mmc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | mmc_regulator_set_vqmmc
Quoted 2 lines
Commit
2b11e5bd4ac0("mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled") calls those functions without introducing them.
Ick, missed that somehow, I thought I had caught it already. I'll go drop it now and push out a -rc2.
thanks,
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.263 release. There are 94 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 07 Dec 2023 03:14:57 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.263-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.4:
10 builds: 10 pass, 0 fail
24 boots: 24 pass, 0 fail
54 tests: 54 pass, 0 failLinux version: 5.4.263-rc1-g5dd6bc1bd552
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Jon