5.10.143-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainercover 5.10.143-rc1 review
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +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.10.143-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.10.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.10.143-rc1
Ionela Voinescu <[email protected]>
arm64: errata: add detection for AMEVCNTR01 incrementing incorrectly
Eliav Farber <[email protected]>
hwmon: (mr75203) enable polling for all VM channels
Eliav Farber <[email protected]>
hwmon: (mr75203) fix multi-channel voltage reading
Eliav Farber <[email protected]>
hwmon: (mr75203) fix voltage equation for negative source input
Eliav Farber <[email protected]>
hwmon: (mr75203) update pvt->v_num and vm_num to the actual number of used sensors
Eliav Farber <[email protected]>
hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined
John Sperbeck <[email protected]>
iommu/amd: use full 64-bit value in build_completion_wait()
Chao Gao <[email protected]>
swiotlb: avoid potential left shift overflow
Yang Ling <[email protected]>
MIPS: loongson32: ls1c: Fix hang during startup
Nathan Chancellor <[email protected]>
ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion
Claudiu Beznea <[email protected]>
ASoC: mchp-spdiftx: remove references to mchp_i2s_caps
Toke Høiland-Jørgensen <[email protected]>
sch_sfb: Also store skb len before calling child enqueue
Neal Cardwell <[email protected]>
tcp: fix early ETIMEDOUT after spurious non-SACK RTO
Sagi Grimberg <[email protected]>
nvme-tcp: fix regression that causes sporadic requests to time out
Sagi Grimberg <[email protected]>
nvme-tcp: fix UAF when detecting digest errors
Chris Mi <[email protected]>
RDMA/mlx5: Set local port to one when accessing counters
Yishai Hadas <[email protected]>
IB/core: Fix a nested dead lock as part of ODP flow
David Lebrun <[email protected]>
ipv6: sr: fix out-of-bounds read when setting HMAC data.
Linus Walleij <[email protected]>
RDMA/siw: Pass a pointer to virt_to_page()
Paul Durrant <[email protected]>
xen-netback: only remove 'hotplug-status' when the vif is actually destroyed
Csókás Bence <[email protected]>
net: fec: Use a spinlock to guard `fep->ptp_clk_on`
Ivan Vecera <[email protected]>
i40e: Fix kernel crash during module removal
Michal Swiatkowski <[email protected]>
ice: use bitmap_free instead of devm_kfree
Dan Carpenter <[email protected]>
tipc: fix shift wrapping bug in map_get()
Toke Høiland-Jørgensen <[email protected]>
sch_sfb: Don't assume the skb is still around after enqueueing to child
David Howells <[email protected]>
afs: Use the operation issue time instead of the reply time for callbacks
David Howells <[email protected]>
rxrpc: Fix an insufficiently large sglist in rxkad_verify_packet_2()
Takashi Iwai <[email protected]>
ALSA: usb-audio: Register card again for iface over delayed_register option
Takashi Iwai <[email protected]>
ALSA: usb-audio: Inform the delayed registration more properly
David Leadbeater <[email protected]>
netfilter: nf_conntrack_irc: Fix forged IP logic
Pablo Neira Ayuso <[email protected]>
netfilter: nf_tables: clean up hook list when offload flags check fails
Harsh Modi <[email protected]>
netfilter: br_netfilter: Drop dst references before setting.
Claudiu Beznea <[email protected]>
ARM: dts: at91: sama5d2_icp: don't keep vdd_other enabled all the time
Claudiu Beznea <[email protected]>
ARM: dts: at91: sama5d27_wlsom1: don't keep ldo2 enabled all the time
Claudiu Beznea <[email protected]>
ARM: dts: at91: sama5d2_icp: specify proper regulator output ranges
Claudiu Beznea <[email protected]>
ARM: dts: at91: sama5d27_wlsom1: specify proper regulator output ranges
Wenpeng Liang <[email protected]>
RDMA/hns: Fix wrong fixed value of qp->rq.wqe_shift
Chengchang Tang <[email protected]>
RDMA/hns: Fix supported page size
Liang He <[email protected]>
soc: brcmstb: pm-arm: Fix refcount leak and __iomem leak bugs
Michael Guralnik <[email protected]>
RDMA/cma: Fix arguments order in net device validation
Jens Wiklander <[email protected]>
tee: fix compiler warning in tee_shm_register()
Andrew Halaney <[email protected]>
regulator: core: Clean up on enable failure
Marco Felsch <[email protected]>
ARM: dts: imx6qdl-kontron-samx6i: remove duplicated node
David Howells <[email protected]>
smb3: missing inode locks in punch hole
Enzo Matsumiya <[email protected]>
cifs: remove useless parameter 'is_fsctl' from SMB2_ioctl()
Tejun Heo <[email protected]>
cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
Tejun Heo <[email protected]>
cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree
Yang Yingliang <[email protected]>
scsi: lpfc: Add missing destroy_workqueue() in error path
Sreekanth Reddy <[email protected]>
scsi: mpt3sas: Fix use-after-free warning
Ville Syrjälä <[email protected]>
drm/i915: Implement WaEdpLinkRateDataReload
Bart Van Assche <[email protected]>
nvmet: fix a use-after-free
Greg Kroah-Hartman <[email protected]>
debugfs: add debugfs_lookup_and_remove()
Christian A. Ehrhardt <[email protected]>
kprobes: Prohibit probes in gate area
Dongxiang Ke <[email protected]>
ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
Pattara Teerapong <[email protected]>
ALSA: aloop: Fix random zeros in capture data when using jiffies timer
Tasos Sahanidis <[email protected]>
ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc()
Qu Huang <[email protected]>
drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly
Yang Yingliang <[email protected]>
fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init()
lily <[email protected]>
net/core/skbuff: Check the return value of skb_copy_bits()
Mark Brown <[email protected]>
arm64/signal: Raise limit on stack frames
Sudeep Holla <[email protected]>
arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level
Helge Deller <[email protected]>
parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines
Li Qiong <[email protected]>
parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources()
Zhenneng Li <[email protected]>
drm/radeon: add a force flush to delay work when radeon
Candice Li <[email protected]>
drm/amdgpu: Check num_gfx_rings for gfx v9_0 rb setup.
YiPeng Chai <[email protected]>
drm/amdgpu: Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to psp_hw_fini
Jeffy Chen <[email protected]>
drm/gem: Fix GEM handle release errors
Guixin Liu <[email protected]>
scsi: megaraid_sas: Fix double kfree()
Tony Battersby <[email protected]>
scsi: qla2xxx: Disable ATIO interrupt coalesce for quad port ISP27XX
Yee Lee <[email protected]>
Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()"
Linus Torvalds <[email protected]>
fs: only do a memory barrier for the first set_buffer_uptodate()
Greg Kroah-Hartman <[email protected]>
net: mvpp2: debugfs: fix memory leak when using debugfs_lookup()
Stanislaw Gruszka <[email protected]>
wifi: iwlegacy: 4965: corrected fix for potential off-by-one overflow in il4965_rs_fill_link_cmd()
Hyunwoo Kim <[email protected]>
efi: capsule-loader: Fix use-after-free in efi_capsule_write
Ard Biesheuvel <[email protected]>
efi: libstub: Disable struct randomization
Fedor Pchelkin <[email protected]>
tty: n_gsm: avoid call of sleeping functions from atomic context
Tetsuo Handa <[email protected]>
tty: n_gsm: initialize more members at gsm_alloc_mux()
SeongJae Park <[email protected]>
xen-blkfront: Cache feature_persistent value before advertisement
Chuck Lever <[email protected]>
NFSD: Fix verifier returned in stable WRITEs
-------------
Diffstat:
Documentation/arm64/silicon-errata.rst | 2 + Makefile | 4 +- arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi | 21 +++--- arch/arm/boot/dts/at91-sama5d2_icp.dts | 21 +++--- arch/arm/boot/dts/imx6qdl-kontron-samx6i.dtsi | 10 --- arch/arm64/Kconfig | 18 +++++ arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/kernel/cacheinfo.c | 6 +- arch/arm64/kernel/cpu_errata.c | 9 +++ arch/arm64/kernel/cpufeature.c | 5 +- arch/arm64/kernel/signal.c | 2 +- arch/mips/loongson32/ls1c/board.c | 1 - arch/parisc/kernel/head.S | 43 ++++++++++- drivers/block/xen-blkfront.c | 14 ++-- drivers/firmware/efi/capsule-loader.c | 31 ++------ drivers/firmware/efi/libstub/Makefile | 7 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 1 + drivers/gpu/drm/drm_gem.c | 17 +---- drivers/gpu/drm/drm_internal.h | 4 +- drivers/gpu/drm/drm_prime.c | 20 +++-- .../gpu/drm/i915/display/intel_dp_link_training.c | 22 ++++++ drivers/gpu/drm/radeon/radeon_device.c | 3 + drivers/hwmon/mr75203.c | 72 ++++++++++++------ drivers/infiniband/core/cma.c | 4 +- drivers/infiniband/core/umem_odp.c | 2 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 7 +- drivers/infiniband/hw/mlx5/mad.c | 6 ++ drivers/infiniband/sw/siw/siw_qp_tx.c | 18 ++++- drivers/iommu/amd/iommu.c | 3 +- drivers/net/ethernet/freescale/fec.h | 1 - drivers/net/ethernet/freescale/fec_main.c | 17 +++-- drivers/net/ethernet/freescale/fec_ptp.c | 28 +++---- drivers/net/ethernet/intel/i40e/i40e_client.c | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c | 4 +- drivers/net/wireless/intel/iwlegacy/4965-rs.c | 5 +- drivers/net/xen-netback/xenbus.c | 2 +- drivers/nvme/host/tcp.c | 7 +- drivers/nvme/target/core.c | 6 +- drivers/parisc/ccio-dma.c | 11 ++- drivers/regulator/core.c | 9 ++- drivers/scsi/lpfc/lpfc_init.c | 5 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 - drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- drivers/scsi/qla2xxx/qla_target.c | 10 +-- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 50 ++++++++++--- drivers/tee/tee_shm.c | 1 + drivers/tty/n_gsm.c | 46 ++++++------ drivers/video/fbdev/chipsfb.c | 1 + fs/afs/flock.c | 2 +- fs/afs/fsclient.c | 2 +- fs/afs/internal.h | 3 +- fs/afs/rxrpc.c | 7 +- fs/afs/yfsclient.c | 3 +- fs/cifs/smb2file.c | 1 - fs/cifs/smb2ops.c | 45 +++++------- fs/cifs/smb2pdu.c | 20 +++-- fs/cifs/smb2proto.h | 4 +- fs/debugfs/inode.c | 22 ++++++ fs/nfsd/vfs.c | 4 + include/linux/buffer_head.h | 11 +++ include/linux/debugfs.h | 6 ++ kernel/cgroup/cgroup.c | 85 ++++++++++++++++------ kernel/cgroup/cpuset.c | 3 +- kernel/dma/swiotlb.c | 5 +- kernel/fork.c | 1 + kernel/kprobes.c | 1 + mm/kmemleak.c | 8 +- net/bridge/br_netfilter_hooks.c | 2 + net/bridge/br_netfilter_ipv6.c | 1 + net/core/skbuff.c | 5 +- net/ipv4/tcp_input.c | 25 +++++-- net/ipv6/seg6.c | 5 ++ net/netfilter/nf_conntrack_irc.c | 5 +- net/netfilter/nf_tables_api.c | 4 +- net/rxrpc/rxkad.c | 2 +- net/sched/sch_sfb.c | 13 ++-- net/tipc/monitor.c | 2 +- sound/drivers/aloop.c | 7 +- sound/pci/emu10k1/emupcm.c | 2 +- sound/soc/atmel/mchp-spdiftx.c | 10 +-- sound/usb/card.c | 2 +- sound/usb/quirks.c | 2 +- sound/usb/stream.c | 9 ++- 88 files changed, 577 insertions(+), 351 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/79 NFSD: Fix verifier returned in stable WRITEs
From: Chuck Lever <[email protected]>
commit f11ad7aa653130b71e2e89bed207f387718216d5 upstream.
RFC 8881 explains the purpose of the write verifier this way:
Quoted 5 lines
The final portion of the result is the field writeverf. This field is the write verifier and is a cookie that the client can use to determine whether a server has changed instance state (e.g., server restart) between a call to WRITE and a subsequent call to either WRITE or COMMIT.
But then it says:
Quoted 6 lines
This cookie MUST be unchanged during a single instance of the NFSv4.1 server and MUST be unique between instances of the NFSv4.1 server. If the cookie changes, then the client MUST assume that any data written with an UNSTABLE4 value for committed and an old writeverf in the reply has been lost and will need to be recovered.
RFC 1813 has similar language for NFSv3. NFSv2 does not have a write verifier since it doesn't implement the COMMIT procedure.
Since commit 19e0663ff9bc ("nfsd: Ensure sampling of the write verifier is atomic with the write"), the Linux NFS server has returned a boot-time-based verifier for UNSTABLE WRITEs, but a zero verifier for FILE_SYNC and DATA_SYNC WRITEs. FILE_SYNC and DATA_SYNC WRITEs are not followed up with a COMMIT, so there's no need for clients to compare verifiers for stable writes.
However, by returning a different verifier for stable and unstable writes, the above commit puts the Linux NFS server a step farther out of compliance with the first MUST above. At least one NFS client (FreeBSD) noticed the difference, making this a potential regression.
[Removed down_write to fix the conflict in the cherry-pick. The down_write functionality was no longer needed there. Upstream commit 555dbf1a9aac6d3150c8b52fa35f768a692f4eeb titled nfsd: Replace use of rwsem with errseq_t removed those and replace it with new functionality that was more scalable. This commit is already backported onto 5.10 and so removing down_write ensures consistency with that change. Tested by compiling and booting successfully. - kochera]
--- fs/nfsd/vfs.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfsd/vfs.c +4 -0
@@ -1014,6 +1014,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, siov_iter_kvec (&iter,WRITE , vec, vlen, *cnt); since =READ_ONCE (file->f_wb_err);if (flags &RWF_SYNC ) { +if (verf) +nfsd_copy_boot_verifier (verf, +net_generic (SVC_NET (rqstp), + nfsd_net_id)); host_err =vfs_iter_write (file, &iter, &pos, flags);if (host_err <0 ) nfsd_reset_boot_verifier(net_generic(SVC_NET(rqstp),
Greg Kroah-Hartman
maintainerPATCH 2/79 xen-blkfront: Cache feature_persistent value before advertisement
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit fe8f65b018effbf473f53af3538d0c1878b8b329 upstream.
Xen blkfront advertises its support of the persistent grants feature when it first setting up and when resuming in 'talk_to_blkback()'. Then, blkback reads the advertised value when it connects with blkfront and decides if it will use the persistent grants feature or not, and advertises its decision to blkfront. Blkfront reads the blkback's decision and it also makes the decision for the use of the feature.
Commit 402c43ea6b34 ("xen-blkfront: Apply 'feature_persistent' parameter when connect"), however, made the blkfront's read of the parameter for disabling the advertisement, namely 'feature_persistent', to be done when it negotiate, not when advertise. Therefore blkfront advertises without reading the parameter. As the field for caching the parameter value is zero-initialized, it always advertises as the feature is disabled, so that the persistent grants feature becomes always disabled.
This commit fixes the issue by making the blkfront does parmeter caching just before the advertisement.
--- drivers/block/xen-blkfront.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/block/xen-blkfront.c +7 -7
@@ -1852,6 +1852,12 @@ static void free_info(struct blkfront_inkfree (info); } +/* Enable the persistent grants feature. */ +static bool feature_persistent = true; +module_param (feature_persistent, bool,0644 ); +MODULE_PARM_DESC (feature_persistent, +"Enables the persistent grants feature" ); +/* Common code used when first setting up, and when resuming. */ static int talk_to_blkback (struct xenbus_device *dev,struct blkfront_info *info)
@@ -1943,6 +1949,7 @@ again: message ="writing protocol" ; goto abort_transaction; } + info->feature_persistent_parm = feature_persistent; err =xenbus_printf (xbt, dev->nodename,"feature-persistent" ,"%u" , info->feature_persistent_parm);if (err)
@@ -2019,12 +2026,6 @@ static int negotiate_mq(struct blkfront_return 0 ; } -/* Enable the persistent grants feature. */ -static bool feature_persistent = true; -module_param (feature_persistent, bool,0644 ); -MODULE_PARM_DESC (feature_persistent, -"Enables the persistent grants feature" ); -/** * Entry point to this code when a new device is created. Allocate the basic * structures and the ring buffer for communication with the backend, and
@@ -2394,7 +2395,6 @@ static void blkfront_gather_backend_featif (xenbus_read_unsigned (info->xbdev->otherend,"feature-discard" ,0 ))blkfront_setup_discard (info); - info->feature_persistent_parm = feature_persistent;if (info->feature_persistent_parm) info->feature_persistent = !!xenbus_read_unsigned(info->xbdev->otherend,
Greg Kroah-Hartman
maintainerPATCH 3/79 tty: n_gsm: initialize more members at gsm_alloc_mux()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit 4bb1a53be85fcb1e24c14860e326a00cdd362c28 upstream.
syzbot is reporting use of uninitialized spinlock at gsmld_write() [1], for commit 32dd59f ("tty: n_gsm: fix race condition in gsmld_write()") allows accessing gsm->tx_lock before gsm_activate_mux() initializes it.
Since object initialization should be done right after allocation in order to avoid accessing uninitialized memory, move initialization of timer/work/waitqueue/spinlock from gsmld_open()/gsm_activate_mux() to gsm_alloc_mux().
--- drivers/tty/n_gsm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/n_gsm.c +4 -5
@@ -2200,11 +2200,6 @@ static int gsm_activate_mux(struct gsm_m {struct gsm_dlci *dlci; -timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); -init_waitqueue_head (&gsm->event); -spin_lock_init (&gsm->control_lock); -spin_lock_init (&gsm->tx_lock); -if (gsm->encoding ==0 ) gsm->receive = gsm0_receive;else
@@ -2306,6 +2301,10 @@ static struct gsm_mux *gsm_alloc_mux(voimutex_init (&gsm->mutex);kref_init (&gsm->ref);INIT_LIST_HEAD (&gsm->tx_list); +timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); +init_waitqueue_head (&gsm->event); +spin_lock_init (&gsm->control_lock); +spin_lock_init (&gsm->tx_lock); gsm->t1 =T1 ; gsm->t2 =T2 ;
Greg Kroah-Hartman
maintainerPATCH 4/79 tty: n_gsm: avoid call of sleeping functions from atomic context
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit 902e02ea9385373ce4b142576eef41c642703955 upstream.
Syzkaller reports the following problem:
BUG: sleeping function called from invalid context at kernel/printk/printk.c:2347
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1105, name: syz-executor423
3 locks held by syz-executor423/1105:
#0: ffff8881468b9098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x90 drivers/tty/tty_ldisc.c:266 #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write_lock drivers/tty/tty_io.c:952 [inline] #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: do_tty_write drivers/tty/tty_io.c:975 [inline] #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: file_tty_write.constprop.0+0x2a8/0x8e0 drivers/tty/tty_io.c:1118 #2: ffff88801b06c398 (&gsm->tx_lock){....}-{2:2}, at: gsmld_write+0x5e/0x150 drivers/tty/n_gsm.c:2717
irq event stamp: 3482 hardirqs last enabled at (3481): [<ffffffff81d13343>] __get_reqs_available+0x143/0x2f0 fs/aio.c:946 hardirqs last disabled at (3482): [<ffffffff87d39722>] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline] hardirqs last disabled at (3482): [<ffffffff87d39722>] _raw_spin_lock_irqsave+0x52/0x60 kernel/locking/spinlock.c:159 softirqs last enabled at (3408): [<ffffffff87e01002>] asm_call_irq_on_stack+0x12/0x20 softirqs last disabled at (3401): [<ffffffff87e01002>] asm_call_irq_on_stack+0x12/0x20 Preemption disabled at: [<0000000000000000>] 0x0 CPU: 2 PID: 1105 Comm: syz-executor423 Not tainted 5.10.137-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x107/0x167 lib/dump_stack.c:118 ___might_sleep.cold+0x1e8/0x22e kernel/sched/core.c:7304 console_lock+0x19/0x80 kernel/printk/printk.c:2347 do_con_write+0x113/0x1de0 drivers/tty/vt/vt.c:2909 con_write+0x22/0xc0 drivers/tty/vt/vt.c:3296 gsmld_write+0xd0/0x150 drivers/tty/n_gsm.c:2720 do_tty_write drivers/tty/tty_io.c:1028 [inline] file_tty_write.constprop.0+0x502/0x8e0 drivers/tty/tty_io.c:1118 call_write_iter include/linux/fs.h:1903 [inline] aio_write+0x355/0x7b0 fs/aio.c:1580 __io_submit_one fs/aio.c:1952 [inline] io_submit_one+0xf45/0x1a90 fs/aio.c:1999 __do_sys_io_submit fs/aio.c:2058 [inline] __se_sys_io_submit fs/aio.c:2028 [inline] __x64_sys_io_submit+0x18c/0x2f0 fs/aio.c:2028 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6
The problem happens in the following control flow:
gsmld_write(...)spin_lock_irqsave(&gsm->tx_lock, flags) // taken a spinlock on TX data
con_write(...)
do_con_write(...)
console_lock()
might_sleep() // -> bug
As far as console_lock() might sleep it should not be called with spinlock held.
The patch replaces tx_lock spinlock with mutex in order to avoid the problem.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/tty/n_gsm.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/tty/n_gsm.c +18 -21
@@ -235,7 +235,7 @@ struct gsm_mux {int old_c_iflag;/* termios c_iflag value before attach */ bool constipated;/* Asked by remote to shut up */ -spinlock_t tx_lock; +struct mutex tx_mutex;unsigned int tx_bytes;/* TX data outstanding */ #define TX_THRESH_HI 8192#define TX_THRESH_LO 2048
@@ -820,15 +820,14 @@ static void __gsm_data_queue(struct gsm_* * Add data to the transmit queue and try and get stuff moving * out of the mux tty if not already doing so. Take the -* the gsm tx lock and dlci lock. +* the gsm tx mutex and dlci lock. */ static void gsm_data_queue (struct gsm_dlci *dlci,struct gsm_msg *msg) { -unsigned long flags; -spin_lock_irqsave (&dlci->gsm->tx_lock, flags); +mutex_lock (&dlci->gsm->tx_mutex);__gsm_data_queue (dlci, msg); -spin_unlock_irqrestore (&dlci->gsm->tx_lock, flags); +mutex_unlock (&dlci->gsm->tx_mutex); }/**
@@ -840,7 +839,7 @@ static void gsm_data_queue(struct gsm_dl* is data. Keep to the MRU of the mux. This path handles the usual tty * interface which is a byte stream with optional modem data. * -* Caller must hold the tx_lock of the mux. +* Caller must hold the tx_mutex of the mux. */ static int gsm_dlci_data_output (struct gsm_mux *gsm,struct gsm_dlci *dlci)
@@ -903,7 +902,7 @@ static int gsm_dlci_data_output(struct g* is data. Keep to the MRU of the mux. This path handles framed data * queued as skbuffs to the DLCI. * -* Caller must hold the tx_lock of the mux. +* Caller must hold the tx_mutex of the mux. */ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
@@ -919,7 +918,7 @@ static int gsm_dlci_data_output_framed(sif (dlci->adaption ==4 ) overhead =1 ; -/* dlci->skb is locked by tx_lock */ +/* dlci->skb is locked by tx_mutex */ if (dlci->skb ==NULL ) { dlci->skb =skb_dequeue_tail (&dlci->skb_list);if (dlci->skb ==NULL )
@@ -1019,13 +1018,12 @@ static void gsm_dlci_data_sweep(struct gstatic void gsm_dlci_data_kick (struct gsm_dlci *dlci) { -unsigned long flags;int sweep;if (dlci->constipated)return ; -spin_lock_irqsave (&dlci->gsm->tx_lock, flags); +mutex_lock (&dlci->gsm->tx_mutex);/* If we have nothing running then we need to fire up */ sweep = (dlci->gsm->tx_bytes <TX_THRESH_LO );if (dlci->gsm->tx_bytes ==0 ) {
@@ -1036,7 +1034,7 @@ static void gsm_dlci_data_kick(struct gs }if (sweep)gsm_dlci_data_sweep (dlci->gsm); -spin_unlock_irqrestore (&dlci->gsm->tx_lock, flags); +mutex_unlock (&dlci->gsm->tx_mutex); }/*
@@ -1258,7 +1256,6 @@ static void gsm_control_message(struct g const u8 *data, int clen) {u8 buf[1 ]; -unsigned long flags;switch (command) {case CMD_CLD : {
@@ -1280,9 +1277,9 @@ static void gsm_control_message(struct g gsm->constipated = false;gsm_control_reply (gsm,CMD_FCON ,NULL ,0 );/* Kick the link in case it is idling */ -spin_lock_irqsave (&gsm->tx_lock, flags); +mutex_lock (&gsm->tx_mutex);gsm_data_kick (gsm,NULL ); -spin_unlock_irqrestore (&gsm->tx_lock, flags); +mutex_unlock (&gsm->tx_mutex);break ;case CMD_FCOFF :/* Modem wants us to STFU */
@@ -2228,6 +2225,7 @@ static void gsm_free_mux(struct gsm_muxbreak ; } } +mutex_destroy (&gsm->tx_mutex);mutex_destroy (&gsm->mutex);kfree (gsm->txframe);kfree (gsm->buf);
@@ -2299,12 +2297,12 @@ static struct gsm_mux *gsm_alloc_mux(voi }spin_lock_init (&gsm->lock);mutex_init (&gsm->mutex); +mutex_init (&gsm->tx_mutex);kref_init (&gsm->ref);INIT_LIST_HEAD (&gsm->tx_list);timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );init_waitqueue_head (&gsm->event);spin_lock_init (&gsm->control_lock); -spin_lock_init (&gsm->tx_lock); gsm->t1 =T1 ; gsm->t2 =T2 ;
@@ -2329,6 +2327,7 @@ static struct gsm_mux *gsm_alloc_mux(voi }spin_unlock (&gsm_mux_lock);if (i ==MAX_MUX ) { +mutex_destroy (&gsm->tx_mutex);mutex_destroy (&gsm->mutex);kfree (gsm->txframe);kfree (gsm->buf);
@@ -2653,16 +2652,15 @@ static int gsmld_open(struct tty_structstatic void gsmld_write_wakeup (struct tty_struct *tty) {struct gsm_mux *gsm = tty->disc_data; -unsigned long flags;/* Queue poll */ clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -spin_lock_irqsave (&gsm->tx_lock, flags); +mutex_lock (&gsm->tx_mutex);gsm_data_kick (gsm,NULL );if (gsm->tx_bytes <TX_THRESH_LO ) {gsm_dlci_data_sweep (gsm); } -spin_unlock_irqrestore (&gsm->tx_lock, flags); +mutex_unlock (&gsm->tx_mutex); }/**
@@ -2705,7 +2703,6 @@ static ssize_t gsmld_write(struct tty_st const unsigned char *buf, size_t nr) {struct gsm_mux *gsm = tty->disc_data; -unsigned long flags;int space;int ret;
@@ -2713,13 +2710,13 @@ static ssize_t gsmld_write(struct tty_streturn -ENODEV ; ret = -ENOBUFS ; -spin_lock_irqsave (&gsm->tx_lock, flags); +mutex_lock (&gsm->tx_mutex); space =tty_write_room (tty);if (space >= nr) ret = tty->ops->write (tty, buf, nr);else set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -spin_unlock_irqrestore (&gsm->tx_lock, flags); +mutex_unlock (&gsm->tx_mutex);return ret; }
Re: [PATCH 5.10 04/79] tty: n_gsm: avoid call of sleeping functions from atomic context
Hi!
Quoted 9 lines
From: Fedor Pchelkin <[email protected]>
commit
902e02ea9385373ce4b142576eef41c642703955upstream.Syzkaller reports the following problem:
BUG: sleeping function called from invalid context at kernel/printk/printk.c:2347
in_atomic(): 1,irqs_disabled(): 1,non_block: 0, pid: 1105, name: syz-executor423 3 locks held by syz-executor423/1105:
Does this happen in 5.10, too? printk locking changed significantly in recent years.
Quoted 11 lines
The problem happens in the following control flow:
gsmld_write(...)spin_lock_irqsave(&gsm->tx_lock, flags)// taken a spinlock on TX data
con_write(...)
do_con_write(...)
console_lock()might_sleep() // -> bugAs far as
console_lock()might sleep it should not be called with spinlock held.
Ok.
Quoted 2 lines
The patch replaces
tx_lockspinlock with mutex in order to avoid the problem.
Are you sure you can do that? Original code disabled interrupts, because parts of protected data were accessed from interrupt context, and you simply removed that protection.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg Kroah-Hartman
maintainerPATCH 5/79 efi: libstub: Disable struct randomization
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 1a3887924a7e6edd331be76da7bf4c1e8eab4b1e upstream.
The EFI stub is a wrapper around the core kernel that makes it look like a EFI compatible PE/COFF application to the EFI firmware. EFI applications run on top of the EFI runtime, which is heavily based on so-called protocols, which are struct types consisting [mostly] of function pointer members that are instantiated and recorded in a protocol database.
These structs look like the ideal randomization candidates to the randstruct plugin (as they only carry function pointers), but of course, these protocols are contracts between the firmware that exposes them, and the EFI applications (including our stubbed kernel) that invoke them. This means that struct randomization for EFI protocols is not a great idea, and given that the stub shares very little data with the core kernel that is represented as a randomizable struct, we're better off just disabling it completely here.
--- drivers/firmware/efi/libstub/Makefile | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/firmware/efi/libstub/Makefile +7 -0
@@ -37,6 +37,13 @@ KBUILD_CFLAGS := $(cflags-y) -Os -DDIS $(call cc-option,-fno-addrsig) \ -D__DISABLE_EXPORTS +# +# struct randomization only makes sense for Linux internal types, which the EFI +# stub code never touches, so let's turn off struct randomization for the stub +# altogether +# +KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS)) + # remove SCS flags from all objects in this directory KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
Greg Kroah-Hartman
maintainerPATCH 6/79 efi: capsule-loader: Fix use-after-free in efi_capsule_write
In reply to Greg Kroah-HartmanFrom: Hyunwoo Kim <[email protected]>
commit 9cb636b5f6a8cc6d1b50809ec8f8d33ae0c84c95 upstream.
A race condition may occur if the user calls close() on another thread during a write() operation on the device node of the efi capsule.
This is a race condition that occurs between the efi_capsule_write() and efi_capsule_flush() functions of efi_capsule_fops, which ultimately results in UAF.
So, the page freeing process is modified to be done in efi_capsule_release() instead of efi_capsule_flush().
--- drivers/firmware/efi/capsule-loader.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
drivers/firmware/efi/capsule-loader.c +7 -24
@@ -243,29 +243,6 @@ failed: }/** -* efi_capsule_flush - called by file close or file flush -* @file: file pointer -* @id: not used -* -* If a capsule is being partially uploaded then calling this function -* will be treated as upload termination and will free those completed -* buffer pages and -ECANCELED will be returned. -**/ -static int efi_capsule_flush (struct file *file,fl_owner_t id) -{ -int ret =0 ; -struct capsule_info *cap_info = file->private_data; - -if (cap_info->index >0 ) { -pr_err ("capsule upload not complete\n" ); -efi_free_all_buff_pages (cap_info); - ret = -ECANCELED ; - } - -return ret; -} - -/** * efi_capsule_release - called by file close * @inode: not used * @file: file pointer
@@ -277,6 +254,13 @@ static int efi_capsule_release(struct in {struct capsule_info *cap_info = file->private_data; +if (cap_info->index >0 && + (cap_info->header.headersize ==0 || + cap_info->count < cap_info->total_size)) { +pr_err ("capsule upload not complete\n" ); +efi_free_all_buff_pages (cap_info); + } +kfree (cap_info->pages);kfree (cap_info->phys);kfree (file->private_data);
@@ -324,7 +308,6 @@ static const struct file_operations efi_ .owner = THIS_MODULE, .open = efi_capsule_open, .write = efi_capsule_write, - .flush = efi_capsule_flush, .release = efi_capsule_release, .llseek = no_llseek, };
Greg Kroah-Hartman
maintainerPATCH 7/79 wifi: iwlegacy: 4965: corrected fix for potential off-by-one overflow in il4965_rs_fill_link_cmd()
In reply to Greg Kroah-HartmanFrom: Stanislaw Gruszka <[email protected]>
commit 6d0ef7241553f3553a0a2764c69b07892705924c upstream.
This reverts commit a8eb8e6f7159c7c20c0ddac428bde3d110890aa7 as it can cause invalid link quality command sent to the firmware and address the off-by-one issue by fixing condition of while loop.
--- drivers/net/wireless/intel/iwlegacy/4965-rs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/intel/iwlegacy/4965-rs.c +1 -4
@@ -2403,7 +2403,7 @@ il4965_rs_fill_link_cmd(struct il_priv */* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ -while (repeat_rate >0 ) { +while (repeat_rate >0 && idx < (LINK_QUAL_MAX_RETRY_NUM -1 )) {if (is_legacy (tbl_type.lq_type)) {if (ant_toggle_cnt <NUM_TRY_BEFORE_ANT_TOGGLE ) ant_toggle_cnt++;
@@ -2422,8 +2422,6 @@ il4965_rs_fill_link_cmd(struct il_priv *cpu_to_le32 (new_rate); repeat_rate--; idx++; -if (idx >=LINK_QUAL_MAX_RETRY_NUM ) - goto out; } il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
@@ -2468,7 +2466,6 @@ il4965_rs_fill_link_cmd(struct il_priv * repeat_rate--; } -out: lq_cmd->agg_params.agg_frame_cnt_limit =LINK_QUAL_AGG_FRAME_LIMIT_DEF ; lq_cmd->agg_params.agg_dis_start_th =LINK_QUAL_AGG_DISABLE_START_DEF ;
Greg Kroah-Hartman
maintainerPATCH 8/79 net: mvpp2: debugfs: fix memory leak when using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit fe2c9c61f668cde28dac2b188028c5299cedcc1e upstream.
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up to be much simpler logic and only create the root debugfs directory once when the driver is first accessed. That resolves the memory leak and makes things more obvious as to what the intent is.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c +2 -2
@@ -700,10 +700,10 @@ void mvpp2_dbgfs_cleanup(struct mvpp2 *pvoid mvpp2_dbgfs_init (struct mvpp2 *priv,const char *name) { -struct dentry *mvpp2_dir, *mvpp2_root; +static struct dentry *mvpp2_root; +struct dentry *mvpp2_dir;int ret, i; - mvpp2_root =debugfs_lookup (MVPP2_DRIVER_NAME ,NULL );if (!mvpp2_root) mvpp2_root =debugfs_create_dir (MVPP2_DRIVER_NAME ,NULL );
Greg Kroah-Hartman
maintainerPATCH 9/79 fs: only do a memory barrier for the first set_buffer_uptodate()
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 2f79cdfe58c13949bbbb65ba5926abfe9561d0ec upstream.
Commit d4252071b97d ("add barriers to buffer_uptodate and set_buffer_uptodate") added proper memory barriers to the buffer head BH_Uptodate bit, so that anybody who tests a buffer for being up-to-date will be guaranteed to actually see initialized state.
However, that commit didn't _just_ add the memory barrier, it also ended up dropping the "was it already set" logic that the BUFFER_FNS() macro had.
That's conceptually the right thing for a generic "this is a memory barrier" operation, but in the case of the buffer contents, we really only care about the memory barrier for the _first_ time we set the bit, in that the only memory ordering protection we need is to avoid anybody seeing uninitialized memory contents.
Any other access ordering wouldn't be about the BH_Uptodate bit anyway, and would require some other proper lock (typically BH_Lock or the folio lock). A reader that races with somebody invalidating the buffer head isn't an issue wrt the memory ordering, it's a serialization issue.
Now, you'd think that the buffer head operations don't matter in this day and age (and I certainly thought so), but apparently some loads still end up being heavy users of buffer heads. In particular, the kernel test robot reported that not having this bit access optimization in place caused a noticeable direct IO performance regression on ext4:
fxmark.ssd_ext4_no_jnl_DWTL_54_directio.works/sec -26.5% regression
although you presumably need a fast disk and a lot of cores to actually notice.
--- include/linux/buffer_head.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/buffer_head.h +11 -0
@@ -137,6 +137,17 @@ BUFFER_FNS(Defer_Completion, defer_compl static __always_inline void set_buffer_uptodate(struct buffer_head *bh) {/* +* If somebody else already set this uptodate, they will +* have done the memory barrier, and a reader will thus +* see *some* valid buffer state. +* +* Any other serialization (with IO errors or whatever that +* might clear the bit) has to come from other state (eg BH_Lock). +*/ +if (test_bit (BH_Uptodate, &bh->b_state)) +return ; + +/* * make it consistent with folio_mark_uptodate * pairs with smp_load_acquire in buffer_uptodate */
Greg Kroah-Hartman
maintainerPATCH 10/79 Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()"
In reply to Greg Kroah-HartmanFrom: Yee Lee <[email protected]>
This reverts commit 23c2d497de21f25898fbea70aeb292ab8acc8c94.
Commit 23c2d497de21 ("mm: kmemleak: take a full lowmem check in kmemleak_*_phys()") brought false leak alarms on some archs like arm64 that does not init pfn boundary in early booting. The final solution lands on linux-6.0: commit 0c24e061196c ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA").
Revert this commit before linux-6.0. The original issue of invalid PA can be mitigated by additional check in devicetree.
The false alarm report is as following: Kmemleak output: (Qemu/arm64) unreferenced object 0xffff0000c0170a00 (size 128):
comm "swapper/0", pid 1, jiffies 4294892404 (age 126.208s) hex dump (first 32 bytes):
62 61 73 65 00 00 00 00 00 00 00 00 00 00 00 00 base............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<(____ptrval____)>] __kmalloc_track_caller+0x1b0/0x2e4
[<(____ptrval____)>] kstrdup_const+0x8c/0xc4
[<(____ptrval____)>] kvasprintf_const+0xbc/0xec
[<(____ptrval____)>] kobject_set_name_vargs+0x58/0xe4
[<(____ptrval____)>] kobject_add+0x84/0x100
[<(____ptrval____)>] __of_attach_node_sysfs+0x78/0xec
[<(____ptrval____)>] of_core_init+0x68/0x104
[<(____ptrval____)>] driver_init+0x28/0x48
[<(____ptrval____)>] do_basic_setup+0x14/0x28
[<(____ptrval____)>] kernel_init_freeable+0x110/0x178
[<(____ptrval____)>] kernel_init+0x20/0x1a0
[<(____ptrval____)>] ret_from_fork+0x10/0x20This pacth is also applicable to linux-5.17.y/linux-5.18.y/linux-5.19.y
--- mm/kmemleak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/kmemleak.c +4 -4
@@ -1123,7 +1123,7 @@ EXPORT_SYMBOL(kmemleak_no_scan);void __ref kmemleak_alloc_phys (phys_addr_t phys,size_t size,int min_count,gfp_t gfp) { -if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn) +if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn)kmemleak_alloc (__va (phys), size, min_count, gfp); }EXPORT_SYMBOL (kmemleak_alloc_phys);
@@ -1137,7 +1137,7 @@ EXPORT_SYMBOL(kmemleak_alloc_phys);*/ void __ref kmemleak_free_part_phys (phys_addr_t phys,size_t size) { -if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn) +if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn)kmemleak_free_part (__va (phys), size); }EXPORT_SYMBOL (kmemleak_free_part_phys);
@@ -1149,7 +1149,7 @@ EXPORT_SYMBOL(kmemleak_free_part_phys);*/ void __ref kmemleak_not_leak_phys (phys_addr_t phys) { -if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn) +if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn)kmemleak_not_leak (__va (phys)); }EXPORT_SYMBOL (kmemleak_not_leak_phys);
@@ -1161,7 +1161,7 @@ EXPORT_SYMBOL(kmemleak_not_leak_phys);*/ void __ref kmemleak_ignore_phys (phys_addr_t phys) { -if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn) +if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn)kmemleak_ignore (__va (phys)); }EXPORT_SYMBOL (kmemleak_ignore_phys);
Greg Kroah-Hartman
maintainerPATCH 11/79 scsi: qla2xxx: Disable ATIO interrupt coalesce for quad port ISP27XX
In reply to Greg Kroah-HartmanFrom: Tony Battersby <[email protected]>
[ Upstream commit 53661ded2460b414644532de6b99bd87f71987e9 ]
This partially reverts commit d2b292c3f6fd ("scsi: qla2xxx: Enable ATIO interrupt handshake for ISP27XX")
For some workloads where the host sends a batch of commands and then pauses, ATIO interrupt coalesce can cause some incoming ATIO entries to be ignored for extended periods of time, resulting in slow performance, timeouts, and aborted commands.
Disable interrupt coalesce and re-enable the dedicated ATIO MSI-X interrupt.
--- drivers/scsi/qla2xxx/qla_target.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +2 -8
@@ -6817,14 +6817,8 @@ qlt_24xx_config_rings(struct scsi_qla_host *vha)if (ha->flags.msix_enabled) {if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { -if (IS_QLA2071 (ha)) { -/* 4 ports Baker: Enable Interrupt Handshake */ - icb->msix_atio =0 ; - icb->firmware_options_2 |=cpu_to_le32 (BIT_26 ); - }else { - icb->msix_atio =cpu_to_le16 (msix->entry); - icb->firmware_options_2 &=cpu_to_le32 (~BIT_26 ); - } + icb->msix_atio =cpu_to_le16 (msix->entry); + icb->firmware_options_2 &=cpu_to_le32 (~BIT_26 );ql_dbg (ql_dbg_init, vha,0xf072 ,"Registering ICB vector 0x%x for atio que.\n" , msix->entry);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 12/79 scsi: megaraid_sas: Fix double kfree()
In reply to Greg Kroah-HartmanFrom: Guixin Liu <[email protected]>
[ Upstream commit 8c499e49240bd93628368c3588975cfb94169b8b ]
When allocating log_to_span fails, kfree(instance->ctrl_context) is called twice. Remove redundant call.
--- drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -1
@@ -5198,7 +5198,6 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)if (!fusion->log_to_span) {dev_err (&instance->pdev->dev,"Failed from %s %d\n" , __func__, __LINE__); -kfree (instance->ctrl_context);return -ENOMEM ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 13/79 drm/gem: Fix GEM handle release errors
In reply to Greg Kroah-HartmanFrom: Jeffy Chen <[email protected]>
[ Upstream commit ea2aa97ca37a9044ade001aef71dbc06318e8d44 ]
Currently we are assuming a one to one mapping between dmabuf and GEM handle when releasing GEM handles.
But that is not always true, since we would create extra handles for the GEM obj in cases like gem_open() and getfb{,2}().
A similar issue was reported at:
https://lore.kernel.org/all/[email protected]/
Another problem is that the imported dmabuf might not always have gem_obj->dma_buf set, which would cause leaks in drm_gem_remove_prime_handles().
Let's fix these for now by using handle to find the exact map to remove.
--- drivers/gpu/drm/drm_gem.c | 17 +---------------- drivers/gpu/drm/drm_internal.h | 4 ++-- drivers/gpu/drm/drm_prime.c | 20 ++++++++++++-------- 3 files changed, 15 insertions(+), 26 deletions(-)
drivers/gpu/drm/drm_gem.c +1 -16
@@ -166,21 +166,6 @@ void drm_gem_private_object_init(struct drm_device *dev, }EXPORT_SYMBOL (drm_gem_private_object_init); -static void -drm_gem_remove_prime_handles (struct drm_gem_object *obj,struct drm_file *filp) -{ -/* -* Note: obj->dma_buf can't disappear as long as we still hold a -* handle reference in obj->handle_count. -*/ -mutex_lock (&filp->prime.lock); -if (obj->dma_buf) { -drm_prime_remove_buf_handle_locked (&filp->prime, - obj->dma_buf); - } -mutex_unlock (&filp->prime.lock); -} -/** * drm_gem_object_handle_free - release resources bound to userspace handles * @obj: GEM object to clean up.
@@ -254,7 +239,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)else if (dev->driver->gem_close_object) dev->driver->gem_close_object (obj, file_priv); -drm_gem_remove_prime_handles (obj, file_priv); +drm_prime_remove_buf_handle (&file_priv->prime, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);
drivers/gpu/drm/drm_internal.h +2 -2
@@ -86,8 +86,8 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv); -void drm_prime_remove_buf_handle_locked (struct drm_prime_file_private *prime_fpriv, -struct dma_buf *dma_buf); +void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +uint32_t handle);/* drm_drv.c */ struct drm_minor *drm_minor_acquire (unsigned int minor_id);
drivers/gpu/drm/drm_prime.c +12 -8
@@ -187,29 +187,33 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fprireturn -ENOENT ; } -void drm_prime_remove_buf_handle_locked (struct drm_prime_file_private *prime_fpriv, -struct dma_buf *dma_buf) +void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +uint32_t handle) {struct rb_node *rb; - rb = prime_fpriv->dmabufs.rb_node; +mutex_lock (&prime_fpriv->lock); + + rb = prime_fpriv->handles.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); -if (member->dma_buf == dma_buf) { + member = rb_entry(rb, struct drm_prime_member, handle_rb); +if (member->handle == handle) {rb_erase (&member->handle_rb, &prime_fpriv->handles);rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs); -dma_buf_put (dma_buf); +dma_buf_put (member->dma_buf);kfree (member); -return ; - }else if (member->dma_buf < dma_buf) { +break ; + }else if (member->handle < handle) { rb = rb->rb_right; }else { rb = rb->rb_left; } } + +mutex_unlock (&prime_fpriv->lock); }void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 14/79 drm/amdgpu: Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to psp_hw_fini
In reply to Greg Kroah-HartmanFrom: YiPeng Chai <[email protected]>
[ Upstream commit 9d705d7741ae70764f3d6d87e67fad3b5c30ffd0 ]
V1:
The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.
V2:
1. Change the commit title.
2. Restore amdgpu_xgmi_remove_device to its original calling location. Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to psp_hw_fini.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -0
@@ -2146,6 +2146,9 @@ static int psp_hw_fini(void *handle)psp_rap_terminate (psp);psp_dtm_terminate (psp);psp_hdcp_terminate (psp); + +if (adev->gmc.xgmi.num_physical_nodes >1 ) +psp_xgmi_terminate (psp); }psp_asd_unload (psp);
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1 -1
@@ -622,7 +622,7 @@ int amdgpu_xgmi_remove_device(struct amdgpu_device *adev)amdgpu_put_xgmi_hive (hive); } -return psp_xgmi_terminate (&adev->psp); +return 0 ; }int amdgpu_xgmi_ras_late_init (struct amdgpu_device *adev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 15/79 drm/amdgpu: Check num_gfx_rings for gfx v9_0 rb setup.
In reply to Greg Kroah-HartmanFrom: Candice Li <[email protected]>
[ Upstream commit c351938350ab9b5e978dede2c321da43de7eb70c ]
No need to set up rb when no gfx rings.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -2570,7 +2570,8 @@ static void gfx_v9_0_constants_init(struct amdgpu_device *adev)gfx_v9_0_tiling_mode_table_init (adev); -gfx_v9_0_setup_rb (adev); +if (adev->gfx.num_gfx_rings) +gfx_v9_0_setup_rb (adev);gfx_v9_0_get_cu_info (adev, &adev->gfx.cu_info); adev->gfx.config.db_debug2 =RREG32_SOC15 (GC ,0 , mmDB_DEBUG2);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 16/79 drm/radeon: add a force flush to delay work when radeon
In reply to Greg Kroah-HartmanFrom: Zhenneng Li <[email protected]>
[ Upstream commit f461950fdc374a3ada5a63c669d997de4600dffe ]
Although radeon card fence and wait for gpu to finish processing current batch rings, there is still a corner case that radeon lockup work queue may not be fully flushed, and meanwhile the radeon_suspend_kms() function has called pci_set_power_state() to put device in D3hot state.
Per PCI spec rev 4.0 on 5.3.1.4.1 D3hot State.
Quoted 3 lines
Configuration and Message requests are the only TLPs accepted by a Function in the D3hot state. All other received Requests must be handled as Unsupported Requests, and all received Completions may optionally be handled as Unexpected Completions.
This issue will happen in following logs:
Unable to handle kernel paging request at virtual address 00008800e0008010
CPU 0 kworker/0:3(131): Oops 0
pc = [<ffffffff811bea5c>] ra = [<ffffffff81240844>] ps = 0000 Tainted: G W
pc is at si_gpu_check_soft_reset+0x3c/0x240
ra is at si_dma_is_lockup+0x34/0xd0
v0 = 0000000000000000 t0 = fff08800e0008010 t1 = 0000000000010000 t2 = 0000000000008010 t3 = fff00007e3c00000 t4 = fff00007e3c00258 t5 = 000000000000ffff t6 = 0000000000000001 t7 = fff00007ef078000 s0 = fff00007e3c016e8 s1 = fff00007e3c00000 s2 = fff00007e3c00018 s3 = fff00007e3c00000 s4 = fff00007fff59d80 s5 = 0000000000000000 s6 = fff00007ef07bd98 a0 = fff00007e3c00000 a1 = fff00007e3c016e8 a2 = 0000000000000008 a3 = 0000000000000001 a4 = 8f5c28f5c28f5c29 a5 = ffffffff810f4338 t8 = 0000000000000275 t9 = ffffffff809b66f8 t10 = ff6769c5d964b800 t11= 000000000000b886 pv = ffffffff811bea20 at = 0000000000000000 gp = ffffffff81d89690 sp = 00000000aa814126 Disabling lock debugging due to kernel taint Trace: [<ffffffff81240844>] si_dma_is_lockup+0x34/0xd0 [<ffffffff81119610>] radeon_fence_check_lockup+0xd0/0x290 [<ffffffff80977010>] process_one_work+0x280/0x550 [<ffffffff80977350>] worker_thread+0x70/0x7c0 [<ffffffff80977410>] worker_thread+0x130/0x7c0 [<ffffffff80982040>] kthread+0x200/0x210 [<ffffffff809772e0>] worker_thread+0x0/0x7c0 [<ffffffff80981f8c>] kthread+0x14c/0x210 [<ffffffff80911658>] ret_from_kernel_thread+0x18/0x20 [<ffffffff80981e40>] kthread+0x0/0x210 Code: ad3e0008 43f0074a ad7e0018 ad9e0020 8c3001e8 40230101 <88210000> 4821ed21
So force lockup work queue flush to fix this problem.
--- drivers/gpu/drm/radeon/radeon_device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/radeon/radeon_device.c +3 -0
@@ -1623,6 +1623,9 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,if (r) {/* delay GPU reset to resume */ radeon_fence_driver_force_completion (rdev, i); + }else { +/* finish executing delayed work */ +flush_delayed_work (&rdev->fence_drv[i].lockup_work); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 17/79 parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources()
In reply to Greg Kroah-HartmanFrom: Li Qiong <[email protected]>
[ Upstream commit d46c742f827fa2326ab1f4faa1cccadb56912341 ]
As the possible failure of the kmalloc(), it should be better to fix this error path, check and return '-ENOMEM' error code.
--- drivers/parisc/ccio-dma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/parisc/ccio-dma.c +8 -3
@@ -1380,15 +1380,17 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr) } } -static void __init ccio_init_resources (struct ioc *ioc) +static int __init ccio_init_resources (struct ioc *ioc) {struct resource *res = ioc->mmio_region;char *name =kmalloc (14 ,GFP_KERNEL ); - +if (unlikely (!name)) +return -ENOMEM ;snprintf (name,14 ,"GSC Bus [%d/]" , ioc->hw_path);ccio_init_resource (res, name, &ioc->ioc_regs->io_io_low);ccio_init_resource (res +1 , name, &ioc->ioc_regs->io_io_low_hv); +return 0 ; } static int new_ioc_area(struct resource *res, unsigned long size,
@@ -1543,7 +1545,10 @@ static int __init ccio_probe(struct parisc_device *dev)return -ENOMEM ; }ccio_ioc_init (ioc); -ccio_init_resources (ioc); +if (ccio_init_resources (ioc)) { +kfree (ioc); +return -ENOMEM ; + } hppa_dma_ops = &ccio_ops; hba =kzalloc (sizeof (*hba),GFP_KERNEL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 18/79 parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 591d2108f3abc4db9f9073cae37cf3591fd250d6 ]
If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x machine is detected.
--- arch/parisc/kernel/head.S | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
arch/parisc/kernel/head.S +42 -1
@@ -22,7 +22,7 @@ #include <linux/init.h> #include <linux/pgtable.h> - .level PA_ASM_LEVEL + .level 1.1 __INITDATA ENTRY(boot_args)
@@ -69,6 +69,47 @@ $bss_loop: stw,ma %arg2,4(%r1) stw,ma %arg3,4(%r1) +#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20) + /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU + * and halt kernel if we detect a PA1.x CPU. */ + ldi 32,%r10 + mtctl %r10,%cr11 + .level 2.0 + mfctl,w %cr11,%r10 + .level 1.1 + comib,<>,n 0,%r10,$cpu_ok + + load32 PA(msg1),%arg0 + ldi msg1_end-msg1,%arg1 +$iodc_panic: + copy %arg0, %r10 + copy %arg1, %r11 + load32 PA(init_stack),%sp +#define MEM_CONS 0x3A0 + ldw MEM_CONS+32(%r0),%arg0 // HPA + ldi ENTRY_IO_COUT,%arg1 + ldw MEM_CONS+36(%r0),%arg2 // SPA + ldw MEM_CONS+8(%r0),%arg3 // layers + load32 PA(__bss_start),%r1 + stw %r1,-52(%sp) // arg4 + stw %r0,-56(%sp) // arg5 + stw %r10,-60(%sp) // arg6 = ptr to text + stw %r11,-64(%sp) // arg7 = len + stw %r0,-68(%sp) // arg8 + load32 PA(.iodc_panic_ret), %rp + ldw MEM_CONS+40(%r0),%r1 // ENTRY_IODC + bv,n (%r1) +.iodc_panic_ret: + b . /* wait endless with ... */ + or %r10,%r10,%r10 /* qemu idle sleep */ +msg1: .ascii "Can't boot kernel which was built for PA8x00 CPUs on this machine.\r\n" +msg1_end: + +$cpu_ok: +#endif + + .level PA_ASM_LEVEL + /* Initialize startup VM. Just map first 16/32 MB of memory */ load32 PA(swapper_pg_dir),%r4 mtctl %r4,%cr24 /* Initialize kernel root pointer */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 19/79 arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level
In reply to Greg Kroah-HartmanFrom: Sudeep Holla <[email protected]>
[ Upstream commit e75d18cecbb3805895d8ed64da4f78575ec96043 ]
Though acpi_find_last_cache_level() always returned signed value and the document states it will return any errors caused by lack of a PPTT table, it never returned negative values before.
Commit 0c80f9e165f8 ("ACPI: PPTT: Leave the table mapped for the runtime usage") however changed it by returning -ENOENT if no PPTT was found. The value returned from acpi_find_last_cache_level() is then assigned to unsigned fw_level.
It will result in the number of cache leaves calculated incorrectly as a huge value which will then cause the following warning from __alloc_pages as the order would be great than MAX_ORDER because of incorrect and huge cache leaves value.
| WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5407 __alloc_pages+0x74/0x314 | Modules linked in: | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-10393-g7c2a8d3ac4c0 #73 | pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) | pc : __alloc_pages+0x74/0x314 | lr : alloc_pages+0xe8/0x318 | Call trace: | __alloc_pages+0x74/0x314 | alloc_pages+0xe8/0x318 | kmalloc_order_trace+0x68/0x1dc | __kmalloc+0x240/0x338 | detect_cache_attributes+0xe0/0x56c | update_siblings_masks+0x38/0x284 | store_cpu_topology+0x78/0x84 | smp_prepare_cpus+0x48/0x134 | kernel_init_freeable+0xc4/0x14c | kernel_init+0x2c/0x1b4 | ret_from_fork+0x10/0x20
Fix the same by changing fw_level to be signed integer and return the error from init_cache_level() early in case of error.
--- arch/arm64/kernel/cacheinfo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/kernel/cacheinfo.c +5 -1
@@ -45,7 +45,8 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,int init_cache_level (unsigned int cpu) { -unsigned int ctype, level, leaves, fw_level; +unsigned int ctype, level, leaves; +int fw_level;struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu);for (level =1 , leaves =0 ; level <=MAX_CACHE_LEVEL ; level++) {
@@ -63,6 +64,9 @@ int init_cache_level(unsigned int cpu)else fw_level =acpi_find_last_cache_level (cpu); +if (fw_level <0 ) +return fw_level; +if (level < fw_level) {/* * some external caches not specified in CLIDR_EL1
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 20/79 arm64/signal: Raise limit on stack frames
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit 7ddcaf78e93c9282b4d92184f511b4d5bee75355 ]
The signal code has a limit of 64K on the size of a stack frame that it will generate, if this limit is exceeded then a process will be killed if it receives a signal. Unfortunately with the advent of SME this limit is too small - the maximum possible size of the ZA register alone is 64K. This is not an issue for practical systems at present but is easily seen using virtual platforms.
Raise the limit to 256K, this is substantially more than could be used by any current architecture extension.
--- arch/arm64/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/signal.c +1 -1
@@ -91,7 +91,7 @@ static size_t sigframe_size(struct rt_sigframe_user_layout const *user)* not taken into account. This limit is not a guarantee and is * NOT ABI. */ -#define SIGFRAME_MAXSZ SZ_64K +#define SIGFRAME_MAXSZ SZ_256Kstatic int __sigframe_alloc (struct rt_sigframe_user_layout *user,unsigned long *offset,size_t size,bool extend)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 21/79 net/core/skbuff: Check the return value of skb_copy_bits()
In reply to Greg Kroah-HartmanFrom: lily <[email protected]>
[ Upstream commit c624c58e08b15105662b9ab9be23d14a6b945a49 ]
skb_copy_bits() could fail, which requires a check on the return value.
--- net/core/skbuff.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/core/skbuff.c +2 -3
@@ -3986,9 +3986,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,SKB_GSO_CB (nskb)->csum_start =skb_headroom (nskb) + doffset; }else { -skb_copy_bits (head_skb, offset, -skb_put (nskb, len), - len); +if (skb_copy_bits (head_skb, offset,skb_put (nskb, len), len)) + goto err; }continue ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 22/79 fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 07c55c9803dea748d17a054000cbf1913ce06399 ]
Add missing pci_disable_device() in error path in chipsfb_pci_init().
--- drivers/video/fbdev/chipsfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/chipsfb.c +1 -0
@@ -430,6 +430,7 @@ static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) err_release_fb:framebuffer_release (p); err_disable: +pci_disable_device (dp); err_out:return rc; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 23/79 drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly
In reply to Greg Kroah-HartmanFrom: Qu Huang <[email protected]>
[ Upstream commit b8983d42524f10ac6bf35bbce6a7cc8e45f61e04 ]
The mmVM_L2_CNTL3 register is not assigned an initial value
--- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +1 -0
@@ -178,6 +178,7 @@ static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev) tmp =REG_SET_FIELD (tmp,VM_L2_CNTL2 ,INVALIDATE_L2_CACHE ,1 );WREG32_SOC15 (MMHUB ,0 , mmVM_L2_CNTL2, tmp); + tmp = mmVM_L2_CNTL3_DEFAULT;if (adev->gmc.translate_further) { tmp =REG_SET_FIELD (tmp,VM_L2_CNTL3 ,BANK_SELECT ,12 ); tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 24/79 ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc()
In reply to Greg Kroah-HartmanFrom: Tasos Sahanidis <[email protected]>
commit d29f59051d3a07b81281b2df2b8c9dfe4716067f upstream.
The voice allocator sometimes begins allocating from near the end of the array and then wraps around, however snd_emu10k1_pcm_channel_alloc() accesses the newly allocated voices as if it never wrapped around.
This results in out of bounds access if the first voice has a high enough index so that first_voice + requested_voice_count > NUM_G (64). The more voices are requested, the more likely it is for this to occur.
This was initially discovered using PipeWire, however it can be reproduced by calling aplay multiple times with 16 channels:
aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero
UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40 index 65 is out of range for type 'snd_emu10k1_voice [64]' CPU: 1 PID: 31977 Comm: aplay Tainted: G W IOE 6.0.0-rc2-emu10k1+ #7 Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002 07/22/2010 Call Trace: <TASK> dump_stack_lvl+0x49/0x63 dump_stack+0x10/0x16 ubsan_epilogue+0x9/0x3f __ubsan_handle_out_of_bounds.cold+0x44/0x49 snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1] snd_pcm_hw_params+0x29f/0x600 [snd_pcm] snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm] ? exit_to_user_mode_prepare+0x35/0x170 ? do_syscall_64+0x69/0x90 ? syscall_exit_to_user_mode+0x26/0x50 ? do_syscall_64+0x69/0x90 ? exit_to_user_mode_prepare+0x35/0x170 snd_pcm_ioctl+0x27/0x40 [snd_pcm] __x64_sys_ioctl+0x95/0xd0 do_syscall_64+0x5c/0x90 ? do_syscall_64+0x69/0x90 ? do_syscall_64+0x69/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- sound/pci/emu10k1/emupcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/emu10k1/emupcm.c +1 -1
@@ -123,7 +123,7 @@ static int snd_emu10k1_pcm_channel_alloc epcm->voices[0 ]->epcm = epcm;if (voices >1 ) {for (i =1 ; i < voices; i++) { - epcm->voices[i] = &epcm->emu->voices[epcm->voices[0 ]->number + i]; + epcm->voices[i] = &epcm->emu->voices[(epcm->voices[0 ]->number + i) %NUM_G ]; epcm->voices[i]->epcm = epcm; } }
Greg Kroah-Hartman
maintainerPATCH 25/79 ALSA: aloop: Fix random zeros in capture data when using jiffies timer
In reply to Greg Kroah-HartmanFrom: Pattara Teerapong <[email protected]>
commit 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 upstream.
In loopback_jiffies_timer_pos_update(), we are getting jiffies twice. First time for playback, second time for capture. Jiffies can be updated between these two calls and if the capture jiffies is larger, extra zeros will be filled in the capture buffer.
Change to get jiffies once and use it for both playback and capture.
--- sound/drivers/aloop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/drivers/aloop.c +4 -3
@@ -606,17 +606,18 @@ static unsigned int loopback_jiffies_tim cable->streams[SNDRV_PCM_STREAM_PLAYBACK ];struct loopback_pcm *dpcm_capt = cable->streams[SNDRV_PCM_STREAM_CAPTURE ]; -unsigned long delta_play =0 , delta_capt =0 ; +unsigned long delta_play =0 , delta_capt =0 , cur_jiffies;unsigned int running, count1, count2; + cur_jiffies = jiffies; running = cable->running ^ cable->pause;if (running & (1 <<SNDRV_PCM_STREAM_PLAYBACK )) { - delta_play = jiffies - dpcm_play->last_jiffies; + delta_play = cur_jiffies - dpcm_play->last_jiffies; dpcm_play->last_jiffies += delta_play; }if (running & (1 <<SNDRV_PCM_STREAM_CAPTURE )) { - delta_capt = jiffies - dpcm_capt->last_jiffies; + delta_capt = cur_jiffies - dpcm_capt->last_jiffies; dpcm_capt->last_jiffies += delta_capt; }
Greg Kroah-Hartman
maintainerPATCH 26/79 ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
In reply to Greg Kroah-HartmanFrom: Dongxiang Ke <[email protected]>
commit e53f47f6c1a56d2af728909f1cb894da6b43d9bf upstream.
There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and the number of it's interfaces less than 4, an out-of-bounds read bug occurs when parsing the interface descriptor for this device.
Fix this by checking the number of interfaces.
--- sound/usb/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/stream.c +1 -1
@@ -1106,7 +1106,7 @@ static int __snd_usb_parse_audio_interfa* Dallas DS4201 workaround: It presents 5 altsettings, but the last * one misses syncpipe, and does not produce any sound. */ -if (chip->usb_id ==USB_ID (0x04fa ,0x4201 )) +if (chip->usb_id ==USB_ID (0x04fa ,0x4201 ) && num >=4 ) num =4 ;for (i =0 ; i < num; i++) {
Greg Kroah-Hartman
maintainerPATCH 27/79 kprobes: Prohibit probes in gate area
In reply to Greg Kroah-HartmanFrom: Christian A. Ehrhardt <[email protected]>
commit 1efda38d6f9ba26ac88b359c6277f1172db03f1e upstream.
The system call gate area counts as kernel text but trying to install a kprobe in this area fails with an Oops later on. To fix this explicitly disallow the gate area for kprobes.
Found by syzkaller with the following reproducer:
perf_event_open$cgroup(&(0x7f00000001c0)={0x6, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80ffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext={0x0, 0xffffffffff600000}}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0)
Sample report:
BUG: unable to handle page fault for address: fffffbfff3ac6000 PGD 6dfcb067 P4D 6dfcb067 PUD 6df8f067 PMD 6de4d067 PTE 0 Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI CPU: 0 PID: 21978 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b-dirty #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline] RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline] RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134 Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89 RSP: 0018:ffffc900088bf860 EFLAGS: 00010246 RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000 RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8 RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001 R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000 FS: 00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <TASK> insn_get_prefixes arch/x86/lib/insn.c:131 [inline] insn_get_opcode arch/x86/lib/insn.c:272 [inline] insn_get_modrm+0x64a/0x7b0 arch/x86/lib/insn.c:343 insn_get_sib+0x29a/0x330 arch/x86/lib/insn.c:421 insn_get_displacement+0x350/0x6b0 arch/x86/lib/insn.c:464 insn_get_immediate arch/x86/lib/insn.c:632 [inline] insn_get_length arch/x86/lib/insn.c:707 [inline] insn_decode+0x43a/0x490 arch/x86/lib/insn.c:747 can_probe+0xfc/0x1d0 arch/x86/kernel/kprobes/core.c:282 arch_prepare_kprobe+0x79/0x1c0 arch/x86/kernel/kprobes/core.c:739 prepare_kprobe kernel/kprobes.c:1160 [inline] register_kprobe kernel/kprobes.c:1641 [inline] register_kprobe+0xb6e/0x1690 kernel/kprobes.c:1603 __register_trace_kprobe kernel/trace/trace_kprobe.c:509 [inline] __register_trace_kprobe+0x26a/0x2d0 kernel/trace/trace_kprobe.c:477 create_local_trace_kprobe+0x1f7/0x350 kernel/trace/trace_kprobe.c:1833 perf_kprobe_init+0x18c/0x280 kernel/trace/trace_event_perf.c:271 perf_kprobe_event_init+0xf8/0x1c0 kernel/events/core.c:9888 perf_try_init_event+0x12d/0x570 kernel/events/core.c:11261 perf_init_event kernel/events/core.c:11325 [inline] perf_event_alloc.part.0+0xf7f/0x36a0 kernel/events/core.c:11619 perf_event_alloc kernel/events/core.c:12059 [inline] __do_sys_perf_event_open+0x4a8/0x2a00 kernel/events/core.c:12157 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f63ef7efaed Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f63eef63028 EFLAGS: 00000246 ORIG_RAX: 000000000000012a RAX: ffffffffffffffda RBX: 00007f63ef90ff80 RCX: 00007f63ef7efaed RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 00000000200001c0 RBP: 00007f63ef86019c R08: 0000000000000000 R09: 0000000000000000 R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000002 R14: 00007f63ef90ff80 R15: 00007f63eef43000 </TASK> Modules linked in: CR2: fffffbfff3ac6000 ---[ end trace 0000000000000000 ]--- RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline] RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline] RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134 Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89 RSP: 0018:ffffc900088bf860 EFLAGS: 00010246 RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000 RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8 RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001 R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000 FS: 00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
PKRU: 55555554
==================================================================
--- kernel/kprobes.c | 1 + 1 file changed, 1 insertion(+)
kernel/kprobes.c +1 -0
@@ -1642,6 +1642,7 @@ static int check_kprobe_address_safe(str/* Ensure it is not in reserved area nor out of text */ if (!(core_kernel_text((unsigned long) p->addr) || is_module_text_address((unsigned long) p->addr)) || + in_gate_area_no_mm((unsigned long) p->addr) || within_kprobe_blacklist((unsigned long) p->addr) || jump_label_text_reserved(p->addr, p->addr) || static_call_text_reserved(p->addr, p->addr) ||
Greg Kroah-Hartman
maintainerPATCH 28/79 debugfs: add debugfs_lookup_and_remove()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit dec9b2f1e0455a151a7293c367da22ab973f713e upstream.
There is a very common pattern of using debugfs_remove(debufs_lookup(..)) which results in a dentry leak of the dentry that was looked up. Instead of having to open-code the correct pattern of calling dput() on the dentry, create debugfs_lookup_and_remove() to handle this pattern automatically and properly without any memory leaks.
--- fs/debugfs/inode.c | 22 ++++++++++++++++++++++ include/linux/debugfs.h | 6 ++++++ 2 files changed, 28 insertions(+)
fs/debugfs/inode.c +22 -0
@@ -731,6 +731,28 @@ void debugfs_remove(struct dentry *dentrEXPORT_SYMBOL_GPL (debugfs_remove);/** +* debugfs_lookup_and_remove - lookup a directory or file and recursively remove it +* @name: a pointer to a string containing the name of the item to look up. +* @parent: a pointer to the parent dentry of the item. +* +* This is the equlivant of doing something like +* debugfs_remove(debugfs_lookup(..)) but with the proper reference counting +* handled for the directory being looked up. +*/ +void debugfs_lookup_and_remove (const char *name,struct dentry *parent) +{ +struct dentry *dentry; + + dentry =debugfs_lookup (name, parent); +if (!dentry) +return ; + +debugfs_remove (dentry); +dput (dentry); +} +EXPORT_SYMBOL_GPL (debugfs_lookup_and_remove); + +/** * debugfs_rename - rename a file/directory in the debugfs filesystem * @old_dir: a pointer to the parent dentry for the renamed object. This * should be a directory dentry.
include/linux/debugfs.h +6 -0
@@ -91,6 +91,8 @@ struct dentry *debugfs_create_automount(void debugfs_remove (struct dentry *dentry);#define debugfs_remove_recursive debugfs_remove +void debugfs_lookup_and_remove (const char *name,struct dentry *parent); +const struct file_operations *debugfs_real_fops (const struct file *filp);int debugfs_file_get (struct dentry *dentry);
@@ -220,6 +222,10 @@ static inline void debugfs_remove(structstatic inline void debugfs_remove_recursive (struct dentry *dentry) { } +static inline void debugfs_lookup_and_remove (const char *name, +struct dentry *parent) +{ } +const struct file_operations *debugfs_real_fops (const struct file *filp);static inline int debugfs_file_get (struct dentry *dentry)
Greg Kroah-Hartman
maintainerPATCH 29/79 nvmet: fix a use-after-free
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 6a02a61e81c231cc5c680c5dbf8665275147ac52 upstream.
Fix the following use-after-free complaint triggered by blktests nvme/004:
BUG: KASAN: user-memory-access in blk_mq_complete_request_remote+0xac/0x350 Read of size 4 at addr 0000607bd1835943 by task kworker/13:1/460 Workqueue: nvmet-wq nvme_loop_execute_work [nvme_loop] Call Trace: show_stack+0x52/0x58 dump_stack_lvl+0x49/0x5e print_report.cold+0x36/0x1e2 kasan_report+0xb9/0xf0 __asan_load4+0x6b/0x80 blk_mq_complete_request_remote+0xac/0x350 nvme_loop_queue_response+0x1df/0x275 [nvme_loop] __nvmet_req_complete+0x132/0x4f0 [nvmet] nvmet_req_complete+0x15/0x40 [nvmet] nvmet_execute_io_connect+0x18a/0x1f0 [nvmet] nvme_loop_execute_work+0x20/0x30 [nvme_loop] process_one_work+0x56e/0xa70 worker_thread+0x2d1/0x640 kthread+0x183/0x1c0 ret_from_fork+0x1f/0x30
--- drivers/nvme/target/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/core.c +4 -2
@@ -730,6 +730,8 @@ static void nvmet_set_error(struct nvmetstatic void __nvmet_req_complete (struct nvmet_req *req,u16 status) { +struct nvmet_ns *ns = req->ns; +if (!req->sq->sqhd_disabled)nvmet_update_sq_head (req); req->cqe->sq_id =cpu_to_le16 (req->sq->qid);
@@ -740,9 +742,9 @@ static void __nvmet_req_complete(structtrace_nvmet_req_complete (req); -if (req->ns) -nvmet_put_namespace (req->ns); req->ops->queue_response (req); +if (ns) +nvmet_put_namespace (ns); }void nvmet_req_complete (struct nvmet_req *req,u16 status)
Greg Kroah-Hartman
maintainerPATCH 30/79 drm/i915: Implement WaEdpLinkRateDataReload
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 672d6ca758651f0ec12cd0d59787067a5bde1c96 upstream.
A lot of modern laptops use the Parade PS8461E MUX for eDP switching. The MUX can operate in jitter cleaning mode or redriver mode, the first one resulting in higher link quality. The jitter cleaning mode needs to know the link rate used and the MUX achieves this by snooping the LINK_BW_SET, LINK_RATE_SELECT and SUPPORTED_LINK_RATES DPCD accesses.
When the MUX is powered down (seems this can happen whenever the display is turned off) it loses track of the snooped link rates so when we do the LINK_RATE_SELECT write it no longer knowns which link rate we're selecting, and thus it falls back to the lower quality redriver mode. This results in unstable high link rates (eg. usually 8.1Gbps link rate no longer works correctly).
In order to avoid all that let's re-snoop SUPPORTED_LINK_RATES from the sink at the start of every link training.
Unfortunately we don't have a way to detect the presence of the MUX. It looks like the set of laptops equipped with this MUX is fairly large and contains devices from multiple manufacturers. It may also still be growing with new models. So a quirk doesn't seem like a very easily maintainable option, thus we shall attempt to do this unconditionally on all machines that use LINK_RATE_SELECT. Hopefully this extra DPCD read doesn't cause issues for any unaffected machine. If that turns out to be the case we'll need to convert this into a quirk in the future.
--- drivers/gpu/drm/i915/display/intel_dp_link_training.c | 22 ++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/i915/display/intel_dp_link_training.c +22 -0
@@ -163,6 +163,28 @@ intel_dp_link_training_clock_recovery(stintel_dp_compute_rate (intel_dp, intel_dp->link_rate, &link_bw, &rate_select); +/* +* WaEdpLinkRateDataReload +* +* Parade PS8461E MUX (used on varius TGL+ laptops) needs +* to snoop the link rates reported by the sink when we +* use LINK_RATE_SET in order to operate in jitter cleaning +* mode (as opposed to redriver mode). Unfortunately it +* loses track of the snooped link rates when powered down, +* so we need to make it re-snoop often. Without this high +* link rates are not stable. +*/ +if (!link_bw) { +struct intel_connector *connector = intel_dp->attached_connector; +__le16 sink_rates[DP_MAX_SUPPORTED_RATES ]; + +drm_dbg_kms (&i915->drm,"[CONNECTOR:%d:%s] Reloading eDP link rates\n" , + connector->base.base.id, connector->base.name); + +drm_dp_dpcd_read (&intel_dp->aux,DP_SUPPORTED_LINK_RATES , + sink_rates,sizeof (sink_rates)); + } +if (link_bw)drm_dbg_kms (&i915->drm,"Using LINK_BW_SET value %02x\n" , link_bw);
Greg Kroah-Hartman
maintainerPATCH 31/79 scsi: mpt3sas: Fix use-after-free warning
In reply to Greg Kroah-HartmanFrom: Sreekanth Reddy <[email protected]>
commit 991df3dd5144f2e6b1c38b8d20ed3d4d21e20b34 upstream.
Fix the following use-after-free warning which is observed during controller reset:
refcount_t: underflow; use-after-free.
WARNING: CPU: 23 PID: 5399 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -1
@@ -3501,6 +3501,7 @@ static struct fw_event_work *dequeue_nex fw_event =list_first_entry (&ioc->fw_event_list, struct fw_event_work, list);list_del_init (&fw_event->list); +fw_event_work_put (fw_event); }spin_unlock_irqrestore (&ioc->fw_event_lock, flags);
@@ -3559,7 +3560,6 @@ _scsih_fw_event_cleanup_queue(struct MPTif (cancel_work_sync (&fw_event->work))fw_event_work_put (fw_event); -fw_event_work_put (fw_event); } ioc->fw_events_cleanup =0 ; }
Greg Kroah-Hartman
maintainerPATCH 32/79 scsi: lpfc: Add missing destroy_workqueue() in error path
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit da6d507f5ff328f346b3c50e19e19993027b8ffd upstream.
Add the missing destroy_workqueue() before return from lpfc_sli4_driver_resource_setup() in the error path.
--- drivers/scsi/lpfc/lpfc_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +4 -1
@@ -6670,7 +6670,7 @@ lpfc_sli4_driver_resource_setup(struct l/* Allocate device driver memory */ rc =lpfc_mem_alloc (phba,SGL_ALIGN_SZ );if (rc) -return -ENOMEM ; + goto out_destroy_workqueue;/* IF Type 2 ports get initialized now. */ if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >=
@@ -7076,6 +7076,9 @@ out_free_bsmbx:lpfc_destroy_bootstrap_mbox (phba); out_free_mem:lpfc_mem_free (phba); +out_destroy_workqueue: +destroy_workqueue (phba->wq); + phba->wq =NULL ;return rc; }
Greg Kroah-Hartman
maintainerPATCH 33/79 cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
[ Upstream commit 671c11f0619e5ccb380bcf0f062f69ba95fc974a ]
cgroup_update_dfl_csses() write-lock the threadgroup_rwsem as updating the csses can trigger process migrations. However, if the subtree doesn't contain any tasks, there aren't gonna be any cgroup migrations. This condition can be trivially detected by testing whether mgctx.preloaded_src_csets is empty. Elide write-locking threadgroup_rwsem if the subtree is empty.
After this optimization, the usage pattern of creating a cgroup, enabling the necessary controllers, and then seeding it with CLONE_INTO_CGROUP and then removing the cgroup after it becomes empty doesn't need to write-lock threadgroup_rwsem at all.
--- kernel/cgroup/cgroup.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/cgroup/cgroup.c +13 -3
@@ -2908,12 +2908,11 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)struct cgroup_subsys_state *d_css;struct cgroup *dsct;struct css_set *src_cset; +bool has_tasks;int ret;lockdep_assert_held (&cgroup_mutex); -percpu_down_write (&cgroup_threadgroup_rwsem); -/* look up all csses currently attached to @cgrp's subtree */ spin_lock_irq (&css_set_lock);cgroup_for_each_live_descendant_pre (dsct, d_css, cgrp) {
@@ -2924,6 +2923,16 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp) }spin_unlock_irq (&css_set_lock); +/* +* We need to write-lock threadgroup_rwsem while migrating tasks. +* However, if there are no source csets for @cgrp, changing its +* controllers isn't gonna produce any task migrations and the +* write-locking can be skipped safely. +*/ + has_tasks = !list_empty (&mgctx.preloaded_src_csets); +if (has_tasks) +percpu_down_write (&cgroup_threadgroup_rwsem); +/* NULL dst indicates self on default hierarchy */ ret =cgroup_migrate_prepare_dst (&mgctx);if (ret)
@@ -2943,7 +2952,8 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp) ret =cgroup_migrate_execute (&mgctx); out_finish:cgroup_migrate_finish (&mgctx); -percpu_up_write (&cgroup_threadgroup_rwsem); +if (has_tasks) +percpu_up_write (&cgroup_threadgroup_rwsem);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 34/79 cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
[ Upstream commit 4f7e7236435ca0abe005c674ebd6892c6e83aeb3 ]
Bringing up a CPU may involve creating and destroying tasks which requires read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside cpus_read_lock(). However, cpuset's ->attach(), which may be called with thredagroup_rwsem write-locked, also wants to disable CPU hotplug and acquires cpus_read_lock(), leading to a deadlock.
Fix it by guaranteeing that ->attach() is always called with CPU hotplug disabled and removing cpus_read_lock() call from cpuset_attach().
--- kernel/cgroup/cgroup.c | 77 +++++++++++++++++++++++++++++------------- kernel/cgroup/cpuset.c | 3 +- 2 files changed, 55 insertions(+), 25 deletions(-)
kernel/cgroup/cgroup.c +54 -23
@@ -2304,6 +2304,47 @@ int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen) }EXPORT_SYMBOL_GPL (task_cgroup_path); +/** +* cgroup_attach_lock - Lock for ->attach() +* @lock_threadgroup: whether to down_write cgroup_threadgroup_rwsem +* +* cgroup migration sometimes needs to stabilize threadgroups against forks and +* exits by write-locking cgroup_threadgroup_rwsem. However, some ->attach() +* implementations (e.g. cpuset), also need to disable CPU hotplug. +* Unfortunately, letting ->attach() operations acquire cpus_read_lock() can +* lead to deadlocks. +* +* Bringing up a CPU may involve creating and destroying tasks which requires +* read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside +* cpus_read_lock(). If we call an ->attach() which acquires the cpus lock while +* write-locking threadgroup_rwsem, the locking order is reversed and we end up +* waiting for an on-going CPU hotplug operation which in turn is waiting for +* the threadgroup_rwsem to be released to create new tasks. For more details: +* +* http://lkml.kernel.org/r/20220711174629.uehfmqegcwn2lqzu@wubuntu +* +* Resolve the situation by always acquiring cpus_read_lock() before optionally +* write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that +* CPU hotplug is disabled on entry. +*/ +static void cgroup_attach_lock (bool lock_threadgroup) +{ +cpus_read_lock (); +if (lock_threadgroup) +percpu_down_write (&cgroup_threadgroup_rwsem); +} + +/** +* cgroup_attach_unlock - Undo cgroup_attach_lock() +* @lock_threadgroup: whether to up_write cgroup_threadgroup_rwsem +*/ +static void cgroup_attach_unlock (bool lock_threadgroup) +{ +if (lock_threadgroup) +percpu_up_write (&cgroup_threadgroup_rwsem); +cpus_read_unlock (); +} +/** * cgroup_migrate_add_task - add a migration target task to a migration context * @task: target task
@@ -2780,8 +2821,7 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader, }struct task_struct *cgroup_procs_write_start (char *buf,bool threadgroup, -bool *locked) - __acquires(&cgroup_threadgroup_rwsem) +bool *threadgroup_locked) {struct task_struct *tsk;pid_t pid;
@@ -2798,12 +2838,8 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,* Therefore, we can skip the global lock. */ lockdep_assert_held (&cgroup_mutex); -if (pid || threadgroup) { -percpu_down_write (&cgroup_threadgroup_rwsem); - *locked = true; - }else { - *locked = false; - } + *threadgroup_locked = pid || threadgroup; +cgroup_attach_lock (*threadgroup_locked);rcu_read_lock ();if (pid) {
@@ -2834,17 +2870,14 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup, goto out_unlock_rcu; out_unlock_threadgroup: -if (*locked) { -percpu_up_write (&cgroup_threadgroup_rwsem); - *locked = false; - } +cgroup_attach_unlock (*threadgroup_locked); + *threadgroup_locked = false; out_unlock_rcu:rcu_read_unlock ();return tsk; } -void cgroup_procs_write_finish (struct task_struct *task,bool locked) - __releases(&cgroup_threadgroup_rwsem) +void cgroup_procs_write_finish (struct task_struct *task,bool threadgroup_locked) {struct cgroup_subsys *ss;int ssid;
@@ -2852,8 +2885,8 @@ void cgroup_procs_write_finish(struct task_struct *task, bool locked)/* release reference from cgroup_procs_write_start() */ put_task_struct (task); -if (locked) -percpu_up_write (&cgroup_threadgroup_rwsem); +cgroup_attach_unlock (threadgroup_locked); +for_each_subsys (ss, ssid)if (ss->post_attach) ss->post_attach ();
@@ -2930,8 +2963,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)* write-locking can be skipped safely. */ has_tasks = !list_empty (&mgctx.preloaded_src_csets); -if (has_tasks) -percpu_down_write (&cgroup_threadgroup_rwsem); +cgroup_attach_lock (has_tasks);/* NULL dst indicates self on default hierarchy */ ret =cgroup_migrate_prepare_dst (&mgctx);
@@ -2952,8 +2984,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp) ret =cgroup_migrate_execute (&mgctx); out_finish:cgroup_migrate_finish (&mgctx); -if (has_tasks) -percpu_up_write (&cgroup_threadgroup_rwsem); +cgroup_attach_unlock (has_tasks);return ret; }
@@ -4809,13 +4840,13 @@ static ssize_t cgroup_procs_write(struct kernfs_open_file *of,struct task_struct *task;const struct cred *saved_cred;ssize_t ret; -bool locked; +bool threadgroup_locked; dst_cgrp =cgroup_kn_lock_live (of->kn, false);if (!dst_cgrp)return -ENODEV ; - task =cgroup_procs_write_start (buf, true, &locked); + task =cgroup_procs_write_start (buf, true, &threadgroup_locked); ret =PTR_ERR_OR_ZERO (task);if (ret) goto out_unlock;
@@ -4841,7 +4872,7 @@ static ssize_t cgroup_procs_write(struct kernfs_open_file *of, ret =cgroup_attach_task (dst_cgrp, task, true); out_finish: -cgroup_procs_write_finish (task, locked); +cgroup_procs_write_finish (task, threadgroup_locked); out_unlock:cgroup_kn_unlock (of->kn);
kernel/cgroup/cpuset.c +1 -2
@@ -2212,7 +2212,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)cgroup_taskset_first (tset, &css); cs =css_cs (css); -cpus_read_lock (); +lockdep_assert_cpus_held ();/* see cgroup_attach_lock() */ percpu_down_write (&cpuset_rwsem);/* prepare for attach */
@@ -2268,7 +2268,6 @@ static void cpuset_attach(struct cgroup_taskset *tset)wake_up (&cpuset_attach_wq);percpu_up_write (&cpuset_rwsem); -cpus_read_unlock (); }/* The various types of files and directories in a cpuset file system */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 35/79 cifs: remove useless parameter is_fsctl from SMB2_ioctl()
In reply to Greg Kroah-HartmanFrom: Enzo Matsumiya <[email protected]>
[ Upstream commit 400d0ad63b190895e29f43bc75b1260111d3fd34 ]
SMB2_ioctl() is always called with is_fsctl = true, so doesn't make any sense to have it at all.
Thus, always set SMB2_0_IOCTL_IS_FSCTL flag on the request.
Also, as per MS-SMB2 3.3.5.15 "Receiving an SMB2 IOCTL Request", servers must fail the request if the request flags is zero anyway.
--- fs/cifs/smb2file.c | 1 - fs/cifs/smb2ops.c | 35 +++++++++++++---------------------- fs/cifs/smb2pdu.c | 20 +++++++++----------- fs/cifs/smb2proto.h | 4 ++-- 4 files changed, 24 insertions(+), 36 deletions(-)
fs/cifs/smb2file.c +0 -1
@@ -74,7 +74,6 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, nr_ioctl_req.Reserved =0 ; rc =SMB2_ioctl (xid, oparms->tcon, fid->persistent_fid, fid->volatile_fid,FSCTL_LMR_REQUEST_RESILIENCY , - true/* is_fsctl */ , (char *)&nr_ioctl_req,sizeof (nr_ioctl_req), CIFSMaxBufSize,NULL ,NULL /* no return info */ );if (rc == -EOPNOTSUPP ) {
fs/cifs/smb2ops.c +13 -22
@@ -587,7 +587,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)struct cifs_ses *ses = tcon->ses; rc =SMB2_ioctl (xid, tcon,NO_FILE_ID ,NO_FILE_ID , -FSCTL_QUERY_NETWORK_INTERFACE_INFO , true/* is_fsctl */ , +FSCTL_QUERY_NETWORK_INTERFACE_INFO ,NULL /* no data input */ ,0 /* no data input */ , CIFSMaxBufSize, (char **)&out_buf, &ret_data_len);if (rc == -EOPNOTSUPP ) {
@@ -1470,9 +1470,8 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,struct resume_key_req *res_key; rc =SMB2_ioctl (xid, tcon, persistent_fid, volatile_fid, -FSCTL_SRV_REQUEST_RESUME_KEY , true/* is_fsctl */ , -NULL ,0 /* no input */ , CIFSMaxBufSize, - (char **)&res_key, &ret_data_len); +FSCTL_SRV_REQUEST_RESUME_KEY ,NULL ,0 /* no input */ , + CIFSMaxBufSize, (char **)&res_key, &ret_data_len);if (rc) {cifs_tcon_dbg (VFS ,"refcpy ioctl error %d getting resume key\n" , rc);
@@ -1611,7 +1610,7 @@ smb2_ioctl_query_info(const unsigned int xid, rqst[1 ].rq_nvec =SMB2_IOCTL_IOV_SIZE ; rc =SMB2_ioctl_init (tcon, server, &rqst[1 ],COMPOUND_FID ,COMPOUND_FID , - qi.info_type, true, buffer, qi.output_buffer_length, + qi.info_type, buffer, qi.output_buffer_length, CIFSMaxBufSize -MAX_SMB2_CREATE_RESPONSE_SIZE -MAX_SMB2_CLOSE_RESPONSE_SIZE ); free_req1_func = SMB2_ioctl_free;
@@ -1787,9 +1786,8 @@ smb2_copychunk_range(const unsigned int xid, retbuf =NULL ; rc =SMB2_ioctl (xid, tcon, trgtfile->fid.persistent_fid, trgtfile->fid.volatile_fid,FSCTL_SRV_COPYCHUNK_WRITE , - true/* is_fsctl */ , (char *)pcchunk, -sizeof (struct copychunk_ioctl ), CIFSMaxBufSize, - (char **)&retbuf, &ret_data_len); + (char *)pcchunk,sizeof (struct copychunk_ioctl ), + CIFSMaxBufSize, (char **)&retbuf, &ret_data_len);if (rc ==0 ) {if (ret_data_len !=sizeof (struct copychunk_ioctl_rsp )) {
@@ -1949,7 +1947,6 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid,FSCTL_SET_SPARSE , - true/* is_fctl */ , &setsparse,1 , CIFSMaxBufSize,NULL ,NULL );if (rc) { tcon->broken_sparse_sup = true;
@@ -2032,7 +2029,6 @@ smb2_duplicate_extents(const unsigned int xid, rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, trgtfile->fid.volatile_fid, FSCTL_DUPLICATE_EXTENTS_TO_FILE, - true /* is_fsctl */, (char *)&dup_ext_buf, sizeof(struct duplicate_extents_to_file), CIFSMaxBufSize, NULL,
@@ -2067,7 +2063,6 @@ smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon, return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, FSCTL_SET_INTEGRITY_INFORMATION, - true /* is_fsctl */, (char *)&integr_info, sizeof(struct fsctl_set_integrity_information_req), CIFSMaxBufSize, NULL,
@@ -2120,7 +2115,6 @@ smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid,FSCTL_SRV_ENUMERATE_SNAPSHOTS , - true/* is_fsctl */ ,NULL ,0 /* no input data */ , max_response_size, (char **)&retbuf, &ret_data_len);
@@ -2762,7 +2756,6 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,do { rc =SMB2_ioctl (xid, tcon,NO_FILE_ID ,NO_FILE_ID ,FSCTL_DFS_GET_REFERRALS , - true/* is_fsctl */ , (char *)dfs_req, dfs_req_size, CIFSMaxBufSize, (char **)&dfs_rsp, &dfs_rsp_size); }while (rc == -EAGAIN );
@@ -2964,8 +2957,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_ioctl_init (tcon, server, &rqst[1 ], fid.persistent_fid, - fid.volatile_fid,FSCTL_GET_REPARSE_POINT , - true/* is_fctl */ ,NULL ,0 , + fid.volatile_fid,FSCTL_GET_REPARSE_POINT ,NULL ,0 , CIFSMaxBufSize -MAX_SMB2_CREATE_RESPONSE_SIZE -MAX_SMB2_CLOSE_RESPONSE_SIZE );
@@ -3145,8 +3137,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_ioctl_init (tcon, server, &rqst[1 ],COMPOUND_FID , -COMPOUND_FID ,FSCTL_GET_REPARSE_POINT , - true/* is_fctl */ ,NULL ,0 , +COMPOUND_FID ,FSCTL_GET_REPARSE_POINT ,NULL ,0 , CIFSMaxBufSize -MAX_SMB2_CREATE_RESPONSE_SIZE -MAX_SMB2_CLOSE_RESPONSE_SIZE );
@@ -3409,7 +3400,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, fsctl_buf.BeyondFinalZero =cpu_to_le64 (offset + len); rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, - cfile->fid.volatile_fid,FSCTL_SET_ZERO_DATA , true, + cfile->fid.volatile_fid,FSCTL_SET_ZERO_DATA , (char *)&fsctl_buf,sizeof (struct file_zero_data_information ),0 ,NULL ,NULL );
@@ -3471,7 +3462,7 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid,FSCTL_SET_ZERO_DATA , - true/* is_fctl */ , (char *)&fsctl_buf, + (char *)&fsctl_buf,sizeof (struct file_zero_data_information ), CIFSMaxBufSize,NULL ,NULL );free_xid (xid);
@@ -3530,7 +3521,7 @@ static int smb3_simple_fallocate_range(unsigned int xid, in_data.length =cpu_to_le64 (len); rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, -FSCTL_QUERY_ALLOCATED_RANGES , true, +FSCTL_QUERY_ALLOCATED_RANGES , (char *)&in_data,sizeof (in_data),1024 *sizeof (struct file_allocated_range_buffer ), (char **)&out_data, &out_data_len);
@@ -3771,7 +3762,7 @@ static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offs rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, -FSCTL_QUERY_ALLOCATED_RANGES , true, +FSCTL_QUERY_ALLOCATED_RANGES , (char *)&in_data,sizeof (in_data),sizeof (struct file_allocated_range_buffer ), (char **)&out_data, &out_data_len);
@@ -3831,7 +3822,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon, rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, -FSCTL_QUERY_ALLOCATED_RANGES , true, +FSCTL_QUERY_ALLOCATED_RANGES , (char *)&in_data,sizeof (in_data),1024 *sizeof (struct file_allocated_range_buffer ), (char **)&out_data, &out_data_len);
fs/cifs/smb2pdu.c +9 -11
@@ -1081,7 +1081,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) } rc =SMB2_ioctl (xid, tcon,NO_FILE_ID ,NO_FILE_ID , -FSCTL_VALIDATE_NEGOTIATE_INFO , true/* is_fsctl */ , +FSCTL_VALIDATE_NEGOTIATE_INFO , (char *)pneg_inbuf, inbuflen, CIFSMaxBufSize, (char **)&pneg_rsp, &rsplen);if (rc == -EOPNOTSUPP ) {
@@ -2922,7 +2922,7 @@ int SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, struct smb_rqst *rqst, u64 persistent_fid, u64 volatile_fid, u32 opcode, - bool is_fsctl, char *in_data, u32 indatalen, + char *in_data, u32 indatalen, __u32 max_response_size) { struct smb2_ioctl_req *req;
@@ -2997,10 +2997,8 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, req->sync_hdr.CreditCharge =cpu_to_le16 (DIV_ROUND_UP (max (indatalen, max_response_size),SMB2_MAX_BUFFER_SIZE )); -if (is_fsctl) - req->Flags =cpu_to_le32 (SMB2_0_IOCTL_IS_FSCTL ); -else - req->Flags =0 ; +/* always an FSCTL (for now) */ + req->Flags =cpu_to_le32 (SMB2_0_IOCTL_IS_FSCTL );/* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ if (opcode ==FSCTL_VALIDATE_NEGOTIATE_INFO )
@@ -3027,9 +3025,9 @@ SMB2_ioctl_free(struct smb_rqst *rqst)*/ int SMB2_ioctl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, -u64 volatile_fid,u32 opcode,bool is_fsctl, -char *in_data,u32 indatalen,u32 max_out_data_len, -char **out_data,u32 *plen/* returned data len */ ) +u64 volatile_fid,u32 opcode,char *in_data,u32 indatalen, +u32 max_out_data_len,char **out_data, +u32 *plen/* returned data len */ ) {struct smb_rqst rqst;struct smb2_ioctl_rsp *rsp =NULL ;
@@ -3071,7 +3069,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, rc =SMB2_ioctl_init (tcon, server, &rqst, persistent_fid, volatile_fid, opcode, - is_fsctl, in_data, indatalen, max_out_data_len); + in_data, indatalen, max_out_data_len);if (rc) goto ioctl_exit;
@@ -3153,7 +3151,7 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,cpu_to_le16 (COMPRESSION_FORMAT_DEFAULT ); rc =SMB2_ioctl (xid, tcon, persistent_fid, volatile_fid, -FSCTL_SET_COMPRESSION , true/* is_fsctl */ , +FSCTL_SET_COMPRESSION , (char *)&fsctl_input/* data input */ ,2 /* in data len */ , CIFSMaxBufSize/* max out data */ , &ret_data/* out data */ ,NULL );
fs/cifs/smb2proto.h +2 -2
@@ -155,13 +155,13 @@ extern int SMB2_open_init(struct cifs_tcon *tcon,extern void SMB2_open_free (struct smb_rqst *rqst);extern int SMB2_ioctl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,u32 opcode, -bool is_fsctl,char *in_data,u32 indatalen,u32 maxoutlen, +char *in_data,u32 indatalen,u32 maxoutlen,char **out_data,u32 *plen/* returned data len */ );extern int SMB2_ioctl_init (struct cifs_tcon *tcon,struct TCP_Server_Info *server,struct smb_rqst *rqst,u64 persistent_fid,u64 volatile_fid,u32 opcode, -bool is_fsctl,char *in_data,u32 indatalen, +char *in_data,u32 indatalen,__u32 max_response_size);extern void SMB2_ioctl_free (struct smb_rqst *rqst); extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 36/79 smb3: missing inode locks in punch hole
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit ba0803050d610d5072666be727bca5e03e55b242 ]
smb3 fallocate punch hole was not grabbing the inode or filemap_invalidate locks so could have race with pagemap reinstantiating the page.
--- fs/cifs/smb2ops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/cifs/smb2ops.c +5 -5
@@ -3430,7 +3430,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,static long smb3_punch_hole (struct file *file,struct cifs_tcon *tcon,loff_t offset,loff_t len) { -struct inode *inode; +struct inode *inode =file_inode (file);struct cifsFileInfo *cfile = file->private_data;struct file_zero_data_information fsctl_buf;long rc;
@@ -3439,14 +3439,12 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, xid =get_xid (); - inode =d_inode (cfile->dentry); - +inode_lock (inode);/* Need to make file sparse, if not already, before freeing range. */ /* Consider adding equivalent for compressed since it could also work */ if (!smb2_set_sparse (xid, tcon, cfile, inode, set_sparse)) { rc = -EOPNOTSUPP ; -free_xid (xid); -return rc; + goto out; }/*
@@ -3465,6 +3463,8 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, (char *)&fsctl_buf,sizeof (struct file_zero_data_information ), CIFSMaxBufSize, NULL, NULL); +out: +inode_unlock (inode);free_xid (xid);return rc; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 37/79 ARM: dts: imx6qdl-kontron-samx6i: remove duplicated node
In reply to Greg Kroah-HartmanFrom: Marco Felsch <[email protected]>
[ Upstream commit 204f67d86f55dd4fa757ed04757d7273f71a169c ]
The regulator node 'regulator-3p3v-s0' was dupplicated. Remove it to clean the DTS.
--- arch/arm/boot/dts/imx6qdl-kontron-samx6i.dtsi | 10 ---------- 1 file changed, 10 deletions(-)
arch/arm/boot/dts/imx6qdl-kontron-samx6i.dtsi +0 -10
@@ -51,16 +51,6 @@ vin-supply = <®_3p3v_s5>; }; - reg_3p3v_s0: regulator-3p3v-s0 { - compatible = "regulator-fixed"; - regulator-name = "V_3V3_S0"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - regulator-boot-on; - vin-supply = <®_3p3v_s5>; - }; - reg_3p3v_s5: regulator-3p3v-s5 { compatible = "regulator-fixed"; regulator-name = "V_3V3_S5";
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 38/79 regulator: core: Clean up on enable failure
In reply to Greg Kroah-HartmanFrom: Andrew Halaney <[email protected]>
[ Upstream commit c32f1ebfd26bece77141257864ed7b4720da1557 ]
If regulator_enable() fails, enable_count is incremented still. A consumer, assuming no matching regulator_disable() is necessary on failure, will then get this error message upon regulator_put() since enable_count is non-zero:
[ 1.277418] WARNING: CPU: 3 PID: 1 at drivers/regulator/core.c:2304 _regulator_put.part.0+0x168/0x170
The consumer could try to fix this in their driver by cleaning up on error from regulator_enable() (i.e. call regulator_disable()), but that results in the following since regulator_enable() failed and didn't increment user_count:
[ 1.258112] unbalanced disables for vreg_l17c
[ 1.262606] WARNING: CPU: 4 PID: 1 at drivers/regulator/core.c:2899 _regulator_disable+0xd4/0x190Fix this by decrementing enable_count upon failure to enable.
With this in place, just the reason for failure to enable is printed as expected and developers can focus on the root cause of their issue instead of thinking their usage of the regulator consumer api is incorrect. For example, in my case:
[ 1.240426] vreg_l17c: invalid input voltage found
--- drivers/regulator/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/regulator/core.c +7 -2
@@ -2596,13 +2596,18 @@ static int _regulator_do_enable(struct regulator_dev *rdev)*/ static int _regulator_handle_consumer_enable (struct regulator *regulator) { +int ret;struct regulator_dev *rdev = regulator->rdev;lockdep_assert_held_once (&rdev->mutex.base); regulator->enable_count++; -if (regulator->uA_load && regulator->enable_count ==1 ) -return drms_uA_update (rdev); +if (regulator->uA_load && regulator->enable_count ==1 ) { + ret =drms_uA_update (rdev); +if (ret) + regulator->enable_count--; +return ret; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 39/79 tee: fix compiler warning in tee_shm_register()
In reply to Greg Kroah-HartmanFrom: Jens Wiklander <[email protected]>
[ Upstream commit eccd7439709810127563e7e3e49b8b44c7b2791d ]
Include <linux/uaccess.h> to avoid the warning:
drivers/tee/tee_shm.c: In function 'tee_shm_register':
Quoted 1 line
Quoted 1 line
drivers/tee/tee_shm.c:242:14: error: implicit declaration of function 'access_ok' [-Werror=implicit-function-declaration]
242 | if (!access_ok((void __user *)addr, length))
| ^~~~~~~~~cc1: some warnings being treated as errors
--- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+)
drivers/tee/tee_shm.c +1 -0
@@ -9,6 +9,7 @@#include <linux/sched.h> #include <linux/slab.h> #include <linux/tee_drv.h> +#include <linux/uaccess.h> #include <linux/uio.h> #include "tee_private.h"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 40/79 RDMA/cma: Fix arguments order in net device validation
In reply to Greg Kroah-HartmanFrom: Michael Guralnik <[email protected]>
[ Upstream commit 27cfde795a96aef1e859a5480489944b95421e46 ]
Fix the order of source and destination addresses when resolving the route between server and client to validate use of correct net device.
The reverse order we had so far didn't actually validate the net device as the server would try to resolve the route to itself, thus always getting the server's net device.
The issue was discovered when running cm applications on a single host between 2 interfaces with same subnet and source based routing rules. When resolving the reverse route the source based route rules were ignored.
--- drivers/infiniband/core/cma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/cma.c +2 -2
@@ -1722,8 +1722,8 @@ cma_ib_id_from_event(struct ib_cm_id *cm_id, }if (!validate_net_dev (*net_dev, - (struct sockaddr *)&req->listen_addr_storage, - (struct sockaddr *)&req->src_addr_storage)) { + (struct sockaddr *)&req->src_addr_storage, + (struct sockaddr *)&req->listen_addr_storage)) { id_priv =ERR_PTR (-EHOSTUNREACH ); goto err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 41/79 soc: brcmstb: pm-arm: Fix refcount leak and __iomem leak bugs
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 1085f5080647f0c9f357c270a537869191f7f2a1 ]
In brcmstb_pm_probe(), there are two kinds of leak bugs:
(1) we need to add of_node_put() when for_each__matching_node() breaks
(2) we need to add iounmap() for each iomap in fail path
--- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 50 ++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-)
drivers/soc/bcm/brcmstb/pm/pm-arm.c +39 -11
@@ -681,13 +681,14 @@ static int brcmstb_pm_probe(struct platform_device *pdev)const struct of_device_id *of_id =NULL ;struct device_node *dn;void __iomem *base; -int ret, i; +int ret, i, s;/* AON ctrl registers */ base =brcmstb_ioremap_match (aon_ctrl_dt_ids,0 ,NULL );if (IS_ERR (base)) {pr_err ("error mapping AON_CTRL\n" ); -return PTR_ERR (base); + ret =PTR_ERR (base); + goto aon_err; } ctrl.aon_ctrl_base = base;
@@ -697,8 +698,10 @@ static int brcmstb_pm_probe(struct platform_device *pdev)/* Assume standard offset */ ctrl.aon_sram = ctrl.aon_ctrl_base +AON_CTRL_SYSTEM_DATA_RAM_OFS ; + s =0 ; }else { ctrl.aon_sram = base; + s =1 ; }writel_relaxed (0 , ctrl.aon_sram +AON_REG_PANIC );
@@ -708,7 +711,8 @@ static int brcmstb_pm_probe(struct platform_device *pdev) (const void **)&ddr_phy_data);if (IS_ERR (base)) {pr_err ("error mapping DDR PHY\n" ); -return PTR_ERR (base); + ret =PTR_ERR (base); + goto ddr_phy_err; } ctrl.support_warm_boot = ddr_phy_data->supports_warm_boot; ctrl.pll_status_offset = ddr_phy_data->pll_status_offset;
@@ -728,17 +732,20 @@ static int brcmstb_pm_probe(struct platform_device *pdev)for_each_matching_node (dn, ddr_shimphy_dt_ids) { i = ctrl.num_memc;if (i >=MAX_NUM_MEMC ) { +of_node_put (dn);pr_warn ("too many MEMCs (max %d)\n" ,MAX_NUM_MEMC );break ; } base =of_io_request_and_map (dn,0 , dn->full_name);if (IS_ERR (base)) { +of_node_put (dn);if (!ctrl.support_warm_boot)break ;pr_err ("error mapping DDR SHIMPHY %d\n" , i); -return PTR_ERR (base); + ret =PTR_ERR (base); + goto ddr_shimphy_err; } ctrl.memcs[i].ddr_shimphy_base = base; ctrl.num_memc++;
@@ -749,14 +756,18 @@ static int brcmstb_pm_probe(struct platform_device *pdev)for_each_matching_node (dn, brcmstb_memc_of_match) { base =of_iomap (dn,0 );if (!base) { +of_node_put (dn);pr_err ("error mapping DDR Sequencer %d\n" , i); -return -ENOMEM ; + ret = -ENOMEM ; + goto brcmstb_memc_err; } of_id =of_match_node (brcmstb_memc_of_match, dn);if (!of_id) {iounmap (base); -return -EINVAL ; +of_node_put (dn); + ret = -EINVAL ; + goto brcmstb_memc_err; } ddr_seq_data = of_id->data;
@@ -776,21 +787,24 @@ static int brcmstb_pm_probe(struct platform_device *pdev) dn =of_find_matching_node (NULL , sram_dt_ids);if (!dn) {pr_err ("SRAM not found\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto brcmstb_memc_err; } ret =brcmstb_init_sram (dn);of_node_put (dn);if (ret) {pr_err ("error setting up SRAM for PM\n" ); -return ret; + goto brcmstb_memc_err; } ctrl.pdev = pdev; ctrl.s3_params =kmalloc (sizeof (*ctrl.s3_params),GFP_KERNEL ); -if (!ctrl.s3_params) -return -ENOMEM ; +if (!ctrl.s3_params) { + ret = -ENOMEM ; + goto s3_params_err; + } ctrl.s3_params_pa =dma_map_single (&pdev->dev, ctrl.s3_params,sizeof (*ctrl.s3_params),DMA_TO_DEVICE );
@@ -810,7 +824,21 @@ static int brcmstb_pm_probe(struct platform_device *pdev) out:kfree (ctrl.s3_params); - +s3_params_err: +iounmap (ctrl.boot_sram); +brcmstb_memc_err: +for (i--; i >=0 ; i--) +iounmap (ctrl.memcs[i].ddr_ctrl); +ddr_shimphy_err: +for (i =0 ; i < ctrl.num_memc; i++) +iounmap (ctrl.memcs[i].ddr_shimphy_base); + +iounmap (ctrl.memcs[0 ].ddr_phy_base); +ddr_phy_err: +iounmap (ctrl.aon_ctrl_base); +if (s) +iounmap (ctrl.aon_sram); +aon_err:pr_warn ("PM: initialization failed with code %d\n" , ret);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 42/79 RDMA/hns: Fix supported page size
In reply to Greg Kroah-HartmanFrom: Chengchang Tang <[email protected]>
[ Upstream commit 55af9d498556f0860eb89ffa7677e8d73f6f643f ]
The supported page size for hns is (4K, 128M), not (4K, 2G).
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +1 -1
@@ -92,7 +92,7 @@#define HNS_ROCE_V2_QPC_TIMER_ENTRY_SZ PAGE_SIZE#define HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ PAGE_SIZE -#define HNS_ROCE_V2_PAGE_SIZE_SUPPORTED 0xFFFFF000 +#define HNS_ROCE_V2_PAGE_SIZE_SUPPORTED 0xFFFF000#define HNS_ROCE_V2_MAX_INNER_MTPT_NUM 2#define HNS_ROCE_INVALID_LKEY 0x100#define HNS_ROCE_CMQ_TX_TIMEOUT 30000
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 43/79 RDMA/hns: Fix wrong fixed value of qp->rq.wqe_shift
In reply to Greg Kroah-HartmanFrom: Wenpeng Liang <[email protected]>
[ Upstream commit 0c8b5d6268d92d141bfd64d21c870d295a84dee1 ]
The value of qp->rq.wqe_shift of HIP08 is always determined by the number of sge. So delete the wrong branch.
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -5
@@ -386,11 +386,8 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap, hr_qp->rq.max_gs =roundup_pow_of_two (max (1U , cap->max_recv_sge)); -if (hr_dev->caps.max_rq_sg <=HNS_ROCE_SGE_IN_WQE ) - hr_qp->rq.wqe_shift =ilog2 (hr_dev->caps.max_rq_desc_sz); -else - hr_qp->rq.wqe_shift =ilog2 (hr_dev->caps.max_rq_desc_sz * - hr_qp->rq.max_gs); + hr_qp->rq.wqe_shift =ilog2 (hr_dev->caps.max_rq_desc_sz * + hr_qp->rq.max_gs); hr_qp->rq.wqe_cnt = cnt;if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_RQ_INLINE )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 44/79 ARM: dts: at91: sama5d27_wlsom1: specify proper regulator output ranges
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit addf7efec23af2b67547800aa232d551945e7de2 ]
Min and max output ranges of regulators need to satisfy board requirements not PMIC requirements. Thus adjust device tree to cope with this.
--- arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi +10 -10
@@ -62,8 +62,8 @@ regulators { vdd_3v3: VDD_IO { regulator-name = "VDD_IO"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -81,8 +81,8 @@ vddio_ddr: VDD_DDR { regulator-name = "VDD_DDR"; - regulator-min-microvolt = <600000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -104,8 +104,8 @@ vdd_core: VDD_CORE { regulator-name = "VDD_CORE"; - regulator-min-microvolt = <600000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <1250000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -146,8 +146,8 @@ LDO1 { regulator-name = "LDO1"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; regulator-always-on; regulator-state-standby {
@@ -161,8 +161,8 @@ LDO2 { regulator-name = "LDO2"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; regulator-always-on; regulator-state-standby {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 45/79 ARM: dts: at91: sama5d2_icp: specify proper regulator output ranges
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 7737d93666eea282febf95e5fa3b3fde1f2549f3 ]
Min and max output ranges of regulators need to satisfy board requirements not PMIC requirements. Thus adjust device tree to cope with this.
--- arch/arm/boot/dts/at91-sama5d2_icp.dts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/boot/dts/at91-sama5d2_icp.dts +10 -10
@@ -195,8 +195,8 @@ regulators { vdd_io_reg: VDD_IO { regulator-name = "VDD_IO"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -214,8 +214,8 @@ VDD_DDR { regulator-name = "VDD_DDR"; - regulator-min-microvolt = <600000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -233,8 +233,8 @@ VDD_CORE { regulator-name = "VDD_CORE"; - regulator-min-microvolt = <600000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <1250000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; regulator-always-on;
@@ -271,8 +271,8 @@ LDO1 { regulator-name = "LDO1"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <2500000>; regulator-always-on; regulator-state-standby {
@@ -286,8 +286,8 @@ LDO2 { regulator-name = "LDO2"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3700000>; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; regulator-always-on; regulator-state-standby {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 46/79 ARM: dts: at91: sama5d27_wlsom1: dont keep ldo2 enabled all the time
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 617a0d9fe6867bf5b3b7272629cd780c27c877d9 ]
ldo2 is not used by any consumer on sama5d27_wlsom1 board, thus don't keep it enabled all the time.
--- arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi +0 -1
@@ -163,7 +163,6 @@ regulator-name = "LDO2"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; - regulator-always-on; regulator-state-standby { regulator-on-in-suspend;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 47/79 ARM: dts: at91: sama5d2_icp: dont keep vdd_other enabled all the time
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 3d074b750d2b4c91962f10ea1df1c289ce0d3ce8 ]
VDD_OTHER is not connected to any on board consumer thus it is not needed to keep it enabled all the time.
--- arch/arm/boot/dts/at91-sama5d2_icp.dts | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/at91-sama5d2_icp.dts +0 -1
@@ -256,7 +256,6 @@ regulator-max-microvolt = <1850000>; regulator-initial-mode = <2>; regulator-allowed-modes = <2>, <4>; - regulator-always-on; regulator-state-standby { regulator-on-in-suspend;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 48/79 netfilter: br_netfilter: Drop dst references before setting.
In reply to Greg Kroah-HartmanFrom: Harsh Modi <[email protected]>
[ Upstream commit d047283a7034140ea5da759a494fd2274affdd46 ]
The IPv6 path already drops dst in the daddr changed case, but the IPv4 path does not. This change makes the two code paths consistent.
Further, it is possible that there is already a metadata_dst allocated from ingress that might already be attached to skbuff->dst while following the bridge path. If it is not released before setting a new metadata_dst, it will be leaked. This is similar to what is done in bpf_set_tunnel_key() or ip6_route_input().
It is important to note that the memory being leaked is not the dst being set in the bridge code, but rather memory allocated from some other code path that is not being freed correctly before the skb dst is overwritten.
An example of the leakage fixed by this commit found using kmemleak:
unreferenced object 0xffff888010112b00 (size 256):
comm "softirq", pid 0, jiffies 4294762496 (age 32.012s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 80 16 f1 83 ff ff ff ff ................
e1 4e f6 82 ff ff ff ff 00 00 00 00 00 00 00 00 .N..............
backtrace:
[<00000000d79567ea>] metadata_dst_alloc+0x1b/0xe0
[<00000000be113e13>] udp_tun_rx_dst+0x174/0x1f0
[<00000000a36848f4>] geneve_udp_encap_recv+0x350/0x7b0
[<00000000d4afb476>] udp_queue_rcv_one_skb+0x380/0x560
[<00000000ac064aea>] udp_unicast_rcv_skb+0x75/0x90
[<000000009a8ee8c5>] ip_protocol_deliver_rcu+0xd8/0x230
[<00000000ef4980bb>] ip_local_deliver_finish+0x7a/0xa0
[<00000000d7533c8c>] __netif_receive_skb_one_core+0x89/0xa0
[<00000000a879497d>] process_backlog+0x93/0x190
[<00000000e41ade9f>] __napi_poll+0x28/0x170
[<00000000b4c0906b>] net_rx_action+0x14f/0x2a0
[<00000000b20dd5d4>] __do_softirq+0xf4/0x305
[<000000003a7d7e15>] __irq_exit_rcu+0xc3/0x140
[<00000000968d39a2>] sysvec_apic_timer_interrupt+0x9e/0xc0
[<000000009e920794>] asm_sysvec_apic_timer_interrupt+0x16/0x20
[<000000008942add0>] native_safe_halt+0x13/0x20Florian Westphal says: "Original code was likely fine because nothing ever did set a skb->dst entry earlier than bridge in those days."
--- net/bridge/br_netfilter_hooks.c | 2 ++ net/bridge/br_netfilter_ipv6.c | 1 + 2 files changed, 3 insertions(+)
net/bridge/br_netfilter_hooks.c +2 -0
@@ -384,6 +384,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_/* - Bridged-and-DNAT'ed traffic doesn't * require ip_forwarding. */ if (rt->dst.dev == dev) { +skb_dst_drop (skb);skb_dst_set (skb, &rt->dst); goto bridged_dnat; }
@@ -413,6 +414,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_kfree_skb (skb);return 0 ; } +skb_dst_drop (skb);skb_dst_set_noref (skb, &rt->dst); }
net/bridge/br_netfilter_ipv6.c +1 -0
@@ -197,6 +197,7 @@ static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struckfree_skb (skb);return 0 ; } +skb_dst_drop (skb);skb_dst_set_noref (skb, &rt->dst); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 49/79 netfilter: nf_tables: clean up hook list when offload flags check fails
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 77972a36ecc4db7fc7c68f0e80714263c5f03f65 ]
splice back the hook list so nft_chain_release_hook() has a chance to release the hooks.
BUG: memory leak
unreferenced object 0xffff88810180b100 (size 96):
comm "syz-executor133", pid 3619, jiffies 4294945714 (age 12.690s)
hex dump (first 32 bytes):
28 64 23 02 81 88 ff ff 28 64 23 02 81 88 ff ff (d#.....(d#.....
90 a8 aa 83 ff ff ff ff 00 00 b5 0f 81 88 ff ff ................
backtrace:
[<ffffffff83a8c59b>] kmalloc include/linux/slab.h:600 [inline]
[<ffffffff83a8c59b>] nft_netdev_hook_alloc+0x3b/0xc0 net/netfilter/nf_tables_api.c:1901
[<ffffffff83a9239a>] nft_chain_parse_netdev net/netfilter/nf_tables_api.c:1998 [inline]
[<ffffffff83a9239a>] nft_chain_parse_hook+0x33a/0x530 net/netfilter/nf_tables_api.c:2073
[<ffffffff83a9b14b>] nf_tables_addchain.constprop.0+0x10b/0x950 net/netfilter/nf_tables_api.c:2218
[<ffffffff83a9c41b>] nf_tables_newchain+0xa8b/0xc60 net/netfilter/nf_tables_api.c:2593
[<ffffffff83a3d6a6>] nfnetlink_rcv_batch+0xa46/0xd20 net/netfilter/nfnetlink.c:517
[<ffffffff83a3db79>] nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:638 [inline]
[<ffffffff83a3db79>] nfnetlink_rcv+0x1f9/0x220 net/netfilter/nfnetlink.c:656
[<ffffffff83a13b17>] netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
[<ffffffff83a13b17>] netlink_unicast+0x397/0x4c0 net/netlink/af_netlink.c:1345
[<ffffffff83a13fd6>] netlink_sendmsg+0x396/0x710 net/netlink/af_netlink.c:1921
[<ffffffff83865ab6>] sock_sendmsg_nosec net/socket.c:714 [inline]
[<ffffffff83865ab6>] sock_sendmsg+0x56/0x80 net/socket.c:734
[<ffffffff8386601c>] ____sys_sendmsg+0x36c/0x390 net/socket.c:2482
[<ffffffff8386a918>] ___sys_sendmsg+0xa8/0x110 net/socket.c:2536
[<ffffffff8386aaa8>] __sys_sendmsg+0x88/0x100 net/socket.c:2565
[<ffffffff845e5955>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff845e5955>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +3 -1
@@ -1971,8 +1971,10 @@ static int nft_basechain_init(struct nft_base_chain *basechain, u8 family, chain->flags |=NFT_CHAIN_BASE | flags; basechain->policy =NF_ACCEPT ;if (chain->flags &NFT_CHAIN_HW_OFFLOAD && - !nft_chain_offload_support (basechain)) + !nft_chain_offload_support (basechain)) { +list_splice_init (&basechain->hook_list, &hook->list);return -EOPNOTSUPP ; + }flow_block_init (&basechain->flow_block);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 50/79 netfilter: nf_conntrack_irc: Fix forged IP logic
In reply to Greg Kroah-HartmanFrom: David Leadbeater <[email protected]>
[ Upstream commit 0efe125cfb99e6773a7434f3463f7c2fa28f3a43 ]
Ensure the match happens in the right direction, previously the destination used was the server, not the NAT host, as the comment shows the code intended.
Additionally nf_nat_irc uses port 0 as a signal and there's no valid way it can appear in a DCC message, so consider port 0 also forged.
--- net/netfilter/nf_conntrack_irc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_irc.c +3 -2
@@ -185,8 +185,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,/* dcc_ip can be the internal OR external (NAT'ed) IP */ tuple = &ct->tuplehash[dir].tuple; -if (tuple->src.u3.ip != dcc_ip && - tuple->dst.u3.ip != dcc_ip) { +if ((tuple->src.u3.ip != dcc_ip && + ct->tuplehash[!dir].tuple.dst.u3.ip != dcc_ip) || + dcc_port ==0 ) {net_warn_ratelimited ("Forged DCC command from %pI4: %pI4:%u\n" , &tuple->src.u3.ip, &dcc_ip, dcc_port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 51/79 ALSA: usb-audio: Inform the delayed registration more properly
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 7e1afce5866e02b45bf88c27dd7de1b9dfade1cc ]
The info message that was added in the commit a4aad5636c72 ("ALSA:
usb-audio: Inform devices that need delayed registration") is actually useful to know the need for the delayed registration. However, it turned out that this doesn't catch the all cases; namely, this warned only when a PCM stream is attached onto the existing PCM instance, but it doesn't count for a newly created PCM instance. This made confusion as if there were no further delayed registration.
This patch moves the check to the code path for either adding a stream or creating a PCM instance. Also, make it simpler by checking the card->registered flag instead of querying each snd_device state.
--- sound/usb/stream.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/usb/stream.c +4 -3
@@ -496,6 +496,10 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,return 0 ; } } + +if (chip->card->registered) + chip->need_delayed_register = true; +/* look for an empty stream */ list_for_each_entry (as, &chip->pcm_list, list) {if (as->fmt_type != fp->fmt_type)
@@ -503,9 +507,6 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip, subs = &as->substream[stream];if (subs->ep_num)continue ; -if (snd_device_get_state (chip->card, as->pcm) != -SNDRV_DEV_BUILD ) - chip->need_delayed_register = true; err =snd_pcm_new_stream (as->pcm, stream,1 );if (err <0 )return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 52/79 ALSA: usb-audio: Register card again for iface over delayed_register option
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 2027f114686e0f3f1f39971964dfc618637c88c2 ]
When the delayed registration is specified via either delayed_register option or the quirk, we delay the invocation of snd_card_register() until the given interface. But if a wrong value has been set there and there are more interfaces over the given interface number, snd_card_register() call would be missing for those interfaces.
This patch catches up those missing calls by fixing the comparison of the interface number. Now the call is skipped only if the processed interface is less than the given interface, instead of the exact match.
--- sound/usb/card.c | 2 +- sound/usb/quirks.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/usb/card.c +1 -1
@@ -667,7 +667,7 @@ static bool check_delayed_register_option(struct snd_usb_audio *chip, int iface)if (delayed_register[i] &&sscanf (delayed_register[i],"%x:%x" , &id, &inum) ==2 && id == chip->usb_id) -return inum != iface; +return iface < inum; }return false;
sound/usb/quirks.c +1 -1
@@ -1911,7 +1911,7 @@ bool snd_usb_registration_quirk(struct snd_usb_audio *chip, int iface)for (q = registration_quirks; q->usb_id; q++)if (chip->usb_id == q->usb_id) -return iface != q->interface; +return iface < q->interface;/* Register as normal */ return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 53/79 rxrpc: Fix an insufficiently large sglist in rxkad_verify_packet_2()
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 0d40f728e28393a8817d1fcae923dfa3409e488c ]
rxkad_verify_packet_2() has a small stack-allocated sglist of 4 elements, but if that isn't sufficient for the number of fragments in the socket buffer, we try to allocate an sglist large enough to hold all the fragments.
However, for large packets with a lot of fragments, this isn't sufficient and we need at least one additional fragment.
The problem manifests as skb_to_sgvec() returning -EMSGSIZE and this then getting returned by userspace. Most of the time, this isn't a problem as rxrpc sets a limit of 5692, big enough for 4 jumbo subpackets to be glued together; occasionally, however, the server will ignore the reported limit and give a packet that's a lot bigger - say 19852 bytes with ->nr_frags being 7. skb_to_sgvec() then tries to return a "zeroth" fragment that seems to occur before the fragments counted by ->nr_frags and we hit the end of the sglist too early.
Note that __skb_to_sgvec() also has an skb_walk_frags() loop that is recursive up to 24 deep. I'm not sure if I need to take account of that too - or if there's an easy way of counting those frags too.
Fix this by counting an extra frag and allocating a larger sglist based on that.
--- net/rxrpc/rxkad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/rxkad.c +1 -1
@@ -451,7 +451,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,* directly into the target buffer. */ sg = _sg; - nsg =skb_shinfo (skb)->nr_frags; + nsg =skb_shinfo (skb)->nr_frags +1 ;if (nsg <=4 ) { nsg =4 ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 54/79 afs: Use the operation issue time instead of the reply time for callbacks
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 7903192c4b4a82d792cb0dc5e2779a2efe60d45b ]
rxrpc and kafs between them try to use the receive timestamp on the first data packet (ie. the one with sequence number 1) as a base from which to calculate the time at which callback promise and lock expiration occurs.
However, we don't know how long it took for the server to send us the reply from it having completed the basic part of the operation - it might then, for instance, have to send a bunch of a callback breaks, depending on the particular operation.
Fix this by using the time at which the operation is issued on the client as a base instead. That should never be longer than the server's idea of the expiry time.
--- fs/afs/flock.c | 2 +- fs/afs/fsclient.c | 2 +- fs/afs/internal.h | 3 +-- fs/afs/rxrpc.c | 7 +------ fs/afs/yfsclient.c | 3 +-- 5 files changed, 5 insertions(+), 12 deletions(-)
fs/afs/flock.c +1 -1
@@ -76,7 +76,7 @@ void afs_lock_op_done(struct afs_call *call)if (call->error ==0 ) {spin_lock (&vnode->lock);trace_afs_flock_ev (vnode,NULL , afs_flock_timestamp,0 ); - vnode->locked_at = call->reply_time; + vnode->locked_at = call->issue_time;afs_schedule_lock_extension (vnode);spin_unlock (&vnode->lock); }
fs/afs/fsclient.c +1 -1
@@ -130,7 +130,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,static time64_t xdr_decode_expiry (struct afs_call *call,u32 expiry) { -return ktime_divns (call->reply_time,NSEC_PER_SEC ) + expiry; +return ktime_divns (call->issue_time,NSEC_PER_SEC ) + expiry; } static void xdr_decode_AFSCallBack(const __be32 **_bp,
fs/afs/internal.h +1 -2
@@ -135,7 +135,6 @@ struct afs_call {bool need_attention;/* T if RxRPC poked us */ bool async;/* T if asynchronous */ bool upgrade;/* T to request service upgrade */ -bool have_reply_time;/* T if have got reply_time */ bool intr;/* T if interruptible */ bool unmarshalling_error;/* T if an unmarshalling error occurred */ u16 service_id;/* Actual service ID (after upgrade) */
@@ -149,7 +148,7 @@ struct afs_call { } __attribute__((packed));__be64 tmp64; }; -ktime_t reply_time;/* Time of first reply packet */ +ktime_t issue_time;/* Time of issue of operation */ };struct afs_call_type {
fs/afs/rxrpc.c +1 -6
@@ -429,6 +429,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)if (call->max_lifespan)rxrpc_kernel_set_max_life (call->net->socket, rxcall, call->max_lifespan); + call->issue_time =ktime_get_real ();/* send the request */ iov[0 ].iov_base = call->request;
@@ -533,12 +534,6 @@ static void afs_deliver_to_call(struct afs_call *call)return ; } -if (!call->have_reply_time && -rxrpc_kernel_get_reply_time (call->net->socket, - call->rxcall, - &call->reply_time)) - call->have_reply_time = true; - ret = call->type->deliver (call); state =READ_ONCE (call->state);if (ret ==0 && call->unmarshalling_error)
fs/afs/yfsclient.c +1 -2
@@ -239,8 +239,7 @@ static void xdr_decode_YFSCallBack(const __be32 **_bp,struct afs_callback *cb = &scb->callback;ktime_t cb_expiry; - cb_expiry = call->reply_time; - cb_expiry =ktime_add (cb_expiry,xdr_to_u64 (x->expiration_time) *100 ); + cb_expiry =ktime_add (call->issue_time,xdr_to_u64 (x->expiration_time) *100 ); cb->expires_at =ktime_divns (cb_expiry,NSEC_PER_SEC ); scb->have_cb = true; *_bp +=xdr_size (x);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 55/79 sch_sfb: Dont assume the skb is still around after enqueueing to child
In reply to Greg Kroah-HartmanFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 9efd23297cca530bb35e1848665805d3fcdd7889 ]
The sch_sfb enqueue() routine assumes the skb is still alive after it has been enqueued into a child qdisc, using the data in the skb cb field in the increment_qlen() routine after enqueue. However, the skb may in fact have been freed, causing a use-after-free in this case. In particular, this happens if sch_cake is used as a child of sfb, and the GSO splitting mode of CAKE is enabled (in which case the skb will be split into segments and the original skb freed).
Fix this by copying the sfb cb data to the stack before enqueueing the skb, and using this stack copy in increment_qlen() instead of the skb pointer itself.
--- net/sched/sch_sfb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/sched/sch_sfb.c +6 -4
@@ -135,15 +135,15 @@ static void increment_one_qlen(u32 sfbhash, u32 slot, struct sfb_sched_data *q) } } -static void increment_qlen (const struct sk_buff *skb,struct sfb_sched_data *q) +static void increment_qlen (const struct sfb_skb_cb *cb,struct sfb_sched_data *q) {u32 sfbhash; - sfbhash =sfb_hash (skb,0 ); + sfbhash = cb->hashes[0 ];if (sfbhash)increment_one_qlen (sfbhash,0 , q); - sfbhash =sfb_hash (skb,1 ); + sfbhash = cb->hashes[1 ];if (sfbhash)increment_one_qlen (sfbhash,1 , q); }
@@ -283,6 +283,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,struct sfb_sched_data *q =qdisc_priv (sch);struct Qdisc *child = q->qdisc;struct tcf_proto *fl; +struct sfb_skb_cb cb;int i;u32 p_min = ~0 ;u32 minqlen = ~0 ;
@@ -399,11 +400,12 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, } enqueue: +memcpy (&cb,sfb_skb_cb (skb),sizeof (cb)); ret =qdisc_enqueue (skb, child, to_free);if (likely (ret ==NET_XMIT_SUCCESS )) {qdisc_qstats_backlog_inc (sch, skb); sch->q.qlen++; -increment_qlen (skb, q); +increment_qlen (&cb, q); }else if (net_xmit_drop_count (ret)) { q->stats.childdrop++;qdisc_qstats_drop (sch);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 56/79 tipc: fix shift wrapping bug in map_get()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e2b224abd9bf45dcb55750479fc35970725a430b ]
There is a shift wrapping bug in this code so anything thing above 31 will return false.
--- net/tipc/monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/monitor.c +1 -1
@@ -130,7 +130,7 @@ static void map_set(u64 *up_map, int i, unsigned int v)static int map_get (u64 up_map,int i) { -return (up_map & (1 << i)) >> i; +return (up_map & (1ULL << i)) >> i; }static struct tipc_peer *peer_prev (struct tipc_peer *peer)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 57/79 ice: use bitmap_free instead of devm_kfree
In reply to Greg Kroah-HartmanFrom: Michal Swiatkowski <[email protected]>
[ Upstream commit 59ac325557b6c14f1f793b90d3946bc145ffa085 ]
pf->avail_txqs was allocated using bitmap_zalloc, bitmap_free should be used to free this memory.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3404,7 +3404,7 @@ static int ice_init_pf(struct ice_pf *pf) pf->avail_rxqs =bitmap_zalloc (pf->max_pf_rxqs,GFP_KERNEL );if (!pf->avail_rxqs) { -devm_kfree (ice_pf_to_dev (pf), pf->avail_txqs); +bitmap_free (pf->avail_txqs); pf->avail_txqs =NULL ;return -ENOMEM ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 58/79 i40e: Fix kernel crash during module removal
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit fb8396aeda5872369a8ed6d2301e2c86e303c520 ]
The driver incorrectly frees client instance and subsequent i40e module removal leads to kernel crash.
Reproducer:
1. Do ethtool offline test followed immediately by another one host# ethtool -t eth0 offline; ethtool -t eth0 offline
2. Remove recursively irdma module that also removes i40e module host# modprobe -r irdma
Result:
[ 8675.035651] i40e 0000:3d:00.0 eno1: offline testing starting [ 8675.193774] i40e 0000:3d:00.0 eno1: testing finished [ 8675.201316] i40e 0000:3d:00.0 eno1: offline testing starting [ 8675.358921] i40e 0000:3d:00.0 eno1: testing finished [ 8675.496921] i40e 0000:3d:00.0: IRDMA hardware initialization FAILED init_state=2 status=-110 [ 8686.188955] i40e 0000:3d:00.1: i40e_ptp_stop: removed PHC on eno2 [ 8686.943890] i40e 0000:3d:00.1: Deleted LAN device PF1 bus=0x3d dev=0x00 func=0x01 [ 8686.952669] i40e 0000:3d:00.0: i40e_ptp_stop: removed PHC on eno1 [ 8687.761787] BUG: kernel NULL pointer dereference, address: 0000000000000030 [ 8687.768755] #PF: supervisor read access in kernel mode [ 8687.773895] #PF: error_code(0x0000) - not-present page [ 8687.779034] PGD 0 P4D 0 [ 8687.781575] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 8687.785935] CPU: 51 PID: 172891 Comm: rmmod Kdump: loaded Tainted: G W I 5.19.0+ #2 [ 8687.794800] Hardware name: Intel Corporation S2600WFD/S2600WFD, BIOS SE5C620.86B.0X.02.0001.051420190324 05/14/2019 [ 8687.805222] RIP: 0010:i40e_lan_del_device+0x13/0xb0 [i40e] [ 8687.810719] Code: d4 84 c0 0f 84 b8 25 01 00 e9 9c 25 01 00 41 bc f4 ff ff ff eb 91 90 0f 1f 44 00 00 41 54 55 53 48 8b 87 58 08 00 00 48 89 fb <48> 8b 68 30 48 89 ef e8 21 8a 0f d5 48 89 ef e8 a9 78 0f d5 48 8b [ 8687.829462] RSP: 0018:ffffa604072efce0 EFLAGS: 00010202 [ 8687.834689] RAX: 0000000000000000 RBX: ffff8f43833b2000 RCX: 0000000000000000 [ 8687.841821] RDX: 0000000000000000 RSI: ffff8f4b0545b298 RDI: ffff8f43833b2000 [ 8687.848955] RBP: ffff8f43833b2000 R08: 0000000000000001 R09: 0000000000000000 [ 8687.856086] R10: 0000000000000000 R11: 000ffffffffff000 R12: ffff8f43833b2ef0 [ 8687.863218] R13: ffff8f43833b2ef0 R14: ffff915103966000 R15: ffff8f43833b2008 [ 8687.870342] FS: 00007f79501c3740(0000) GS:ffff8f4adffc0000(0000) knlGS:0000000000000000 [ 8687.878427] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8687.884174] CR2: 0000000000000030 CR3: 000000014276e004 CR4: 00000000007706e0 [ 8687.891306] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 8687.898441] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 8687.905572] PKRU: 55555554 [ 8687.908286] Call Trace: [ 8687.910737] <TASK> [ 8687.912843] i40e_remove+0x2c0/0x330 [i40e] [ 8687.917040] pci_device_remove+0x33/0xa0 [ 8687.920962] device_release_driver_internal+0x1aa/0x230 [ 8687.926188] driver_detach+0x44/0x90 [ 8687.929770] bus_remove_driver+0x55/0xe0 [ 8687.933693] pci_unregister_driver+0x2a/0xb0 [ 8687.937967] i40e_exit_module+0xc/0xf48 [i40e]
Two offline tests cause IRDMA driver failure (ETIMEDOUT) and this failure is indicated back to i40e_client_subtask() that calls i40e_client_del_instance() to free client instance referenced by pf->cinst and sets this pointer to NULL. During the module removal i40e_remove() calls i40e_lan_del_device() that dereferences pf->cinst that is NULL -> crash.
Do not remove client instance when client open callbacks fails and just clear __I40E_CLIENT_INSTANCE_OPENED bit. The driver also needs to take care about this situation (when netdev is up and client is NOT opened) in i40e_notify_client_of_netdev_close() and calls client close callback only when __I40E_CLIENT_INSTANCE_OPENED is set.
--- drivers/net/ethernet/intel/i40e/i40e_client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_client.c +4 -1
@@ -178,6 +178,10 @@ void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset) "Cannot locate client instance close routine\n");return ; } +if (!test_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { +dev_dbg (&pf->pdev->dev,"Client is not open, abort close\n" ); +return ; + } cdev->client->ops->close (&cdev->lan_info, cdev->client, reset);clear_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);i40e_client_release_qvlist (&cdev->lan_info);
@@ -374,7 +378,6 @@ void i40e_client_subtask(struct i40e_pf *pf)/* Remove failed client instance */ clear_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); -i40e_client_del_instance (pf);return ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 59/79 net: fec: Use a spinlock to guard `fep->ptp_clk_on`
In reply to Greg Kroah-HartmanFrom: Csókás Bence <[email protected]>
[ Upstream commit b353b241f1eb9b6265358ffbe2632fdcb563354f ]
Mutexes cannot be taken in a non-preemptible context, causing a panic in fec_ptp_save_state(). Replacing ptp_clk_mutex by tmreg_lock fixes this.
--- drivers/net/ethernet/freescale/fec.h | 1 - drivers/net/ethernet/freescale/fec_main.c | 17 +++++++------- drivers/net/ethernet/freescale/fec_ptp.c | 28 ++++++++--------------- 3 files changed, 19 insertions(+), 27 deletions(-)
drivers/net/ethernet/freescale/fec.h +0 -1
@@ -523,7 +523,6 @@ struct fec_enet_private {struct clk *clk_ptp;bool ptp_clk_on; -struct mutex ptp_clk_mutex;unsigned int num_tx_queues;unsigned int num_rx_queues;
drivers/net/ethernet/freescale/fec_main.c +9 -8
@@ -1937,6 +1937,7 @@ static void fec_enet_phy_reset_after_clk_enable(struct net_device *ndev)static int fec_enet_clk_enable (struct net_device *ndev,bool enable) {struct fec_enet_private *fep =netdev_priv (ndev); +unsigned long flags;int ret;if (enable) {
@@ -1945,15 +1946,15 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)return ret;if (fep->clk_ptp) { -mutex_lock (&fep->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags); ret =clk_prepare_enable (fep->clk_ptp);if (ret) { -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags); goto failed_clk_ptp; }else { fep->ptp_clk_on = true; } -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags); } ret =clk_prepare_enable (fep->clk_ref);
@@ -1964,10 +1965,10 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) }else {clk_disable_unprepare (fep->clk_enet_out);if (fep->clk_ptp) { -mutex_lock (&fep->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags);clk_disable_unprepare (fep->clk_ptp); fep->ptp_clk_on = false; -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags); }clk_disable_unprepare (fep->clk_ref); }
@@ -1976,10 +1977,10 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) failed_clk_ref:if (fep->clk_ptp) { -mutex_lock (&fep->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags);clk_disable_unprepare (fep->clk_ptp); fep->ptp_clk_on = false; -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags); } failed_clk_ptp:clk_disable_unprepare (fep->clk_enet_out);
@@ -3665,7 +3666,7 @@ fec_probe(struct platform_device *pdev) fep->clk_enet_out =NULL ; fep->ptp_clk_on = false; -mutex_init (&fep->ptp_clk_mutex); +spin_lock_init (&fep->tmreg_lock);/* clk_ref is optional, depends on board */ fep->clk_ref =devm_clk_get (&pdev->dev,"enet_clk_ref" );
drivers/net/ethernet/freescale/fec_ptp.c +10 -18
@@ -366,21 +366,19 @@ static int fec_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)*/ static int fec_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) { -struct fec_enet_private *adapter = +struct fec_enet_private *fep = container_of(ptp, struct fec_enet_private, ptp_caps);u64 ns;unsigned long flags; -mutex_lock (&adapter->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags);/* Check the ptp clock */ -if (!adapter->ptp_clk_on) { -mutex_unlock (&adapter->ptp_clk_mutex); +if (!fep->ptp_clk_on) { +spin_unlock_irqrestore (&fep->tmreg_lock, flags);return -EINVAL ; } -spin_lock_irqsave (&adapter->tmreg_lock, flags); - ns =timecounter_read (&adapter->tc); -spin_unlock_irqrestore (&adapter->tmreg_lock, flags); -mutex_unlock (&adapter->ptp_clk_mutex); + ns =timecounter_read (&fep->tc); +spin_unlock_irqrestore (&fep->tmreg_lock, flags); *ts =ns_to_timespec64 (ns);
@@ -405,10 +403,10 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,unsigned long flags;u32 counter; -mutex_lock (&fep->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags);/* Check the ptp clock */ if (!fep->ptp_clk_on) { -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags);return -EINVAL ; }
@@ -418,11 +416,9 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,*/ counter = ns & fep->cc.mask; -spin_lock_irqsave (&fep->tmreg_lock, flags);writel (counter, fep->hwp +FEC_ATIME );timecounter_init (&fep->tc, &fep->cc, ns);spin_unlock_irqrestore (&fep->tmreg_lock, flags); -mutex_unlock (&fep->ptp_clk_mutex);return 0 ; }
@@ -523,13 +519,11 @@ static void fec_time_keep(struct work_struct *work) struct fec_enet_private *fep = container_of(dwork, struct fec_enet_private, time_keep);unsigned long flags; -mutex_lock (&fep->ptp_clk_mutex); +spin_lock_irqsave (&fep->tmreg_lock, flags);if (fep->ptp_clk_on) { -spin_lock_irqsave (&fep->tmreg_lock, flags);timecounter_read (&fep->tc); -spin_unlock_irqrestore (&fep->tmreg_lock, flags); } -mutex_unlock (&fep->ptp_clk_mutex); +spin_unlock_irqrestore (&fep->tmreg_lock, flags);schedule_delayed_work (&fep->time_keep,HZ ); }
@@ -604,8 +598,6 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) } fep->ptp_inc =NSEC_PER_SEC / fep->cycle_speed; -spin_lock_init (&fep->tmreg_lock); -fec_ptp_start_cyclecounter (ndev);INIT_DELAYED_WORK (&fep->time_keep, fec_time_keep);
Signature · 1 line
2.35.1
Re: [PATCH 5.10 59/79] net: fec: Use a spinlock to guard `fep->ptp_clk_on`
Quoted 8 lines · Greg Kroah-Hartman
From: Csókás Bence <[email protected]>
[ Upstream commit
b353b241f1eb9b6265358ffbe2632fdcb563354f]Mutexes cannot be taken in a non-preemptible context, causing a panic in
fec_ptp_save_state(). Replacingptp_clk_mutexbytmreg_lockfixes this.
Quoted 9 lines
Fixes 6a4d7234ae9a ("net: fec: ptp: avoid register access when ipg clock is disabled")Fixes f79959220fa5 ("fec: Restart PPS after link state change")Reported-by Marc Kleine-Budde <[email protected]>Signed-off-by Csókás Bence <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>
If possible please drop this patch, a revert for this is pending. For details see:
https://lore.kernel.org/all/[email protected]/
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Greg Kroah-Hartman
maintainerPATCH 60/79 xen-netback: only remove hotplug-status when the vif is actually destroyed
In reply to Greg Kroah-HartmanFrom: Paul Durrant <[email protected]>
[ Upstream commit c55f34b6aec2a8cb47eadaffea773e83bf85de91 ]
Removing 'hotplug-status' in backend_disconnected() means that it will be removed even in the case that the frontend unilaterally disconnects (which it is free to do at any time). The consequence of this is that, when the frontend attempts to re-connect, the backend gets stuck in 'InitWait' rather than moving straight to 'Connected' (which it can do because the hotplug script has already run).
Instead, the 'hotplug-status' mode should be removed in netback_remove() i.e. when the vif really is going away.
--- drivers/net/xen-netback/xenbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +1 -1
@@ -256,7 +256,6 @@ static void backend_disconnect(struct backend_info *be)unsigned int queue_index;xen_unregister_watchers (vif); -xenbus_rm (XBT_NIL , be->dev->nodename,"hotplug-status" );#ifdef CONFIG_DEBUG_FS xenvif_debugfs_delif (vif);#endif /* CONFIG_DEBUG_FS */
@@ -984,6 +983,7 @@ static int netback_remove(struct xenbus_device *dev)struct backend_info *be =dev_get_drvdata (&dev->dev);unregister_hotplug_status_watch (be); +xenbus_rm (XBT_NIL , dev->nodename,"hotplug-status" );if (be->vif) {kobject_uevent (&dev->dev.kobj,KOBJ_OFFLINE );backend_disconnect (be);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 61/79 RDMA/siw: Pass a pointer to virt_to_page()
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit 0d1b756acf60da5004c1e20ca4462f0c257bf6e1 ]
Functions that work on a pointer to virtual memory such as virt_to_pfn() and users of that function such as virt_to_page() are supposed to pass a pointer to virtual memory, ideally a (void *) or other pointer. However since many architectures implement virt_to_pfn() as a macro, this function becomes polymorphic and accepts both a (unsigned long) and a (void *).
If we instead implement a proper virt_to_pfn(void *addr) function the following happens (occurred on arch/arm):
drivers/infiniband/sw/siw/siw_qp_tx.c:32:23: warning: incompatible
integer to pointer conversion passing 'dma_addr_t' (aka 'unsigned int') to parameter of type 'const void *' [-Wint-conversion]drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: passing argument
1 of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion]drivers/infiniband/sw/siw/siw_qp_tx.c:538:36: warning: incompatible
integer to pointer conversion passing 'unsigned long long' to parameter of type 'const void *' [-Wint-conversion]
Fix this with an explicit cast. In one case where the SIW SGE uses an unaligned u64 we need a double cast modifying the virtual address (va) to a platform-specific uintptr_t before casting to a (void *).
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +14 -4
@@ -29,7 +29,7 @@ static struct page *siw_get_pblpage(struct siw_mem *mem, u64 addr, int *idx)dma_addr_t paddr =siw_pbl_get_buffer (pbl, offset,NULL , idx);if (paddr) -return virt_to_page (paddr); +return virt_to_page ((void *)paddr);return NULL ; }
@@ -523,13 +523,23 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s)kunmap (p); } }else { -u64 va = sge->laddr + sge_off; +/* +* Cast to an uintptr_t to preserve all 64 bits +* in sge->laddr. +*/ +uintptr_t va = (uintptr_t )(sge->laddr + sge_off); - page_array[seg] =virt_to_page (va &PAGE_MASK ); +/* +* virt_to_page() takes a (void *) pointer +* so cast to a (void *) meaning it will be 64 +* bits on a 64 bit platform and 32 bits on a +* 32 bit platform. +*/ + page_array[seg] =virt_to_page ((void *)(va &PAGE_MASK ));if (do_crc)crypto_shash_update ( c_tx->mpa_crc_hd, - (void *)(uintptr_t )va, + (void *)va, plen); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 62/79 ipv6: sr: fix out-of-bounds read when setting HMAC data.
In reply to Greg Kroah-HartmanFrom: David Lebrun <[email protected]>
[ Upstream commit 84a53580c5d2138c7361c7c3eea5b31827e63b35 ]
The SRv6 layer allows defining HMAC data that can later be used to sign IPv6 Segment Routing Headers. This configuration is realised via netlink through four attributes: SEG6_ATTR_HMACKEYID, SEG6_ATTR_SECRET, SEG6_ATTR_SECRETLEN and SEG6_ATTR_ALGID. Because the SECRETLEN attribute is decoupled from the actual length of the SECRET attribute, it is possible to provide invalid combinations (e.g., secret = "", secretlen = 64). This case is not checked in the code and with an appropriately crafted netlink message, an out-of-bounds read of up to 64 bytes (max secret length) can occur past the skb end pointer and into skb_shared_info:
Breakpoint 1, seg6_genl_sethmac (skb=<optimized out>, info=<optimized out>) at net/ipv6/seg6.c:208
208 memcpy(hinfo->secret, secret, slen);
(gdb) bt
#0 seg6_genl_sethmac (skb=<optimized out>, info=<optimized out>) at net/ipv6/seg6.c:208
#1 0xffffffff81e012e9 in genl_family_rcv_msg_doit (skb=skb@entry=0xffff88800b1f9f00, nlh=nlh@entry=0xffff88800b1b7600,
extack=extack@entry=0xffffc90000ba7af0, ops=ops@entry=0xffffc90000ba7a80, hdrlen=4, net=0xffffffff84237580 <init_net>, family=<optimized out>, family=<optimized out>) at net/netlink/genetlink.c:731
#2 0xffffffff81e01435 in genl_family_rcv_msg (extack=0xffffc90000ba7af0, nlh=0xffff88800b1b7600, skb=0xffff88800b1f9f00,
family=0xffffffff82fef6c0 <seg6_genl_family>) at net/netlink/genetlink.c:775
#3 genl_rcv_msg (skb=0xffff88800b1f9f00, nlh=0xffff88800b1b7600, extack=0xffffc90000ba7af0) at net/netlink/genetlink.c:792
#4 0xffffffff81dfffc3 in netlink_rcv_skb (skb=skb@entry=0xffff88800b1f9f00, cb=cb@entry=0xffffffff81e01350 <genl_rcv_msg>)
at net/netlink/af_netlink.c:2501
#5 0xffffffff81e00919 in genl_rcv (skb=0xffff88800b1f9f00) at net/netlink/genetlink.c:803
#6 0xffffffff81dff6ae in netlink_unicast_kernel (ssk=0xffff888010eec800, skb=0xffff88800b1f9f00, sk=0xffff888004aed000)
at net/netlink/af_netlink.c:1319
#7 netlink_unicast (ssk=ssk@entry=0xffff888010eec800, skb=skb@entry=0xffff88800b1f9f00, portid=portid@entry=0, nonblock=<optimized out>)
at net/netlink/af_netlink.c:1345
#8 0xffffffff81dff9a4 in netlink_sendmsg (sock=<optimized out>, msg=0xffffc90000ba7e48, len=<optimized out>) at net/netlink/af_netlink.c:1921...
(gdb) p/x ((struct sk_buff *)0xffff88800b1f9f00)->head + ((struct sk_buff *)0xffff88800b1f9f00)->end $1 = 0xffff88800b1b76c0
(gdb) p/x secret
$2 = 0xffff88800b1b76c0
(gdb) p slen
$3 = 64 '@'
The OOB data can then be read back from userspace by dumping HMAC state. This commit fixes this by ensuring SECRETLEN cannot exceed the actual length of SECRET.
Tested: verified that EINVAL is correctly returned when secretlen > len(secret)
--- net/ipv6/seg6.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv6/seg6.c +5 -0
@@ -135,6 +135,11 @@ static int seg6_genl_sethmac(struct sk_buff *skb, struct genl_info *info) goto out_unlock; } +if (slen >nla_len (info->attrs[SEG6_ATTR_SECRET ])) { + err = -EINVAL ; + goto out_unlock; + } +if (hinfo) { err =seg6_hmac_info_del (net, hmackeyid);if (err)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 63/79 IB/core: Fix a nested dead lock as part of ODP flow
In reply to Greg Kroah-HartmanFrom: Yishai Hadas <[email protected]>
[ Upstream commit 85eaeb5058f0f04dffb124c97c86b4f18db0b833 ]
Fix a nested dead lock as part of ODP flow by using mmput_async().
Quoted 1 line
From the below call trace [1] can see that calling
mmput()once we have
the umem_odp->umem_mutex locked as required by ib_umem_odp_map_dma_and_lock() might trigger in the same task the exit_mmap()->__mmu_notifier_release()->mlx5_ib_invalidate_range() which may dead lock when trying to lock the same mutex.
Moving to use mmput_async() will solve the problem as the above exit_mmap() flow will be called in other task and will be executed once the lock will be available.
[1]
[64843.077665] task:kworker/u133:2 state:D stack: 0 pid:80906 ppid: 2 flags:0x00004000 [64843.077672] Workqueue: mlx5_ib_page_fault mlx5_ib_eqe_pf_action [mlx5_ib] [64843.077719] Call Trace: [64843.077722] <TASK> [64843.077724] __schedule+0x23d/0x590 [64843.077729] schedule+0x4e/0xb0 [64843.077735] schedule_preempt_disabled+0xe/0x10 [64843.077740] __mutex_lock.constprop.0+0x263/0x490 [64843.077747] __mutex_lock_slowpath+0x13/0x20 [64843.077752] mutex_lock+0x34/0x40 [64843.077758] mlx5_ib_invalidate_range+0x48/0x270 [mlx5_ib] [64843.077808] __mmu_notifier_release+0x1a4/0x200 [64843.077816] exit_mmap+0x1bc/0x200 [64843.077822] ? walk_page_range+0x9c/0x120 [64843.077828] ? __cond_resched+0x1a/0x50 [64843.077833] ? mutex_lock+0x13/0x40 [64843.077839] ? uprobe_clear_state+0xac/0x120 [64843.077860] mmput+0x5f/0x140 [64843.077867] ib_umem_odp_map_dma_and_lock+0x21b/0x580 [ib_core] [64843.077931] pagefault_real_mr+0x9a/0x140 [mlx5_ib] [64843.077962] pagefault_mr+0xb4/0x550 [mlx5_ib] [64843.077992] pagefault_single_data_segment.constprop.0+0x2ac/0x560 [mlx5_ib] [64843.078022] mlx5_ib_eqe_pf_action+0x528/0x780 [mlx5_ib] [64843.078051] process_one_work+0x22b/0x3d0 [64843.078059] worker_thread+0x53/0x410 [64843.078065] ? process_one_work+0x3d0/0x3d0 [64843.078073] kthread+0x12a/0x150 [64843.078079] ? set_kthread_struct+0x50/0x50 [64843.078085] ret_from_fork+0x22/0x30 [64843.078093] </TASK>
--- drivers/infiniband/core/umem_odp.c | 2 +- kernel/fork.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/umem_odp.c +1 -1
@@ -466,7 +466,7 @@ int ib_umem_odp_map_dma_and_lock(struct ib_umem_odp *umem_odp, u64 user_virt,mutex_unlock (&umem_odp->umem_mutex); out_put_mm: -mmput (owning_mm); +mmput_async (owning_mm); out_put_task:if (owning_process)put_task_struct (owning_process);
kernel/fork.c +1 -0
@@ -1127,6 +1127,7 @@ void mmput_async(struct mm_struct *mm) schedule_work(&mm->async_put_work); } } +EXPORT_SYMBOL_GPL (mmput_async);#endif /**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 64/79 RDMA/mlx5: Set local port to one when accessing counters
In reply to Greg Kroah-HartmanFrom: Chris Mi <[email protected]>
[ Upstream commit 74b30b3ad5cec95d2647e796d10137438a098bc1 ]
When accessing Ports Performance Counters Register (PPCNT), local port must be one if it is Function-Per-Port HCA that HCA_CAP.num_ports is 1.
The offending patch can change the local port to other values when accessing PPCNT after enabling switchdev mode. The following syndrome will be printed:
# cat /sys/class/infiniband/rdmap4s0f0/ports/2/counters/* # dmesg mlx5_core 0000:04:00.0: mlx5_cmd_check:756:(pid 12450): ACCESS_REG(0x805) op_mod(0x1) failed, status bad parameter(0x3), syndrome (0x1e5585)
Fix it by setting local port to one for Function-Per-Port HCA.
--- drivers/infiniband/hw/mlx5/mad.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/hw/mlx5/mad.c +6 -0
@@ -166,6 +166,12 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u8 port_num, mdev = dev->mdev; mdev_port_num =1 ; } +if (MLX5_CAP_GEN (dev->mdev, num_ports) ==1 ) { +/* set local port to one for Function-Per-Port HCA. */ + mdev = dev->mdev; + mdev_port_num =1 ; + } +/* Declaring support of extended counters */ if (in_mad->mad_hdr.attr_id ==IB_PMA_CLASS_PORT_INFO ) {struct ib_class_port_info cpi = {};
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 65/79 nvme-tcp: fix UAF when detecting digest errors
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 160f3549a907a50e51a8518678ba2dcf2541abea ]
We should also bail from the io_work loop when we set rd_enabled to true, so we don't attempt to read data from the socket when the TCP stream is already out-of-sync or corrupted.
--- drivers/nvme/host/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/tcp.c +1 -1
@@ -1196,7 +1196,7 @@ static void nvme_tcp_io_work(struct work_struct *w)else if (unlikely (result <0 ))return ; -if (!pending) +if (!pending || !queue->rd_enabled)return ; }while (!time_after (jiffies, deadline));/* quota is exhausted */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 66/79 nvme-tcp: fix regression that causes sporadic requests to time out
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 3770a42bb8ceb856877699257a43c0585a5d2996 ]
When we queue requests, we strive to batch as much as possible and also signal the network stack that more data is about to be sent over a socket with MSG_SENDPAGE_NOTLAST. This flag looks at the pending requests queued as well as queue->more_requests that is derived from the block layer last-in-batch indication.
We set more_request=true when we flush the request directly from .queue_rq submission context (in nvme_tcp_send_all), however this is wrongly assuming that no other requests may be queued during the execution of nvme_tcp_send_all.
Due to this, a race condition may happen where:
1. request X is queued as !last-in-batch
2. request X submission context calls nvme_tcp_send_all directly
3. nvme_tcp_send_all is preempted and schedules to a different cpu
4. request Y is queued as last-in-batch
5. nvme_tcp_send_all context sends request X+Y, however signals for
both MSG_SENDPAGE_NOTLAST because queue->more_requests=true.
==> none of the requests is pushed down to the wire as the network stack is waiting for more data, both requests timeout.
To fix this, we eliminate queue->more_requests and only rely on the queue req_list and send_list to be not-empty.
--- drivers/nvme/host/tcp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/nvme/host/tcp.c +1 -4
@@ -118,7 +118,6 @@ struct nvme_tcp_queue {struct mutex send_mutex;struct llist_head req_list;struct list_head send_list; -bool more_requests;/* recv state */ void *pdu;
@@ -314,7 +313,7 @@ static inline void nvme_tcp_send_all(struct nvme_tcp_queue *queue)static inline bool nvme_tcp_queue_more (struct nvme_tcp_queue *queue) {return !list_empty (&queue->send_list) || - !llist_empty (&queue->req_list) || queue->more_requests; + !llist_empty (&queue->req_list); } static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
@@ -333,9 +332,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,*/ if (queue->io_cpu ==raw_smp_processor_id () && sync && empty &&mutex_trylock (&queue->send_mutex)) { - queue->more_requests = !last;nvme_tcp_send_all (queue); - queue->more_requests = false;mutex_unlock (&queue->send_mutex); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 67/79 tcp: fix early ETIMEDOUT after spurious non-SACK RTO
In reply to Greg Kroah-HartmanFrom: Neal Cardwell <[email protected]>
[ Upstream commit 686dc2db2a0fdc1d34b424ec2c0a735becd8d62b ]
Fix a bug reported and analyzed by Nagaraj Arankal, where the handling of a spurious non-SACK RTO could cause a connection to fail to clear retrans_stamp, causing a later RTO to very prematurely time out the connection with ETIMEDOUT.
Here is the buggy scenario, expanding upon Nagaraj Arankal's excellent report:
(*1) Send one data packet on a non-SACK connection
(*2) Because no ACK packet is received, the packet is retransmitted
and we enter CA_Loss; but this retransmission is spurious.
(*3) The ACK for the original data is received. The transmitted packet
is acknowledged. The TCP timestamp is before the retrans_stamp, so tcp_may_undo() returns true, and tcp_try_undo_loss() returns true without changing state to Open (because tcp_is_sack() is false), and tcp_process_loss() returns without calling tcp_try_undo_recovery(). Normally after undoing a CA_Loss episode, tcp_fastretrans_alert() would see that the connection has returned to CA_Open and fall through and call tcp_try_to_open(), which would set retrans_stamp to 0. However, for non-SACK connections we hold the connection in CA_Loss, so do not fall through to call tcp_try_to_open() and do not set retrans_stamp to 0. So retrans_stamp is (erroneously) still non-zero.
At this point the first "retransmission event" has passed and been recovered from. Any future retransmission is a completely new "event". However, retrans_stamp is erroneously still set. (And we are still in CA_Loss, which is correct.)
(*4) After 16 minutes (to correspond with tcp_retries2=15), a new data
packet is sent. Note: No data is transmitted between (*3) and (*4) and we disabled keep alives.
The socket's timeout SHOULD be calculated from this point in time, but instead it's calculated from the prior "event" 16 minutes ago (step (*2)).
(*5) Because no ACK packet is received, the packet is retransmitted.
(*6) At the time of the 2nd retransmission, the socket returns
ETIMEDOUT, prematurely, because retrans_stamp is (erroneously) too far in the past (set at the time of (*2)).
This commit fixes this bug by ensuring that we reuse in tcp_try_undo_loss() the same careful logic for non-SACK connections that we have in tcp_try_undo_recovery(). To avoid duplicating logic, we factor out that logic into a new tcp_is_non_sack_preventing_reopen() helper and call that helper from both undo functions.
--- net/ipv4/tcp_input.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
net/ipv4/tcp_input.c +18 -7
@@ -2496,6 +2496,21 @@ static inline bool tcp_may_undo(const struct tcp_sock *tp)return tp->undo_marker && (!tp->undo_retrans ||tcp_packet_delayed (tp)); } +static bool tcp_is_non_sack_preventing_reopen (struct sock *sk) +{ +struct tcp_sock *tp =tcp_sk (sk); + +if (tp->snd_una == tp->high_seq &&tcp_is_reno (tp)) { +/* Hold old state until something *above* high_seq +* is ACKed. For Reno it is MUST to prevent false +* fast retransmits (RFC2582). SACK TCP is safe. */ +if (!tcp_any_retrans_done (sk)) + tp->retrans_stamp =0 ; +return true; + } +return false; +} +/* People celebrate: "We love our President!" */ static bool tcp_try_undo_recovery (struct sock *sk) {
@@ -2518,14 +2533,8 @@ static bool tcp_try_undo_recovery(struct sock *sk) }else if (tp->rack.reo_wnd_persist) { tp->rack.reo_wnd_persist--; } -if (tp->snd_una == tp->high_seq &&tcp_is_reno (tp)) { -/* Hold old state until something *above* high_seq -* is ACKed. For Reno it is MUST to prevent false -* fast retransmits (RFC2582). SACK TCP is safe. */ -if (!tcp_any_retrans_done (sk)) - tp->retrans_stamp =0 ; +if (tcp_is_non_sack_preventing_reopen (sk))return true; - }tcp_set_ca_state (sk, TCP_CA_Open); tp->is_sack_reneg =0 ;return false;
@@ -2561,6 +2570,8 @@ static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo)NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSPURIOUSRTOS );inet_csk (sk)->icsk_retransmits =0 ; +if (tcp_is_non_sack_preventing_reopen (sk)) +return true;if (frto_undo ||tcp_is_sack (tp)) {tcp_set_ca_state (sk, TCP_CA_Open); tp->is_sack_reneg =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 68/79 sch_sfb: Also store skb len before calling child enqueue
In reply to Greg Kroah-HartmanFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 2f09707d0c972120bf794cfe0f0c67e2c2ddb252 ]
Cong Wang noticed that the previous fix for sch_sfb accessing the queued skb after enqueueing it to a child qdisc was incomplete: the SFB enqueue function was also calling qdisc_qstats_backlog_inc() after enqueue, which reads the pkt len from the skb cb field. Fix this by also storing the skb len, and using the stored value to increment the backlog after enqueueing.
--- net/sched/sch_sfb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_sfb.c +2 -1
@@ -281,6 +281,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, {struct sfb_sched_data *q =qdisc_priv (sch); +unsigned int len =qdisc_pkt_len (skb);struct Qdisc *child = q->qdisc;struct tcf_proto *fl;struct sfb_skb_cb cb;
@@ -403,7 +404,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,memcpy (&cb,sfb_skb_cb (skb),sizeof (cb)); ret =qdisc_enqueue (skb, child, to_free);if (likely (ret ==NET_XMIT_SUCCESS )) { -qdisc_qstats_backlog_inc (sch, skb); + sch->qstats.backlog += len; sch->q.qlen++;increment_qlen (&cb, q); }else if (net_xmit_drop_count (ret)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 69/79 ASoC: mchp-spdiftx: remove references to mchp_i2s_caps
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
commit 403fcb5118a0f4091001a537e76923031fb45eaf upstream.
Remove references to struct mchp_i2s_caps as they are not used.
--- sound/soc/atmel/mchp-spdiftx.c | 8 -------- 1 file changed, 8 deletions(-)
sound/soc/atmel/mchp-spdiftx.c +0 -8
@@ -196,7 +196,6 @@ struct mchp_spdiftx_dev {struct clk *pclk;struct clk *gclk;unsigned int fmt; -const struct mchp_i2s_caps *caps; int gclk_enabled:1; };
@@ -766,8 +765,6 @@ static const struct of_device_id mchp_spMODULE_DEVICE_TABLE (of, mchp_spdiftx_dt_ids);static int mchp_spdiftx_probe (struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; -const struct of_device_id *match;struct mchp_spdiftx_dev *dev;struct resource *mem;struct regmap *regmap;
@@ -781,11 +778,6 @@ static int mchp_spdiftx_probe(struct plaif (!dev)return -ENOMEM ; -/* Get hardware capabilities. */ - match =of_match_node (mchp_spdiftx_dt_ids, np); -if (match) - dev->caps = match->data; -/* Map I/O registers. */ base =devm_platform_get_and_ioremap_resource (pdev,0 , &mem);if (IS_ERR (base))
Greg Kroah-Hartman
maintainerPATCH 70/79 ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5c5c2baad2b55cc0a4b190266889959642298f79 upstream.
A recent change in clang strengthened its -Wbitfield-constant-conversion to warn when 1 is assigned to a 1-bit signed integer bitfield, as it can only be 0 or -1, not 1:
sound/soc/atmel/mchp-spdiftx.c:505:20: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
dev->gclk_enabled = 1;
^ ~1 error generated.
The actual value of the field is never checked, just that it is not zero, so there is not a real bug here. However, it is simple enough to silence the warning by making the bitfield unsigned, which matches the mchp-spdifrx driver.
--- sound/soc/atmel/mchp-spdiftx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/atmel/mchp-spdiftx.c +1 -1
@@ -196,7 +196,7 @@ struct mchp_spdiftx_dev {struct clk *pclk;struct clk *gclk;unsigned int fmt; - int gclk_enabled:1; + unsigned int gclk_enabled:1; };static inline int mchp_spdiftx_is_running (struct mchp_spdiftx_dev *dev)
Signature · 1 line
2.37.3
Greg Kroah-Hartman
maintainerPATCH 71/79 MIPS: loongson32: ls1c: Fix hang during startup
In reply to Greg Kroah-HartmanFrom: Yang Ling <[email protected]>
[ Upstream commit 35508d2424097f9b6a1a17aac94f702767035616 ]
The RTCCTRL reg of LS1C is obselete.
Writing this reg will cause system hang.
--- arch/mips/loongson32/ls1c/board.c | 1 - 1 file changed, 1 deletion(-)
arch/mips/loongson32/ls1c/board.c +0 -1
@@ -15,7 +15,6 @@ static struct platform_device *ls1c_platform_devices[] __initdata = {static int __init ls1c_platform_init (void ) {ls1x_serial_set_uartclk (&ls1x_uart_pdev); -ls1x_rtc_set_extclk (&ls1x_rtc_pdev);return platform_add_devices (ls1c_platform_devices,ARRAY_SIZE (ls1c_platform_devices));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 72/79 swiotlb: avoid potential left shift overflow
In reply to Greg Kroah-HartmanFrom: Chao Gao <[email protected]>
[ Upstream commit 3f0461613ebcdc8c4073e235053d06d5aa58750f ]
The second operand passed to slot_addr() is declared as int or unsigned int in all call sites. The left-shift to get the offset of a slot can overflow if swiotlb size is larger than 4G.
Convert the macro to an inline function and declare the second argument as phys_addr_t to avoid the potential overflow.
--- kernel/dma/swiotlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/dma/swiotlb.c +4 -1
@@ -452,7 +452,10 @@ static void swiotlb_bounce(phys_addr_t orig_addr, phys_addr_t tlb_addr, } } -#define slot_addr (start, idx) ((start) + ((idx) << IO_TLB_SHIFT)) +static inline phys_addr_t slot_addr (phys_addr_t start,phys_addr_t idx) +{ +return start + (idx <<IO_TLB_SHIFT ); +}/* * Return the offset into a iotlb slot required to keep the device happy.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 73/79 iommu/amd: use full 64-bit value in build_completion_wait()
In reply to Greg Kroah-HartmanFrom: John Sperbeck <[email protected]>
[ Upstream commit 94a568ce32038d8ff9257004bb4632e60eb43a49 ]
We started using a 64 bit completion value. Unfortunately, we only stored the low 32-bits, so a very large completion value would never be matched in iommu_completion_wait().
--- drivers/iommu/amd/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +2 -1
@@ -923,7 +923,8 @@ static void build_completion_wait(struct iommu_cmd *cmd,memset (cmd,0 ,sizeof (*cmd)); cmd->data[0 ] =lower_32_bits (paddr) |CMD_COMPL_WAIT_STORE_MASK ; cmd->data[1 ] =upper_32_bits (paddr); - cmd->data[2 ] = data; + cmd->data[2 ] =lower_32_bits (data); + cmd->data[3 ] =upper_32_bits (data);CMD_SET_TYPE (cmd,CMD_COMPL_WAIT ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 74/79 hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined
In reply to Greg Kroah-HartmanFrom: Eliav Farber <[email protected]>
[ Upstream commit 81114fc3d27bf5b06b2137d2fd2b63da656a8b90 ]
Bug - in case "intel,vm-map" is missing in device-tree ,'num' is set to 0, and no voltage channel infos are allocated.
The reason num is set to 0 when "intel,vm-map" is missing is to set the entire pvt->vm_idx[] with incremental channel numbers, but it didn't take into consideration that same num is used later in devm_kcalloc().
If "intel,vm-map" does exist there is no need to set the unspecified channels with incremental numbers, because the unspecified channels can't be accessed in pvt_read_in() which is the only other place besides the probe functions that uses pvt->vm_idx[].
This change fixes the bug by moving the incremental channel numbers setting to be done only if "intel,vm-map" property is defined (starting loop from 0), and removing 'num = 0'.
--- drivers/hwmon/mr75203.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/hwmon/mr75203.c +6 -8
@@ -594,7 +594,12 @@ static int mr75203_probe(struct platform_device *pdev) ret =device_property_read_u8_array (dev,"intel,vm-map" , pvt->vm_idx, vm_num);if (ret) { - num =0 ; +/* +* Incase intel,vm-map property is not defined, we +* assume incremental channel numbers. +*/ +for (i =0 ; i < vm_num; i++) + pvt->vm_idx[i] = i; }else {for (i =0 ; i < vm_num; i++) if (pvt->vm_idx[i] >= vm_num ||
@@ -604,13 +609,6 @@ static int mr75203_probe(struct platform_device *pdev) } } -/* -* Incase intel,vm-map property is not defined, we assume -* incremental channel numbers. -*/ -for (i = num; i < vm_num; i++) - pvt->vm_idx[i] = i; - in_config =devm_kcalloc (dev, num +1 ,sizeof (*in_config),GFP_KERNEL );if (!in_config)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 75/79 hwmon: (mr75203) update pvt->v_num and vm_num to the actual number of used sensors
In reply to Greg Kroah-HartmanFrom: Eliav Farber <[email protected]>
[ Upstream commit bb9195bd6664d94d71647631593e09f705ff5edd ]
This issue is relevant when "intel,vm-map" is set in device-tree, and defines a lower number of VMs than actually supported.
This change is needed for all places that use pvt->v_num or vm_num later on in the code.
--- drivers/hwmon/mr75203.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/mr75203.c +2 -0
@@ -605,6 +605,8 @@ static int mr75203_probe(struct platform_device *pdev)if (pvt->vm_idx[i] >= vm_num || pvt->vm_idx[i] ==0xff ) { num = i; + pvt->v_num = i; + vm_num = i;break ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 76/79 hwmon: (mr75203) fix voltage equation for negative source input
In reply to Greg Kroah-HartmanFrom: Eliav Farber <[email protected]>
[ Upstream commit 227a3a2fc31d8e4bb9c88d4804e19530af245b1b ]
According to Moortec Embedded Voltage Monitor (MEVM) series 3 data sheet, the minimum input signal is -100mv and maximum input signal is +1000mv.
The equation used to convert the digital word to voltage uses mixed types (*val signed and n unsigned), and on 64 bit machines also has different size, since sizeof(u32) = 4 and sizeof(long) = 8.
So when measuring a negative input, n will be small enough, such that PVT_N_CONST * n < PVT_R_CONST, and the result of (PVT_N_CONST * n - PVT_R_CONST) will overflow to a very big positive 32 bit number. Then when storing the result in *val it will be the same value just in 64 bit (instead of it representing a negative number which will what happen when sizeof(long) = 4).
When -1023 <= (PVT_N_CONST * n - PVT_R_CONST) <= -1
dividing the number by 1024 should result of in 0, but because ">> 10" is used, and the sign bit is used to fill the vacated bit positions, it results in -1 (0xf...fffff) which is wrong.
This change fixes the sign problem and supports negative values by casting n to long and replacing the shift right with div operation.
--- drivers/hwmon/mr75203.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/hwmon/mr75203.c +12 -2
@@ -201,8 +201,18 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val)return ret; n &=SAMPLE_DATA_MSK ; -/* Convert the N bitstream count into voltage */ - *val = (PVT_N_CONST * n -PVT_R_CONST ) >>PVT_CONV_BITS ; +/* +* Convert the N bitstream count into voltage. +* To support negative voltage calculation for 64bit machines +* n must be cast to long, since n and *val differ both in +* signedness and in size. +* Division is used instead of right shift, because for signed +* numbers, the sign bit is used to fill the vacated bit +* positions, and if the number is negative, 1 is used. +* BIT(x) may not be used instead of (1 << x) because it's +* unsigned. +*/ + *val = (PVT_N_CONST * (long )n -PVT_R_CONST ) / (1 <<PVT_CONV_BITS );return 0 ;default :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 77/79 hwmon: (mr75203) fix multi-channel voltage reading
In reply to Greg Kroah-HartmanFrom: Eliav Farber <[email protected]>
[ Upstream commit 91a9e063cdcfca8fe642b078d6fae4ce49187975 ]
Fix voltage allocation and reading to support all channels in all VMs. Prior to this change allocation and reading were done only for the first channel in each VM.
This change counts the total number of channels for allocation, and takes into account the channel offset when reading the sample data register.
--- drivers/hwmon/mr75203.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/hwmon/mr75203.c +17 -12
@@ -68,8 +68,9 @@/* VM Individual Macro Register */ #define VM_COM_REG_SIZE 0x200 -#define VM_SDIF_DONE (n) (VM_COM_REG_SIZE + 0x34 + 0x200 * (n)) -#define VM_SDIF_DATA (n) (VM_COM_REG_SIZE + 0x40 + 0x200 * (n)) +#define VM_SDIF_DONE (vm) (VM_COM_REG_SIZE + 0x34 + 0x200 * (vm)) +#define VM_SDIF_DATA (vm, ch) \ + (VM_COM_REG_SIZE + 0x40 + 0x200 * (vm) + 0x4 * (ch))/* SDA Slave Register */ #define IP_CTRL 0x00
@@ -115,6 +116,7 @@ struct pvt_device {u32 t_num;u32 p_num;u32 v_num; +u32 c_num;u32 ip_freq;u8 *vm_idx; };
@@ -178,14 +180,15 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) {struct pvt_device *pvt =dev_get_drvdata (dev);struct regmap *v_map = pvt->v_map; +u8 vm_idx, ch_idx;u32 n, stat; -u8 vm_idx;int ret; -if (channel >= pvt->v_num) +if (channel >= pvt->v_num * pvt->c_num)return -EINVAL ; - vm_idx = pvt->vm_idx[channel]; + vm_idx = pvt->vm_idx[channel / pvt->c_num]; + ch_idx = channel % pvt->c_num;switch (attr) {case hwmon_in_input:
@@ -196,7 +199,7 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val)if (ret)return ret; - ret =regmap_read (v_map,VM_SDIF_DATA (vm_idx), &n); + ret =regmap_read (v_map,VM_SDIF_DATA (vm_idx, ch_idx), &n);if (ret <0 )return ret;
@@ -509,8 +512,8 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvtstatic int mr75203_probe (struct platform_device *pdev) { +u32 ts_num, vm_num, pd_num, ch_num, val, index, i;const struct hwmon_channel_info **pvt_info; -u32 ts_num, vm_num, pd_num, val, index, i;struct device *dev = &pdev->dev;u32 *temp_config, *in_config;struct device *hwmon_dev;
@@ -551,9 +554,11 @@ static int mr75203_probe(struct platform_device *pdev) ts_num = (val &TS_NUM_MSK ) >>TS_NUM_SFT ; pd_num = (val &PD_NUM_MSK ) >>PD_NUM_SFT ; vm_num = (val &VM_NUM_MSK ) >>VM_NUM_SFT ; + ch_num = (val &CH_NUM_MSK ) >>CH_NUM_SFT ; pvt->t_num = ts_num; pvt->p_num = pd_num; pvt->v_num = vm_num; + pvt->c_num = ch_num; val =0 ;if (ts_num) val++;
@@ -590,7 +595,7 @@ static int mr75203_probe(struct platform_device *pdev) }if (vm_num) { -u32 num = vm_num; +u32 total_ch; ret =pvt_get_regmap (pdev,"vm" , pvt);if (ret)
@@ -614,20 +619,20 @@ static int mr75203_probe(struct platform_device *pdev)for (i =0 ; i < vm_num; i++)if (pvt->vm_idx[i] >= vm_num || pvt->vm_idx[i] ==0xff ) { - num = i; pvt->v_num = i; vm_num = i;break ; } } - in_config =devm_kcalloc (dev, num +1 , + total_ch = ch_num * vm_num; + in_config =devm_kcalloc (dev, total_ch +1 ,sizeof (*in_config),GFP_KERNEL );if (!in_config)return -ENOMEM ; -memset32 (in_config,HWMON_I_INPUT , num); - in_config[num] =0 ; +memset32 (in_config,HWMON_I_INPUT , total_ch); + in_config[total_ch] =0 ; pvt_in.config = in_config; pvt_info[index++] = &pvt_in;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 78/79 hwmon: (mr75203) enable polling for all VM channels
In reply to Greg Kroah-HartmanFrom: Eliav Farber <[email protected]>
[ Upstream commit e43212e0f55dc2d6b15d6c174cc0a64b25fab5e7 ]
Configure ip-polling register to enable polling for all voltage monitor channels.
This enables reading the voltage values for all inputs other than just input 0.
--- drivers/hwmon/mr75203.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/hwmon/mr75203.c +13 -0
@@ -398,6 +398,19 @@ static int pvt_init(struct pvt_device *pvt)if (ret)return ret; + val = (BIT (pvt->c_num) -1 ) |VM_CH_INIT | +IP_POLL <<SDIF_ADDR_SFT |SDIF_WRN_W |SDIF_PROG ; + ret =regmap_write (v_map,SDIF_W , val); +if (ret <0 ) +return ret; + + ret =regmap_read_poll_timeout (v_map,SDIF_STAT , + val, !(val &SDIF_BUSY ), +PVT_POLL_DELAY_US , +PVT_POLL_TIMEOUT_US ); +if (ret) +return ret; + val =CFG1_VOL_MEAS_MODE |CFG1_PARALLEL_OUT |CFG1_14_BIT |IP_CFG <<SDIF_ADDR_SFT |SDIF_WRN_W |SDIF_PROG ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 79/79 arm64: errata: add detection for AMEVCNTR01 incrementing incorrectly
In reply to Greg Kroah-HartmanFrom: Ionela Voinescu <[email protected]>
commit e89d120c4b720e232cc6a94f0fcbd59c15d41489 upstream.
The AMU counter AMEVCNTR01 (constant counter) should increment at the same rate as the system counter. On affected Cortex-A510 cores, AMEVCNTR01 increments incorrectly giving a significantly higher output value. This results in inaccurate task scheduler utilization tracking and incorrect feedback on CPU frequency.
Work around this problem by returning 0 when reading the affected counter in key locations that results in disabling all users of this counter from using it either for frequency invariance or as FFH reference counter. This effect is the same to firmware disabling affected counters.
Details on how the two features are affected by this erratum:
- AMU counters will not be used for frequency invariance for affected CPUs and CPUs in the same cpufreq policy. AMUs can still be used for frequency invariance for unaffected CPUs in the system. Although unlikely, if no alternative method can be found to support frequency invariance for affected CPUs (cpufreq based or solution based on platform counters) frequency invariance will be disabled. Please check the chapter on frequency invariance at Documentation/scheduler/sched-capacity.rst for details of its effect.
- Given that FFH can be used to fetch either the core or constant counter values, restrictions are lifted regarding any of these counters returning a valid (!0) value. Therefore FFH is considered supported if there is a least one CPU that support AMUs, independent of any counters being disabled or affected by this erratum. Clarifying comments are now added to the cpc_ffh_supported(), cpu_read_constcnt() and cpu_read_corecnt() functions.
The above is achieved through adding a new erratum: ARM64_ERRATUM_2457168.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 18 ++++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/kernel/cpufeature.c | 5 ++++- 5 files changed, 35 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -92,6 +92,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A77 | #1508412 | ARM64_ERRATUM_1508412 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A510 | #2457168 | ARM64_ERRATUM_2457168 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Neoverse-N1 | #1349291 | N/A |
arch/arm64/Kconfig +18 -0
@@ -657,6 +657,24 @@ config ARM64_ERRATUM_1508412 If unsure, say Y. +config ARM64_ERRATUM_2457168 + bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly" + depends on ARM64_AMU_EXTN + default y + help + This option adds the workaround for ARM Cortex-A510 erratum 2457168. + + The AMU counter AMEVCNTR01 (constant counter) should increment at the same rate + as the system counter. On affected Cortex-A510 cores AMEVCNTR01 increments + incorrectly giving a significantly higher output value. + + Work around this problem by keeping the reference values of affected counters + to 0 thus signaling an error case. This effect is the same to firmware disabling + affected counters, in which case 0 will be returned when reading the disabled + counters. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -67,7 +67,8 @@#define ARM64_MTE 57#define ARM64_WORKAROUND_1508412 58#define ARM64_SPECTRE_BHB 59 +#define ARM64_WORKAROUND_2457168 60 -#define ARM64_NCAPS 60 +#define ARM64_NCAPS 61#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +9 -0
@@ -546,6 +546,15 @@ const struct arm64_cpu_capabilities arm6 1, 0), },#endif +#ifdef CONFIG_ARM64_ERRATUM_2457168 + { + .desc = "ARM erratum 2457168", + .capability = ARM64_WORKAROUND_2457168, + .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, + /* Cortex-A510 r0p0-r1p1 */ + CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) + }, +#endif { } };
arch/arm64/kernel/cpufeature.c +4 -1
@@ -1559,7 +1559,10 @@ static void cpu_amu_enable(struct arm64_pr_info ("detected CPU%d: Activity Monitors Unit (AMU)\n" ,smp_processor_id ());cpumask_set_cpu (smp_processor_id (), &amu_cpus); -init_cpu_freq_invariance_counters (); + +/* 0 reference values signal broken/disabled counters */ +if (!this_cpu_has_cap (ARM64_WORKAROUND_2457168 )) +init_cpu_freq_invariance_counters (); } }
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +0000. Anything received after that time might be too late.
Build test (gcc version 11.3.1 20220819):
mips: 63 configs -> no failure
arm: 104 configs -> no failure
arm64: 3 configs -> no failurex86_64: 4 configs -> no failure alpha allmodconfig -> no failure powerpc allmodconfig -> no failure riscv allmodconfig -> no failure s390 allmodconfig -> no failure xtensa allmodconfig -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
arm64: Booted on rpi4b (4GB model). No regression. [2]
[1]. https://openqa.qa.codethink.co.uk/tests/1818
[2]. https://openqa.qa.codethink.co.uk/tests/1823
--
Regards
Sudip
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.10.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +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.10.143-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro's test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.10.143-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.10.y
* git commit: c8d43c9a1242725c78f2bf5b0274413727673ac2
* git describe: v5.10.142-80-gc8d43c9a1242
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.10.y/build/v5.10.142-80-gc8d43c9a1242
## No test Regressions (compared to v5.10.142)
## No metric Regressions (compared to v5.10.142)
## No test Fixes (compared to v5.10.142)
## No metric Fixes (compared to v5.10.142)
## Test result summary
total: 103035, pass: 90648, fail: 769, skip: 11310, xfail: 308
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 333 total, 333 passed, 0 failed
* arm64: 65 total, 63 passed, 2 failed
* i386: 55 total, 53 passed, 2 failed
* mips: 56 total, 56 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 60 total, 55 passed, 5 failed
* riscv: 27 total, 27 passed, 0 failed
* s390: 24 total, 24 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 58 total, 56 passed, 2 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* packetdrill
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +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.10.143-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.10:
10 builds: 10 pass, 0 fail
28 boots: 28 pass, 0 fail
75 tests: 75 pass, 0 failLinux version: 5.10.143-rc1-gb99fe4c8b8d4
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +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.10.143-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +0000. Anything received after that time might be too late.
Build results:
total: 163 pass: 163 fail: 0 Qemu test results: total: 475 pass: 475 fail: 0
As with 5.15.y and 5.19.y, new runtime warning:
BUG: sleeping function called from invalid context at drivers/clk/imx/clk-pllv3.c:68
Guenter
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +0000. Anything received after that time might be too late.
Hi Greg,
5.10.143-rc1 tested.
Run tested on:
- Intel Skylake x86_64 (nuc6 i5-6260U)
In addition - build tested for:
- Allwinner A64
- Allwinner H3
- Allwinner H5
- Allwinner H6
- Rockchip RK3288
- Rockchip RK3328
- Rockchip RK3399pro
--
Rudi
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.143 release. There are 79 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, 15 Sep 2022 14:03:27 +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.10.143-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Tested on arm64 and x86 for 5.10.143-rc1,
Kernel repo:https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-5.10.y
Version: 5.10.143-rc1
Commit: b99fe4c8b8d4c43ac80d3f4ffaa7e2825463abd7
Compiler: gcc version 7.3.0 (GCC)
arm64:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9023
passed: 9023
failed: 0
timeout: 0
--------------------------------------------------------------------
x86:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9023
passed: 9023
failed: 0
timeout: 0
--------------------------------------------------------------------