5.6.19-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainercover 5.6.19-rc1 review
This is the start of the stable review cycle for the 5.6.19 release. There are 161 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, 18 Jun 2020 15:30:25 +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.6.19-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.6.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.6.19-rc1
Marc Zyngier <[email protected]>
KVM: arm64: Save the host's PtrAuth keys in non-preemptible context
Marc Zyngier <[email protected]>
KVM: arm64: Synchronize sysreg state on injecting an AArch32 exception
Mattia Dongili <[email protected]>
platform/x86: sony-laptop: Make resuming thermal profile safer
Mattia Dongili <[email protected]>
platform/x86: sony-laptop: SNC calls should handle BUFFER types
Juergen Gross <[email protected]>
xen/pvcalls-back: test for errors when calling backend_connect()
Jiri Kosina <[email protected]>
block/floppy: fix contended case in floppy_queue_rq()
Ulf Hansson <[email protected]>
mmc: sdio: Fix several potential memory leaks in mmc_sdio_init_card()
Ulf Hansson <[email protected]>
mmc: sdio: Fix potential NULL pointer error in mmc_sdio_init_card()
Ludovic Desroches <[email protected]>
ARM: dts: at91: sama5d2_ptc_ek: fix sdmmc0 node description
Masahiro Yamada <[email protected]>
mmc: uniphier-sd: call devm_request_irq() after tmio_mmc_host_probe()
Ulf Hansson <[email protected]>
mmc: tmio: Further fixup runtime PM management at remove
Ludovic Barre <[email protected]>
mmc: mmci_sdmmc: fix DMA API warning overlapping mappings
Eugen Hristev <[email protected]>
mmc: sdhci-of-at91: fix CALCR register being rewritten
Veerabhadrarao Badiganti <[email protected]>
mmc: sdhci-msm: Clear tuning done flag while hs400 tuning
Chris Wilson <[email protected]>
agp/intel: Reinforce the barrier after GTT updates
Barret Rhoden <[email protected]>
perf: Add cond_resched() to task_function_call()
OGAWA Hirofumi <[email protected]>
fat: don't allow to mount if the FAT length == 0
Wang Hai <[email protected]>
mm/slub: fix a memory leak in sysfs_slab_add()
Ezequiel Garcia <[email protected]>
drm/vkms: Hold gem object while still in-use
Casey Schaufler <[email protected]>
Smack: slab-out-of-bounds in vsscanf
Qiujun Huang <[email protected]>
ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb
Qiujun Huang <[email protected]>
ath9x: Fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb
Qiujun Huang <[email protected]>
ath9k: Fix use-after-free Write in ath9k_htc_rx_msg
Qiujun Huang <[email protected]>
ath9k: Fix use-after-free Read in ath9k_wmi_ctrl_rx
Qiujun Huang <[email protected]>
ath9k: Fix use-after-free Read in htc_connect_service
Masami Hiramatsu <[email protected]>
selftests/ftrace: Return unsupported if no error_log file
Shivasharan S <[email protected]>
scsi: megaraid_sas: Replace undefined MFI_BIG_ENDIAN macro with __BIG_ENDIAN_BITFIELD macro
Dick Kennedy <[email protected]>
scsi: lpfc: Fix negation of else clause in lpfc_prep_node_fc4type
Sumit Saxena <[email protected]>
scsi: megaraid_sas: TM command refire leads to controller firmware crash
Marc Zyngier <[email protected]>
KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts
James Morse <[email protected]>
KVM: arm64: Stop writing aarch32's CSSELR into ACTLR
Xing Li <[email protected]>
KVM: MIPS: Fix VPN2_MASK definition for variable cpu_vmbits
Xing Li <[email protected]>
KVM: MIPS: Define KVM_ENTRYHI_ASID to cpu_asid_mask(&boot_cpu_data)
Sean Christopherson <[email protected]>
KVM: nVMX: Consult only the "basic" exit reason when routing nested exit
Paolo Bonzini <[email protected]>
KVM: nSVM: leave ASID aside in copy_vmcb_control_area
Paolo Bonzini <[email protected]>
KVM: nSVM: fix condition for filtering async PF
Sean Christopherson <[email protected]>
KVM: nVMX: Skip IBPB when switching between vmcs01 and vmcs02
Tomi Valkeinen <[email protected]>
media: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size
Christophe JAILLET <[email protected]>
video: fbdev: w100fb: Fix a potential double free.
Sam Ravnborg <[email protected]>
video: vt8500lcdfb: fix fallthrough warning
Qiuxu Zhuo <[email protected]>
EDAC/skx: Use the mcmtr register to retrieve close_pg/bank_xor_enable
Rafael J. Wysocki <[email protected]>
cpufreq: Fix up cpufreq_boost_set_sw()
Suman Anna <[email protected]>
remoteproc: Fix and restore the parenting hierarchy for vdev
Tero Kristo <[email protected]>
remoteproc: Fall back to using parent memory pool if no dedicated available
Eric W. Biederman <[email protected]>
proc: Use new_inode not new_inode_pseudo
Yuxuan Shui <[email protected]>
ovl: initialize error in ovl_copy_xattr
Amir Goldstein <[email protected]>
ovl: fix out of bounds access warning in ovl_check_fb_len()
Parav Pandit <[email protected]>
net/mlx5: Disable reload while removing the device
Charles Keepax <[email protected]>
net: macb: Only disable NAPI on the actual error path
Corentin Labbe <[email protected]>
net: cadence: macb: disable NAPI on error
Maxim Mikityanskiy <[email protected]>
net/mlx5e: Fix repeated XSK usage on one channel
Shay Drory <[email protected]>
net/mlx5: Fix fatal error handling during device load
Shay Drory <[email protected]>
net/mlx5: drain health workqueue in case of driver load error
tannerlove <[email protected]>
selftests/net: in rxtimestamp getopt_long needs terminating null entry
Lorenzo Bianconi <[email protected]>
net: mvneta: do not redirect frames during reconfiguration
Wang Hai <[email protected]>
dccp: Fix possible memleak in dccp_init and dccp_fini
Franck LENORMAND <[email protected]>
firmware: imx: scu: Fix corruption of header
Peng Fan <[email protected]>
firmware: imx-scu: Support one TX and one RX
Tony Luck <[email protected]>
x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned
Pavel Begunkov <[email protected]>
io_uring: fix flush req->refs underflow
Xiaoguang Wang <[email protected]>
io_uring: fix mismatched finish_wait() calls in io_uring_cancel_files()
Longpeng(Mike) <[email protected]>
crypto: virtio: Fix src/dst scatterlist calculation in __virtio_crypto_skcipher_do_req()
Longpeng(Mike) <[email protected]>
crypto: virtio: Fix use-after-free in virtio_crypto_skcipher_finalize_req()
Longpeng(Mike) <[email protected]>
crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
Wei Yongjun <[email protected]>
crypto: drbg - fix error return code in drbg_alloc_state()
Eric Biggers <[email protected]>
crypto: algapi - Avoid spurious modprobe on LOADED
Christophe JAILLET <[email protected]>
crypto: cavium/nitrox - Fix 'nitrox_get_first_device()' when ndevlist is fully iterated
Linus Torvalds <[email protected]>
gup: document and work around "COW can break either way" issue
Rafael J. Wysocki <[email protected]>
PM: runtime: clk: Fix clk_pm_runtime_get() error path
Justin Chen <[email protected]>
spi: bcm-qspi: when tx/rx buffer is NULL set to 0
Florian Fainelli <[email protected]>
spi: bcm-qspi: Handle clock probe deferral
Lukas Wunner <[email protected]>
spi: bcm2835aux: Fix controller unregister order
Lukas Wunner <[email protected]>
spi: bcm2835: Fix controller unregister order
Lukas Wunner <[email protected]>
spi: pxa2xx: Fix runtime PM ref imbalance on probe error
Lukas Wunner <[email protected]>
spi: pxa2xx: Fix controller unregister order
Lukas Wunner <[email protected]>
spi: Fix controller unregister order
Lukas Wunner <[email protected]>
spi: dw: Fix controller unregister order
Alexander Gordeev <[email protected]>
lib: fix bitmap_parse() on 64-bit big endian archs
Ryusuke Konishi <[email protected]>
nilfs2: fix null pointer dereference at nilfs_segctor_do_construct()
Dave Rodgman <[email protected]>
lib/lzo: fix ambiguous encoding bug in lzo-rle
Nick Desaulniers <[email protected]>
arm64: acpi: fix UBSAN warning
Rafael J. Wysocki <[email protected]>
ACPI: PM: Avoid using power resources if there are none for D0
Ard Biesheuvel <[email protected]>
ACPI: GED: add support for _Exx / _Lxx handler methods
Qiushi Wu <[email protected]>
ACPI: CPPC: Fix reference count leak in acpi_cppc_processor_probe()
Qiushi Wu <[email protected]>
ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile()
Kai-Heng Feng <[email protected]>
ALSA: usb-audio: Add vendor, product and profile name for HP Thunderbolt Dock
Takashi Iwai <[email protected]>
ALSA: usb-audio: Fix inconsistent card PM state after resume
Michał Mirosław <[email protected]>
ALSA: pcm: fix snd_pcm_link() lockdep splat
Michał Mirosław <[email protected]>
ALSA: pcm: disallow linking stream to itself
Hui Wang <[email protected]>
ALSA: hda/realtek - add a pintbl quirk for several Lenovo machines
Takashi Sakamoto <[email protected]>
ALSA: fireface: start IR context immediately
Takashi Sakamoto <[email protected]>
ALSA: fireface: fix configuration error for nominal sampling transfer frequency
Hersen Wu <[email protected]>
ALSA: hda: add sienna_cichlid audio asic id for sienna_cichlid up
Chuhong Yuan <[email protected]>
ALSA: es1688: Add the missed snd_card_free()
Fabio Estevam <[email protected]>
watchdog: imx_sc_wdt: Fix reboot on crash
Steve French <[email protected]>
smb3: fix typo in mount options displayed in /proc/mounts
Namjae Jeon <[email protected]>
smb3: add indatalen that can be a non-zero value to calculation of credit charge in smb2 ioctl
Steve French <[email protected]>
smb3: fix incorrect number of credits when ioctl MaxOutputResponse > 64K
Ard Biesheuvel <[email protected]>
efi/efivars: Add missing kobject_put() in sysfs entry creation error path
Denis Efremov <[email protected]>
io_uring: use kvfree() in io_sqe_buffer_register()
Pavel Dobias <[email protected]>
ASoC: max9867: fix volume controls
Christophe Leroy <[email protected]>
powerpc/ptdump: Properly handle non standard page size
Eiichi Tsukata <[email protected]>
KVM: x86: Fix APIC page invalidation race
Felipe Franciosi <[email protected]>
KVM: x86: respect singlestep when emulating instruction
Sean Christopherson <[email protected]>
KVM: x86/mmu: Set mmio_value to '0' if reserved #PF can't be generated
Paolo Bonzini <[email protected]>
KVM: x86: allow KVM_STATE_NESTED_MTF_PENDING in kvm_state flags
Kan Liang <[email protected]>
perf/x86/intel: Add more available bits for OFFCORE_RESPONSE of Intel Tremont
Hill Ma <[email protected]>
x86/reboot/quirks: Add MacBook6,1 reboot quirk
Anthony Steinhauser <[email protected]>
x86/speculation: PR_SPEC_FORCE_DISABLE enforcement for indirect branches.
Anthony Steinhauser <[email protected]>
x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.
Anthony Steinhauser <[email protected]>
x86/speculation: Prevent rogue cross-process SSBD shutdown
Xiaochun Lee <[email protected]>
x86/PCI: Mark Intel C620 MROMs as having non-compliant BARs
Steven Price <[email protected]>
x86: mm: ptdump: calculate effective permissions correctly
Bob Haarman <[email protected]>
x86_64: Fix jiffies ODR violation
Vlastimil Babka <[email protected]>
usercopy: mark dma-kmalloc caches as usercopy caches
Miklos Szeredi <[email protected]>
aio: fix async fsync creds
Yongqiang Sun <[email protected]>
drm/amd/display: Not doing optimize bandwidth if flip pending.
Joseph Gravenor <[email protected]>
drm/amd/display: remove invalid dc_is_hw_initialized function
Maurizio Lombardi <[email protected]>
scsi: target: fix hang when multiple threads try to destroy the same iscsi session
Maurizio Lombardi <[email protected]>
scsi: target: remove boilerplate code
Heikki Krogerus <[email protected]>
kobject: Make sure the parent does not get released before its children
Bjorn Helgaas <[email protected]>
PCI/PM: Adjust pcie_wait_for_link_delay() for caller delay
Paolo Bonzini <[email protected]>
KVM: x86: only do L1TF workaround on affected processors
Kim Phillips <[email protected]>
x86/cpu/amd: Make erratum #1054 a legacy erratum
Petr Tesarik <[email protected]>
s390/pci: Log new handle in clp_disable_fh()
Daniel Jordan <[email protected]>
padata: add separate cpuhp node for CPUHP_PADATA_DEAD
Jason Gunthorpe <[email protected]>
RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
Arnd Bergmann <[email protected]>
smack: avoid unused 'sip' variable warning
Masashi Honma <[email protected]>
ath9k_htc: Silence undersized packet warnings
Sasha Levin <[email protected]>
spi: dw: Fix native CS being unset
Pierre-Louis Bossart <[email protected]>
ASoC: SOF: imx: fix undefined reference issue
YueHaibing <[email protected]>
ASoC: SOF: imx8: Fix randbuild error
Cédric Le Goater <[email protected]>
powerpc/xive: Clear the page tables for the ESB IO mapping
Saravana Kannan <[email protected]>
driver core: Update device link status correctly for SYNC_STATE_ONLY links
Amir Goldstein <[email protected]>
fanotify: fix ignore mask logic for events on child and on dir
Vlad Buslov <[email protected]>
selftests: fix flower parent qdisc
Waiman Long <[email protected]>
mm: add kvfree_sensitive() for freeing sensitive data objects
Masami Hiramatsu <[email protected]>
perf probe: Accept the instance number of kretprobe event
Sergio Paracuellos <[email protected]>
staging: mt7621-pci: properly power off dual-ported pcie phy
Jérôme Pouiller <[email protected]>
staging: wfx: fix double free
Thomas Falcon <[email protected]>
drivers/net/ibmvnic: Update VNIC protocol version reporting
Andreas Gruenbacher <[email protected]>
gfs2: Even more gfs2_find_jhead fixes
Guo Ren <[email protected]>
csky: Fixup abiv2 syscall_trace break a4 & a5
Dennis Kadioglu <[email protected]>
Input: synaptics - add a second working PNP_ID for Lenovo T470s
Jens Axboe <[email protected]>
sched/fair: Don't NUMA balance for kthreads
Fredrik Strupe <[email protected]>
ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook
Hans de Goede <[email protected]>
Input: axp20x-pek - always register interrupt handlers
Stephan Gerhold <[email protected]>
Input: mms114 - fix handling of mms345l
Nick Desaulniers <[email protected]>
elfnote: mark all .note sections SHF_ALLOC
Fangrui Song <[email protected]>
bpf: Support llvm-objcopy for vmlinux BTF
Tuong Lien <[email protected]>
tipc: fix NULL pointer dereference in streaming
Michal Vokáč <[email protected]>
net: dsa: qca8k: Fix "Unexpected gfp" kernel exception
Cong Wang <[email protected]>
genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()
Sameeh Jubran <[email protected]>
net: ena: xdp: update napi budget for DROP and ABORTED
Sameeh Jubran <[email protected]>
net: ena: xdp: XDP_TX: fix memory leak
Ido Schimmel <[email protected]>
vxlan: Avoid infinite loop when suppressing NS messages with invalid options
Ido Schimmel <[email protected]>
bridge: Avoid infinite loop when suppressing NS messages with invalid options
Willem de Bruijn <[email protected]>
tun: correct header offsets in napi frags mode
Vasily Averin <[email protected]>
net_failover: fixed rollback in net_failover_open()
Vadim Pasternak <[email protected]>
mlxsw: core: Use different get_trend() callbacks for different thermal zones
Hangbin Liu <[email protected]>
ipv6: fix IPV6_ADDRFORM operation logic
-------------
Diffstat:
Documentation/lzo.txt | 8 +- Makefile | 4 +- arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts | 2 - arch/arm/include/asm/kvm_emulate.h | 3 +- arch/arm/include/asm/kvm_host.h | 2 + arch/arm/kernel/ptrace.c | 4 +- arch/arm64/include/asm/acpi.h | 5 +- arch/arm64/include/asm/kvm_emulate.h | 6 -- arch/arm64/include/asm/kvm_host.h | 8 +- arch/arm64/kvm/handle_exit.c | 19 +---- arch/arm64/kvm/sys_regs.c | 10 ++- arch/csky/abiv2/inc/abi/entry.h | 2 + arch/csky/kernel/entry.S | 6 +- arch/mips/include/asm/kvm_host.h | 6 +- arch/powerpc/kernel/vmlinux.lds.S | 6 -- arch/powerpc/mm/ptdump/ptdump.c | 21 ++--- arch/powerpc/sysdev/xive/common.c | 5 ++ arch/s390/pci/pci_clp.c | 3 +- arch/x86/events/intel/core.c | 4 +- arch/x86/include/asm/set_memory.h | 19 +++-- arch/x86/kernel/cpu/amd.c | 3 +- arch/x86/kernel/cpu/bugs.c | 92 ++++++++++++--------- arch/x86/kernel/cpu/mce/core.c | 11 ++- arch/x86/kernel/process.c | 28 +++---- arch/x86/kernel/reboot.c | 8 ++ arch/x86/kernel/time.c | 4 - arch/x86/kernel/vmlinux.lds.S | 4 +- arch/x86/kvm/mmu/mmu.c | 46 +++++------ arch/x86/kvm/svm.c | 6 +- arch/x86/kvm/vmx/nested.c | 4 +- arch/x86/kvm/vmx/vmx.c | 18 ++++- arch/x86/kvm/vmx/vmx.h | 3 +- arch/x86/kvm/x86.c | 11 +-- arch/x86/mm/dump_pagetables.c | 33 +++++--- arch/x86/pci/fixup.c | 4 + crypto/algapi.c | 2 +- crypto/drbg.c | 4 +- drivers/acpi/cppc_acpi.c | 1 + drivers/acpi/device_pm.c | 2 +- drivers/acpi/evged.c | 22 ++++- drivers/acpi/scan.c | 28 ++++--- drivers/acpi/sysfs.c | 4 +- drivers/base/core.c | 34 ++++++-- drivers/block/floppy.c | 10 +-- drivers/char/agp/intel-gtt.c | 4 +- drivers/clk/clk.c | 6 +- drivers/cpufreq/cpufreq.c | 11 +-- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 +- drivers/crypto/virtio/virtio_crypto_algs.c | 21 +++-- drivers/edac/i10nm_base.c | 2 +- drivers/edac/skx_base.c | 20 ++--- drivers/edac/skx_common.c | 6 +- drivers/edac/skx_common.h | 2 +- drivers/firmware/efi/efivars.c | 4 +- drivers/firmware/imx/imx-scu.c | 62 ++++++++++---- drivers/gpu/drm/amd/display/dc/core/dc.c | 23 +++++- drivers/gpu/drm/amd/display/dc/dc.h | 1 - drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 ++ drivers/gpu/drm/vkms/vkms_drv.h | 5 -- drivers/gpu/drm/vkms/vkms_gem.c | 11 +-- drivers/infiniband/core/uverbs_main.c | 2 + drivers/input/misc/axp20x-pek.c | 72 +++++++++-------- drivers/input/mouse/synaptics.c | 1 + drivers/input/touchscreen/mms114.c | 12 ++- .../media/common/videobuf2/videobuf2-dma-contig.c | 20 +---- drivers/mmc/core/sdio.c | 61 +++++++------- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 + drivers/mmc/host/sdhci-msm.c | 6 ++ drivers/mmc/host/sdhci-of-at91.c | 7 +- drivers/mmc/host/tmio_mmc_core.c | 6 +- drivers/mmc/host/uniphier-sd.c | 12 +-- drivers/net/dsa/qca8k.c | 3 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 10 +-- drivers/net/ethernet/cadence/macb_main.c | 14 ++-- drivers/net/ethernet/ibm/ibmvnic.c | 8 +- drivers/net/ethernet/marvell/mvneta.c | 13 +++ drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 2 - .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 4 + drivers/net/ethernet/mellanox/mlx5/core/health.c | 14 +++- drivers/net/ethernet/mellanox/mlx5/core/main.c | 7 ++ drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 23 +++++- drivers/net/net_failover.c | 3 +- drivers/net/tun.c | 14 +++- drivers/net/vxlan.c | 4 + drivers/net/wireless/ath/ath9k/hif_usb.c | 58 ++++++++++--- drivers/net/wireless/ath/ath9k/hif_usb.h | 6 ++ drivers/net/wireless/ath/ath9k/htc_drv_init.c | 10 ++- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 6 +- drivers/net/wireless/ath/ath9k/htc_hst.c | 6 +- drivers/net/wireless/ath/ath9k/wmi.c | 6 +- drivers/net/wireless/ath/ath9k/wmi.h | 3 +- drivers/pci/pci.c | 4 +- drivers/platform/x86/sony-laptop.c | 60 +++++++------- drivers/remoteproc/remoteproc_core.c | 2 +- drivers/remoteproc/remoteproc_virtio.c | 12 +++ drivers/scsi/lpfc/lpfc_ct.c | 1 - drivers/scsi/megaraid/megaraid_sas.h | 4 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 7 +- drivers/scsi/megaraid/megaraid_sas_fusion.h | 6 +- drivers/spi/spi-bcm-qspi.c | 20 +++-- drivers/spi/spi-bcm2835.c | 4 +- drivers/spi/spi-bcm2835aux.c | 4 +- drivers/spi/spi-dw.c | 14 +++- drivers/spi/spi-pxa2xx.c | 5 +- drivers/spi/spi.c | 3 +- drivers/staging/mt7621-pci/pci-mt7621.c | 12 ++- drivers/staging/wfx/main.c | 1 - drivers/target/iscsi/iscsi_target.c | 79 ++++++------------ drivers/target/iscsi/iscsi_target.h | 1 - drivers/target/iscsi/iscsi_target_configfs.c | 5 +- drivers/target/iscsi/iscsi_target_login.c | 5 +- drivers/video/fbdev/vt8500lcdfb.c | 1 + drivers/video/fbdev/w100fb.c | 2 + drivers/watchdog/imx_sc_wdt.c | 5 ++ drivers/xen/pvcalls-back.c | 3 +- fs/aio.c | 8 ++ fs/cifs/cifsfs.c | 2 +- fs/cifs/smb2pdu.c | 4 +- fs/fat/inode.c | 6 ++ fs/gfs2/lops.c | 15 ++-- fs/io_uring.c | 15 ++-- fs/nilfs2/segment.c | 2 + fs/notify/fanotify/fanotify.c | 5 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/overlayfs.h | 3 + fs/proc/inode.c | 2 +- fs/proc/self.c | 2 +- fs/proc/thread_self.c | 2 +- include/asm-generic/vmlinux.lds.h | 15 ++++ include/linux/elfnote.h | 2 +- include/linux/kvm_host.h | 4 +- include/linux/mm.h | 1 + include/linux/padata.h | 6 +- include/linux/ptdump.h | 1 + include/linux/set_memory.h | 2 +- include/media/videobuf2-dma-contig.h | 2 +- include/net/inet_hashtables.h | 6 ++ include/target/iscsi/iscsi_target_core.h | 2 +- kernel/bpf/btf.c | 9 +-- kernel/bpf/sysfs_btf.c | 11 ++- kernel/events/core.c | 23 +++--- kernel/padata.c | 14 ++-- kernel/sched/fair.c | 2 +- lib/bitmap.c | 9 ++- lib/kobject.c | 30 ++++--- lib/lzo/lzo1x_compress.c | 13 +++ mm/gup.c | 44 ++++++++-- mm/huge_memory.c | 7 +- mm/ptdump.c | 17 +++- mm/slab_common.c | 3 +- mm/slub.c | 4 +- mm/util.c | 18 +++++ net/bridge/br_arp_nd_proxy.c | 4 + net/dccp/proto.c | 7 +- net/ipv6/ipv6_sockglue.c | 13 +-- net/netlink/genetlink.c | 94 +++++++++++++--------- net/tipc/msg.c | 4 +- scripts/link-vmlinux.sh | 24 +++--- security/keys/internal.h | 11 --- security/keys/keyctl.c | 16 ++-- security/smack/smack.h | 6 -- security/smack/smack_lsm.c | 25 ++---- security/smack/smackfs.c | 10 +++ sound/core/pcm_native.c | 20 ++++- sound/firewire/fireface/ff-protocol-latter.c | 12 +-- sound/firewire/fireface/ff-stream.c | 10 +-- sound/isa/es1688/es1688.c | 4 +- sound/pci/hda/hda_intel.c | 3 + sound/pci/hda/patch_realtek.c | 6 ++ sound/soc/codecs/max9867.c | 4 +- sound/soc/sof/imx/Kconfig | 17 +++- sound/usb/card.c | 19 +++-- sound/usb/quirks-table.h | 20 +++++ sound/usb/usbaudio.h | 2 +- tools/perf/util/probe-event.c | 3 +- .../ftrace/test.d/ftrace/tracing-error-log.tc | 2 + .../networking/timestamping/rxtimestamp.c | 1 + .../tc-testing/tc-tests/filters/tests.json | 6 +- tools/testing/selftests/tc-testing/tdc_batch.py | 6 +- virt/kvm/arm/aarch32.c | 28 +++++++ virt/kvm/arm/arm.c | 22 ++++- virt/kvm/kvm_main.c | 26 +++--- 182 files changed, 1325 insertions(+), 804 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/161 ipv6: fix IPV6_ADDRFORM operation logic
From: Hangbin Liu <[email protected]>
[ Upstream commit 79a1f0ccdbb4ad700590f61b00525b390cb53905 ]
Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present. Previously the checking logic looks like:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol != IPPROTO_TCP) break;
After commit b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP was blocked as the logic changed to:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol == IPPROTO_TCP) do_some_check; break; else break;
Then after commit 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation") UDP/UDPLITE were blocked as the logic changed to:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; if (sk->sk_protocol == IPPROTO_TCP) do_some_check;
if (sk->sk_protocol != IPPROTO_TCP)
break;
Fix it by using Eric's code and simply remove the break in TCP check, which looks like:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol == IPPROTO_TCP) do_some_check; else break;
--- net/ipv6/ipv6_sockglue.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/ipv6/ipv6_sockglue.c +7 -6
@@ -183,14 +183,15 @@ static int do_ipv6_setsockopt(struct soc retv = -EBUSY ;break ; } - } -if (sk->sk_protocol ==IPPROTO_TCP && - sk->sk_prot != &tcpv6_prot) { - retv = -EBUSY ; + }else if (sk->sk_protocol ==IPPROTO_TCP ) { +if (sk->sk_prot != &tcpv6_prot) { + retv = -EBUSY ; +break ; + } + }else {break ; } -if (sk->sk_protocol !=IPPROTO_TCP ) -break ; +if (sk->sk_state !=TCP_ESTABLISHED ) { retv = -ENOTCONN ;break ;
Greg Kroah-Hartman
maintainerPATCH 2/161 mlxsw: core: Use different get_trend() callbacks for different thermal zones
In reply to Greg Kroah-HartmanFrom: Vadim Pasternak <[email protected]>
[ Upstream commit 2dc2f760052da4925482ecdcdc5c94d4a599153c ]
The driver registers three different types of thermal zones: For the ASIC itself, for port modules and for gearboxes.
Currently, all three types use the same get_trend() callback which does not work correctly for the ASIC thermal zone. The callback assumes that the device data is of type 'struct mlxsw_thermal_module', whereas for the ASIC thermal zone 'struct mlxsw_thermal' is passed as device data.
Fix this by using one get_trend() callback for the ASIC thermal zone and another for the other two types.
--- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 23 +++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +19 -4
@@ -391,8 +391,7 @@ static int mlxsw_thermal_set_trip_hyst(sstatic int mlxsw_thermal_trend_get (struct thermal_zone_device *tzdev,int trip,enum thermal_trend *trend) { -struct mlxsw_thermal_module *tz = tzdev->devdata; -struct mlxsw_thermal *thermal = tz->parent; +struct mlxsw_thermal *thermal = tzdev->devdata;if (trip <0 || trip >=MLXSW_THERMAL_NUM_TRIPS )return -EINVAL ;
@@ -593,6 +592,22 @@ mlxsw_thermal_module_trip_hyst_set(strucreturn 0 ; } +static int mlxsw_thermal_module_trend_get (struct thermal_zone_device *tzdev, +int trip,enum thermal_trend *trend) +{ +struct mlxsw_thermal_module *tz = tzdev->devdata; +struct mlxsw_thermal *thermal = tz->parent; + +if (trip <0 || trip >=MLXSW_THERMAL_NUM_TRIPS ) +return -EINVAL ; + +if (tzdev == thermal->tz_highest_dev) +return 1 ; + + *trend =THERMAL_TREND_STABLE ; +return 0 ; +} +static struct thermal_zone_device_ops mlxsw_thermal_module_ops = { .bind = mlxsw_thermal_module_bind, .unbind = mlxsw_thermal_module_unbind,
@@ -604,7 +619,7 @@ static struct thermal_zone_device_ops ml .set_trip_temp = mlxsw_thermal_module_trip_temp_set, .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, - .get_trend = mlxsw_thermal_trend_get, + .get_trend = mlxsw_thermal_module_trend_get, }; static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
@@ -643,7 +658,7 @@ static struct thermal_zone_device_ops ml .set_trip_temp = mlxsw_thermal_module_trip_temp_set, .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, - .get_trend = mlxsw_thermal_trend_get, + .get_trend = mlxsw_thermal_module_trend_get, }; static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,
Greg Kroah-Hartman
maintainerPATCH 3/161 net_failover: fixed rollback in net_failover_open()
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
[ Upstream commit e8224bfe77293494626f6eec1884fee7b87d0ced ]
found by smatch:drivers/net/net_failover.c:65 net_failover_open() error:
we previously assumed 'primary_dev' could be null (see line 43)
--- drivers/net/net_failover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/net_failover.c +2 -1
@@ -61,7 +61,8 @@ static int net_failover_open(struct net_return 0 ; err_standby_open: -dev_close (primary_dev); +if (primary_dev) +dev_close (primary_dev); err_primary_open:netif_tx_disable (dev);return err;
Greg Kroah-Hartman
maintainerPATCH 4/161 tun: correct header offsets in napi frags mode
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 96aa1b22bd6bb9fccf62f6261f390ed6f3e7967f ]
Tun in IFF_NAPI_FRAGS mode calls napi_gro_frags. Unlike netif_rx and netif_gro_receive, this expects skb->data to point to the mac layer.
But skb_probe_transport_header, __skb_get_hash_symmetric, and xdp_do_generic in tun_get_user need skb->data to point to the network header. Flow dissection also needs skb->protocol set, so eth_type_trans has to be called.
Ensure the link layer header lies in linear as eth_type_trans pulls ETH_HLEN. Then take the same code paths for frags as for not frags. Push the link layer header back just before calling napi_gro_frags.
By pulling up to ETH_HLEN from frag0 into linear, this disables the frag0 optimization in the special case when IFF_NAPI_FRAGS is used with zero length iov[0] (and thus empty skb->linear).
--- drivers/net/tun.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/tun.c +10 -4
@@ -1908,8 +1908,11 @@ drop: skb->dev = tun->dev;break ;case IFF_TAP : -if (!frags) - skb->protocol =eth_type_trans (skb, tun->dev); +if (frags && !pskb_may_pull (skb,ETH_HLEN )) { + err = -ENOMEM ; + goto drop; + } + skb->protocol =eth_type_trans (skb, tun->dev);break ; }
@@ -1966,9 +1969,12 @@ drop: }if (frags) { +u32 headlen; +/* Exercise flow dissector code path. */ -u32 headlen =eth_get_headlen (tun->dev, skb->data, -skb_headlen (skb)); +skb_push (skb,ETH_HLEN ); + headlen =eth_get_headlen (tun->dev, skb->data, +skb_headlen (skb));if (unlikely (headlen >skb_headlen (skb))) {this_cpu_inc (tun->pcpu_stats->rx_dropped);
Greg Kroah-Hartman
maintainerPATCH 5/161 bridge: Avoid infinite loop when suppressing NS messages with invalid options
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 53fc685243bd6fb90d90305cea54598b78d3cbfc ]
When neighbor suppression is enabled the bridge device might reply to Neighbor Solicitation (NS) messages on behalf of remote hosts.
In case the NS message includes the "Source link-layer address" option [1], the bridge device will use the specified address as the link-layer destination address in its reply.
To avoid an infinite loop, break out of the options parsing loop when encountering an option with length zero and disregard the NS message.
This is consistent with the IPv6 ndisc code and RFC 4886 which states that "Nodes MUST silently discard an ND packet that contains an option with length zero" [2].
[1] https://tools.ietf.org/html/rfc4861#section-4.3
[2] https://tools.ietf.org/html/rfc4861#section-4.6
--- net/bridge/br_arp_nd_proxy.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bridge/br_arp_nd_proxy.c +4 -0
@@ -276,6 +276,10 @@ static void br_nd_send(struct net_bridge ns_olen = request->len - (skb_network_offset (request) +sizeof (struct ipv6hdr )) -sizeof (*ns);for (i =0 ; i < ns_olen -1 ; i += (ns->opt[i +1 ] <<3 )) { +if (!ns->opt[i +1 ]) { +kfree_skb (reply); +return ; + }if (ns->opt[i] ==ND_OPT_SOURCE_LL_ADDR ) { daddr = ns->opt + i +sizeof (struct nd_opt_hdr );break ;
Greg Kroah-Hartman
maintainerPATCH 6/161 vxlan: Avoid infinite loop when suppressing NS messages with invalid options
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 8066e6b449e050675df48e7c4b16c29f00507ff0 ]
When proxy mode is enabled the vxlan device might reply to Neighbor Solicitation (NS) messages on behalf of remote hosts.
In case the NS message includes the "Source link-layer address" option [1], the vxlan device will use the specified address as the link-layer destination address in its reply.
To avoid an infinite loop, break out of the options parsing loop when encountering an option with length zero and disregard the NS message.
This is consistent with the IPv6 ndisc code and RFC 4886 which states that "Nodes MUST silently discard an ND packet that contains an option with length zero" [2].
[1] https://tools.ietf.org/html/rfc4861#section-4.3
[2] https://tools.ietf.org/html/rfc4861#section-4.6
--- drivers/net/vxlan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/vxlan.c +4 -0
@@ -1924,6 +1924,10 @@ static struct sk_buff *vxlan_na_create(s ns_olen = request->len -skb_network_offset (request) -sizeof (struct ipv6hdr ) -sizeof (*ns);for (i =0 ; i < ns_olen-1 ; i += (ns->opt[i+1 ]<<3 )) { +if (!ns->opt[i +1 ]) { +kfree_skb (reply); +return NULL ; + }if (ns->opt[i] ==ND_OPT_SOURCE_LL_ADDR ) { daddr = ns->opt + i +sizeof (struct nd_opt_hdr );break ;
Greg Kroah-Hartman
maintainerPATCH 7/161 net: ena: xdp: XDP_TX: fix memory leak
In reply to Greg Kroah-HartmanFrom: Sameeh Jubran <[email protected]>
[ Upstream commit cd07ecccba13b8bd5023ffe7be57363d07e3105f ]
When sending very high packet rate, the XDP tx queues can get full and start dropping packets. In this case we don't free the pages which results in ena driver draining the system memory.
Fix:
Simply free the pages when necessary.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -1
@@ -358,7 +358,7 @@ error_unmap_dma:ena_unmap_tx_buff (xdp_ring, tx_info); tx_info->xdpf =NULL ; error_drop_packet: - +__free_page (tx_info->xdp_rx_page);return NETDEV_TX_OK ; }
Greg Kroah-Hartman
maintainerPATCH 8/161 net: ena: xdp: update napi budget for DROP and ABORTED
In reply to Greg Kroah-HartmanFrom: Sameeh Jubran <[email protected]>
[ Upstream commit 3921a81c31df6057183aeb7f7d204003bf699d6f ]
This patch fixes two issues with XDP:
1. If the XDP verdict is XDP_ABORTED we break the loop, which results in us handling one buffer per napi cycle instead of the total budget (usually 64). To overcome this simply change the xdp_verdict check to != XDP_PASS. When the verdict is XDP_PASS, the skb is not expected to be NULL.
2. Update the residual budget for XDP_DROP and XDP_ABORTED, since packets are handled in these cases.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +4 -4
@@ -1642,11 +1642,9 @@ static int ena_clean_rx_irq(struct ena_r &next_to_clean);if (unlikely (!skb)) { -if (xdp_verdict ==XDP_TX ) { +if (xdp_verdict ==XDP_TX )ena_free_rx_page (rx_ring, &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0 ].req_id]); - res_budget--; - }for (i =0 ; i < ena_rx_ctx.descs; i++) { rx_ring->free_ids[next_to_clean] = rx_ring->ena_bufs[i].req_id;
@@ -1654,8 +1652,10 @@ static int ena_clean_rx_irq(struct ena_rENA_RX_RING_IDX_NEXT (next_to_clean, rx_ring->ring_size); } -if (xdp_verdict ==XDP_TX || xdp_verdict ==XDP_DROP ) +if (xdp_verdict !=XDP_PASS ) { + res_budget--;continue ; + }break ; }
Greg Kroah-Hartman
maintainerPATCH 9/161 genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit c36f05559104b66bcd7f617e931e38c680227b74 ]
There are two kinds of memory leaks in genl_family_rcv_msg_dumpit():
1. Before we call ops->start(), whenever an error happens, we forget to free the memory allocated in genl_family_rcv_msg_dumpit().
2. When ops->start() fails, the 'info' has been already installed on the per socket control block, so we should not free it here. More importantly, nlk->cb_running is still false at this point, so netlink_sock_destruct() cannot free it either.
The first kind of memory leaks is easier to resolve, but the second one requires some deeper thoughts.
After reviewing how netfilter handles this, the most elegant solution I find is just to use a similar way to allocate the memory, that is, moving memory allocations from caller into ops->start(). With this, we can solve both kinds of memory leaks: for 1), no memory allocation happens before ops->start(); for 2), ops->start() handles its own failures and 'info' is installed to the socket control block only when success. The only ugliness here is we have to pass all local variables on stack via a struct, but this is not hard to understand.
Alternatively, we can introduce a ops->free() to solve this too, but it is overkill as only genetlink has this problem so far.
--- net/netlink/genetlink.c | 94 +++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 36 deletions(-)
net/netlink/genetlink.c +58 -36
@@ -513,15 +513,58 @@ static void genl_family_rcv_msg_attrs_frkfree (attrbuf); } -static int genl_lock_start (struct netlink_callback *cb) +struct genl_start_context { +const struct genl_family *family; +struct nlmsghdr *nlh; +struct netlink_ext_ack *extack; +const struct genl_ops *ops; +int hdrlen; +}; + +static int genl_start (struct netlink_callback *cb) { -const struct genl_ops *ops =genl_dumpit_info (cb)->ops; +struct genl_start_context *ctx = cb->data; +const struct genl_ops *ops = ctx->ops; +struct genl_dumpit_info *info; +struct nlattr **attrs =NULL ;int rc =0 ; +if (ops->validate &GENL_DONT_VALIDATE_DUMP ) + goto no_attrs; + +if (ctx->nlh->nlmsg_len <nlmsg_msg_size (ctx->hdrlen)) +return -EINVAL ; + + attrs =genl_family_rcv_msg_attrs_parse (ctx->family, ctx->nlh, ctx->extack, + ops, ctx->hdrlen, +GENL_DONT_VALIDATE_DUMP_STRICT , + true); +if (IS_ERR (attrs)) +return PTR_ERR (attrs); + +no_attrs: + info =genl_dumpit_info_alloc (); +if (!info) { +kfree (attrs); +return -ENOMEM ; + } + info->family = ctx->family; + info->ops = ops; + info->attrs = attrs; + + cb->data = info;if (ops->start) { -genl_lock (); +if (!ctx->family->parallel_ops) +genl_lock (); rc = ops->start (cb); -genl_unlock (); +if (!ctx->family->parallel_ops) +genl_unlock (); + } + +if (rc) { +kfree (attrs); +genl_dumpit_info_free (info); + cb->data =NULL ; }return rc; }
@@ -548,7 +591,7 @@ static int genl_lock_done(struct netlink rc = ops->done (cb);genl_unlock (); } -genl_family_rcv_msg_attrs_free (info->family, info->attrs, true); +genl_family_rcv_msg_attrs_free (info->family, info->attrs, false);genl_dumpit_info_free (info);return rc; }
@@ -573,43 +616,23 @@ static int genl_family_rcv_msg_dumpit(coconst struct genl_ops *ops, int hdrlen, struct net *net) { - struct genl_dumpit_info *info; -struct nlattr **attrs =NULL ; + struct genl_start_context ctx;int err;if (!ops->dumpit)return -EOPNOTSUPP ; -if (ops->validate &GENL_DONT_VALIDATE_DUMP ) - goto no_attrs; - -if (nlh->nlmsg_len <nlmsg_msg_size (hdrlen)) -return -EINVAL ; - - attrs =genl_family_rcv_msg_attrs_parse (family, nlh, extack, - ops, hdrlen, -GENL_DONT_VALIDATE_DUMP_STRICT , - true); -if (IS_ERR (attrs)) -return PTR_ERR (attrs); - -no_attrs: -/* Allocate dumpit info. It is going to be freed by done() callback. */ - info =genl_dumpit_info_alloc (); -if (!info) { -genl_family_rcv_msg_attrs_free (family, attrs, true); -return -ENOMEM ; - } - - info->family = family; - info->ops = ops; - info->attrs = attrs; + ctx.family = family; + ctx.nlh = nlh; + ctx.extack = extack; + ctx.ops = ops; + ctx.hdrlen = hdrlen;if (!family->parallel_ops) {struct netlink_dump_control c = { .module = family->module, - .data = info, - .start = genl_lock_start, + .data = &ctx, + .start = genl_start, .dump = genl_lock_dumpit, .done = genl_lock_done, };
@@ -617,12 +640,11 @@ no_attrs:genl_unlock (); err =__netlink_dump_start (net->genl_sock, skb, nlh, &c);genl_lock (); - }else {struct netlink_dump_control c = { .module = family->module, - .data = info, - .start = ops->start, + .data = &ctx, + .start = genl_start, .dump = ops->dumpit, .done = genl_parallel_done, };
Greg Kroah-Hartman
maintainerPATCH 10/161 net: dsa: qca8k: Fix "Unexpected gfp" kernel exception
In reply to Greg Kroah-HartmanFrom: "Michal Vokáč" <[email protected]>
[ Upstream commit 67122a7910bf2135dc7f7ececfcf16a5bdb362c1 ]
Commit 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper") replaced the dsa_switch_alloc helper by devm_kzalloc in all DSA drivers. Unfortunately it introduced a typo in qca8k.c driver and wrong argument is passed to the devm_kzalloc function.
This fix mitigates the following kernel exception:
Unexpected gfp: 0x6 (__GFP_HIGHMEM|GFP_DMA32). Fixing up to gfp: 0x101 (GFP_DMA|__GFP_ZERO). Fix your code!
CPU: 1 PID: 44 Comm: kworker/1:1 Not tainted 5.5.9-yocto-ua #1 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) Workqueue: events deferred_probe_work_func [<c0014924>] (unwind_backtrace) from [<c00123bc>] (show_stack+0x10/0x14) [<c00123bc>] (show_stack) from [<c04c8fb4>] (dump_stack+0x90/0xa4) [<c04c8fb4>] (dump_stack) from [<c00e1b10>] (new_slab+0x20c/0x214) [<c00e1b10>] (new_slab) from [<c00e1cd0>] (___slab_alloc.constprop.0+0x1b8/0x540) [<c00e1cd0>] (___slab_alloc.constprop.0) from [<c00e2074>] (__slab_alloc.constprop.0+0x1c/0x24) [<c00e2074>] (__slab_alloc.constprop.0) from [<c00e4538>] (__kmalloc_track_caller+0x1b0/0x298) [<c00e4538>] (__kmalloc_track_caller) from [<c02cccac>] (devm_kmalloc+0x24/0x70) [<c02cccac>] (devm_kmalloc) from [<c030d888>] (qca8k_sw_probe+0x94/0x1ac) [<c030d888>] (qca8k_sw_probe) from [<c0304788>] (mdio_probe+0x30/0x54) [<c0304788>] (mdio_probe) from [<c02c93bc>] (really_probe+0x1e0/0x348) [<c02c93bc>] (really_probe) from [<c02c9884>] (driver_probe_device+0x60/0x16c) [<c02c9884>] (driver_probe_device) from [<c02c7fb0>] (bus_for_each_drv+0x70/0x94) [<c02c7fb0>] (bus_for_each_drv) from [<c02c9708>] (__device_attach+0xb4/0x11c) [<c02c9708>] (__device_attach) from [<c02c8148>] (bus_probe_device+0x84/0x8c) [<c02c8148>] (bus_probe_device) from [<c02c8cec>] (deferred_probe_work_func+0x64/0x90) [<c02c8cec>] (deferred_probe_work_func) from [<c0033c14>] (process_one_work+0x1d4/0x41c) [<c0033c14>] (process_one_work) from [<c00340a4>] (worker_thread+0x248/0x528) [<c00340a4>] (worker_thread) from [<c0039148>] (kthread+0x124/0x150) [<c0039148>] (kthread) from [<c00090d8>] (ret_from_fork+0x14/0x3c) Exception stack(0xee1b5fb0 to 0xee1b5ff8) 5fa0: 00000000 00000000 00000000 00000000 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 qca8k 2188000.ethernet-1:0a: Using legacy PHYLIB callbacks. Please migrate to PHYLINK! qca8k 2188000.ethernet-1:0a eth2 (uninitialized): PHY [2188000.ethernet-1:01] driver [Generic PHY] qca8k 2188000.ethernet-1:0a eth1 (uninitialized): PHY [2188000.ethernet-1:02] driver [Generic PHY]
--- drivers/net/dsa/qca8k.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/dsa/qca8k.c +1 -2
@@ -1079,8 +1079,7 @@ qca8k_sw_probe(struct mdio_device *mdiodif (id !=QCA8K_ID_QCA8337 )return -ENODEV ; - priv->ds =devm_kzalloc (&mdiodev->dev,sizeof (*priv->ds), -QCA8K_NUM_PORTS ); + priv->ds =devm_kzalloc (&mdiodev->dev,sizeof (*priv->ds),GFP_KERNEL );if (!priv->ds)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 11/161 tipc: fix NULL pointer dereference in streaming
In reply to Greg Kroah-HartmanFrom: Tuong Lien <[email protected]>
[ Upstream commit 5e9eeccc58f3e6bcc99b929670665d2ce047e9c9 ]
syzbot found the following crash:
general protection fault, probably for non-canonical address 0xdffffc0000000019: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf] CPU: 1 PID: 7060 Comm: syz-executor394 Not tainted 5.7.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__tipc_sendstream+0xbde/0x11f0 net/tipc/socket.c:1591 Code: 00 00 00 00 48 39 5c 24 28 48 0f 44 d8 e8 fa 3e db f9 48 b8 00 00 00 00 00 fc ff df 48 8d bb c8 00 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 e2 04 00 00 48 8b 9b c8 00 00 00 48 b8 00 00 00 RSP: 0018:ffffc90003ef7818 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff8797fd9d RDX: 0000000000000019 RSI: ffffffff8797fde6 RDI: 00000000000000c8 RBP: ffff888099848040 R08: ffff88809a5f6440 R09: fffffbfff1860b4c R10: ffffffff8c305a5f R11: fffffbfff1860b4b R12: ffff88809984857e R13: 0000000000000000 R14: ffff888086aa4000 R15: 0000000000000000 FS: 00000000009b4880(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000140 CR3: 00000000a7fdf000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: tipc_sendstream+0x4c/0x70 net/tipc/socket.c:1533 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:672 ____sys_sendmsg+0x32f/0x810 net/socket.c:2352 ___sys_sendmsg+0x100/0x170 net/socket.c:2406 __sys_sendmmsg+0x195/0x480 net/socket.c:2496 __do_sys_sendmmsg net/socket.c:2525 [inline] __se_sys_sendmmsg net/socket.c:2522 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2522 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295 entry_SYSCALL_64_after_hwframe+0x49/0xb3 RIP: 0033:0x440199
...
This bug was bisected to commit 0a3e060f340d ("tipc: add test for Nagle algorithm effectiveness"). However, it is not the case, the trouble was from the base in the case of zero data length message sending, we would unexpectedly make an empty 'txq' queue after the 'tipc_msg_append()' in Nagle mode.
A similar crash can be generated even without the bisected patch but at the link layer when it accesses the empty queue.
We solve the issues by building at least one buffer to go with socket's header and an optional data section that may be empty like what we had with the 'tipc_msg_build()'.
Note: the previous commit 4c21daae3dbc ("tipc: Fix NULL pointer dereference in __tipc_sendstream()") is obsoleted by this one since the 'txq' will be never empty and the check of 'skb != NULL' is unnecessary but it is safe anyway.
--- net/tipc/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tipc/msg.c +2 -2
@@ -221,7 +221,7 @@ int tipc_msg_append(struct tipc_msg *_hd accounted = skb ?msg_blocks (buf_msg (skb)) :0 ; total = accounted; -while (rem) { + do { if (!skb || skb->len >= mss) { prev = skb; skb = tipc_buf_acquire(mss, GFP_KERNEL);
@@ -249,7 +249,7 @@ int tipc_msg_append(struct tipc_msg *_hdskb_put (skb, cpy); rem -= cpy; total +=msg_blocks (hdr) - curr; - } + }while (rem);return total - accounted; }
Greg Kroah-Hartman
maintainerPATCH 12/161 bpf: Support llvm-objcopy for vmlinux BTF
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit 90ceddcb495008ac8ba7a3dce297841efcd7d584 upstream.
Simplify gen_btf logic to make it work with llvm-objcopy. The existing 'file format' and 'architecture' parsing logic is brittle and does not work with llvm-objcopy/llvm-objdump.
'file format' output of llvm-objdump>=11 will match GNU objdump, but 'architecture' (bfdarch) may not.
.BTF in .tmp_vmlinux.btf is non-SHF_ALLOC. Add the SHF_ALLOC flag because it is part of vmlinux image used for introspection. C code can reference the section via linker script defined __start_BTF and __stop_BTF. This fixes a small problem that previous .BTF had the SHF_WRITE flag (objcopy -I binary -O elf* synthesized .data).
Additionally, objcopy -I binary synthesized symbols _binary__btf_vmlinux_bin_start and _binary__btf_vmlinux_bin_stop (not used elsewhere) are replaced with more commonplace __start_BTF and __stop_BTF.
Add 2>/dev/null because GNU objcopy (but not llvm-objcopy) warns "empty loadable segment detected at vaddr=0xffffffff81000000, is this intentional?"
We use a dd command to change the e_type field in the ELF header from ET_EXEC to ET_REL so that lld will accept .btf.vmlinux.bin.o. Accepting ET_EXEC as an input file is an extremely rare GNU ld feature that lld does not intend to support, because this is error-prone.
The output section description .BTF in include/asm-generic/vmlinux.lds.h avoids potential subtle orphan section placement issues and suppresses --orphan-handling=warn warnings.
--- arch/powerpc/kernel/vmlinux.lds.S | 6 ------ include/asm-generic/vmlinux.lds.h | 15 +++++++++++++++ kernel/bpf/btf.c | 9 ++++----- kernel/bpf/sysfs_btf.c | 11 +++++------ scripts/link-vmlinux.sh | 24 ++++++++++-------------- 5 files changed, 34 insertions(+), 31 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +0 -6
@@ -303,12 +303,6 @@ SECTIONS *(.branch_lt) } -#ifdef CONFIG_DEBUG_INFO_BTF - .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { - *(.BTF) - } -#endif - .opd : AT(ADDR(.opd) - LOAD_OFFSET) { __start_opd = .; KEEP(*(.opd))
include/asm-generic/vmlinux.lds.h +15 -0
@@ -535,6 +535,7 @@ \RO_EXCEPTION_TABLE \ NOTES \ +BTF \ \ . = ALIGN((align)); \ __end_rodata = .;
@@ -622,6 +623,20 @@ }/* +* .BTF +*/ +#ifdef CONFIG_DEBUG_INFO_BTF +#define BTF \ + .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \ + __start_BTF = .; \ + *(.BTF) \ + __stop_BTF = .; \ + } +#else +#define BTF +#endif + +/* * Init task */ #define INIT_TASK_DATA_SECTION (align) \
kernel/bpf/btf.c +4 -5
@@ -3477,8 +3477,8 @@ errout:return ERR_PTR (err); } -extern char __weak _binary__btf_vmlinux_bin_start[]; -extern char __weak _binary__btf_vmlinux_bin_end[]; +extern char __weak __start_BTF[]; +extern char __weak __stop_BTF[];extern struct btf *btf_vmlinux;#define BPF_MAP_TYPE (_id, _ops)
@@ -3605,9 +3605,8 @@ struct btf *btf_parse_vmlinux(void) } env->btf = btf; - btf->data = _binary__btf_vmlinux_bin_start; - btf->data_size = _binary__btf_vmlinux_bin_end - - _binary__btf_vmlinux_bin_start; + btf->data = __start_BTF; + btf->data_size = __stop_BTF - __start_BTF; err =btf_parse_hdr (env);if (err)
kernel/bpf/sysfs_btf.c +5 -6
@@ -9,15 +9,15 @@#include <linux/sysfs.h> /* See scripts/link-vmlinux.sh, gen_btf() func for details */ -extern char __weak _binary__btf_vmlinux_bin_start[]; -extern char __weak _binary__btf_vmlinux_bin_end[]; +extern char __weak __start_BTF[]; +extern char __weak __stop_BTF[];static ssize_t btf_vmlinux_read (struct file *file,struct kobject *kobj,struct bin_attribute *bin_attr,char *buf,loff_t off,size_t len) { -memcpy (buf, _binary__btf_vmlinux_bin_start + off, len); +memcpy (buf, __start_BTF + off, len);return len; }
@@ -30,15 +30,14 @@ static struct kobject *btf_kobj;static int __init btf_vmlinux_init (void ) { -if (!_binary__btf_vmlinux_bin_start) +if (!__start_BTF)return 0 ; btf_kobj =kobject_create_and_add ("btf" , kernel_kobj);if (!btf_kobj)return -ENOMEM ; - bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end - - _binary__btf_vmlinux_bin_start; + bin_attr_btf_vmlinux.size = __stop_BTF - __start_BTF;return sysfs_create_bin_file (btf_kobj, &bin_attr_btf_vmlinux); }
scripts/link-vmlinux.sh +10 -14
@@ -113,9 +113,6 @@ vmlinux_link() gen_btf() { local pahole_ver - local bin_arch - local bin_format - local bin_file if ! [ -x "$(command -v ${PAHOLE})" ]; then echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
@@ -133,17 +130,16 @@ gen_btf() info "BTF" ${2} LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} - # dump .BTF section into raw binary file to link with final vmlinux - bin_arch=$(LANG=C ${OBJDUMP} -f ${1} | grep architecture | \ - cut -d, -f1 | cut -d' ' -f2) - bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ - awk '{print $4}') - bin_file=.btf.vmlinux.bin - ${OBJCOPY} --change-section-address .BTF=0 \ - --set-section-flags .BTF=alloc -O binary \ - --only-section=.BTF ${1} $bin_file - ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \ - --rename-section .data=.BTF $bin_file ${2} + # Create ${2} which contains just .BTF section but no symbols. Add + # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all + # deletes all symbols including __start_BTF and __stop_BTF, which will + # be redefined in the linker script. Add 2>/dev/null to suppress GNU + # objcopy warnings: "empty loadable segment detected at ..." + ${OBJCOPY} --only-section=.BTF --set-section-flags .BTF=alloc,readonly \ + --strip-all ${1} ${2} 2>/dev/null + # Change e_type to ET_REL so that it can be used to link final vmlinux. + # Unlike GNU ld, lld does not allow an ET_EXEC input. + printf '\1' | dd of=${2} conv=notrunc bs=1 seek=16 status=none } # Create ${2} .o file with all symbols from the ${1} object file
Greg Kroah-Hartman
maintainerPATCH 13/161 elfnote: mark all .note sections SHF_ALLOC
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
commit 51da9dfb7f20911ae4e79e9b412a9c2d4c373d4b upstream.
ELFNOTE_START allows callers to specify flags for .pushsection assembler directives. All callsites but ELF_NOTE use "a" for SHF_ALLOC. For vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same section is specified twice after preprocessing, once with "a" flag, once without. Example:
.pushsection .note.Linux, "a", @note ;
.pushsection .note.Linux, "", @note ;
While GNU as allows this ordering, it warns for the opposite ordering, making these directives position dependent. We'd prefer not to precisely match this behavior in Clang's integrated assembler. Instead, the non __ASSEMBLY__ definition of ELF_NOTE uses __attribute__((section(".note.Linux"))) which is created with SHF_ALLOC, so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C and just always use "a" flag.
This allows Clang to assemble a working mainline (5.6) kernel via:
$ make CC=clang AS=clang
--- include/linux/elfnote.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/elfnote.h +1 -1
@@ -54,7 +54,7 @@ .popsection ;#define ELFNOTE (name, type, desc) \ - ELFNOTE_START(name, type, "") \ + ELFNOTE_START(name, type, "a") \ desc ; \ ELFNOTE_END
Greg Kroah-Hartman
maintainerPATCH 14/161 Input: mms114 - fix handling of mms345l
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 3f8f770575d911c989043d8f0fb8dec96360c41c ]
MMS345L is another first generation touch screen from Melfas, which uses the same registers as MMS152.
However, using I2C_M_NOSTART for it causes errors when reading:
i2c i2c-0: sendbytes: NAK bailout. mms114 0-0048: __mms114_read_reg: i2c transfer failed (-5)
The driver works fine as soon as I2C_M_NOSTART is removed.
[dtor: removed separate mms345l handling, made everyone use standard transfer mode, propagated the 10bit addressing flag to the read part of the transfer as well.]
--- drivers/input/touchscreen/mms114.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/input/touchscreen/mms114.c +5 -7
@@ -91,15 +91,15 @@ static int __mms114_read_reg(struct mms114_data *data, unsigned int reg,if (reg <=MMS114_MODE_CONTROL && reg + len >MMS114_MODE_CONTROL )BUG (); -/* Write register: use repeated start */ +/* Write register */ xfer[0 ].addr = client->addr; - xfer[0 ].flags =I2C_M_TEN |I2C_M_NOSTART ; + xfer[0 ].flags = client->flags &I2C_M_TEN ; xfer[0 ].len =1 ; xfer[0 ].buf = &buf;/* Read data */ xfer[1 ].addr = client->addr; - xfer[1 ].flags =I2C_M_RD ; + xfer[1 ].flags = (client->flags &I2C_M_TEN ) |I2C_M_RD ; xfer[1 ].len = len; xfer[1 ].buf = val;
@@ -428,10 +428,8 @@ static int mms114_probe(struct i2c_client *client,const void *match_data;int error; -if (!i2c_check_functionality (client->adapter, -I2C_FUNC_PROTOCOL_MANGLING )) { -dev_err (&client->dev, -"Need i2c bus that supports protocol mangling\n" ); +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) { +dev_err (&client->dev,"Not supported I2C adapter\n" );return -ENODEV ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 15/161 Input: axp20x-pek - always register interrupt handlers
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 9747070c11d6ae021ed7a8e96e2950ed46cd53a9 ]
On some X86 devices we do not register an input-device, because the power-button is also handled by the soc_button_array (GPIO) input driver, and we want to avoid reporting power-button presses to userspace twice.
Sofar when we did this we also did not register our interrupt handlers, since those were only necessary to report input events.
But on at least 2 device models the Medion Akoya E1239T and the GPD win, the GPIO pin used by the soc_button_array driver for the power-button cannot wakeup the system from suspend. Why this does not work is not clear, I've tried comparing the value of all relevant registers on the Cherry Trail SoC, with those from models where this does work. I've checked:
PMC registers: FUNC_DIS, FUNC_DIS2, SOIX_WAKE_EN, D3_STS_0, D3_STS_1, D3_STDBY_STS_0, D3_STDBY_STS_1; PMC ACPI I/O regs: PM1_STS_EN, GPE0a_EN and they all have identical contents in the working and non working cases. I suspect that the firmware either sets some unknown register to a value causing this, or that it turns off a power-plane which is necessary for GPIO wakeups to work during suspend.
What does work on the Medion Akoya E1239T is letting the AXP288 wakeup the system on a power-button press (the GPD win has a different PMIC).
Move the registering of the power-button press/release interrupt-handler from axp20x_pek_probe_input_device() to axp20x_pek_probe() so that the PMIC will wakeup the system on a power-button press, even if we do not register an input device.
--- drivers/input/misc/axp20x-pek.c | 72 +++++++++++++++++---------------- 1 file changed, 37 insertions(+), 35 deletions(-)
drivers/input/misc/axp20x-pek.c +37 -35
@@ -205,8 +205,11 @@ ATTRIBUTE_GROUPS(axp20x);static irqreturn_t axp20x_pek_irq (int irq,void *pwr) { -struct input_dev *idev = pwr; -struct axp20x_pek *axp20x_pek =input_get_drvdata (idev); +struct axp20x_pek *axp20x_pek = pwr; +struct input_dev *idev = axp20x_pek->input; + +if (!idev) +return IRQ_HANDLED ;/* * The power-button is connected to ground so a falling edge (dbf)
@@ -225,22 +228,9 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)static int axp20x_pek_probe_input_device (struct axp20x_pek *axp20x_pek,struct platform_device *pdev) { -struct axp20x_dev *axp20x = axp20x_pek->axp20x;struct input_dev *idev;int error; - axp20x_pek->irq_dbr =platform_get_irq_byname (pdev,"PEK_DBR" ); -if (axp20x_pek->irq_dbr <0 ) -return axp20x_pek->irq_dbr; - axp20x_pek->irq_dbr =regmap_irq_get_virq (axp20x->regmap_irqc, - axp20x_pek->irq_dbr); - - axp20x_pek->irq_dbf =platform_get_irq_byname (pdev,"PEK_DBF" ); -if (axp20x_pek->irq_dbf <0 ) -return axp20x_pek->irq_dbf; - axp20x_pek->irq_dbf =regmap_irq_get_virq (axp20x->regmap_irqc, - axp20x_pek->irq_dbf); - axp20x_pek->input =devm_input_allocate_device (&pdev->dev);if (!axp20x_pek->input)return -ENOMEM ;
@@ -255,24 +245,6 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,input_set_drvdata (idev, axp20x_pek); - error =devm_request_any_context_irq (&pdev->dev, axp20x_pek->irq_dbr, - axp20x_pek_irq,0 , -"axp20x-pek-dbr" , idev); -if (error <0 ) { -dev_err (&pdev->dev,"Failed to request dbr IRQ#%d: %d\n" , - axp20x_pek->irq_dbr, error); -return error; - } - - error =devm_request_any_context_irq (&pdev->dev, axp20x_pek->irq_dbf, - axp20x_pek_irq,0 , -"axp20x-pek-dbf" , idev); -if (error <0 ) { -dev_err (&pdev->dev,"Failed to request dbf IRQ#%d: %d\n" , - axp20x_pek->irq_dbf, error); -return error; - } - error =input_register_device (idev);if (error) { dev_err(&pdev->dev, "Can't register input device: %d\n",
@@ -280,8 +252,6 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,return error; } -device_init_wakeup (&pdev->dev, true); -return 0 ; }
@@ -339,6 +309,18 @@ static int axp20x_pek_probe(struct platform_device *pdev) axp20x_pek->axp20x =dev_get_drvdata (pdev->dev.parent); + axp20x_pek->irq_dbr =platform_get_irq_byname (pdev,"PEK_DBR" ); +if (axp20x_pek->irq_dbr <0 ) +return axp20x_pek->irq_dbr; + axp20x_pek->irq_dbr =regmap_irq_get_virq ( + axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbr); + + axp20x_pek->irq_dbf =platform_get_irq_byname (pdev,"PEK_DBF" ); +if (axp20x_pek->irq_dbf <0 ) +return axp20x_pek->irq_dbf; + axp20x_pek->irq_dbf =regmap_irq_get_virq ( + axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbf); +if (axp20x_pek_should_register_input (axp20x_pek, pdev)) { error =axp20x_pek_probe_input_device (axp20x_pek, pdev);if (error)
@@ -347,6 +329,26 @@ static int axp20x_pek_probe(struct platform_device *pdev) axp20x_pek->info = (struct axp20x_info *)match->driver_data; + error =devm_request_any_context_irq (&pdev->dev, axp20x_pek->irq_dbr, + axp20x_pek_irq,0 , +"axp20x-pek-dbr" , axp20x_pek); +if (error <0 ) { +dev_err (&pdev->dev,"Failed to request dbr IRQ#%d: %d\n" , + axp20x_pek->irq_dbr, error); +return error; + } + + error =devm_request_any_context_irq (&pdev->dev, axp20x_pek->irq_dbf, + axp20x_pek_irq,0 , +"axp20x-pek-dbf" , axp20x_pek); +if (error <0 ) { +dev_err (&pdev->dev,"Failed to request dbf IRQ#%d: %d\n" , + axp20x_pek->irq_dbf, error); +return error; + } + +device_init_wakeup (&pdev->dev, true); +platform_set_drvdata (pdev, axp20x_pek);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 16/161 ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook
In reply to Greg Kroah-HartmanFrom: Fredrik Strupe <[email protected]>
[ Upstream commit 3866f217aaa81bf7165c7f27362eee5d7919c496 ]
call_undef_hook() in traps.c applies the same instr_mask for both 16-bit and 32-bit thumb instructions. If instr_mask then is only 16 bits wide (0xffff as opposed to 0xffffffff), the first half-word of 32-bit thumb instructions will be masked out. This makes the function match 32-bit thumb instructions where the second half-word is equal to instr_val, regardless of the first half-word.
The result in this case is that all undefined 32-bit thumb instructions with the second half-word equal to 0xde01 (udf #1) work as breakpoints and will raise a SIGTRAP instead of a SIGILL, instead of just the one intended 16-bit instruction. An example of such an instruction is 0xeaa0de01, which is unallocated according to Arm ARM and should raise a SIGILL, but instead raises a SIGTRAP.
This patch fixes the issue by setting all the bits in instr_mask, which will still match the intended 16-bit thumb instruction (where the upper half is always 0), but not any 32-bit thumb instructions.
--- arch/arm/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/ptrace.c +2 -2
@@ -219,8 +219,8 @@ static struct undef_hook arm_break_hook = { };static struct undef_hook thumb_break_hook = { - .instr_mask =0xffff , - .instr_val =0xde01 , + .instr_mask =0xffffffff , + .instr_val =0x0000de01 , .cpsr_mask =PSR_T_BIT , .cpsr_val =PSR_T_BIT , .fn = break_trap,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 17/161 sched/fair: Dont NUMA balance for kthreads
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit 18f855e574d9799a0e7489f8ae6fd8447d0dd74a ]
Stefano reported a crash with using SQPOLL with io_uring:
BUG: kernel NULL pointer dereference, address: 00000000000003b0 CPU: 2 PID: 1307 Comm: io_uring-sq Not tainted 5.7.0-rc7 #11 RIP: 0010:task_numa_work+0x4f/0x2c0 Call Trace: task_work_run+0x68/0xa0 io_sq_thread+0x252/0x3d0 kthread+0xf9/0x130 ret_from_fork+0x35/0x40
which is task_numa_work() oopsing on current->mm being NULL.
The task work is queued by task_tick_numa(), which checks if current->mm is NULL at the time of the call. But this state isn't necessarily persistent, if the kthread is using use_mm() to temporarily adopt the mm of a task.
Change the task_tick_numa() check to exclude kernel threads in general, as it doesn't make sense to attempt ot balance for kthreads anyway.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -2682,7 +2682,7 @@ static void task_tick_numa(struct rq *rq, struct task_struct *curr)/* * We don't care about NUMA placement if we don't have memory. */ -if (!curr->mm || (curr->flags &PF_EXITING ) || work->next != work) +if ((curr->flags & (PF_EXITING |PF_KTHREAD )) || work->next != work)return ;/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 18/161 Input: synaptics - add a second working PNP_ID for Lenovo T470s
In reply to Greg Kroah-HartmanFrom: Dennis Kadioglu <[email protected]>
[ Upstream commit 642aa86eaf8f1e6fe894f20fd7f12f0db52ee03c ]
The Lenovo Thinkpad T470s I own has a different touchpad with "LEN007a" instead of the already included PNP ID "LEN006c". However, my touchpad seems to work well without any problems using RMI. So this patch adds the other PNP ID.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -170,6 +170,7 @@ static const char * const smbus_pnp_ids[] = {"LEN005b" ,/* P50 */ "LEN005e" ,/* T560 */ "LEN006c" ,/* T470s */ +"LEN007a" ,/* T470s */ "LEN0071" ,/* T480 */ "LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073", /* X1 Carbon G5 (Elantech) */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 19/161 csky: Fixup abiv2 syscall_trace break a4 & a5
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
[ Upstream commit e0bbb53843b5fdfe464b099217e3b9d97e8a75d7 ]
Current implementation could destory a4 & a5 when strace, so we need to get them from pt_regs by SAVE_ALL.
--- arch/csky/abiv2/inc/abi/entry.h | 2 ++ arch/csky/kernel/entry.S | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/csky/abiv2/inc/abi/entry.h +2 -0
@@ -13,6 +13,8 @@#define LSAVE_A1 28#define LSAVE_A2 32#define LSAVE_A3 36 +#define LSAVE_A4 40 +#define LSAVE_A5 44#define KSPTOUSP #define USPTOKSP
arch/csky/kernel/entry.S +4 -2
@@ -170,8 +170,10 @@ csky_syscall_trace: ldw a3, (sp, LSAVE_A3) #if defined(__CSKYABIV2__) subi sp, 8 - stw r5, (sp, 0x4) - stw r4, (sp, 0x0) + ldw r9, (sp, LSAVE_A4) + stw r9, (sp, 0x0) + ldw r9, (sp, LSAVE_A5) + stw r9, (sp, 0x4) #else ldw r6, (sp, LSAVE_A4) ldw r7, (sp, LSAVE_A5)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 20/161 gfs2: Even more gfs2_find_jhead fixes
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 20be493b787cd581c9fffad7fcd6bfbe6af1050c ]
Fix several issues in the previous gfs2_find_jhead fix:
* When updating @blocks_submitted, @block refers to the first block block not submitted yet, not the last block submitted, so fix an off-by-one error.
* We want to ensure that @blocks_submitted is far enough ahead of @blocks_read to guarantee that there is in-flight I/O. Otherwise, we'll eventually end up waiting for pages that haven't been submitted, yet.
* It's much easier to compare the number of blocks added with the number of blocks submitted to limit the maximum bio size.
* Even with bio chaining, we can keep adding blocks until we reach the maximum bio size, as long as we stop at a page boundary. This simplifies the logic.
--- fs/gfs2/lops.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
fs/gfs2/lops.c +5 -10
@@ -505,12 +505,12 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,unsigned int bsize = sdp->sd_sb.sb_bsize, off;unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift;unsigned int shift =PAGE_SHIFT - bsize_shift; -unsigned int max_bio_size =2 *1024 *1024 ; +unsigned int max_blocks =2 *1024 *1024 >> bsize_shift;struct gfs2_journal_extent *je;int sz, ret =0 ;struct bio *bio =NULL ;struct page *page =NULL ; -bool bio_chained = false, done = false; +bool done = false;errseq_t since;memset (head,0 ,sizeof (*head));
@@ -533,10 +533,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head, off =0 ; } -if (!bio || (bio_chained && !off) || - bio->bi_iter.bi_size >= max_bio_size) { -/* start new bio */ - }else { +if (bio && (off || block < blocks_submitted + max_blocks)) {sector_t sector = dblock << sdp->sd_fsb2bb_shift;if (bio_end_sector (bio) == sector) {
@@ -549,19 +546,17 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head, (PAGE_SIZE - off) >> bsize_shift; bio =gfs2_chain_bio (bio, blocks); - bio_chained = true; goto add_block_to_new_bio; } }if (bio) { - blocks_submitted = block +1 ; + blocks_submitted = block;submit_bio (bio); } bio =gfs2_log_alloc_bio (sdp, dblock, gfs2_end_log_read); bio->bi_opf =REQ_OP_READ ; - bio_chained = false; add_block_to_new_bio: sz =bio_add_page (bio, page, bsize, off);BUG_ON (sz != bsize);
@@ -569,7 +564,7 @@ block_added: off += bsize;if (off ==PAGE_SIZE ) page =NULL ; -if (blocks_submitted <2 * max_bio_size >> bsize_shift) { +if (blocks_submitted <= blocks_read + max_blocks) {/* Keep at least one bio in flight */ continue ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 21/161 drivers/net/ibmvnic: Update VNIC protocol version reporting
In reply to Greg Kroah-HartmanFrom: Thomas Falcon <[email protected]>
[ Upstream commit 784688993ebac34dffe44a9f2fabbe126ebfd4db ]
VNIC protocol version is reported in big-endian format, but it is not byteswapped before logging. Fix that, and remove version comparison as only one protocol version exists at this time.
--- drivers/net/ethernet/ibm/ibmvnic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +3 -5
@@ -4678,12 +4678,10 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,dev_err (dev,"Error %ld in VERSION_EXCHG_RSP\n" , rc);break ; } -dev_info (dev,"Partner protocol version is %d\n" , - crq->version_exchange_rsp.version); -if (be16_to_cpu (crq->version_exchange_rsp.version) < - ibmvnic_version) - ibmvnic_version = + ibmvnic_version =be16_to_cpu (crq->version_exchange_rsp.version); +dev_info (dev,"Partner protocol version is %d\n" , + ibmvnic_version);send_cap_queries (adapter);break ;case QUERY_CAPABILITY_RSP :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 22/161 staging: wfx: fix double free
In reply to Greg Kroah-HartmanFrom: Jérôme Pouiller <[email protected]>
[ Upstream commit 832cc98141b4b93acbb9231ca9e36f7fbe347f47 ]
In case of error in wfx_probe(), wdev->hw is freed. Since an error occurred, wfx_free_common() is called, then wdev->hw is freed again.
--- drivers/staging/wfx/main.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/wfx/main.c +0 -1
@@ -466,7 +466,6 @@ int wfx_probe(struct wfx_dev *wdev) err2:ieee80211_unregister_hw (wdev->hw); -ieee80211_free_hw (wdev->hw); err1:wfx_bh_unregister (wdev);return err;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 23/161 staging: mt7621-pci: properly power off dual-ported pcie phy
In reply to Greg Kroah-HartmanFrom: Sergio Paracuellos <[email protected]>
[ Upstream commit 5fcded5e857cf66c9592e4be28c4dab4520c9177 ]
Pcie phy for pcie0 and pcie1 is shared using a dual ported one. Current code was assuming that if nothing is connected in pcie0 it won't be also nothing connected in pcie1. This assumtion is wrong for some devices such us 'Mikrotik rbm33g' and 'ZyXEL LTE3301-PLUS' where only connecting a card to the second bus on the phy is possible. For such devices kernel hangs in the same point because of the wrong poweroff of the phy getting the following trace:
mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1) mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0) mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK) [hangs]
The wrong assumption is located in the 'mt7621_pcie_init_ports' function where we are just making a power off of the phy for slots 0 and 2 if nothing is connected in them. Hence, only poweroff the phy if nothing is connected in both slot 0 and slot 1 avoiding the kernel to hang.
--- drivers/staging/mt7621-pci/pci-mt7621.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/staging/mt7621-pci/pci-mt7621.c +10 -2
@@ -479,17 +479,25 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie)mt7621_perst_gpio_pcie_deassert (pcie); + tmp =NULL ;list_for_each_entry (port, &pcie->ports, list) {u32 slot = port->slot;if (!mt7621_pcie_port_is_linkup (port)) {dev_err (dev,"pcie%d no card, disable it (RST & CLK)\n" , slot); -if (slot !=1 ) -phy_power_off (port->phy);mt7621_control_assert (port);mt7621_pcie_port_clk_disable (port); port->enabled = false; + +if (slot ==0 ) { + tmp = port; +continue ; + } + +if (slot ==1 && tmp && !tmp->enabled) +phy_power_off (tmp->phy); + } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 24/161 perf probe: Accept the instance number of kretprobe event
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit c6aab66a728b6518772c74bd9dff66e1a1c652fd ]
Since the commit 6a13a0d7b4d1 ("ftrace/kprobe: Show the maxactive number on kprobe_events") introduced to show the instance number of kretprobe events, the length of the 1st format of the kprobe event will not 1, but it can be longer. This caused a parser error in perf-probe.
Skip the length check the 1st format of the kprobe event to accept this instance number.
Without this fix:
# perf probe -a vfs_read%return
Added new event:
probe:vfs_read__return (on vfs_read%return)You can now use it in all perf tools, such as:
perf record -e probe:vfs_read__return -aR sleep 1
# perf probe -l
Semantic error :Failed to parse event name: r16:probe/vfs_read__return
Error: Failed to show event list.And with this fixes:
# perf probe -a vfs_read%return
...
# perf probe -l
probe:vfs_read__return (on vfs_read%return)Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207587
--- tools/perf/util/probe-event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/probe-event.c +1 -2
@@ -1765,8 +1765,7 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev) fmt1_str =strtok_r (argv0_str,":" , &fmt); fmt2_str =strtok_r (NULL ,"/" , &fmt); fmt3_str =strtok_r (NULL ," \t" , &fmt); -if (fmt1_str ==NULL ||strlen (fmt1_str) !=1 || fmt2_str ==NULL - || fmt3_str ==NULL ) { +if (fmt1_str ==NULL || fmt2_str ==NULL || fmt3_str ==NULL ) {semantic_error ("Failed to parse event name: %s\n" , argv[0 ]); ret = -EINVAL ; goto out;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 25/161 mm: add kvfree_sensitive() for freeing sensitive data objects
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit d4eaa2837851db2bfed572898bfc17f9a9f9151e ]
For kvmalloc'ed data object that contains sensitive information like cryptographic keys, we need to make sure that the buffer is always cleared before freeing it. Using memset() alone for buffer clearing may not provide certainty as the compiler may compile it away. To be sure, the special memzero_explicit() has to be used.
This patch introduces a new kvfree_sensitive() for freeing those sensitive data objects allocated by kvmalloc(). The relevant places where kvfree_sensitive() can be used are modified to use it.
--- include/linux/mm.h | 1 + mm/util.c | 18 ++++++++++++++++++ security/keys/internal.h | 11 ----------- security/keys/keyctl.c | 16 +++++----------- 4 files changed, 24 insertions(+), 22 deletions(-)
include/linux/mm.h +1 -0
@@ -669,6 +669,7 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) }extern void kvfree (const void *addr); +extern void kvfree_sensitive (const void *addr,size_t len);/* * Mapcount of compound page as a whole, does not include mapped sub-pages.
mm/util.c +18 -0
@@ -604,6 +604,24 @@ void kvfree(const void *addr) }EXPORT_SYMBOL (kvfree); +/** +* kvfree_sensitive - Free a data object containing sensitive information. +* @addr: address of the data object to be freed. +* @len: length of the data object. +* +* Use the special memzero_explicit() function to clear the content of a +* kvmalloc'ed object containing sensitive data to make sure that the +* compiler won't optimize out the data clearing. +*/ +void kvfree_sensitive (const void *addr,size_t len) +{ +if (likely (!ZERO_OR_NULL_PTR (addr))) { +memzero_explicit ((void *)addr, len); +kvfree (addr); + } +} +EXPORT_SYMBOL (kvfree_sensitive); +static inline void *__page_rmapping (struct page *page) {unsigned long mapping;
security/keys/internal.h +0 -11
@@ -350,15 +350,4 @@ static inline void key_check(const struct key *key)#define key_check (key) do {} while(0)#endif - -/* -* Helper function to clear and free a kvmalloc'ed memory object. -*/ -static inline void __kvzfree (const void *addr,size_t len) -{ -if (addr) { -memset ((void *)addr,0 , len); -kvfree (addr); - } -}#endif /* _INTERNAL_H */
security/keys/keyctl.c +5 -11
@@ -142,10 +142,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,key_ref_put (keyring_ref); error3: -if (payload) { -memzero_explicit (payload, plen); -kvfree (payload); - } +kvfree_sensitive (payload, plen); error2:kfree (description); error:
@@ -360,7 +357,7 @@ long keyctl_update_key(key_serial_t id,key_ref_put (key_ref); error2: -__kvzfree (payload, plen); +kvfree_sensitive (payload, plen); error:return ret; }
@@ -914,7 +911,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)*/ if (ret > key_data_len) {if (unlikely (key_data)) -__kvzfree (key_data, key_data_len); +kvfree_sensitive (key_data, key_data_len); key_data_len = ret;continue ;/* Allocate buffer */ }
@@ -923,7 +920,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) ret = -EFAULT ;break ; } -__kvzfree (key_data, key_data_len); +kvfree_sensitive (key_data, key_data_len); key_put_out:key_put (key);
@@ -1225,10 +1222,7 @@ long keyctl_instantiate_key_common(key_serial_t id,keyctl_change_reqkey_auth (NULL ); error2: -if (payload) { -memzero_explicit (payload, plen); -kvfree (payload); - } +kvfree_sensitive (payload, plen); error:return ret; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 26/161 selftests: fix flower parent qdisc
In reply to Greg Kroah-HartmanFrom: Vlad Buslov <[email protected]>
[ Upstream commit 0531b0357ba37464e5c0033e1b7c69bbf5ecd8fb ]
Flower tests used to create ingress filter with specified parent qdisc "parent ffff:" but dump them on "ingress". With recent commit that fixed tcm_parent handling in dump those are not considered same parent anymore, which causes iproute2 tc to emit additional "parent ffff:" in first line of filter dump output. The change in output causes filter match in tests to fail.
Prevent parent qdisc output when dumping filters in flower tests by always correctly specifying "ingress" parent both when creating and dumping filters.
--- .../selftests/tc-testing/tc-tests/filters/tests.json | 6 +++--- tools/testing/selftests/tc-testing/tdc_batch.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/tc-testing/tc-tests/filters/tests.json +3 -3
@@ -32,7 +32,7 @@ "setup": [ "$TC qdisc add dev $DEV2 ingress" ], - "cmdUnderTest": "$TC filter add dev $DEV2 protocol ip pref 1 parent ffff: handle 0xffffffff flower action ok", + "cmdUnderTest": "$TC filter add dev $DEV2 protocol ip pref 1 ingress handle 0xffffffff flower action ok", "expExitCode": "0", "verifyCmd": "$TC filter show dev $DEV2 ingress", "matchPattern": "filter protocol ip pref 1 flower.*handle 0xffffffff",
@@ -77,9 +77,9 @@ }, "setup": [ "$TC qdisc add dev $DEV2 ingress", - "$TC filter add dev $DEV2 protocol ip prio 1 parent ffff: flower dst_mac e4:11:22:11:4a:51 src_mac e4:11:22:11:4a:50 ip_proto tcp src_ip 1.1.1.1 dst_ip 2.2.2.2 action drop" + "$TC filter add dev $DEV2 protocol ip prio 1 ingress flower dst_mac e4:11:22:11:4a:51 src_mac e4:11:22:11:4a:50 ip_proto tcp src_ip 1.1.1.1 dst_ip 2.2.2.2 action drop" ], - "cmdUnderTest": "$TC filter add dev $DEV2 protocol ip prio 1 parent ffff: flower dst_mac e4:11:22:11:4a:51 src_mac e4:11:22:11:4a:50 ip_proto tcp src_ip 1.1.1.1 dst_ip 2.2.2.2 action drop", + "cmdUnderTest": "$TC filter add dev $DEV2 protocol ip prio 1 ingress flower dst_mac e4:11:22:11:4a:51 src_mac e4:11:22:11:4a:50 ip_proto tcp src_ip 1.1.1.1 dst_ip 2.2.2.2 action drop", "expExitCode": "2", "verifyCmd": "$TC -s filter show dev $DEV2 ingress", "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
tools/testing/selftests/tc-testing/tdc_batch.py +3 -3
@@ -72,21 +72,21 @@ mac_prefix = args.mac_prefix def format_add_filter(device, prio, handle, skip, src_mac, dst_mac, share_action): - return ("filter add dev {} {} protocol ip parent ffff: handle {} " + return ("filter add dev {} {} protocol ip ingress handle {} " " flower {} src_mac {} dst_mac {} action drop {}".format( device, prio, handle, skip, src_mac, dst_mac, share_action)) def format_rep_filter(device, prio, handle, skip, src_mac, dst_mac, share_action): - return ("filter replace dev {} {} protocol ip parent ffff: handle {} " + return ("filter replace dev {} {} protocol ip ingress handle {} " " flower {} src_mac {} dst_mac {} action drop {}".format( device, prio, handle, skip, src_mac, dst_mac, share_action)) def format_del_filter(device, prio, handle, skip, src_mac, dst_mac, share_action): - return ("filter del dev {} {} protocol ip parent ffff: handle {} " + return ("filter del dev {} {} protocol ip ingress handle {} " "flower".format(device, prio, handle))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 27/161 fanotify: fix ignore mask logic for events on child and on dir
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
[ Upstream commit 2f02fd3fa13e51713b630164f8a8e5b42de8283b ]
The comments in fanotify_group_event_mask() say:
"If the event is on dir/child and this mark doesn't care about
events on dir/child, don't send it!"
Specifically, mount and filesystem marks do not care about events on child, but they can still specify an ignore mask for those events. For example, a group that has:
- A mount mark with mask 0 and ignore_mask FAN_OPEN
- An inode mark on a directory with mask FAN_OPEN | FAN_OPEN_EXEC with flag FAN_EVENT_ON_CHILD
A child file open for exec would be reported to group with the FAN_OPEN event despite the fact that FAN_OPEN is in ignore mask of mount mark, because the mark iteration loop skips over non-inode marks for events on child when calculating the ignore mask.
Move ignore mask calculation to the top of the iteration loop block before excluding marks for events on dir/child.
--- fs/notify/fanotify/fanotify.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/notify/fanotify/fanotify.c +4 -1
@@ -171,6 +171,10 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group,if (!fsnotify_iter_should_report_type (iter_info, type))continue ; mark = iter_info->marks[type]; + +/* Apply ignore mask regardless of ISDIR and ON_CHILD flags */ + marks_ignored_mask |= mark->ignored_mask; +/* * If the event is on dir and this mark doesn't care about * events on dir, don't send it!
@@ -188,7 +192,6 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group,continue ; marks_mask |= mark->mask; - marks_ignored_mask |= mark->ignored_mask; } test_mask = event_mask & marks_mask & ~marks_ignored_mask;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 28/161 driver core: Update device link status correctly for SYNC_STATE_ONLY links
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 8c3e315d4296421cd26b3300ee0ac117f0877f20 ]
When SYNC_STATE_ONLY support was added in commit 05ef983e0d65 ("driver
core: Add device link support for SYNC_STATE_ONLY flag"), SYNC_STATE_ONLY links were treated similar to STATELESS links in terms of not blocking consumer probe if the supplier hasn't probed yet.
That caused a SYNC_STATE_ONLY device link's status to not get updated. Since SYNC_STATE_ONLY device link is no longer useful once the consumer probes, commit 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link implementation") addresses the status update issue by deleting the SYNC_STATE_ONLY device link instead of complicating the status update code.
However, there are still some cases where we need to update the status of a SYNC_STATE_ONLY device link. This is because a SYNC_STATE_ONLY device link can later get converted into a normal MANAGED device link when a normal MANAGED device link is created between a supplier and consumer that already have a SYNC_STATE_ONLY device link between them.
If a SYNC_STATE_ONLY device link's status isn't maintained correctly till it's converted to a normal MANAGED device link, then the normal MANAGED device link will end up with a wrong link status. This can cause a warning stack trace[1] when the consumer device probes successfully.
This commit fixes the SYNC_STATE_ONLY device link status update issue where it wouldn't transition correctly from DL_STATE_DORMANT or DL_STATE_AVAILABLE to DL_STATE_CONSUMER_PROBE. It also resets the status back to DL_STATE_DORMANT or DL_STATE_AVAILABLE if the consumer probe fails.
[1] - https://lore.kernel.org/lkml/20200522204120.3b3c9ed6@apollo/
--- drivers/base/core.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/base/core.c +26 -8
@@ -643,9 +643,17 @@ static void device_links_missing_supplier(struct device *dev) {struct device_link *link; -list_for_each_entry (link, &dev->links.suppliers, c_node) -if (link->status ==DL_STATE_CONSUMER_PROBE ) +list_for_each_entry (link, &dev->links.suppliers, c_node) { +if (link->status !=DL_STATE_CONSUMER_PROBE ) +continue ; + +if (link->supplier->links.status ==DL_DEV_DRIVER_BOUND ) {WRITE_ONCE (link->status,DL_STATE_AVAILABLE ); + }else { +WARN_ON (!(link->flags &DL_FLAG_SYNC_STATE_ONLY )); +WRITE_ONCE (link->status,DL_STATE_DORMANT ); + } + } }/**
@@ -684,11 +692,11 @@ int device_links_check_suppliers(struct device *dev)device_links_write_lock ();list_for_each_entry (link, &dev->links.suppliers, c_node) { -if (!(link->flags &DL_FLAG_MANAGED ) || - link->flags &DL_FLAG_SYNC_STATE_ONLY ) +if (!(link->flags &DL_FLAG_MANAGED ))continue ; -if (link->status !=DL_STATE_AVAILABLE ) { +if (link->status !=DL_STATE_AVAILABLE && + !(link->flags &DL_FLAG_SYNC_STATE_ONLY )) {device_links_missing_supplier (dev); ret = -EPROBE_DEFER ;break ;
@@ -949,11 +957,21 @@ static void __device_links_no_driver(struct device *dev)if (!(link->flags &DL_FLAG_MANAGED ))continue ; -if (link->flags &DL_FLAG_AUTOREMOVE_CONSUMER ) +if (link->flags &DL_FLAG_AUTOREMOVE_CONSUMER ) {device_link_drop_managed (link); -else if (link->status ==DL_STATE_CONSUMER_PROBE || - link->status ==DL_STATE_ACTIVE ) +continue ; + } + +if (link->status !=DL_STATE_CONSUMER_PROBE && + link->status !=DL_STATE_ACTIVE ) +continue ; + +if (link->supplier->links.status ==DL_DEV_DRIVER_BOUND ) {WRITE_ONCE (link->status,DL_STATE_AVAILABLE ); + }else { +WARN_ON (!(link->flags &DL_FLAG_SYNC_STATE_ONLY )); +WRITE_ONCE (link->status,DL_STATE_DORMANT ); + } } dev->links.status =DL_DEV_NO_DRIVER ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 29/161 powerpc/xive: Clear the page tables for the ESB IO mapping
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
[ Upstream commit a101950fcb78b0ba20cd487be6627dea58d55c2b ]
Commit 1ca3dec2b2df ("powerpc/xive: Prevent page fault issues in the machine crash handler") fixed an issue in the FW assisted dump of machines using hash MMU and the XIVE interrupt mode under the POWER hypervisor. It forced the mapping of the ESB page of interrupts being mapped in the Linux IRQ number space to make sure the 'crash kexec' sequence worked during such an event. But it didn't handle the un-mapping.
This mapping is now blocking the removal of a passthrough IO adapter under the POWER hypervisor because it expects the guest OS to have cleared all page table entries related to the adapter. If some are still present, the RTAS call which isolates the PCI slot returns error 9001 "valid outstanding translations".
Remove these mapping in the IRQ data cleanup routine.
Under KVM, this cleanup is not required because the ESB pages for the adapter interrupts are un-mapped from the guest by the hypervisor in the KVM XIVE native device. This is now redundant but it's harmless.
--- arch/powerpc/sysdev/xive/common.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/sysdev/xive/common.c +5 -0
@@ -19,6 +19,7 @@#include <linux/slab.h> #include <linux/spinlock.h> #include <linux/msi.h> +#include <linux/vmalloc.h> #include <asm/prom.h> #include <asm/io.h>
@@ -1013,12 +1014,16 @@ EXPORT_SYMBOL_GPL(is_xive_irq);void xive_cleanup_irq_data (struct xive_irq_data *xd) {if (xd->eoi_mmio) { +unmap_kernel_range ((unsigned long )xd->eoi_mmio, +1u << xd->esb_shift);iounmap (xd->eoi_mmio);if (xd->eoi_mmio == xd->trig_mmio) xd->trig_mmio =NULL ; xd->eoi_mmio =NULL ; }if (xd->trig_mmio) { +unmap_kernel_range ((unsigned long )xd->trig_mmio, +1u << xd->esb_shift);iounmap (xd->trig_mmio); xd->trig_mmio =NULL ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 30/161 ASoC: SOF: imx8: Fix randbuild error
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit fe17e6cdc0fefca96ba9659be4b2b07487cbf0c5 ]
when do randconfig like this:CONFIG_SND_SOC_SOF_IMX8_SUPPORT=yCONFIG_SND_SOC_SOF_IMX8=yCONFIG_SND_SOC_SOF_OF=yCONFIG_IMX_DSP=mCONFIG_IMX_SCU=y
there is a link error:
sound/soc/sof/imx/imx8.o: In function 'imx8_send_msg':
imx8.c:(.text+0x380): undefined reference to 'imx_dsp_ring_doorbell'
Select IMX_DSP in SND_SOC_SOF_IMX8_SUPPORT to fix this
--- sound/soc/sof/imx/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/imx/Kconfig +1 -1
@@ -14,7 +14,7 @@ if SND_SOC_SOF_IMX_TOPLEVEL config SND_SOC_SOF_IMX8_SUPPORT bool "SOF support for i.MX8" depends on IMX_SCU - depends on IMX_DSP + select IMX_DSP help This adds support for Sound Open Firmware for NXP i.MX8 platforms Say Y if you have such a device.
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 31/161 ASoC: SOF: imx: fix undefined reference issue
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit cb0312f61c3e95c71ec8955a94d42bf7eb5ba617 ]
make.cross ARCH=mips allyesconfig fails with the following error:
sound/soc/sof/sof-of-dev.o:(.data.sof_of_imx8qxp_desc+0x40): undefined reference to `sof_imx8x_ops'.
This seems to be a Makefile order issue, solve by using the same structure as for Intel platforms.
dependency")
--- sound/soc/sof/imx/Kconfig | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
sound/soc/sof/imx/Kconfig +13 -4
@@ -11,17 +11,26 @@ config SND_SOC_SOF_IMX_TOPLEVEL if SND_SOC_SOF_IMX_TOPLEVEL +config SND_SOC_SOF_IMX_OF + def_tristate SND_SOC_SOF_OF + select SND_SOC_SOF_IMX8 if SND_SOC_SOF_IMX8_SUPPORT + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level + config SND_SOC_SOF_IMX8_SUPPORT bool "SOF support for i.MX8" - depends on IMX_SCU - select IMX_DSP help This adds support for Sound Open Firmware for NXP i.MX8 platforms Say Y if you have such a device. If unsure select "N". config SND_SOC_SOF_IMX8 - def_tristate SND_SOC_SOF_OF - depends on SND_SOC_SOF_IMX8_SUPPORT + tristate + depends on IMX_SCU + select IMX_DSP + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level endif ## SND_SOC_SOF_IMX_IMX_TOPLEVEL
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 32/161 spi: dw: Fix native CS being unset
In reply to Greg Kroah-Hartman[ Upstream commit 9aea644ca17b94f82ad7fa767cbc4509642f4420 ]
Commit 6e0a32d6f376 ("spi: dw: Fix default polarity of native chipselect") attempted to fix the problem when GPIO active-high chip-select is utilized to communicate with some SPI slave. It fixed the problem, but broke the normal native CS support. At the same time the reversion commit ada9e3fcc175 ("spi: dw: Correct handling of native chipselect") didn't solve the problem either, since it just inverted the set_cs() polarity perception without taking into account that CS-high might be applicable. Here is what is done to finally fix the problem.
DW SPI controller demands any native CS being set in order to proceed with data transfer. So in order to activate the SPI communications we must set any bit in the Slave Select DW SPI controller register no matter whether the platform requests the GPIO- or native CS. Preferably it should be the bit corresponding to the SPI slave CS number. But currently the dw_spi_set_cs() method activates the chip-select only if the second argument is false. Since the second argument of the set_cs callback is expected to be a boolean with "is-high" semantics (actual chip-select pin state value), the bit in the DW SPI Slave Select register will be set only if SPI core requests the driver to set the CS in the low state. So this will work for active-low GPIO-based CS case, and won't work for active-high CS setting the bit when SPI core actually needs to deactivate the CS.
This commit fixes the problem for all described cases. So no matter whether an SPI slave needs GPIO- or native-based CS with active-high or low signal the corresponding bit will be set in SER.
--- drivers/spi/spi-dw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/spi/spi-dw.c +9 -1
@@ -128,12 +128,20 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable) {struct dw_spi *dws =spi_controller_get_devdata (spi->controller);struct chip_data *chip =spi_get_ctldata (spi); +bool cs_high = !!(spi->mode &SPI_CS_HIGH );/* Chip select logic is inverted from spi_set_cs() */ if (chip && chip->cs_control) chip->cs_control (!enable); -if (!enable) +/* +* DW SPI controller demands any native CS being set in order to +* proceed with data transfer. So in order to activate the SPI +* communications we must set a corresponding bit in the Slave +* Enable register no matter whether the SPI core is configured to +* support active-high or active-low CS level. +*/ +if (cs_high == enable)dw_writel (dws,DW_SPI_SER ,BIT (spi->chip_select));else if (dws->cs_override)dw_writel (dws,DW_SPI_SER ,0 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 33/161 ath9k_htc: Silence undersized packet warnings
In reply to Greg Kroah-HartmanFrom: Masashi Honma <[email protected]>
[ Upstream commit 450edd2805982d14ed79733a82927d2857b27cac ]
Some devices like TP-Link TL-WN722N produces this kind of messages frequently.
kernel: ath: phy0: Short RX data len, dropping (dlen: 4)
This warning is useful for developers to recognize that the device (Wi-Fi dongle or USB hub etc) is noisy but not for general users. So this patch make this warning to debug message.
Ref: https://bugzilla.kernel.org/show_bug.cgi?id=207539
--- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +3 -3
@@ -999,9 +999,9 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,* which are not PHY_ERROR (short radar pulses have a length of 3) */ if (unlikely (!rs_datalen || (rs_datalen <10 && !is_phyerr))) { -ath_warn (common, -"Short RX data len, dropping (dlen: %d)\n" , - rs_datalen); +ath_dbg (common,ANY , +"Short RX data len, dropping (dlen: %d)\n" , + rs_datalen); goto rx_next; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 34/161 smack: avoid unused sip variable warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 00720f0e7f288d29681d265c23b22bb0f0f4e5b4 ]
The mix of IS_ENABLED() and #ifdef checks has left a combination that causes a warning about an unused variable:
security/smack/smack_lsm.c: In function 'smack_socket_connect':security/smack/smack_lsm.c:2838:24: error: unused variable 'sip' [-Werror=unused-variable]
2838 | struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;
Change the code to use C-style checks consistently so the compiler can handle it correctly.
--- security/smack/smack.h | 6 ------ security/smack/smack_lsm.c | 25 ++++++++----------------- 2 files changed, 8 insertions(+), 23 deletions(-)
security/smack/smack.h +0 -6
@@ -148,7 +148,6 @@ struct smk_net4addr {struct smack_known *smk_label;/* label */ }; -#if IS_ENABLED (CONFIG_IPV6 )/* * An entry in the table identifying IPv6 hosts. */
@@ -159,9 +158,7 @@ struct smk_net6addr {int smk_masks;/* mask size */ struct smack_known *smk_label;/* label */ }; -#endif /* CONFIG_IPV6 */ -#ifdef SMACK_IPV6_PORT_LABELING /* * An entry in the table identifying ports. */
@@ -174,7 +171,6 @@ struct smk_port_label {short smk_sock_type;/* Socket type */ short smk_can_reuse; }; -#endif /* SMACK_IPV6_PORT_LABELING */ struct smack_known_list_elem {struct list_head list;
@@ -335,9 +331,7 @@ extern struct smack_known smack_known_web;extern struct mutex smack_known_lock;extern struct list_head smack_known_list;extern struct list_head smk_net4addr_list; -#if IS_ENABLED (CONFIG_IPV6 )extern struct list_head smk_net6addr_list; -#endif /* CONFIG_IPV6 */ extern struct mutex smack_onlycap_lock;extern struct list_head smack_onlycap_list;
security/smack/smack_lsm.c +8 -17
@@ -50,10 +50,8 @@#define SMK_RECEIVING 1#define SMK_SENDING 2 -#ifdef SMACK_IPV6_PORT_LABELING -DEFINE_MUTEX (smack_ipv6_lock); +static DEFINE_MUTEX (smack_ipv6_lock);static LIST_HEAD (smk_ipv6_port_list); -#endif static struct kmem_cache *smack_inode_cache;struct kmem_cache *smack_rule_cache;int smack_enabled;
@@ -2320,7 +2318,6 @@ static struct smack_known *smack_ipv4host_label(struct sockaddr_in *sip)return NULL ; } -#if IS_ENABLED (CONFIG_IPV6 )/* * smk_ipv6_localhost - Check for local ipv6 host address * @sip: the address
@@ -2388,7 +2385,6 @@ static struct smack_known *smack_ipv6host_label(struct sockaddr_in6 *sip)return NULL ; } -#endif /* CONFIG_IPV6 */ /** * smack_netlabel - Set the secattr on a socket
@@ -2477,7 +2473,6 @@ static int smack_netlabel_send(struct sock *sk, struct sockaddr_in *sap)return smack_netlabel (sk, sk_lbl); } -#if IS_ENABLED (CONFIG_IPV6 )/** * smk_ipv6_check - check Smack access * @subject: subject Smack label
@@ -2510,7 +2505,6 @@ static int smk_ipv6_check(struct smack_known *subject, rc =smk_bu_note ("IPv6 check" , subject, object,MAY_WRITE , rc);return rc; } -#endif /* CONFIG_IPV6 */ #ifdef SMACK_IPV6_PORT_LABELING /**
@@ -2599,6 +2593,7 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)mutex_unlock (&smack_ipv6_lock); return; } +#endif /** * smk_ipv6_port_check - check Smack port access
@@ -2661,7 +2656,6 @@ static int smk_ipv6_port_check(struct sock *sk, struct sockaddr_in6 *address,return smk_ipv6_check (skp, object, address, act); } -#endif /* SMACK_IPV6_PORT_LABELING */ /** * smack_inode_setsecurity - set smack xattrs
@@ -2836,24 +2830,21 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,return 0 ;if (IS_ENABLED (CONFIG_IPV6 ) && sap->sa_family ==AF_INET6 ) {struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap; -#ifdef SMACK_IPV6_SECMARK_LABELING -struct smack_known *rsp; -#endif +struct smack_known *rsp =NULL ;if (addrlen <SIN6_LEN_RFC2133 )return 0 ; -#ifdef SMACK_IPV6_SECMARK_LABELING - rsp =smack_ipv6host_label (sip); +if (__is_defined (SMACK_IPV6_SECMARK_LABELING )) + rsp =smack_ipv6host_label (sip);if (rsp !=NULL ) {struct socket_smack *ssp = sock->sk->sk_security; rc =smk_ipv6_check (ssp->smk_out, rsp, sip,SMK_CONNECTING ); } -#endif -#ifdef SMACK_IPV6_PORT_LABELING - rc =smk_ipv6_port_check (sock->sk, sip,SMK_CONNECTING ); -#endif +if (__is_defined (SMACK_IPV6_PORT_LABELING )) + rc =smk_ipv6_port_check (sock->sk, sip,SMK_CONNECTING ); +return rc; }if (sap->sa_family !=AF_INET || addrlen <sizeof (struct sockaddr_in ))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 35/161 RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit eb356e6dc15a30af604f052cd0e170450193c254 ]
If is_closed is set, and the event list is empty, then read() will return -EIO without blocking. After setting is_closed in ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait, but the fops->poll() function does not check it, so poll will continue to sleep on an empty list.
--- drivers/infiniband/core/uverbs_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/uverbs_main.c +2 -0
@@ -296,6 +296,8 @@ static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,spin_lock_irq (&ev_queue->lock);if (!list_empty (&ev_queue->event_list)) pollflags =EPOLLIN |EPOLLRDNORM ; +else if (ev_queue->is_closed) + pollflags =EPOLLERR ;spin_unlock_irq (&ev_queue->lock);return pollflags;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 36/161 padata: add separate cpuhp node for CPUHP_PADATA_DEAD
In reply to Greg Kroah-HartmanFrom: Daniel Jordan <[email protected]>
[ Upstream commit 3c2214b6027ff37945799de717c417212e1a8c54 ]
Removing the pcrypt module triggers this:
general protection fault, probably for non-canonical
address 0xdead000000000122
CPU: 5 PID: 264 Comm: modprobe Not tainted 5.6.0+ #2
Hardware name: QEMU Standard PC
RIP: 0010:__cpuhp_state_remove_instance+0xcc/0x120
Call Trace:
padata_sysfs_release+0x74/0xce
kobject_put+0x81/0xd0
padata_free+0x12/0x20
pcrypt_exit+0x43/0x8ee [pcrypt]padata instances wrongly use the same hlist node for the online and dead states, so __padata_free()'s second cpuhp remove call chokes on the node that the first poisoned.
cpuhp multi-instance callbacks only walk forward in cpuhp_step->list and the same node is linked in both the online and dead lists, so the list corruption that results from padata_alloc() adding the node to a second list without removing it from the first doesn't cause problems as long as no instances are freed.
Avoid the issue by giving each state its own node.
--- include/linux/padata.h | 6 ++++-- kernel/padata.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-)
include/linux/padata.h +4 -2
@@ -139,7 +139,8 @@ struct padata_shell {/** * struct padata_instance - The overall control structure. * -* @node: Used by CPU hotplug. +* @cpu_online_node: Linkage for CPU online callback. +* @cpu_dead_node: Linkage for CPU offline callback. * @parallel_wq: The workqueue used for parallel work. * @serial_wq: The workqueue used for serial work. * @pslist: List of padata_shell objects attached to this instance.
@@ -150,7 +151,8 @@ struct padata_shell {* @flags: padata flags. */ struct padata_instance { -struct hlist_node node; +struct hlist_node cpu_online_node; +struct hlist_node cpu_dead_node;struct workqueue_struct *parallel_wq;struct workqueue_struct *serial_wq;struct list_head pslist;
kernel/padata.c +8 -6
@@ -703,7 +703,7 @@ static int padata_cpu_online(unsigned int cpu, struct hlist_node *node)struct padata_instance *pinst;int ret; - pinst = hlist_entry_safe(node, struct padata_instance, node); + pinst = hlist_entry_safe(node, struct padata_instance, cpu_online_node);if (!pinst_has_cpu (pinst, cpu))return 0 ;
@@ -718,7 +718,7 @@ static int padata_cpu_dead(unsigned int cpu, struct hlist_node *node)struct padata_instance *pinst;int ret; - pinst = hlist_entry_safe(node, struct padata_instance, node); + pinst = hlist_entry_safe(node, struct padata_instance, cpu_dead_node);if (!pinst_has_cpu (pinst, cpu))return 0 ;
@@ -734,8 +734,9 @@ static enum cpuhp_state hp_online;static void __padata_free (struct padata_instance *pinst) {#ifdef CONFIG_HOTPLUG_CPU -cpuhp_state_remove_instance_nocalls (CPUHP_PADATA_DEAD , &pinst->node); -cpuhp_state_remove_instance_nocalls (hp_online, &pinst->node); +cpuhp_state_remove_instance_nocalls (CPUHP_PADATA_DEAD , + &pinst->cpu_dead_node); +cpuhp_state_remove_instance_nocalls (hp_online, &pinst->cpu_online_node);#endif WARN_ON (!list_empty (&pinst->pslist));
@@ -939,9 +940,10 @@ static struct padata_instance *padata_alloc(const char *name,mutex_init (&pinst->lock);#ifdef CONFIG_HOTPLUG_CPU -cpuhp_state_add_instance_nocalls_cpuslocked (hp_online, &pinst->node); +cpuhp_state_add_instance_nocalls_cpuslocked (hp_online, + &pinst->cpu_online_node);cpuhp_state_add_instance_nocalls_cpuslocked (CPUHP_PADATA_DEAD , - &pinst->node); + &pinst->cpu_dead_node);#endif put_online_cpus ();
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 37/161 s390/pci: Log new handle in clp_disable_fh()
In reply to Greg Kroah-HartmanFrom: Petr Tesarik <[email protected]>
[ Upstream commit e1750a3d9abbea2ece29cac8dc5a6f5bc19c1492 ]
After disabling a function, the original handle is logged instead of the disabled handle.
--- arch/s390/pci/pci_clp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/pci/pci_clp.c +1 -2
@@ -309,14 +309,13 @@ int clp_enable_fh(struct zpci_dev *zdev, u8 nr_dma_as)int clp_disable_fh (struct zpci_dev *zdev) { -u32 fh = zdev->fh;int rc;if (!zdev_enabled (zdev))return 0 ; rc =clp_set_pci_fn (zdev,0 ,CLP_SET_DISABLE_PCI_FN ); -zpci_dbg (3 ,"dis fid:%x, fh:%x, rc:%d\n" , zdev->fid, fh, rc); +zpci_dbg (3 ,"dis fid:%x, fh:%x, rc:%d\n" , zdev->fid, zdev->fh, rc);return rc; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 38/161 x86/cpu/amd: Make erratum #1054 a legacy erratum
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
[ Upstream commit e2abfc0448a46d8a137505aa180caf14070ec535 ]
Commit
21b5ee59ef18 ("x86/cpu/amd: Enable the fixed Instructions Retired
counter IRPERF")
mistakenly added erratum #1054 as an OS Visible Workaround (OSVW) ID 0. Erratum #1054 is not OSVW ID 0 [1], so make it a legacy erratum.
There would never have been a false positive on older hardware that has OSVW bit 0 set, since the IRPERF feature was not available.
However, save a couple of RDMSR executions per thread, on modern system configurations that correctly set non-zero values in their OSVW_ID_Length MSRs.
[1] Revision Guide for AMD Family 17h Models 00h-0Fh Processors. The revision guide is available from the bugzilla link below.
--- arch/x86/kernel/cpu/amd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/amd.c +1 -2
@@ -1111,8 +1111,7 @@ static const int amd_erratum_383[] =/* #1054: Instructions Retired Performance Counter May Be Inaccurate */ static const int amd_erratum_1054[] = -AMD_OSVW_ERRATUM (0 ,AMD_MODEL_RANGE (0x17 ,0 ,0 ,0x2f ,0xf )); - +AMD_LEGACY_ERRATUM (AMD_MODEL_RANGE (0x17 ,0 ,0 ,0x2f ,0xf ));static bool cpu_has_amd_erratum (struct cpuinfo_x86 *cpu,const int *erratum) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 39/161 KVM: x86: only do L1TF workaround on affected processors
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
[ Upstream commit d43e2675e96fc6ae1a633b6a69d296394448cc32 ]
KVM stores the gfn in MMIO SPTEs as a caching optimization. These are split in two parts, as in "[high 11111 low]", to thwart any attempt to use these bits in an L1TF attack. This works as long as there are 5 free bits between MAXPHYADDR and bit 50 (inclusive), leaving bit 51 free so that the MMIO access triggers a reserved-bit-set page fault.
The bit positions however were computed wrongly for AMD processors that have encryption support. In this case, x86_phys_bits is reduced (for example from 48 to 43, to account for the C bit at position 47 and four bits used internally to store the SEV ASID and other stuff) while x86_cache_bits in would remain set to 48, and _all_ bits between the reduced MAXPHYADDR and bit 51 are set. Then low_phys_bits would also cover some of the bits that are set in the shadow_mmio_value, terribly confusing the gfn caching mechanism.
To fix this, avoid splitting gfns as long as the processor does not have the L1TF bug (which includes all AMD processors). When there is no splitting, low_phys_bits can be set to the reduced MAXPHYADDR removing the overlap. This fixes "npt=0" operation on EPYC processors.
Thanks to Maxim Levitsky for bisecting this bug.
--- arch/x86/kvm/mmu/mmu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
arch/x86/kvm/mmu/mmu.c +10 -9
@@ -343,6 +343,8 @@ void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value, u64 access_mask) {BUG_ON ((u64 )(unsigned )access_mask != access_mask);BUG_ON ((mmio_mask & mmio_value) != mmio_value); +WARN_ON (mmio_value & (shadow_nonpresent_or_rsvd_mask << shadow_nonpresent_or_rsvd_mask_len)); +WARN_ON (mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask); shadow_mmio_value = mmio_value |SPTE_MMIO_MASK ; shadow_mmio_mask = mmio_mask |SPTE_SPECIAL_MASK ; shadow_mmio_access_mask = access_mask;
@@ -591,16 +593,15 @@ static void kvm_mmu_reset_all_pte_masks(void)* the most significant bits of legal physical address space. */ shadow_nonpresent_or_rsvd_mask =0 ; - low_phys_bits = boot_cpu_data.x86_cache_bits; -if (boot_cpu_data.x86_cache_bits < -52 - shadow_nonpresent_or_rsvd_mask_len) { + low_phys_bits = boot_cpu_data.x86_phys_bits; +if (boot_cpu_has_bug (X86_BUG_L1TF ) && + !WARN_ON_ONCE (boot_cpu_data.x86_cache_bits >= +52 - shadow_nonpresent_or_rsvd_mask_len)) { + low_phys_bits = boot_cpu_data.x86_cache_bits + - shadow_nonpresent_or_rsvd_mask_len; shadow_nonpresent_or_rsvd_mask = -rsvd_bits (boot_cpu_data.x86_cache_bits - - shadow_nonpresent_or_rsvd_mask_len, - boot_cpu_data.x86_cache_bits -1 ); - low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; - }else -WARN_ON_ONCE (boot_cpu_has_bug (X86_BUG_L1TF )); +rsvd_bits (low_phys_bits, boot_cpu_data.x86_cache_bits -1 ); + } shadow_nonpresent_or_rsvd_lower_gfn_mask =GENMASK_ULL (low_phys_bits -1 ,PAGE_SHIFT );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 40/161 PCI/PM: Adjust pcie_wait_for_link_delay() for caller delay
In reply to Greg Kroah-HartmanFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit f044baaff1eb7ae5aa7a36f1b7ad5bd8eeb672c4 ]
The caller of pcie_wait_for_link_delay() specifies the time to wait after the link becomes active. When the downstream port doesn't support link active reporting, obviously we can't tell when the link becomes active, so we waited the worst-case time (1000 ms) plus 100 ms, ignoring the delay from the caller.
Instead, wait for 1000 ms + the delay from the caller.
--- drivers/pci/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci.c +2 -2
@@ -4616,10 +4616,10 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,/* * Some controllers might not implement link active reporting. In this -* case, we wait for 1000 + 100 ms. +* case, we wait for 1000 ms + any delay requested by the caller. */ if (!pdev->link_active_reporting) { -msleep (1100 ); +msleep (timeout + delay);return true; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 41/161 kobject: Make sure the parent does not get released before its children
In reply to Greg Kroah-HartmanFrom: Heikki Krogerus <[email protected]>
[ Upstream commit 4ef12f7198023c09ad6d25b652bd8748c965c7fa ]
In the function kobject_cleanup(), kobject_del(kobj) is called before the kobj->release(). That makes it possible to release the parent of the kobject before the kobject itself.
To fix that, adding function __kboject_del() that does everything that kobject_del() does except release the parent reference. kobject_cleanup() then calls __kobject_del() instead of kobject_del(), and separately decrements the reference count of the parent kobject after kobj->release() has been called.
--- lib/kobject.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
lib/kobject.c +20 -10
@@ -599,14 +599,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) }EXPORT_SYMBOL_GPL (kobject_move); -/** -* kobject_del() - Unlink kobject from hierarchy. -* @kobj: object. -* -* This is the function that should be called to delete an object -* successfully added via kobject_add(). -*/ -void kobject_del (struct kobject *kobj) +static void __kobject_del (struct kobject *kobj) {struct kernfs_node *sd;const struct kobj_type *ktype;
@@ -625,9 +618,23 @@ void kobject_del(struct kobject *kobj) kobj->state_in_sysfs =0 ;kobj_kset_leave (kobj); -kobject_put (kobj->parent); kobj->parent =NULL ; } + +/** +* kobject_del() - Unlink kobject from hierarchy. +* @kobj: object. +* +* This is the function that should be called to delete an object +* successfully added via kobject_add(). +*/ +void kobject_del (struct kobject *kobj) +{ +struct kobject *parent = kobj->parent; + +__kobject_del (kobj); +kobject_put (parent); +}EXPORT_SYMBOL (kobject_del);/**
@@ -663,6 +670,7 @@ EXPORT_SYMBOL(kobject_get_unless_zero);*/ static void kobject_cleanup (struct kobject *kobj) { +struct kobject *parent = kobj->parent;struct kobj_type *t =get_ktype (kobj);const char *name = kobj->name;
@@ -684,7 +692,7 @@ static void kobject_cleanup(struct kobject *kobj)if (kobj->state_in_sysfs) {pr_debug ("kobject: '%s' (%p): auto cleanup kobject_del\n" ,kobject_name (kobj), kobj); -kobject_del (kobj); +__kobject_del (kobj); }if (t && t->release) {
@@ -698,6 +706,8 @@ static void kobject_cleanup(struct kobject *kobj)pr_debug ("kobject: '%s': free name\n" , name);kfree_const (name); } + +kobject_put (parent); }#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
Signature · 1 line
2.25.1
Re: [PATCH 5.6 041/161] kobject: Make sure the parent does not get released before its children
Quoted 96 lines · Greg Kroah-Hartman
From: Heikki Krogerus <[email protected]>
[ Upstream commit
4ef12f7198023c09ad6d25b652bd8748c965c7fa]In the function
kobject_cleanup(),kobject_del(kobj)is called before thekobj->release(). That makes it possible to release the parent of the kobject before the kobject itself.To fix that, adding function
__kboject_del()that does everything thatkobject_del()does except release the parent reference.kobject_cleanup()then calls__kobject_del()instead ofkobject_del(), and separately decrements the reference count of the parent kobject afterkobj->release()has been called.Reported-by Naresh Kamboju <[email protected]>Reported-by kernel test robot <[email protected]>Fixes 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"")Suggested-by "Rafael J. Wysocki" <[email protected]>Signed-off-by Heikki Krogerus <[email protected]>Reviewed-by Rafael J. Wysocki <[email protected]>Reviewed-by Brendan Higgins <[email protected]>Tested-by Brendan Higgins <[email protected]>Acked-by Randy Dunlap <[email protected]>Cc stable <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- lib/kobject.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)lib/kobject.c +18
-10@@ -599,14 +599,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) }EXPORT_SYMBOL_GPL (kobject_move); -/** -* kobject_del() - Unlink kobject from hierarchy. -* @kobj: object. -* -* This is the function that should be called to delete an object -* successfully added via kobject_add(). -*/ -void kobject_del (struct kobject *kobj) +static void __kobject_del (struct kobject *kobj) {struct kernfs_node *sd;const struct kobj_type *ktype;@@ -625,9 +618,23 @@ void kobject_del(struct kobject *kobj) kobj->state_in_sysfs =0 ;kobj_kset_leave (kobj); -kobject_put (kobj->parent); kobj->parent =NULL ; } + +/** +* kobject_del() - Unlink kobject from hierarchy. +* @kobj: object. +* +* This is the function that should be called to delete an object +* successfully added via kobject_add(). +*/ +void kobject_del (struct kobject *kobj) +{ +struct kobject *parent = kobj->parent; + +__kobject_del (kobj); +kobject_put (parent); +}EXPORT_SYMBOL (kobject_del);/** @@ -663,6 +670,7 @@ EXPORT_SYMBOL(kobject_get_unless_zero);*/ static void kobject_cleanup (struct kobject *kobj) { +struct kobject *parent = kobj->parent;struct kobj_type *t =get_ktype (kobj);const char *name = kobj->name;@@ -684,7 +692,7 @@ static void kobject_cleanup(struct kobject *kobj)if (kobj->state_in_sysfs) {pr_debug ("kobject: '%s' (%p): auto cleanup kobject_del\n" ,kobject_name (kobj), kobj); -kobject_del (kobj); +__kobject_del (kobj); }if (t && t->release) {
lib/kobject.c static void kobject_cleanup(struct kobject *kobj) · line 710
Quoted 5 lines
lib/kobject.c +2
-0@@ -698,6 +706,8 @@ static void kobject_cleanup(struct kobject *kobj)pr_debug ("kobject: '%s': free name\n" , name);kfree_const (name); } + +kobject_put (parent);
This is known incorrect, because that should only be done if the __kobject_del() above has run.
Also this commit has been reverted from the mainline.
I have posted a fixed replacement for it with no response whatever so far:
Quoted 4 lines
lib/kobject.c +0
-1}#ifdef CONFIG_DEBUG_KOBJECT_RELEASE --
Greg Kroah-Hartman
maintainerRe: [PATCH 5.6 041/161] kobject: Make sure the parent does not get released before its children
Quoted 107 lines · Rafael J. Wysocki
Quoted 96 lines · Greg Kroah-Hartman
From: Heikki Krogerus <[email protected]>
[ Upstream commit
4ef12f7198023c09ad6d25b652bd8748c965c7fa]In the function
kobject_cleanup(),kobject_del(kobj)is called before thekobj->release(). That makes it possible to release the parent of the kobject before the kobject itself.To fix that, adding function
__kboject_del()that does everything thatkobject_del()does except release the parent reference.kobject_cleanup()then calls__kobject_del()instead ofkobject_del(), and separately decrements the reference count of the parent kobject afterkobj->release()has been called.Reported-by Naresh Kamboju <[email protected]>Reported-by kernel test robot <[email protected]>Fixes 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"")Suggested-by "Rafael J. Wysocki" <[email protected]>Signed-off-by Heikki Krogerus <[email protected]>Reviewed-by Rafael J. Wysocki <[email protected]>Reviewed-by Brendan Higgins <[email protected]>Tested-by Brendan Higgins <[email protected]>Acked-by Randy Dunlap <[email protected]>Cc stable <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- lib/kobject.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)lib/kobject.c +18
-10@@ -599,14 +599,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) }EXPORT_SYMBOL_GPL (kobject_move); -/** -* kobject_del() - Unlink kobject from hierarchy. -* @kobj: object. -* -* This is the function that should be called to delete an object -* successfully added via kobject_add(). -*/ -void kobject_del (struct kobject *kobj) +static void __kobject_del (struct kobject *kobj) {struct kernfs_node *sd;const struct kobj_type *ktype;@@ -625,9 +618,23 @@ void kobject_del(struct kobject *kobj) kobj->state_in_sysfs =0 ;kobj_kset_leave (kobj); -kobject_put (kobj->parent); kobj->parent =NULL ; } + +/** +* kobject_del() - Unlink kobject from hierarchy. +* @kobj: object. +* +* This is the function that should be called to delete an object +* successfully added via kobject_add(). +*/ +void kobject_del (struct kobject *kobj) +{ +struct kobject *parent = kobj->parent; + +__kobject_del (kobj); +kobject_put (parent); +}EXPORT_SYMBOL (kobject_del);/** @@ -663,6 +670,7 @@ EXPORT_SYMBOL(kobject_get_unless_zero);*/ static void kobject_cleanup (struct kobject *kobj) { +struct kobject *parent = kobj->parent;struct kobj_type *t =get_ktype (kobj);const char *name = kobj->name;@@ -684,7 +692,7 @@ static void kobject_cleanup(struct kobject *kobj)if (kobj->state_in_sysfs) {pr_debug ("kobject: '%s' (%p): auto cleanup kobject_del\n" ,kobject_name (kobj), kobj); -kobject_del (kobj); +__kobject_del (kobj); }if (t && t->release) {lib/kobject.c static void kobject_cleanup(struct kobject *kobj) · line 710
Quoted 5 lines
lib/kobject.c +2
-0@@ -698,6 +706,8 @@ static void kobject_cleanup(struct kobject *kobj)pr_debug ("kobject: '%s': free name\n" , name);kfree_const (name); } + +kobject_put (parent);This is known incorrect, because that should only be done if the
__kobject_del()above has run.
Quoted 1 line
Also this commit has been reverted from the mainline.
Argh, I should have caught this, my fault, sorry, I'll go drop it.
Quoted 3 lines
I have posted a fixed replacement for it with no response whatever so far:
It's been the merge window, I couldn't do anything until Monday :)
It's in my queue, give me a chance to catch up...
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 42/161 scsi: target: remove boilerplate code
In reply to Greg Kroah-HartmanFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit e49a7d994379278d3353d7ffc7994672752fb0ad ]
iscsit_free_session() is equivalent to iscsit_stop_session() followed by a call to iscsit_close_session().
--- drivers/target/iscsi/iscsi_target.c | 46 ++--------------------------- drivers/target/iscsi/iscsi_target.h | 1 - 2 files changed, 2 insertions(+), 45 deletions(-)
drivers/target/iscsi/iscsi_target.c +2 -44
@@ -4566,49 +4566,6 @@ void iscsit_fail_session(struct iscsi_session *sess) sess->session_state =TARG_SESS_STATE_FAILED ; } -int iscsit_free_session (struct iscsi_session *sess) -{ -u16 conn_count =atomic_read (&sess->nconn); -struct iscsi_conn *conn, *conn_tmp =NULL ; -int is_last; - -spin_lock_bh (&sess->conn_lock); -atomic_set (&sess->sleep_on_sess_wait_comp,1 ); - -list_for_each_entry_safe (conn, conn_tmp, &sess->sess_conn_list, - conn_list) { -if (conn_count ==0 ) -break ; - -if (list_is_last (&conn->conn_list, &sess->sess_conn_list)) { - is_last =1 ; - }else { -iscsit_inc_conn_usage_count (conn_tmp); - is_last =0 ; - } -iscsit_inc_conn_usage_count (conn); - -spin_unlock_bh (&sess->conn_lock); -iscsit_cause_connection_reinstatement (conn,1 ); -spin_lock_bh (&sess->conn_lock); - -iscsit_dec_conn_usage_count (conn); -if (is_last ==0 ) -iscsit_dec_conn_usage_count (conn_tmp); - - conn_count--; - } - -if (atomic_read (&sess->nconn)) { -spin_unlock_bh (&sess->conn_lock); -wait_for_completion (&sess->session_wait_comp); - }else -spin_unlock_bh (&sess->conn_lock); - -iscsit_close_session (sess); -return 0 ; -} - void iscsit_stop_session( struct iscsi_session *sess, int session_sleep,
@@ -4693,7 +4650,8 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)list_for_each_entry_safe (se_sess, se_sess_tmp, &free_list, sess_list) { sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; -iscsit_free_session (sess); +iscsit_stop_session (sess,1 ,1 ); +iscsit_close_session (sess); session_count++; }
drivers/target/iscsi/iscsi_target.h +0 -1
@@ -43,7 +43,6 @@ extern int iscsi_target_rx_thread(void *);extern int iscsit_close_connection (struct iscsi_conn *);extern int iscsit_close_session (struct iscsi_session *);extern void iscsit_fail_session (struct iscsi_session *); -extern int iscsit_free_session (struct iscsi_session *);extern void iscsit_stop_session (struct iscsi_session *,int ,int );extern int iscsit_release_sessions_for_tpg (struct iscsi_portal_group *,int );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 43/161 scsi: target: fix hang when multiple threads try to destroy the same iscsi session
In reply to Greg Kroah-HartmanFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit 57c46e9f33da530a2485fa01aa27b6d18c28c796 ]
A number of hangs have been reported against the target driver; they are due to the fact that multiple threads may try to destroy the iscsi session at the same time. This may be reproduced for example when a "targetcli iscsi/iqn.../tpg1 disable" command is executed while a logout operation is underway.
When this happens, two or more threads may end up sleeping and waiting for iscsit_close_connection() to execute "complete(session_wait_comp)". Only one of the threads will wake up and proceed to destroy the session structure, the remaining threads will hang forever.
Note that if the blocked threads are somehow forced to wake up with complete_all(), they will try to free the same iscsi session structure destroyed by the first thread, causing double frees, memory corruptions etc...
With this patch, the threads that want to destroy the iscsi session will increase the session refcount and will set the "session_close" flag to 1; then they wait for the driver to close the remaining active connections. When the last connection is closed, iscsit_close_connection() will wake up all the threads and will wait for the session's refcount to reach zero; when this happens, iscsit_close_connection() will destroy the session structure because no one is referencing it anymore.
INFO: task targetcli:5971 blocked for more than 120 seconds.
Tainted: P OE 4.15.0-72-generic #81~16.04.1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
targetcli D 0 5971 1 0x00000080
Call Trace:
__schedule+0x3d6/0x8b0
? vprintk_func+0x44/0xe0
schedule+0x36/0x80
schedule_timeout+0x1db/0x370
? __dynamic_pr_debug+0x8a/0xb0
wait_for_completion+0xb4/0x140
? wake_up_q+0x70/0x70
iscsit_free_session+0x13d/0x1a0 [iscsi_target_mod]
iscsit_release_sessions_for_tpg+0x16b/0x1e0 [iscsi_target_mod]
iscsit_tpg_disable_portal_group+0xca/0x1c0 [iscsi_target_mod]
lio_target_tpg_enable_store+0x66/0xe0 [iscsi_target_mod]
configfs_write_file+0xb9/0x120
__vfs_write+0x1b/0x40
vfs_write+0xb8/0x1b0
SyS_write+0x5c/0xe0
do_syscall_64+0x73/0x130
entry_SYSCALL_64_after_hwframe+0x3d/0xa2--- drivers/target/iscsi/iscsi_target.c | 35 ++++++++++++-------- drivers/target/iscsi/iscsi_target_configfs.c | 5 ++- drivers/target/iscsi/iscsi_target_login.c | 5 +-- include/target/iscsi/iscsi_target_core.h | 2 +- 4 files changed, 30 insertions(+), 17 deletions(-)
drivers/target/iscsi/iscsi_target.c +22 -13
@@ -4301,30 +4301,37 @@ int iscsit_close_connection(if (!atomic_read (&sess->session_reinstatement) &&atomic_read (&sess->session_fall_back_to_erl0)) {spin_unlock_bh (&sess->conn_lock); +complete_all (&sess->session_wait_comp);iscsit_close_session (sess);return 0 ; }else if (atomic_read (&sess->session_logout)) {pr_debug ("Moving to TARG_SESS_STATE_FREE.\n" ); sess->session_state =TARG_SESS_STATE_FREE ; -spin_unlock_bh (&sess->conn_lock); -if (atomic_read (&sess->sleep_on_sess_wait_comp)) -complete (&sess->session_wait_comp); +if (atomic_read (&sess->session_close)) { +spin_unlock_bh (&sess->conn_lock); +complete_all (&sess->session_wait_comp); +iscsit_close_session (sess); + }else { +spin_unlock_bh (&sess->conn_lock); + }return 0 ; }else {pr_debug ("Moving to TARG_SESS_STATE_FAILED.\n" ); sess->session_state =TARG_SESS_STATE_FAILED ; -if (!atomic_read (&sess->session_continuation)) { -spin_unlock_bh (&sess->conn_lock); +if (!atomic_read (&sess->session_continuation))iscsit_start_time2retain_handler (sess); - }else -spin_unlock_bh (&sess->conn_lock); -if (atomic_read (&sess->sleep_on_sess_wait_comp)) -complete (&sess->session_wait_comp); +if (atomic_read (&sess->session_close)) { +spin_unlock_bh (&sess->conn_lock); +complete_all (&sess->session_wait_comp); +iscsit_close_session (sess); + }else { +spin_unlock_bh (&sess->conn_lock); + }return 0 ; }
@@ -4429,9 +4436,9 @@ static void iscsit_logout_post_handler_closesession(complete (&conn->conn_logout_comp);iscsit_dec_conn_usage_count (conn); +atomic_set (&sess->session_close,1 );iscsit_stop_session (sess, sleep, sleep);iscsit_dec_session_usage_count (sess); -iscsit_close_session (sess); } static void iscsit_logout_post_handler_samecid(
@@ -4576,8 +4583,6 @@ void iscsit_stop_session(int is_last;spin_lock_bh (&sess->conn_lock); -if (session_sleep) -atomic_set (&sess->sleep_on_sess_wait_comp,1 );if (connection_sleep) { list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list,
@@ -4635,12 +4640,15 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)spin_lock (&sess->conn_lock);if (atomic_read (&sess->session_fall_back_to_erl0) ||atomic_read (&sess->session_logout) || +atomic_read (&sess->session_close) || (sess->time2retain_timer_flags &ISCSI_TF_EXPIRED )) {spin_unlock (&sess->conn_lock);continue ; } +iscsit_inc_session_usage_count (sess);atomic_set (&sess->session_reinstatement,1 );atomic_set (&sess->session_fall_back_to_erl0,1 ); +atomic_set (&sess->session_close,1 );spin_unlock (&sess->conn_lock);list_move_tail (&se_sess->sess_list, &free_list);
@@ -4650,8 +4658,9 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)list_for_each_entry_safe (se_sess, se_sess_tmp, &free_list, sess_list) { sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; +list_del_init (&se_sess->sess_list);iscsit_stop_session (sess,1 ,1 ); -iscsit_close_session (sess); +iscsit_dec_session_usage_count (sess); session_count++; }
drivers/target/iscsi/iscsi_target_configfs.c +4 -1
@@ -1476,20 +1476,23 @@ static void lio_tpg_close_session(struct se_session *se_sess)spin_lock (&sess->conn_lock);if (atomic_read (&sess->session_fall_back_to_erl0) ||atomic_read (&sess->session_logout) || +atomic_read (&sess->session_close) || (sess->time2retain_timer_flags &ISCSI_TF_EXPIRED )) {spin_unlock (&sess->conn_lock);spin_unlock_bh (&se_tpg->session_lock);return ; } +iscsit_inc_session_usage_count (sess);atomic_set (&sess->session_reinstatement,1 );atomic_set (&sess->session_fall_back_to_erl0,1 ); +atomic_set (&sess->session_close,1 );spin_unlock (&sess->conn_lock);iscsit_stop_time2retain_timer (sess);spin_unlock_bh (&se_tpg->session_lock);iscsit_stop_session (sess,1 ,1 ); -iscsit_close_session (sess); +iscsit_dec_session_usage_count (sess); }static u32 lio_tpg_get_inst_index (struct se_portal_group *se_tpg)
drivers/target/iscsi/iscsi_target_login.c +3 -2
@@ -156,6 +156,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)spin_lock (&sess_p->conn_lock);if (atomic_read (&sess_p->session_fall_back_to_erl0) ||atomic_read (&sess_p->session_logout) || +atomic_read (&sess_p->session_close) || (sess_p->time2retain_timer_flags &ISCSI_TF_EXPIRED )) {spin_unlock (&sess_p->conn_lock);continue ;
@@ -166,6 +167,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) (sess_p->sess_ops->SessionType == sessiontype))) {atomic_set (&sess_p->session_reinstatement,1 );atomic_set (&sess_p->session_fall_back_to_erl0,1 ); +atomic_set (&sess_p->session_close,1 );spin_unlock (&sess_p->conn_lock);iscsit_inc_session_usage_count (sess_p);iscsit_stop_time2retain_timer (sess_p);
@@ -190,7 +192,6 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)if (sess->session_state ==TARG_SESS_STATE_FAILED ) {spin_unlock_bh (&sess->conn_lock);iscsit_dec_session_usage_count (sess); -iscsit_close_session (sess);return 0 ; }spin_unlock_bh (&sess->conn_lock);
@@ -198,7 +199,6 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)iscsit_stop_session (sess,1 ,1 );iscsit_dec_session_usage_count (sess); -iscsit_close_session (sess);return 0 ; }
@@ -486,6 +486,7 @@ static int iscsi_login_non_zero_tsih_s2( sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr;if (atomic_read (&sess_p->session_fall_back_to_erl0) ||atomic_read (&sess_p->session_logout) || +atomic_read (&sess_p->session_close) || (sess_p->time2retain_timer_flags &ISCSI_TF_EXPIRED ))continue ; if (!memcmp(sess_p->isid, pdu->isid, 6) &&
include/target/iscsi/iscsi_target_core.h +1 -1
@@ -676,7 +676,7 @@ struct iscsi_session {atomic_t session_logout;atomic_t session_reinstatement;atomic_t session_stop_active; -atomic_t sleep_on_sess_wait_comp; +atomic_t session_close;/* connection list */ struct list_head sess_conn_list;struct list_head cr_active_list;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 44/161 drm/amd/display: remove invalid dc_is_hw_initialized function
In reply to Greg Kroah-HartmanFrom: Joseph Gravenor <[email protected]>
[ Upstream commit e2d533eceb1feb0b8b965c3ff11184921532a28e ]
[why/how]
We found out that the register we read actually gets reset by SMU after we loose power, meaning this always returns true
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ------ drivers/gpu/drm/amd/display/dc/dc.h | 1 - 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -6
@@ -1362,12 +1362,6 @@ bool dc_commit_state(struct dc *dc, struct dc_state *context)return (result ==DC_OK ); } -bool dc_is_hw_initialized (struct dc *dc) -{ -struct dc_bios *dcb = dc->ctx->dc_bios; -return dcb->funcs->is_accelerated_mode (dcb); -} -bool dc_post_update_surfaces_to_stream (struct dc *dc) {int i;
drivers/gpu/drm/amd/display/dc/dc.h +0 -1
@@ -1075,7 +1075,6 @@ unsigned int dc_get_current_backlight_pwm(struct dc *dc);unsigned int dc_get_target_backlight_pwm (struct dc *dc);bool dc_is_dmcu_initialized (struct dc *dc); -bool dc_is_hw_initialized (struct dc *dc);enum dc_status dc_set_clock (struct dc *dc,enum dc_clock_type clock_type,uint32_t clk_khz,uint32_t stepping);void dc_get_clock (struct dc *dc,enum dc_clock_type clock_type,struct dc_clock_config *clock_cfg);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 45/161 drm/amd/display: Not doing optimize bandwidth if flip pending.
In reply to Greg Kroah-HartmanFrom: Yongqiang Sun <[email protected]>
[ Upstream commit 9941b8129030c9202aaf39114477a0e58c0d6ffc ]
[Why]
In some scenario like 1366x768 VSR enabled connected with a 4K monitor and playing 4K video in clone mode, underflow will be observed due to decrease dppclk when previouse surface scan isn't finished
[How]
In this use case, surface flip is switching between 4K and 1366x768, 1366x768 needs smaller dppclk, and when decrease the clk and previous surface scan is for 4K and scan isn't done, underflow will happen. Not doing optimize bandwidth in case of flip pending.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +23 -0
@@ -1362,6 +1362,26 @@ bool dc_commit_state(struct dc *dc, struct dc_state *context)return (result ==DC_OK ); } +static bool is_flip_pending_in_pipes (struct dc *dc,struct dc_state *context) +{ +int i; +struct pipe_ctx *pipe; + +for (i =0 ; i <MAX_PIPES ; i++) { + pipe = &context->res_ctx.pipe_ctx[i]; + +if (!pipe->plane_state) +continue ; + +/* Must set to false to start with, due to OR in update function */ + pipe->plane_state->status.is_flip_pending = false; + dc->hwss.update_pending_status (pipe); +if (pipe->plane_state->status.is_flip_pending) +return true; + } +return false; +} +bool dc_post_update_surfaces_to_stream (struct dc *dc) {int i;
@@ -1372,6 +1392,9 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)post_surface_trace (dc); +if (is_flip_pending_in_pipes (dc, context)) +return true; +for (i =0 ; i < dc->res_pool->pipe_count; i++)if (context->res_ctx.pipe_ctx[i].stream ==NULL || context->res_ctx.pipe_ctx[i].plane_state ==NULL ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 46/161 aio: fix async fsync creds
In reply to Greg Kroah-HartmanFrom: Miklos Szeredi <[email protected]>
commit 530f32fc370fd1431ea9802dbc53ab5601dfccdb upstream.
Avi Kivity reports that on fuse filesystems running in a user namespace asyncronous fsync fails with EOVERFLOW.
The reason is that f_ops->fsync() is called with the creds of the kthread performing aio work instead of the creds of the process originally submitting IOCB_CMD_FSYNC.
Fuse sends the creds of the caller in the request header and it needs to translate the uid and gid into the server's user namespace. Since the kthread is running in init_user_ns, the translation will fail and the operation returns an error.
It can be argued that fsync doesn't actually need any creds, but just zeroing out those fields in the header (as with requests that currently don't take creds) is a backward compatibility risk.
Instead of working around this issue in fuse, solve the core of the problem by calling the filesystem with the proper creds.
--- fs/aio.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/aio.c +8 -0
@@ -176,6 +176,7 @@ struct fsync_iocb {struct file *file;struct work_struct work;bool datasync; +struct cred *creds; };struct poll_iocb {
@@ -1589,8 +1590,11 @@ static int aio_write(struct kiocb *req,static void aio_fsync_work (struct work_struct *work) { struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work); +const struct cred *old_cred =override_creds (iocb->fsync.creds); iocb->ki_res.res =vfs_fsync (iocb->fsync.file, iocb->fsync.datasync); +revert_creds (old_cred); +put_cred (iocb->fsync.creds);iocb_put (iocb); }
@@ -1604,6 +1608,10 @@ static int aio_fsync(struct fsync_iocb *if (unlikely (!req->file->f_op->fsync))return -EINVAL ; + req->creds =prepare_creds (); +if (!req->creds) +return -ENOMEM ; + req->datasync = datasync;INIT_WORK (&req->work, aio_fsync_work);schedule_work (&req->work);
Greg Kroah-Hartman
maintainerPATCH 47/161 usercopy: mark dma-kmalloc caches as usercopy caches
In reply to Greg Kroah-HartmanFrom: Vlastimil Babka <[email protected]>
commit 49f2d2419d60a103752e5fbaf158cf8d07c0d884 upstream.
We have seen a "usercopy: Kernel memory overwrite attempt detected to SLUB object 'dma-kmalloc-1 k' (offset 0, size 11)!" error on s390x, as IUCV uses kmalloc() with __GFP_DMA because of memory address restrictions. The issue has been discussed [2] and it has been noted that if all the kmalloc caches are marked as usercopy, there's little reason not to mark dma-kmalloc caches too. The 'dma' part merely means that __GFP_DMA is used to restrict memory address range.
As Jann Horn put it [3]:
"I think dma-kmalloc slabs should be handled the same way as normal
kmalloc slabs. When a dma-kmalloc allocation is freshly created, it is just normal kernel memory - even if it might later be used for DMA -, and it should be perfectly fine to copy_from_user() into such allocations at that point, and to copy_to_user() out of them at the end. If you look at the places where such allocations are created, you can see things like kmemdup(), memcpy() and so on - all normal operations that shouldn't conceptually be different from usercopy in any relevant way."
Thus this patch marks the dma-kmalloc-* caches as usercopy.
[1] https://bugzilla.suse.com/show_bug.cgi?id=1156053
[2] https://lore.kernel.org/kernel-hardening/[email protected]/
[3] https://lore.kernel.org/kernel-hardening/CAG48ez1a4waGk9kB0WLaSbs4muSoK0AYAVk8=XYaKj4_+6e6Hg@mail.gmail.com/
--- mm/slab_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/slab_common.c +2 -1
@@ -1303,7 +1303,8 @@ void __init create_kmalloc_caches(slab_f kmalloc_caches[KMALLOC_DMA ][i] =create_kmalloc_cache ( kmalloc_info[i].name[KMALLOC_DMA ], kmalloc_info[i].size, - SLAB_CACHE_DMA | flags, 0, 0); +SLAB_CACHE_DMA | flags,0 , + kmalloc_info[i].size); } }#endif
Greg Kroah-Hartman
maintainerPATCH 48/161 x86_64: Fix jiffies ODR violation
In reply to Greg Kroah-HartmanFrom: Bob Haarman <[email protected]>
commit d8ad6d39c35d2b44b3d48b787df7f3359381dcbf upstream.
'jiffies' and 'jiffies_64' are meant to alias (two different symbols that share the same address). Most architectures make the symbols alias to the same address via a linker script assignment in their arch/<arch>/kernel/vmlinux.lds.S:
jiffies = jiffies_64;
which is effectively a definition of jiffies.
jiffies and jiffies_64 are both forward declared for all architectures in include/linux/jiffies.h. jiffies_64 is defined in kernel/time/timer.c.
x86_64 was peculiar in that it wasn't doing the above linker script assignment, but rather was:
1. defining jiffies in arch/x86/kernel/time.c instead via the linker script.
2. overriding the symbol jiffies_64 from kernel/time/timer.c in arch/x86/kernel/vmlinux.lds.s via 'jiffies_64 = jiffies;'.
As Fangrui notes:
In LLD, symbol assignments in linker scripts override definitions in object files. GNU ld appears to have the same behavior. It would probably make sense for LLD to error "duplicate symbol" but GNU ld is unlikely to adopt for compatibility reasons.
This results in an ODR violation (UB), which seems to have survived thus far. Where it becomes harmful is when;
1. -fno-semantic-interposition is used:
As Fangrui notes:
Clang after LLVM commit 5b22bcc2b70d
("[X86][ELF] Prefer to lower MC_GlobalAddress operands to .Lfoo$local") defaults to -fno-semantic-interposition similar semantics which help -fpic/-fPIC code avoid GOT/PLT when the referenced symbol is defined within the same translation unit. Unlike GCC -fno-semantic-interposition, Clang emits such relocations referencing local symbols for non-pic code as well.
This causes references to jiffies to refer to '.Ljiffies$local' when jiffies is defined in the same translation unit. Likewise, references to jiffies_64 become references to '.Ljiffies_64$local' in translation units that define jiffies_64. Because these differ from the names used in the linker script, they will not be rewritten to alias one another.
2. Full LTO
Full LTO effectively treats all source files as one translation unit, causing these local references to be produced everywhere. When the linker processes the linker script, there are no longer any references to jiffies_64' anywhere to replace with 'jiffies'. And thus '.Ljiffies$local' and '.Ljiffies_64$local' no longer alias at all.
In the process of porting patches enabling Full LTO from arm64 to x86_64, spooky bugs have been observed where the kernel appeared to boot, but init doesn't get scheduled.
Avoid the ODR violation by matching other architectures and define jiffies only by linker script. For -fno-semantic-interposition + Full LTO, there is no longer a global definition of jiffies for the compiler to produce a local symbol which the linker script won't ensure aliases to jiffies_64.
--- arch/x86/kernel/time.c | 4 ---- arch/x86/kernel/vmlinux.lds.S | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/kernel/time.c +0 -4
@@ -25,10 +25,6 @@#include <asm/hpet.h> #include <asm/time.h> -#ifdef CONFIG_X86_64 -__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = INITIAL_JIFFIES; -#endif -unsigned long profile_pc (struct pt_regs *regs) {unsigned long pc =instruction_pointer (regs);
arch/x86/kernel/vmlinux.lds.S +2 -2
@@ -39,13 +39,13 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT) #ifdef CONFIG_X86_32 OUTPUT_ARCH(i386) ENTRY(phys_startup_32) -jiffies = jiffies_64; #else OUTPUT_ARCH(i386:x86-64) ENTRY(phys_startup_64) -jiffies_64 = jiffies; #endif +jiffies = jiffies_64; + #if defined(CONFIG_X86_64) /* * On 64-bit, align RODATA to 2MB so we retain large page mappings for
Greg Kroah-Hartman
maintainerPATCH 49/161 x86: mm: ptdump: calculate effective permissions correctly
In reply to Greg Kroah-HartmanFrom: Steven Price <[email protected]>
commit 1494e0c38ee903e83aefb58caf54a9217273d49a upstream.
Patch series "Fix W+X debug feature on x86"
Jan alerted me[1] that the W+X detection debug feature was broken in x86 by my change[2] to switch x86 to use the generic ptdump infrastructure.
Fundamentally the approach of trying to move the calculation of effective permissions into note_page() was broken because note_page() is only called for 'leaf' entries and the effective permissions are passed down via the internal nodes of the page tree. The solution I've taken here is to create a new (optional) callback which is called for all nodes of the page tree and therefore can calculate the effective permissions.
Secondly on some configurations (32 bit with PAE) "unsigned long" is not large enough to store the table entries. The fix here is simple - let's just use a u64.
[1] https://lore.kernel.org/lkml/[email protected]/
[2] 2ae27137b2db ("x86: mm: convert dump_pagetables to use walk_page_range")
This patch (of 2):
By switching the x86 page table dump code to use the generic code the effective permissions are no longer calculated correctly because the note_page() function is only called for *leaf* entries. To calculate the actual effective permissions it is necessary to observe the full hierarchy of the page tree.
Introduce a new callback for ptdump which is called for every entry and can therefore update the prot_levels array correctly. note_page() can then simply access the appropriate element in the array.
--- arch/x86/mm/dump_pagetables.c | 33 ++++++++++++++++++++------------- include/linux/ptdump.h | 1 + mm/ptdump.c | 17 ++++++++++++++++- 3 files changed, 37 insertions(+), 14 deletions(-)
arch/x86/mm/dump_pagetables.c +20 -13
@@ -249,10 +249,22 @@ static void note_wx(struct pg_state *st, (void *)st->start_address); } -static inline pgprotval_t effective_prot (pgprotval_t prot1,pgprotval_t prot2) +static void effective_prot (struct ptdump_state *pt_st,int level,u64 val) { -return (prot1 & prot2 & (_PAGE_USER | _PAGE_RW)) | - ((prot1 | prot2) & _PAGE_NX); + struct pg_state *st = container_of(pt_st, struct pg_state, ptdump); +pgprotval_t prot = val &PTE_FLAGS_MASK ; +pgprotval_t effective; + +if (level >0 ) { +pgprotval_t higher_prot = st->prot_levels[level -1 ]; + + effective = (higher_prot & prot & (_PAGE_USER | _PAGE_RW)) | + ((higher_prot | prot) & _PAGE_NX); + }else { + effective = prot; + } + + st->prot_levels[level] = effective; }/*
@@ -270,16 +282,10 @@ static void note_page(struct ptdump_statstruct seq_file *m = st->seq; new_prot = val &PTE_FLAGS_MASK ; - -if (level >0 ) { - new_eff =effective_prot (st->prot_levels[level -1 ], - new_prot); - }else { - new_eff = new_prot; - } - -if (level >=0 ) - st->prot_levels[level] = new_eff; +if (!val) + new_eff =0 ; +else + new_eff = st->prot_levels[level];/* * If we have a "break" in the series, we need to flush the state that
@@ -374,6 +380,7 @@ static void ptdump_walk_pgd_level_core(sstruct pg_state st = { .ptdump = { .note_page = note_page, + .effective_prot = effective_prot, .range = ptdump_ranges }, .level =-1 ,
include/linux/ptdump.h +1 -0
@@ -14,6 +14,7 @@ struct ptdump_state {/* level is 0:PGD to 4:PTE, or -1 if unknown */ void (*note_page)(struct ptdump_state *st,unsigned long addr,int level,unsigned long val); +void (*effective_prot)(struct ptdump_state *st,int level,u64 val);const struct ptdump_range *range; };
mm/ptdump.c +16 -1
@@ -36,6 +36,9 @@ static int ptdump_pgd_entry(pgd_t *pgd,return note_kasan_page_table (walk, addr);#endif +if (st->effective_prot) + st->effective_prot (st,0 ,pgd_val (val)); +if (pgd_leaf (val)) st->note_page (st, addr,0 ,pgd_val (val));
@@ -53,6 +56,9 @@ static int ptdump_p4d_entry(p4d_t *p4d,return note_kasan_page_table (walk, addr);#endif +if (st->effective_prot) + st->effective_prot (st,1 ,p4d_val (val)); +if (p4d_leaf (val)) st->note_page (st, addr,1 ,p4d_val (val));
@@ -70,6 +76,9 @@ static int ptdump_pud_entry(pud_t *pud,return note_kasan_page_table (walk, addr);#endif +if (st->effective_prot) + st->effective_prot (st,2 ,pud_val (val)); +if (pud_leaf (val)) st->note_page (st, addr,2 ,pud_val (val));
@@ -87,6 +96,8 @@ static int ptdump_pmd_entry(pmd_t *pmd,return note_kasan_page_table (walk, addr);#endif +if (st->effective_prot) + st->effective_prot (st,3 ,pmd_val (val));if (pmd_leaf (val)) st->note_page (st, addr,3 ,pmd_val (val));
@@ -97,8 +108,12 @@ static int ptdump_pte_entry(pte_t *pte, unsigned long next, struct mm_walk *walk) { struct ptdump_state *st = walk->private; +pte_t val =READ_ONCE (*pte); + +if (st->effective_prot) + st->effective_prot (st,4 ,pte_val (val)); - st->note_page (st, addr,4 ,pte_val (READ_ONCE (*pte))); + st->note_page (st, addr,4 ,pte_val (val));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 50/161 x86/PCI: Mark Intel C620 MROMs as having non-compliant BARs
In reply to Greg Kroah-HartmanFrom: Xiaochun Lee <[email protected]>
commit 1574051e52cb4b5b7f7509cfd729b76ca1117808 upstream.
The Intel C620 Platform Controller Hub has MROM functions that have non-PCI registers (undocumented in the public spec) where BAR 0 is supposed to be, which results in messages like this:
pci 0000:00:11.0: [Firmware Bug]: reg 0x30: invalid BAR (can't size)
Mark these MROM functions as having non-compliant BARs so we don't try to probe any of them. There are no other BARs on these devices.
See the Intel C620 Series Chipset Platform Controller Hub Datasheet, May 2019, Document Number 336067-007US, sec 2.1, 35.5, 35.6.
--- arch/x86/pci/fixup.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/pci/fixup.c +4 -0
@@ -572,6 +572,10 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INDECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6f60 , pci_invalid_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fa0 , pci_invalid_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fc0 , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa1ec , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa1ed , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa26c , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa26d , pci_invalid_bar);/* * Device [1022:7808]
Greg Kroah-Hartman
maintainerPATCH 51/161 x86/speculation: Prevent rogue cross-process SSBD shutdown
In reply to Greg Kroah-HartmanFrom: Anthony Steinhauser <[email protected]>
commit dbbe2ad02e9df26e372f38cc3e70dab9222c832e upstream.
On context switch the change of TIF_SSBD and TIF_SPEC_IB are evaluated to adjust the mitigations accordingly. This is optimized to avoid the expensive MSR write if not needed.
This optimization is buggy and allows an attacker to shutdown the SSBD protection of a victim process.
The update logic reads the cached base value for the speculation control MSR which has neither the SSBD nor the STIBP bit set. It then OR's the SSBD bit only when TIF_SSBD is different and requests the MSR update.
That means if TIF_SSBD of the previous and next task are the same, then the base value is not updated, even if TIF_SSBD is set. The MSR write is not requested.
Subsequently if the TIF_STIBP bit differs then the STIBP bit is updated in the base value and the MSR is written with a wrong SSBD value.
This was introduced when the per task/process conditional STIPB switching was added on top of the existing SSBD switching.
It is exploitable if the attacker creates a process which enforces SSBD and has the contrary value of STIBP than the victim process (i.e. if the victim process enforces STIBP, the attacker process must not enforce it; if the victim process does not enforce STIBP, the attacker process must enforce it) and schedule it on the same core as the victim process. If the victim runs after the attacker the victim becomes vulnerable to Spectre V4.
To fix this, update the MSR value independent of the TIF_SSBD difference and dependent on the SSBD mitigation method available. This ensures that a subsequent STIPB initiated MSR write has the correct state of SSBD.
[ tglx: Handle X86_FEATURE_VIRT_SSBD & X86_FEATURE_VIRT_SSBD correctly
and massaged changelog ]
--- arch/x86/kernel/process.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
arch/x86/kernel/process.c +10 -18
@@ -546,28 +546,20 @@ static __always_inline void __speculatiolockdep_assert_irqs_disabled (); -/* -* If TIF_SSBD is different, select the proper mitigation -* method. Note that if SSBD mitigation is disabled or permanentely -* enabled this branch can't be taken because nothing can set -* TIF_SSBD. -*/ -if (tif_diff & _TIF_SSBD) { -if (static_cpu_has (X86_FEATURE_VIRT_SSBD )) { +/* Handle change of TIF_SSBD depending on the mitigation method. */ +if (static_cpu_has (X86_FEATURE_VIRT_SSBD )) { +if (tif_diff & _TIF_SSBD)amd_set_ssb_virt_state (tifn); - }else if (static_cpu_has (X86_FEATURE_LS_CFG_SSBD )) { + }else if (static_cpu_has (X86_FEATURE_LS_CFG_SSBD )) { +if (tif_diff & _TIF_SSBD)amd_set_core_ssb_state (tifn); - }else if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) || -static_cpu_has (X86_FEATURE_AMD_SSBD )) { - msr |=ssbd_tif_to_spec_ctrl (tifn); - updmsr = true; - } + }else if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) || +static_cpu_has (X86_FEATURE_AMD_SSBD )) { + updmsr |= !!(tif_diff & _TIF_SSBD); + msr |=ssbd_tif_to_spec_ctrl (tifn); } -/* -* Only evaluate TIF_SPEC_IB if conditional STIBP is enabled, -* otherwise avoid the MSR write. -*/ +/* Only evaluate TIF_SPEC_IB if conditional STIBP is enabled. */ if (IS_ENABLED (CONFIG_SMP ) &&static_branch_unlikely (&switch_to_cond_stibp)) { updmsr |= !!(tif_diff & _TIF_SPEC_IB);
Greg Kroah-Hartman
maintainerPATCH 52/161 x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.
In reply to Greg Kroah-HartmanFrom: Anthony Steinhauser <[email protected]>
commit 21998a351512eba4ed5969006f0c55882d995ada upstream.
When STIBP is unavailable or enhanced IBRS is available, Linux force-disables the IBPB mitigation of Spectre-BTB even when simultaneous multithreading is disabled. While attempts to enable IBPB using prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, ...) fail with EPERM, the seccomp syscall (or its prctl(PR_SET_SECCOMP, ...) equivalent) which are used e.g. by Chromium or OpenSSH succeed with no errors but the application remains silently vulnerable to cross-process Spectre v2 attacks (classical BTB poisoning). At the same time the SYSFS reporting (/sys/devices/system/cpu/vulnerabilities/spectre_v2) displays that IBPB is conditionally enabled when in fact it is unconditionally disabled.
STIBP is useful only when SMT is enabled. When SMT is disabled and STIBP is unavailable, it makes no sense to force-disable also IBPB, because IBPB protects against cross-process Spectre-BTB attacks regardless of the SMT state. At the same time since missing STIBP was only observed on AMD CPUs, AMD does not recommend using STIBP, but recommends using IBPB, so disabling IBPB because of missing STIBP goes directly against AMD's advice:
https://developer.amd.com/wp-content/resources/Architecture_Guidelines_Update_Indirect_Branch_Control.pdf
Similarly, enhanced IBRS is designed to protect cross-core BTB poisoning and BTB-poisoning attacks from user space against kernel (and BTB-poisoning attacks from guest against hypervisor), it is not designed to prevent cross-process (or cross-VM) BTB poisoning between processes (or VMs) running on the same core. Therefore, even with enhanced IBRS it is necessary to flush the BTB during context-switches, so there is no reason to force disable IBPB when enhanced IBRS is available.
Enable the prctl control of IBPB even when STIBP is unavailable or enhanced IBRS is available.
--- arch/x86/kernel/cpu/bugs.c | 87 +++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 37 deletions(-)
arch/x86/kernel/cpu/bugs.c +50 -37
@@ -588,7 +588,9 @@ early_param("nospectre_v1", nospectre_v1static enum spectre_v2_mitigation spectre_v2_enabled__ro_after_init =SPECTRE_V2_NONE ; -static enum spectre_v2_user_mitigation spectre_v2_user__ro_after_init = +static enum spectre_v2_user_mitigation spectre_v2_user_stibp__ro_after_init = +SPECTRE_V2_USER_NONE ; +static enum spectre_v2_user_mitigation spectre_v2_user_ibpb__ro_after_init =SPECTRE_V2_USER_NONE ;#ifdef CONFIG_RETPOLINE
@@ -734,15 +736,6 @@ spectre_v2_user_select_mitigation(enum sbreak ; } -/* -* At this point, an STIBP mode other than "off" has been set. -* If STIBP support is not being forced, check if STIBP always-on -* is preferred. -*/ -if (mode !=SPECTRE_V2_USER_STRICT && -boot_cpu_has (X86_FEATURE_AMD_STIBP_ALWAYS_ON )) - mode =SPECTRE_V2_USER_STRICT_PREFERRED ; -/* Initialize Indirect Branch Prediction Barrier */ if (boot_cpu_has (X86_FEATURE_IBPB )) {setup_force_cpu_cap (X86_FEATURE_USE_IBPB );
@@ -765,23 +758,36 @@ spectre_v2_user_select_mitigation(enum spr_info ("mitigation: Enabling %s Indirect Branch Prediction Barrier\n" ,static_key_enabled (&switch_mm_always_ibpb) ?"always-on" :"conditional" ); + + spectre_v2_user_ibpb = mode; } -/* If enhanced IBRS is enabled no STIBP required */ -if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED ) +/* +* If enhanced IBRS is enabled or SMT impossible, STIBP is not +* required. +*/ +if (!smt_possible || spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return ;/* -* If SMT is not possible or STIBP is not available clear the STIBP -* mode. +* At this point, an STIBP mode other than "off" has been set. +* If STIBP support is not being forced, check if STIBP always-on +* is preferred. +*/ +if (mode !=SPECTRE_V2_USER_STRICT && +boot_cpu_has (X86_FEATURE_AMD_STIBP_ALWAYS_ON )) + mode =SPECTRE_V2_USER_STRICT_PREFERRED ; + +/* +* If STIBP is not available, clear the STIBP mode. */ -if (!smt_possible || !boot_cpu_has (X86_FEATURE_STIBP )) +if (!boot_cpu_has (X86_FEATURE_STIBP )) mode =SPECTRE_V2_USER_NONE ; + + spectre_v2_user_stibp = mode; + set_mode: - spectre_v2_user = mode; -/* Only print the STIBP mode when SMT possible */ -if (smt_possible) -pr_info ("%s\n" , spectre_v2_user_strings[mode]); +pr_info ("%s\n" , spectre_v2_user_strings[mode]); }static const char *const spectre_v2_strings[] = {
@@ -1014,7 +1020,7 @@ void cpu_bugs_smt_update(void) {mutex_lock (&spec_ctrl_mutex); -switch (spectre_v2_user) { +switch (spectre_v2_user_stibp) {case SPECTRE_V2_USER_NONE :break ;case SPECTRE_V2_USER_STRICT :
@@ -1257,14 +1263,16 @@ static int ib_prctl_set(struct task_stru {switch (ctrl) {case PR_SPEC_ENABLE : -if (spectre_v2_user ==SPECTRE_V2_USER_NONE ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return 0 ;/* * Indirect branch speculation is always disabled in strict * mode. */ -if (spectre_v2_user ==SPECTRE_V2_USER_STRICT || - spectre_v2_user ==SPECTRE_V2_USER_STRICT_PREFERRED ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED )return -EPERM ;task_clear_spec_ib_disable (task);task_update_spec_tif (task);
@@ -1275,10 +1283,12 @@ static int ib_prctl_set(struct task_stru* Indirect branch speculation is always allowed when * mitigation is force disabled. */ -if (spectre_v2_user ==SPECTRE_V2_USER_NONE ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return -EPERM ; -if (spectre_v2_user ==SPECTRE_V2_USER_STRICT || - spectre_v2_user ==SPECTRE_V2_USER_STRICT_PREFERRED ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED )return 0 ;task_set_spec_ib_disable (task);if (ctrl ==PR_SPEC_FORCE_DISABLE )
@@ -1309,7 +1319,8 @@ void arch_seccomp_spec_mitigate(struct t {if (ssb_mode ==SPEC_STORE_BYPASS_SECCOMP )ssb_prctl_set (task,PR_SPEC_FORCE_DISABLE ); -if (spectre_v2_user ==SPECTRE_V2_USER_SECCOMP ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_SECCOMP || + spectre_v2_user_stibp ==SPECTRE_V2_USER_SECCOMP )ib_prctl_set (task,PR_SPEC_FORCE_DISABLE ); }#endif
@@ -1340,22 +1351,24 @@ static int ib_prctl_get(struct task_struif (!boot_cpu_has_bug (X86_BUG_SPECTRE_V2 ))return PR_SPEC_NOT_AFFECTED ; -switch (spectre_v2_user) { -case SPECTRE_V2_USER_NONE : +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return PR_SPEC_ENABLE ; -case SPECTRE_V2_USER_PRCTL : -case SPECTRE_V2_USER_SECCOMP : +else if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED ) +return PR_SPEC_DISABLE ; +else if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_PRCTL || + spectre_v2_user_ibpb ==SPECTRE_V2_USER_SECCOMP || + spectre_v2_user_stibp ==SPECTRE_V2_USER_PRCTL || + spectre_v2_user_stibp ==SPECTRE_V2_USER_SECCOMP ) {if (task_spec_ib_force_disable (task))return PR_SPEC_PRCTL |PR_SPEC_FORCE_DISABLE ;if (task_spec_ib_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -case SPECTRE_V2_USER_STRICT : -case SPECTRE_V2_USER_STRICT_PREFERRED : -return PR_SPEC_DISABLE ; -default : + }else return PR_SPEC_NOT_AFFECTED ; - } }int arch_prctl_spec_ctrl_get (struct task_struct *task,unsigned long which)
@@ -1594,7 +1607,7 @@ static char *stibp_state(void)if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return "" ; -switch (spectre_v2_user) { +switch (spectre_v2_user_stibp) {case SPECTRE_V2_USER_NONE :return ", STIBP: disabled" ;case SPECTRE_V2_USER_STRICT :
Greg Kroah-Hartman
maintainerPATCH 53/161 x86/speculation: PR_SPEC_FORCE_DISABLE enforcement for indirect branches.
In reply to Greg Kroah-HartmanFrom: Anthony Steinhauser <[email protected]>
commit 4d8df8cbb9156b0a0ab3f802b80cb5db57acc0bf upstream.
Currently, it is possible to enable indirect branch speculation even after it was force-disabled using the PR_SPEC_FORCE_DISABLE option. Moreover, the PR_GET_SPECULATION_CTRL command gives afterwards an incorrect result (force-disabled when it is in fact enabled). This also is inconsistent vs. STIBP and the documention which cleary states that PR_SPEC_FORCE_DISABLE cannot be undone.
Fix this by actually enforcing force-disabled indirect branch speculation. PR_SPEC_ENABLE called after PR_SPEC_FORCE_DISABLE now fails with -EPERM as described in the documentation.
--- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -2
@@ -1268,11 +1268,14 @@ static int ib_prctl_set(struct task_strureturn 0 ;/* * Indirect branch speculation is always disabled in strict -* mode. +* mode. It can neither be enabled if it was force-disabled +* by a previous prctl call. +*/ if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || - spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED ) + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED || +task_spec_ib_force_disable (task))return -EPERM ;task_clear_spec_ib_disable (task);task_update_spec_tif (task);
Greg Kroah-Hartman
maintainerPATCH 54/161 x86/reboot/quirks: Add MacBook6,1 reboot quirk
In reply to Greg Kroah-HartmanFrom: Hill Ma <[email protected]>
commit 140fd4ac78d385e6c8e6a5757585f6c707085f87 upstream.
On MacBook6,1 reboot would hang unless parameter reboot=pci is added. Make it automatic.
--- arch/x86/kernel/reboot.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kernel/reboot.c +8 -0
@@ -197,6 +197,14 @@ static const struct dmi_system_id reboot DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5"), }, }, + { /* Handle problems with rebooting on Apple MacBook6,1 */ + .callback = set_pci_reboot, + .ident = "Apple MacBook6,1", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Apple Inc." ), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBook6,1"), + }, + }, { /* Handle problems with rebooting on Apple MacBookPro5 */ .callback = set_pci_reboot, .ident = "Apple MacBookPro5",
Greg Kroah-Hartman
maintainerPATCH 55/161 perf/x86/intel: Add more available bits for OFFCORE_RESPONSE of Intel Tremont
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit 0813c40556fce1eeefb996e020cc5339e0b84137 upstream.
The mask in the extra_regs for Intel Tremont need to be extended to allow more defined bits.
"Outstanding Requests" (bit 63) is only available on MSR_OFFCORE_RSP0;
--- arch/x86/events/intel/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/intel/core.c +2 -2
@@ -1892,8 +1892,8 @@ static __initconst const u64 tnt_hw_cachstatic struct extra_reg intel_tnt_extra_regs[]__read_mostly = {/* must define OFFCORE_RSP_X first, see intel_fixup_er() */ -INTEL_UEVENT_EXTRA_REG (0x01b7 ,MSR_OFFCORE_RSP_0 ,0xffffff9fffull ,RSP_0 ), -INTEL_UEVENT_EXTRA_REG (0x02b7 ,MSR_OFFCORE_RSP_1 ,0xffffff9fffull ,RSP_1 ), +INTEL_UEVENT_EXTRA_REG (0x01b7 ,MSR_OFFCORE_RSP_0 ,0x800ff0ffffff9fffull ,RSP_0 ), +INTEL_UEVENT_EXTRA_REG (0x02b7 ,MSR_OFFCORE_RSP_1 ,0xff0ffffff9fffull ,RSP_1 ),EVENT_EXTRA_END };
Greg Kroah-Hartman
maintainerPATCH 56/161 KVM: x86: allow KVM_STATE_NESTED_MTF_PENDING in kvm_state flags
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit df2a69af85bef169ab6810cc57f6b6b943941e7e upstream.
The migration functionality was left incomplete in commit 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing instruction emulation", 2020-02-23), fix it.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -4568,7 +4568,7 @@ long kvm_arch_vcpu_ioctl(struct file *fiif (kvm_state.flags & ~(KVM_STATE_NESTED_RUN_PENDING |KVM_STATE_NESTED_GUEST_MODE - |KVM_STATE_NESTED_EVMCS )) + |KVM_STATE_NESTED_EVMCS |KVM_STATE_NESTED_MTF_PENDING ))break ;/* nested_run_pending implies guest_mode. */
Greg Kroah-Hartman
maintainerPATCH 57/161 KVM: x86/mmu: Set mmio_value to 0 if reserved #PF cant be generated
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 6129ed877d409037b79866327102c9dc59a302fe upstream.
Set the mmio_value to '0' instead of simply clearing the present bit to squash a benign warning in kvm_mmu_set_mmio_spte_mask() that complains about the mmio_value overlapping the lower GFN mask on systems with 52 bits of PA space.
Opportunistically clean up the code and comments.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/mmu.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
arch/x86/kvm/mmu/mmu.c +9 -18
@@ -6132,25 +6132,16 @@ static void kvm_set_mmio_spte_mask(void)u64 mask;/* -* Set the reserved bits and the present bit of an paging-structure -* entry to generate page fault with PFER.RSV = 1. +* Set a reserved PA bit in MMIO SPTEs to generate page faults with +* PFEC.RSVD=1 on MMIO accesses. 64-bit PTEs (PAE, x86-64, and EPT +* paging) support a maximum of 52 bits of PA, i.e. if the CPU supports +* 52-bit physical addresses then there are no reserved PA bits in the +* PTEs and so the reserved PA approach must be disabled. */ - -/* -* Mask the uppermost physical address bit, which would be reserved as -* long as the supported physical address width is less than 52. -*/ - mask =1ull <<51 ; - -/* Set the present bit. */ - mask |=1ull ; - -/* -* If reserved bit is not supported, clear the present bit to disable -* mmio page fault. -*/ -if (shadow_phys_bits ==52 ) - mask &= ~1ull ; +if (shadow_phys_bits <52 ) + mask =BIT_ULL (51 ) |PT_PRESENT_MASK ; +else + mask =0 ;kvm_mmu_set_mmio_spte_mask (mask, mask,ACC_WRITE_MASK |ACC_USER_MASK ); }
Greg Kroah-Hartman
maintainerPATCH 58/161 KVM: x86: respect singlestep when emulating instruction
In reply to Greg Kroah-HartmanFrom: Felipe Franciosi <[email protected]>
commit 384dea1c9183880be183cfaae161d99aafd16df6 upstream.
When userspace configures KVM_GUESTDBG_SINGLESTEP, KVM will manage the presence of X86_EFLAGS_TF via kvm_set/get_rflags on vcpus. The actual rflag bit is therefore hidden from callers.
That includes init_emulate_ctxt() which uses the value returned from kvm_get_flags() to set ctxt->tf. As a result, x86_emulate_instruction() will skip a single step, leaving singlestep_rip stale and not returning to userspace.
This resolves the issue by observing the vcpu guest_debug configuration alongside ctxt->tf in x86_emulate_instruction(), performing the single step if set.
Message-Id: <[email protected]>
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -6908,7 +6908,7 @@ restart:if (!ctxt->have_exception ||exception_type (ctxt->exception.vector) ==EXCPT_TRAP ) {kvm_rip_write (vcpu, ctxt->eip); -if (r && ctxt->tf) +if (r && (ctxt->tf || (vcpu->guest_debug &KVM_GUESTDBG_SINGLESTEP ))) r =kvm_vcpu_do_singlestep (vcpu);if (kvm_x86_ops->update_emulated_instruction) kvm_x86_ops->update_emulated_instruction (vcpu);
Greg Kroah-Hartman
maintainerPATCH 59/161 KVM: x86: Fix APIC page invalidation race
In reply to Greg Kroah-HartmanFrom: Eiichi Tsukata <[email protected]>
commit e649b3f0188f8fd34dd0dde8d43fd3312b902fb2 upstream.
Commit b1394e745b94 ("KVM: x86: fix APIC page invalidation") tried to fix inappropriate APIC page invalidation by re-introducing arch specific kvm_arch_mmu_notifier_invalidate_range() and calling it from kvm_mmu_notifier_invalidate_range_start. However, the patch left a possible race where the VMCS APIC address cache is updated *before* it is unmapped:
(Invalidator) kvm_mmu_notifier_invalidate_range_start() (Invalidator) kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD) (KVM VCPU) vcpu_enter_guest()
(KVM VCPU) kvm_vcpu_reload_apic_access_page() (Invalidator) actually unmap page
Because of the above race, there can be a mismatch between the host physical address stored in the APIC_ACCESS_PAGE VMCS field and the host physical address stored in the EPT entry for the APIC GPA (0xfee0000). When this happens, the processor will not trap APIC accesses, and will instead show the raw contents of the APIC-access page. Because Windows OS periodically checks for unexpected modifications to the LAPIC register, this will show up as a BSOD crash with BugCheck CRITICAL_STRUCTURE_CORRUPTION (109) we are currently seeing in
https://bugzilla.redhat.com/show_bug.cgi?id=1751017.
The root cause of the issue is that kvm_arch_mmu_notifier_invalidate_range() cannot guarantee that no additional references are taken to the pages in the range before kvm_mmu_notifier_invalidate_range_end(). Fortunately, this case is supported by the MMU notifier API, as documented in include/linux/mmu_notifier.h:
* If the subsystem
* can't guarantee that no additional references are taken to
* the pages in the range, it has to implement the
* invalidate_range() notifier to remove any references taken
* after invalidate_range_start().
The fix therefore is to reload the APIC-access page field in the VMCS from kvm_mmu_notifier_invalidate_range() instead of ..._range_start().
Message-Id: <[email protected]>
--- arch/x86/kvm/x86.c | 7 ++----- include/linux/kvm_host.h | 4 ++-- virt/kvm/kvm_main.c | 26 ++++++++++++++++---------- 3 files changed, 20 insertions(+), 17 deletions(-)
arch/x86/kvm/x86.c +2 -5
@@ -8115,9 +8115,8 @@ static void vcpu_load_eoi_exitmap(struct kvm_x86_ops->load_eoi_exitmap (vcpu, eoi_exit_bitmap); } -int kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, -unsigned long start,unsigned long end, -bool blockable) +void kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, +unsigned long start,unsigned long end) {unsigned long apic_address;
@@ -8128,8 +8127,6 @@ int kvm_arch_mmu_notifier_invalidate_ran apic_address =gfn_to_hva (kvm,APIC_DEFAULT_PHYS_BASE >>PAGE_SHIFT );if (start <= apic_address && apic_address < end)kvm_make_all_cpus_request (kvm,KVM_REQ_APIC_PAGE_RELOAD ); - -return 0 ; }void kvm_vcpu_reload_apic_access_page (struct kvm_vcpu *vcpu)
include/linux/kvm_host.h +2 -2
@@ -1394,8 +1394,8 @@ static inline long kvm_arch_vcpu_async_i }#endif /* CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL */ -int kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, -unsigned long start,unsigned long end,bool blockable); +void kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, +unsigned long start,unsigned long end);#ifdef CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE int kvm_arch_vcpu_run_pid_change (struct kvm_vcpu *vcpu);
virt/kvm/kvm_main.c +16 -10
@@ -157,10 +157,9 @@ static void kvm_uevent_notify_change(unsstatic unsigned long long kvm_createvm_count;static unsigned long long kvm_active_vms; -__weak int kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, -unsigned long start,unsigned long end,bool blockable) +__weak void kvm_arch_mmu_notifier_invalidate_range (struct kvm *kvm, +unsigned long start,unsigned long end) { -return 0 ; }bool kvm_is_zone_device_pfn (kvm_pfn_t pfn)
@@ -378,6 +377,18 @@ static inline struct kvm *mmu_notifier_t return container_of(mn, struct kvm, mmu_notifier); } +static void kvm_mmu_notifier_invalidate_range (struct mmu_notifier *mn, +struct mm_struct *mm, +unsigned long start,unsigned long end) +{ +struct kvm *kvm =mmu_notifier_to_kvm (mn); +int idx; + + idx =srcu_read_lock (&kvm->srcu); +kvm_arch_mmu_notifier_invalidate_range (kvm, start, end); +srcu_read_unlock (&kvm->srcu, idx); +} + static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn, struct mm_struct *mm, unsigned long address,
@@ -402,7 +413,6 @@ static int kvm_mmu_notifier_invalidate_r {struct kvm *kvm =mmu_notifier_to_kvm (mn);int need_tlb_flush =0 , idx; -int ret; idx =srcu_read_lock (&kvm->srcu);spin_lock (&kvm->mmu_lock);
@@ -419,14 +429,9 @@ static int kvm_mmu_notifier_invalidate_rkvm_flush_remote_tlbs (kvm);spin_unlock (&kvm->mmu_lock); - - ret =kvm_arch_mmu_notifier_invalidate_range (kvm, range->start, - range->end, -mmu_notifier_range_blockable (range)); -srcu_read_unlock (&kvm->srcu, idx); -return ret; +return 0 ; } static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
@@ -532,6 +537,7 @@ static void kvm_mmu_notifier_release(str }static const struct mmu_notifier_ops kvm_mmu_notifier_ops = { + .invalidate_range = kvm_mmu_notifier_invalidate_range, .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start, .invalidate_range_end = kvm_mmu_notifier_invalidate_range_end, .clear_flush_young = kvm_mmu_notifier_clear_flush_young,
Greg Kroah-Hartman
maintainerPATCH 60/161 powerpc/ptdump: Properly handle non standard page size
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit b00ff6d8c1c3898b0f768cbb38ef722d25bd2f39 upstream.
In order to properly display information regardless of the page size, it is necessary to take into account real page size.
--- arch/powerpc/mm/ptdump/ptdump.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
arch/powerpc/mm/ptdump/ptdump.c +12 -9
@@ -60,6 +60,7 @@ struct pg_state {unsigned long start_address;unsigned long start_pa;unsigned long last_pa; +unsigned long page_size;unsigned int level;u64 current_flags;bool check_wx;
@@ -157,9 +158,9 @@ static void dump_addr(struct pg_state *s#endif pt_dump_seq_printf (st->seq,REG "-" REG " " , st->start_address, addr -1 ); -if (st->start_pa == st->last_pa && st->start_address +PAGE_SIZE != addr) { +if (st->start_pa == st->last_pa && st->start_address + st->page_size != addr) {pt_dump_seq_printf (st->seq,"[" REG "]" , st->start_pa); - delta =PAGE_SIZE >>10 ; + delta = st->page_size >>10 ; }else {pt_dump_seq_printf (st->seq," " REG " " , st->start_pa); delta = (addr - st->start_address) >>10 ;
@@ -190,7 +191,7 @@ static void note_prot_wx(struct pg_state }static void note_page (struct pg_state *st,unsigned long addr, -unsigned int level,u64 val) +unsigned int level,u64 val,unsigned long page_size) {u64 flag = val & pg_level[level].mask;u64 pa = val &PTE_RPN_MASK ;
@@ -202,6 +203,7 @@ static void note_page(struct pg_state *s st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size;pt_dump_seq_printf (st->seq,"---[ %s ]---\n" , st->marker->name);/* * Dump the section of virtual memory when:
@@ -213,7 +215,7 @@ static void note_page(struct pg_state *s*/ }else if (flag != st->current_flags || level != st->level || addr >= st->marker[1 ].start_address || - (pa != st->last_pa +PAGE_SIZE && + (pa != st->last_pa + st->page_size && (pa != st->start_pa || st->start_pa != st->last_pa))) {/* Check the PTE flags */
@@ -241,6 +243,7 @@ static void note_page(struct pg_state *s st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size; st->current_flags = flag; st->level = level; }else {
@@ -256,7 +259,7 @@ static void walk_pte(struct pg_state *stfor (i =0 ; i <PTRS_PER_PTE ; i++, pte++) { addr = start + i *PAGE_SIZE ; -note_page (st, addr,4 ,pte_val (*pte)); +note_page (st, addr,4 ,pte_val (*pte),PAGE_SIZE ); } }
@@ -273,7 +276,7 @@ static void walk_pmd(struct pg_state *st/* pmd exists */ walk_pte (st, pmd, addr); else - note_page(st, addr, 3, pmd_val(*pmd)); + note_page(st, addr, 3, pmd_val(*pmd), PMD_SIZE); } }
@@ -289,7 +292,7 @@ static void walk_pud(struct pg_state *st/* pud exists */ walk_pmd (st, pud, addr); else - note_page(st, addr, 2, pud_val(*pud)); + note_page(st, addr, 2, pud_val(*pud), PUD_SIZE); } }
@@ -308,7 +311,7 @@ static void walk_pagetables(struct pg_st/* pgd exists */ walk_pud (st, pgd, addr); else - note_page(st, addr, 1, pgd_val(*pgd)); + note_page(st, addr, 1, pgd_val(*pgd), PGDIR_SIZE); } }
@@ -363,7 +366,7 @@ static int ptdump_show(struct seq_file */* Traverse kernel page tables */ walk_pagetables (&st); -note_page (&st,0 ,0 ,0 ); +note_page (&st,0 ,0 ,0 ,0 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 61/161 ASoC: max9867: fix volume controls
In reply to Greg Kroah-HartmanFrom: Pavel Dobias <[email protected]>
commit 8ba4dc3cff8cbe2c571063a5fd7116e8bde563ca upstream.
The xmax values for Master Playback Volume and Mic Boost Capture Volume are specified incorrectly (one greater) which results in the wrong dB gain being shown to the user in the case of Master Playback Volume.
--- sound/soc/codecs/max9867.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/max9867.c +2 -2
@@ -46,13 +46,13 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_Rstatic const struct snd_kcontrol_new max9867_snd_controls[] = {SOC_DOUBLE_R_TLV ("Master Playback Volume" ,MAX9867_LEFTVOL , -MAX9867_RIGHTVOL ,0 ,41 ,1 , max9867_master_tlv), +MAX9867_RIGHTVOL ,0 ,40 ,1 , max9867_master_tlv),SOC_DOUBLE_R_TLV ("Line Capture Volume" ,MAX9867_LEFTLINELVL ,MAX9867_RIGHTLINELVL ,0 ,15 ,1 , max9867_line_tlv),SOC_DOUBLE_R_TLV ("Mic Capture Volume" ,MAX9867_LEFTMICGAIN ,MAX9867_RIGHTMICGAIN ,0 ,20 ,1 , max9867_mic_tlv),SOC_DOUBLE_R_TLV ("Mic Boost Capture Volume" ,MAX9867_LEFTMICGAIN , -MAX9867_RIGHTMICGAIN ,5 ,4 ,0 , max9867_micboost_tlv), +MAX9867_RIGHTMICGAIN ,5 ,3 ,0 , max9867_micboost_tlv),SOC_SINGLE ("Digital Sidetone Volume" ,MAX9867_SIDETONE ,0 ,31 ,1 ),SOC_SINGLE_TLV ("Digital Playback Volume" ,MAX9867_DACLEVEL ,0 ,15 ,1 , max9867_dac_tlv),
Greg Kroah-Hartman
maintainerPATCH 62/161 io_uring: use kvfree() in io_sqe_buffer_register()
In reply to Greg Kroah-HartmanFrom: Denis Efremov <[email protected]>
commit a8c73c1a614f6da6c0b04c393f87447e28cb6de4 upstream.
Use kvfree() to free the pages and vmas, since they are allocated by kvmalloc_array() in a loop.
--- fs/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io_uring.c +2 -2
@@ -6254,8 +6254,8 @@ static int io_sqe_buffer_register(struct ret =0 ;if (!pages || nr_pages > got_pages) { -kfree (vmas); -kfree (pages); +kvfree (vmas); +kvfree (pages); pages =kvmalloc_array (nr_pages,sizeof (struct page *),GFP_KERNEL ); vmas = kvmalloc_array(nr_pages,
Greg Kroah-Hartman
maintainerPATCH 63/161 efi/efivars: Add missing kobject_put() in sysfs entry creation error path
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit d8bd8c6e2cfab8b78b537715255be8d7557791c0 upstream.
The documentation provided by kobject_init_and_add() clearly spells out the need to call kobject_put() on the kobject if an error is returned. Add this missing call to the error path.
--- drivers/firmware/efi/efivars.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/efi/efivars.c +3 -1
@@ -522,8 +522,10 @@ efivar_create_sysfs_entry(struct efivar_ ret =kobject_init_and_add (&new_var->kobj, &efivar_ktype,NULL ,"%s" , short_name);kfree (short_name); -if (ret) +if (ret) { +kobject_put (&new_var->kobj);return ret; + }kobject_uevent (&new_var->kobj,KOBJ_ADD );if (efivar_entry_add (new_var, &efivar_sysfs_list)) {
Greg Kroah-Hartman
maintainerPATCH 64/161 smb3: fix incorrect number of credits when ioctl MaxOutputResponse > 64K
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit e80ddeb2f70ebd0786aa7cdba3e58bc931fa0bb5 upstream.
We were not checking to see if ioctl requests asked for more than 64K (ie when CIFSMaxBufSize was > 64K) so when setting larger CIFSMaxBufSize then ioctls would fail with invalid parameter errors. When requests ask for more than 64K in MaxOutputResponse then we need to ask for more than 1 credit.
--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2pdu.c +1 -1
@@ -2868,7 +2868,7 @@ SMB2_ioctl_init(struct cifs_tcon *tcon,* response size smaller. */ req->MaxOutputResponse =cpu_to_le32 (max_response_size); - + req->sync_hdr.CreditCharge =cpu_to_le16 (DIV_ROUND_UP (max_response_size,SMB2_MAX_BUFFER_SIZE ));if (is_fsctl) req->Flags =cpu_to_le32 (SMB2_0_IOCTL_IS_FSCTL );else
Greg Kroah-Hartman
maintainerPATCH 65/161 smb3: add indatalen that can be a non-zero value to calculation of credit charge in smb2 ioctl
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit ebf57440ec59a36e1fc5fe91e31d66ae0d1662d0 upstream.
Some of tests in xfstests failed with cifsd kernel server since commit e80ddeb2f70e. cifsd kernel server validates credit charge from client by calculating it base on max((InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse)) according to specification.
MS-SMB2 specification describe credit charge calculation of smb2 ioctl :
If Connection.SupportsMultiCredit is TRUE, the server MUST validate CreditCharge based on the maximum of (InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse), as specified in section 3.3.5.2.5. If the validation fails, it MUST fail the IOCTL request with STATUS_INVALID_PARAMETER.
This patch add indatalen that can be a non-zero value to calculation of credit charge in SMB2_ioctl_init().
MaxOutputResponse > 64K")
--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
@@ -2868,7 +2868,9 @@ SMB2_ioctl_init(struct cifs_tcon *tcon,* response size smaller. */ req->MaxOutputResponse =cpu_to_le32 (max_response_size); - req->sync_hdr.CreditCharge =cpu_to_le16 (DIV_ROUND_UP (max_response_size,SMB2_MAX_BUFFER_SIZE )); + 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
Greg Kroah-Hartman
maintainerPATCH 66/161 smb3: fix typo in mount options displayed in /proc/mounts
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit 7866c177a03b18be3d83175014c643546e5b53c6 upstream.
Missing the final 's' in "max_channels" mount option when displayed in /proc/mounts (or by mount command)
--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifsfs.c +1 -1
@@ -621,7 +621,7 @@ cifs_show_options(struct seq_file *s, stseq_printf (s,",actimeo=%lu" , cifs_sb->actimeo /HZ );if (tcon->ses->chan_max >1 ) -seq_printf (s,",multichannel,max_channel=%zu" , +seq_printf (s,",multichannel,max_channels=%zu" , tcon->ses->chan_max);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 67/161 watchdog: imx_sc_wdt: Fix reboot on crash
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
commit e56d48e92b1017b6a8dbe64923a889283733fd96 upstream.
Currently when running the samples/watchdog/watchdog-simple.c application and forcing a kernel crash by doing:
# ./watchdog-simple & # echo c > /proc/sysrq-trigger
The system does not reboot as expected.
Fix it by calling imx_sc_wdt_set_timeout() to configure the i.MX8QXP watchdog with a proper timeout.
--- drivers/watchdog/imx_sc_wdt.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/watchdog/imx_sc_wdt.c +5 -0
@@ -177,6 +177,11 @@ static int imx_sc_wdt_probe(struct platf wdog->timeout =DEFAULT_TIMEOUT ;watchdog_init_timeout (wdog,0 , dev); + + ret =imx_sc_wdt_set_timeout (wdog, wdog->timeout); +if (ret) +return ret; +watchdog_stop_on_reboot (wdog);watchdog_stop_on_unregister (wdog);
Greg Kroah-Hartman
maintainerPATCH 68/161 ALSA: es1688: Add the missed snd_card_free()
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
commit d9b8fbf15d05350b36081eddafcf7b15aa1add50 upstream.
snd_es968_pnp_detect() misses a snd_card_free() in a failed path. Add the missed function call to fix it.
--- sound/isa/es1688/es1688.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/isa/es1688/es1688.c +3 -1
@@ -267,8 +267,10 @@ static int snd_es968_pnp_detect(struct preturn error; } error =snd_es1688_probe (card, dev); -if (error <0 ) +if (error <0 ) { +snd_card_free (card);return error; + }pnp_set_card_drvdata (pcard, card); snd_es968_pnp_is_probed =1 ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 69/161 ALSA: hda: add sienna_cichlid audio asic id for sienna_cichlid up
In reply to Greg Kroah-HartmanFrom: Hersen Wu <[email protected]>
commit 27a7c67012cfa6d79f87fbb51afa13c6c0e24e34 upstream.
dp/hdmi ati hda is not shown in audio settings
[ rearranged to a more appropriate place per device number order
-- tiwai ]
--- sound/pci/hda/hda_intel.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/hda_intel.c +3 -0
@@ -2659,6 +2659,9 @@ static const struct pci_device_id azx_id { PCI_DEVICE(0x1002, 0xab20), .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab28), + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab38), .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | AZX_DCAPS_PM_RUNTIME },
Greg Kroah-Hartman
maintainerPATCH 70/161 ALSA: fireface: fix configuration error for nominal sampling transfer frequency
In reply to Greg Kroah-HartmanFrom: Takashi Sakamoto <[email protected]>
commit bbd6aac3ae15bef762af03bf62e35ace5c4292bd upstream.
128000 and 192000 are congruence modulo 32000, thus it's wrong to distinguish them as multiple of 32000 and 48000 by modulo 32000 at first.
Additionally, used condition statement to detect quadruple speed can cause missing bit flag.
Furthermore, counter to ensure the configuration is wrong and it causes false positive.
This commit fixes the above three bugs.
--- sound/firewire/fireface/ff-protocol-latter.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/firewire/fireface/ff-protocol-latter.c +6 -6
@@ -107,18 +107,18 @@ static int latter_allocate_resources(strint err;// Set the number of data blocks transferred in a second. -if (rate %32000 ==0 ) - code =0x00 ; +if (rate %48000 ==0 ) + code =0x04 ;else if (rate %44100 ==0 ) code =0x02 ; -else if (rate %48000 ==0 ) - code =0x04 ; +else if (rate %32000 ==0 ) + code =0x00 ;else return -EINVAL ;if (rate >=64000 && rate <128000 ) code |=0x08 ; -else if (rate >=128000 && rate <192000 ) +else if (rate >=128000 ) code |=0x10 ; reg =cpu_to_le32 (code);
@@ -140,7 +140,7 @@ static int latter_allocate_resources(strif (curr_rate == rate)break ; } -if (count ==10 ) +if (count >10 )return -ETIMEDOUT ;for (i =0 ; i <ARRAY_SIZE (amdtp_rate_table); ++i) {
Greg Kroah-Hartman
maintainerPATCH 71/161 ALSA: fireface: start IR context immediately
In reply to Greg Kroah-HartmanFrom: Takashi Sakamoto <[email protected]>
commit f4588cc425beb62e355bc2a5de5d5c83e26a74ca upstream.
In the latter models of RME Fireface series, device start to transfer packets several dozens of milliseconds. On the other hand, ALSA fireface driver starts IR context 2 milliseconds after the start. This results in loss to handle incoming packets on the context.
This commit changes to start IR context immediately instead of postponement. For Fireface 800, this affects nothing because the device transfer packets 100 milliseconds or so after the start and this is within wait timeout.
--- sound/firewire/fireface/ff-stream.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
sound/firewire/fireface/ff-stream.c +1 -9
@@ -184,7 +184,6 @@ int snd_ff_stream_start_duplex(struct sn*/ if (!amdtp_stream_running (&ff->rx_stream)) {int spd =fw_parent_device (ff->unit)->max_speed; -unsigned int ir_delay_cycle; err = ff->spec->protocol->begin_session (ff, rate);if (err <0 )
@@ -200,14 +199,7 @@ int snd_ff_stream_start_duplex(struct snif (err <0 ) goto error; -// The device postpones start of transmission mostly for several -// cycles after receiving packets firstly. -if (ff->spec->protocol == &snd_ff_protocol_ff800) - ir_delay_cycle =800 ;// = 100 msec -else - ir_delay_cycle =16 ;// = 2 msec - - err =amdtp_domain_start (&ff->domain, ir_delay_cycle); + err =amdtp_domain_start (&ff->domain,0 );if (err <0 ) goto error;
Greg Kroah-Hartman
maintainerPATCH 72/161 ALSA: hda/realtek - add a pintbl quirk for several Lenovo machines
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 573fcbfd319ccef26caa3700320242accea7fd5c upstream.
A couple of Lenovo ThinkCentre machines all have 2 front mics and they use the same codec alc623 and have the same pin config, so add a pintbl entry for those machines to apply the fixup ALC283_FIXUP_HEADSET_MIC.
--- sound/pci/hda/patch_realtek.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/pci/hda/patch_realtek.c +6 -0
@@ -8124,6 +8124,12 @@ static const struct snd_hda_pin_quirk alALC225_STANDARD_PINS , {0x12, 0xb7a60130}, {0x17, 0x90170110}), +SND_HDA_PIN_QUIRK (0x10ec0623 ,0x17aa ,"Lenovo" ,ALC283_FIXUP_HEADSET_MIC , + {0x14, 0x01014010}, + {0x17, 0x90170120}, + {0x18, 0x02a11030}, + {0x19, 0x02a1103f}, + {0x21, 0x0221101f}), {} };
Greg Kroah-Hartman
maintainerPATCH 73/161 ALSA: pcm: disallow linking stream to itself
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
commit 951e2736f4b11b58dc44d41964fa17c3527d882a upstream.
Prevent SNDRV_PCM_IOCTL_LINK linking stream to itself - the code can't handle it. Fixed commit is not where bug was introduced, but changes the context significantly.
--- sound/core/pcm_native.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/core/pcm_native.c +6 -0
@@ -2163,6 +2163,12 @@ static int snd_pcm_link(struct snd_pcm_s } pcm_file = f.file->private_data; substream1 = pcm_file->substream; + +if (substream == substream1) { + res = -EINVAL ; + goto _badf; + } + group =kzalloc (sizeof (*group),GFP_KERNEL );if (!group) { res = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 74/161 ALSA: pcm: fix snd_pcm_link() lockdep splat
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
commit e18035cf5cb3d2bf8e4f4d350a23608bd208b934 upstream.
Add and use snd_pcm_stream_lock_nested() in snd_pcm_link/unlink implementation. The code is fine, but generates a lockdep complaint:
============================================
WARNING: possible recursive locking detected
5.7.1mq+ #381 Tainted: G O
--------------------------------------------
pulseaudio/4180 is trying to acquire lock:ffff888402d6f508 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xda8/0xee0 [snd_pcm]
but task is already holding lock:ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&group->lock);
lock(&group->lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by pulseaudio/4180:
#0: ffffffffa1a05190 (snd_pcm_link_rwsem){++++}-{3:3}, at: snd_pcm_common_ioctl+0xca0/0xee0 [snd_pcm] #1: ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]
[...]
--- sound/core/pcm_native.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
sound/core/pcm_native.c +12 -2
@@ -138,6 +138,16 @@ void snd_pcm_stream_lock_irq(struct snd_ }EXPORT_SYMBOL_GPL (snd_pcm_stream_lock_irq); +static void snd_pcm_stream_lock_nested (struct snd_pcm_substream *substream) +{ +struct snd_pcm_group *group = &substream->self_group; + +if (substream->pcm->nonatomic) +mutex_lock_nested (&group->mutex,SINGLE_DEPTH_NESTING ); +else +spin_lock_nested (&group->lock,SINGLE_DEPTH_NESTING ); +} +/** * snd_pcm_stream_unlock_irq - Unlock the PCM stream * @substream: PCM substream
@@ -2197,7 +2207,7 @@ static int snd_pcm_link(struct snd_pcm_ssnd_pcm_stream_unlock_irq (substream);snd_pcm_group_lock_irq (target_group, nonatomic); -snd_pcm_stream_lock (substream1); +snd_pcm_stream_lock_nested (substream1);snd_pcm_group_assign (substream1, target_group);refcount_inc (&target_group->refs);snd_pcm_stream_unlock (substream1);
@@ -2213,7 +2223,7 @@ static int snd_pcm_link(struct snd_pcm_sstatic void relink_to_local (struct snd_pcm_substream *substream) { -snd_pcm_stream_lock (substream); +snd_pcm_stream_lock_nested (substream);snd_pcm_group_assign (substream, &substream->self_group);snd_pcm_stream_unlock (substream); }
Greg Kroah-Hartman
maintainerPATCH 75/161 ALSA: usb-audio: Fix inconsistent card PM state after resume
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 862b2509d157c629dd26d7ac6c6cdbf043d332eb upstream.
When a USB-audio interface gets runtime-suspended via auto-pm feature, the driver suspends all functionality and increment chip->num_suspended_intf. Later on, when the system gets suspended to S3, the driver increments chip->num_suspended_intf again, skips the device changes, and sets the card power state to SNDRV_CTL_POWER_D3hot. In return, when the system gets resumed from S3, the resume callback decrements chip->num_suspended_intf. Since this refcount is still not zero (it's been runtime-suspended), the whole resume is skipped. But there is a small pitfall here.
The problem is that the driver doesn't restore the card power state after this resume call, leaving it as SNDRV_CTL_POWER_D3hot. So, even after the system resume finishes, the card instance still appears as if it were system-suspended, and this confuses many ioctl accesses that are blocked unexpectedly.
In details, we have two issues behind the scene: one is that the card power state is changed only when the refcount becomes zero, and another is that the prior auto-suspend check is kept in a boolean flag. Although the latter problem is almost negligible since the auto-pm feature is imposed only on the primary interface, but this can be a potential problem on the devices with multiple interfaces.
This patch addresses those issues by the following:
- Replace chip->autosuspended boolean flag with chip->system_suspend counter
- At the first system-suspend, chip->num_suspended_intf is recorded to chip->system_suspend
- At system-resume, the card power state is restored when the chip->num_suspended_intf refcount reaches to chip->system_suspend, i.e. the state returns to the auto-suspended
Also, the patch fixes yet another hidden problem by the code refactoring along with the fixes above: namely, when some resume procedure failed, the driver left chip->num_suspended_intf that was already decreased, and it might lead to the refcount unbalance. In the new code, the refcount decrement is done after the whole resume procedure, and the problem is avoided as well.
--- sound/usb/card.c | 19 ++++++++++++------- sound/usb/usbaudio.h | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-)
sound/usb/card.c +12 -7
@@ -813,9 +813,6 @@ static int usb_audio_suspend(struct usb_if (chip == (void *)-1L )return 0 ; - chip->autosuspended = !!PMSG_IS_AUTO (message); -if (!chip->autosuspended) -snd_power_change_state (chip->card, SNDRV_CTL_POWER_D3hot);if (!chip->num_suspended_intf++) {list_for_each_entry (as, &chip->pcm_list, list) {snd_usb_pcm_suspend (as);
@@ -828,6 +825,11 @@ static int usb_audio_suspend(struct usb_snd_usb_mixer_suspend (mixer); } +if (!PMSG_IS_AUTO (message) && !chip->system_suspend) { +snd_power_change_state (chip->card, SNDRV_CTL_POWER_D3hot); + chip->system_suspend = chip->num_suspended_intf; + } +return 0 ; }
@@ -841,10 +843,10 @@ static int __usb_audio_resume(struct usbif (chip == (void *)-1L )return 0 ; -if (--chip->num_suspended_intf) -return 0 ;atomic_inc (&chip->active);/* avoid autopm */ +if (chip->num_suspended_intf >1 ) + goto out;list_for_each_entry (as, &chip->pcm_list, list) { err =snd_usb_pcm_resume (as);
@@ -866,9 +868,12 @@ static int __usb_audio_resume(struct usbsnd_usbmidi_resume (p); } -if (!chip->autosuspended) + out: +if (chip->num_suspended_intf == chip->system_suspend) {snd_power_change_state (chip->card,SNDRV_CTL_POWER_D0 ); - chip->autosuspended =0 ; + chip->system_suspend =0 ; + } + chip->num_suspended_intf--; err_out:atomic_dec (&chip->active);/* allow autopm after this point */
sound/usb/usbaudio.h +1 -1
@@ -26,7 +26,7 @@ struct snd_usb_audio {struct usb_interface *pm_intf;u32 usb_id;struct mutex mutex; - unsigned int autosuspended:1; +unsigned int system_suspend;atomic_t active;atomic_t shutdown;atomic_t usage_count;
Greg Kroah-Hartman
maintainerPATCH 76/161 ALSA: usb-audio: Add vendor, product and profile name for HP Thunderbolt Dock
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 0c5086f5699906ec8e31ea6509239489f060f2dc upstream.
The HP Thunderbolt Dock has two separate USB devices, one is for speaker and one is for headset. Add names for them so userspace can apply UCM settings.
--- sound/usb/quirks-table.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/usb/quirks-table.h +20 -0
@@ -25,6 +25,26 @@ .idProduct = prod, \ .bInterfaceClass = USB_CLASS_VENDOR_SPEC +/* HP Thunderbolt Dock Audio Headset */ +{ + USB_DEVICE(0x03f0, 0x0269), + .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + .vendor_name ="HP" , + .product_name ="Thunderbolt Dock Audio Headset" , + .profile_name ="HP-Thunderbolt-Dock-Audio-Headset" , + .ifnum =QUIRK_NO_INTERFACE + } +}, +/* HP Thunderbolt Dock Audio Module */ +{ + USB_DEVICE(0x03f0, 0x0567), + .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + .vendor_name ="HP" , + .product_name ="Thunderbolt Dock Audio Module" , + .profile_name ="HP-Thunderbolt-Dock-Audio-Module" , + .ifnum =QUIRK_NO_INTERFACE + } +},/* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8),
Greg Kroah-Hartman
maintainerPATCH 77/161 ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile()
In reply to Greg Kroah-HartmanFrom: Qiushi Wu <[email protected]>
commit 6e6c25283dff866308c87b49434c7dbad4774cc0 upstream.
kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject.
--- drivers/acpi/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/sysfs.c +3 -1
@@ -993,8 +993,10 @@ void acpi_sysfs_add_hotplug_profile(stru error =kobject_init_and_add (&hotplug->kobj, &acpi_hotplug_profile_ktype, hotplug_kobj,"%s" , name); -if (error) +if (error) { +kobject_put (&hotplug->kobj); goto err_out; + }kobject_uevent (&hotplug->kobj,KOBJ_ADD );return ;
Greg Kroah-Hartman
maintainerPATCH 78/161 ACPI: CPPC: Fix reference count leak in acpi_cppc_processor_probe()
In reply to Greg Kroah-HartmanFrom: Qiushi Wu <[email protected]>
commit 4d8be4bc94f74bb7d096e1c2e44457b530d5a170 upstream.
kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Previous commit "b8eb718348b8" fixed a similar problem.
--- drivers/acpi/cppc_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/cppc_acpi.c +1 -0
@@ -865,6 +865,7 @@ int acpi_cppc_processor_probe(struct acp "acpi_cppc");if (ret) {per_cpu (cpc_desc_ptr, pr->id) =NULL ; +kobject_put (&cpc_ptr->kobj); goto out_free; }
Greg Kroah-Hartman
maintainerPATCH 79/161 ACPI: GED: add support for _Exx / _Lxx handler methods
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit ea6f3af4c5e63f6981c0b0ab8ebec438e2d5ef40 upstream.
Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.
Add support for this missing feature to our ACPI GED driver.
--- drivers/acpi/evged.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +19 -3
@@ -79,6 +79,8 @@ static acpi_status acpi_ged_request_intestruct resource r;struct acpi_resource_irq *p = &ares->data.irq;struct acpi_resource_extended_irq *pext = &ares->data.extended_irq; +char ev_name[5 ]; +u8 trigger;if (ares->type ==ACPI_RESOURCE_TYPE_END_TAG )return AE_OK ;
@@ -87,14 +89,28 @@ static acpi_status acpi_ged_request_intedev_err (dev,"unable to parse IRQ resource\n" );return AE_ERROR ; } -if (ares->type ==ACPI_RESOURCE_TYPE_IRQ ) +if (ares->type ==ACPI_RESOURCE_TYPE_IRQ ) { gsi = p->interrupts[0 ]; -else + trigger = p->triggering; + }else { gsi = pext->interrupts[0 ]; + trigger = p->triggering; + } irq = r.start; -if (ACPI_FAILURE (acpi_get_handle (handle,"_EVT" , &evt_handle))) { +switch (gsi) { + case 0 ... 255: +sprintf (ev_name,"_%c%02hhX" , + trigger ==ACPI_EDGE_SENSITIVE ?'E' :'L' , gsi); + +if (ACPI_SUCCESS (acpi_get_handle (handle, ev_name, &evt_handle))) +break ; +/* fall through */ +default : +if (ACPI_SUCCESS (acpi_get_handle (handle,"_EVT" , &evt_handle))) +break ; +dev_err (dev,"cannot locate _EVT method\n" );return AE_ERROR ; }
Greg Kroah-Hartman
maintainerPATCH 80/161 ACPI: PM: Avoid using power resources if there are none for D0
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 956ad9d98b73f59e442cc119c98ba1e04e94fe6d upstream.
As recently reported, some platforms provide a list of power resources for device power state D3hot, through the _PR3 object, but they do not provide a list of power resources for device power state D0.
Among other things, this causes acpi_device_get_power() to return D3hot as the current state of the device in question if all of the D3hot power resources are "on", because it sees the power_resources flag set and calls acpi_power_get_inferred_state() which finds that D3hot is the shallowest power state with all of the associated power resources turned "on", so that's what it returns. Moreover, that value takes precedence over the acpi_dev_pm_explicit_get() return value, because it means a deeper power state. The device may very well be in D0 physically at that point, however.
Moreover, the presence of _PR3 without _PR0 for a given device means that only one D3-level power state can be supported by it. Namely, because there are no power resources to turn "off" when transitioning the device from D0 into D3cold (which should be supported since _PR3 is present), the evaluation of _PS3 should be sufficient to put it straight into D3cold, but this means that the effect of turning "on" the _PR3 power resources is unclear, so it is better to avoid doing that altogether. Consequently, there is no practical way do distinguish D3cold from D3hot for the device in question and the power states of it can be labeled so that D3hot is the deepest supported one (and Linux assumes that putting a device into D3hot via ACPI may cause power to be removed from it anyway, for legacy reasons).
To work around the problem described above modify the ACPI enumeration of devices so that power resources are only used for device power management if the list of D0 power resources is not empty and make it mart D3cold as supported only if that is the case and the D3hot list of power resources is not empty too.
--- drivers/acpi/device_pm.c | 2 +- drivers/acpi/scan.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/acpi/device_pm.c +1 -1
@@ -186,7 +186,7 @@ int acpi_device_set_power(struct acpi_de* possibly drop references to the power resources in use. */ state =ACPI_STATE_D3_HOT ; -/* If _PR3 is not available, use D3hot as the target state. */ +/* If D3cold is not supported, use D3hot as the target state. */ if (!device->power.states[ACPI_STATE_D3_COLD ].flags.valid) target_state = state; }else if (!device->power.states[state].flags.valid) {
drivers/acpi/scan.c +19 -9
@@ -919,12 +919,9 @@ static void acpi_bus_init_power_state(stif (buffer.length && package && package->type ==ACPI_TYPE_PACKAGE - && package->package.count) { -int err =acpi_extract_power_resources (package,0 , - &ps->resources); -if (!err) - device->power.flags.power_resources =1 ; - } + && package->package.count) +acpi_extract_power_resources (package,0 , &ps->resources); +ACPI_FREE (buffer.pointer); }
@@ -971,14 +968,27 @@ static void acpi_bus_get_power_flags(stracpi_bus_init_power_state (device, i);INIT_LIST_HEAD (&device->power.states[ACPI_STATE_D3_COLD ].resources); -if (!list_empty (&device->power.states[ACPI_STATE_D3_HOT ].resources)) - device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; -/* Set defaults for D0 and D3hot states (always valid) */ +/* Set the defaults for D0 and D3hot (always supported). */ device->power.states[ACPI_STATE_D0 ].flags.valid =1 ; device->power.states[ACPI_STATE_D0 ].power =100 ; device->power.states[ACPI_STATE_D3_HOT ].flags.valid =1 ; +/* +* Use power resources only if the D0 list of them is populated, because +* some platforms may provide _PR3 only to indicate D3cold support and +* in those cases the power resources list returned by it may be bogus. +*/ +if (!list_empty (&device->power.states[ACPI_STATE_D0 ].resources)) { + device->power.flags.power_resources =1 ; +/* +* D3cold is supported if the D3hot list of power resources is +* not empty. +*/ +if (!list_empty (&device->power.states[ACPI_STATE_D3_HOT ].resources)) + device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; + } +if (acpi_bus_init_power (device)) device->flags.power_manageable =0 ; }
Greg Kroah-Hartman
maintainerPATCH 81/161 arm64: acpi: fix UBSAN warning
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
commit a194c33f45f83068ef13bf1d16e26d4ca3ecc098 upstream.
Will reported a UBSAN warning:
UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 member access within null pointer of type 'struct acpi_madt_generic_interrupt' CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 Call trace: dump_backtrace+0x0/0x384 show_stack+0x28/0x38 dump_stack+0xec/0x174 handle_null_ptr_deref+0x134/0x174 __ubsan_handle_type_mismatch_v1+0x84/0xa4 acpi_parse_gic_cpu_interface+0x60/0xe8 acpi_parse_entries_array+0x288/0x498 acpi_table_parse_entries_array+0x178/0x1b4 acpi_table_parse_madt+0xa4/0x110 acpi_parse_and_init_cpus+0x38/0x100 smp_init_cpus+0x74/0x258 setup_arch+0x350/0x3ec start_kernel+0x98/0x6f4
This is from the use of the ACPI_OFFSET in arch/arm64/include/asm/acpi.h. Replace its use with offsetof from include/linux/stddef.h which should implement the same logic using __builtin_offsetof, so that UBSAN wont warn.
--- arch/arm64/include/asm/acpi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/acpi.h +3 -2
@@ -12,6 +12,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/psci.h> +#include <linux/stddef.h> #include <asm/cputype.h> #include <asm/io.h>
@@ -31,14 +32,14 @@* is therefore used to delimit the MADT GICC structure minimum length * appropriately. */ -#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ +#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ struct acpi_madt_generic_interrupt, efficiency_class)#define BAD_MADT_GICC_ENTRY (entry, end) \ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) -#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ +#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16))/* Basic configuration for ACPI */
Greg Kroah-Hartman
maintainerPATCH 82/161 lib/lzo: fix ambiguous encoding bug in lzo-rle
In reply to Greg Kroah-HartmanFrom: Dave Rodgman <[email protected]>
commit b5265c813ce4efbfa2e46fd27cdf9a7f44a35d2e upstream.
In some rare cases, for input data over 32 KB, lzo-rle could encode two different inputs to the same compressed representation, so that decompression is then ambiguous (i.e. data may be corrupted - although zram is not affected because it operates over 4 KB pages).
This modifies the compressor without changing the decompressor or the bitstream format, such that:
- there is no change to how data produced by the old compressor is decompressed
- an old decompressor will correctly decode data from the updated compressor
- performance and compression ratio are not affected
- we avoid introducing a new bitstream format
In testing over 12.8M real-world files totalling 903 GB, three files were affected by this bug. I also constructed 37M semi-random 64 KB files totalling 2.27 TB, and saw no affected files. Finally I tested over files constructed to contain each of the ~1024 possible bad input sequences; for all of these cases, updated lzo-rle worked correctly.
There is no significant impact to performance or compression ratio.
--- Documentation/lzo.txt | 8 ++++++-- lib/lzo/lzo1x_compress.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-)
Documentation/lzo.txt +6 -2
@@ -159,11 +159,15 @@ Byte sequences distance = 16384 + (H << 14) + D state = S (copy S literals after this block) End of stream is reached if distance == 16384 + In version 1 only, to prevent ambiguity with the RLE case when + ((distance & 0x803f) == 0x803f) && (261 <= length <= 264), the + compressor must not emit block copies where distance and length + meet these conditions. In version 1 only, this instruction is also used to encode a run of - zeros if distance = 0xbfff, i.e. H = 1 and the D bits are all 1. + zeros if distance = 0xbfff, i.e. H = 1 and the D bits are all 1. In this case, it is followed by a fourth byte, X. - run length = ((X << 3) | (0 0 0 0 0 L L L)) + 4. + run length = ((X << 3) | (0 0 0 0 0 L L L)) + 4 0 0 1 L L L L L (32..63) Copy of small block within 16kB distance (preferably less than 34B)
lib/lzo/lzo1x_compress.c +13 -0
@@ -268,6 +268,19 @@ m_len_done: *op++ = (M4_MARKER | ((m_off >>11 ) &8 ) | (m_len -2 )); else { +if (unlikely (((m_off &0x403f ) ==0x403f ) + && (m_len >=261 ) + && (m_len <=264 )) + &&likely (bitstream_version)) { +// Under lzo-rle, block copies +// for 261 <= length <= 264 and +// (distance & 0x80f3) == 0x80f3 +// can result in ambiguous +// output. Adjust length +// to 260 to prevent ambiguity. + ip -= m_len -260 ; + m_len =260 ; + } m_len -=M4_MAX_LEN ; *op++ = (M4_MARKER | ((m_off >>11 ) &8 ));while (unlikely (m_len >255 )) {
Greg Kroah-Hartman
maintainerPATCH 83/161 nilfs2: fix null pointer dereference at nilfs_segctor_do_construct()
In reply to Greg Kroah-HartmanFrom: Ryusuke Konishi <[email protected]>
commit 8301c719a2bd131436438e49130ee381d30933f5 upstream.
After commit c3aab9a0bd91 ("mm/filemap.c: don't initiate writeback if mapping has no dirty pages"), the following null pointer dereference has been reported on nilfs2:
BUG: kernel NULL pointer dereference, address: 00000000000000a8
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] SMP PTI
...
RIP: 0010:percpu_counter_add_batch+0xa/0x60
...
Call Trace:
__test_set_page_writeback+0x2d3/0x330
nilfs_segctor_do_construct+0x10d3/0x2110 [nilfs2]
nilfs_segctor_construct+0x168/0x260 [nilfs2]
nilfs_segctor_thread+0x127/0x3b0 [nilfs2]
kthread+0xf8/0x130
...This crash turned out to be caused by set_page_writeback() call for segment summary buffers at nilfs_segctor_prepare_write().
set_page_writeback() can call inc_wb_stat(inode_to_wb(inode), WB_WRITEBACK) where inode_to_wb(inode) is NULL if the inode of underlying block device does not have an associated wb.
This fixes the issue by calling inode_attach_wb() in advance to ensure to associate the bdev inode with its wb.
--- fs/nilfs2/segment.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nilfs2/segment.c +2 -0
@@ -2780,6 +2780,8 @@ int nilfs_attach_log_writer(struct superif (!nilfs->ns_writer)return -ENOMEM ; +inode_attach_wb (nilfs->ns_bdev->bd_inode,NULL ); + err =nilfs_segctor_start_thread (nilfs->ns_writer);if (err) {kfree (nilfs->ns_writer);
Greg Kroah-Hartman
maintainerPATCH 84/161 lib: fix bitmap_parse() on 64-bit big endian archs
In reply to Greg Kroah-HartmanFrom: Alexander Gordeev <[email protected]>
commit 81c4f4d924d5d009b5ed785a3e22b18d0f7b831f upstream.
Commit 2d6261583be0 ("lib: rework bitmap_parse()") does not take into account order of halfwords on 64-bit big endian architectures. As result (at least) Receive Packet Steering, IRQ affinity masks and runtime kernel test "test_bitmap" get broken on s390.
--- lib/bitmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/bitmap.c +7 -2
@@ -740,8 +740,9 @@ int bitmap_parse(const char *start, unsiint chunks =BITS_TO_U32 (nmaskbits);u32 *bitmap = (u32 *)maskp;int unset_bit; +int chunk; -while (1 ) { +for (chunk =0 ; ; chunk++) { end =bitmap_find_region_reverse (start, end);if (start > end)break ;
@@ -749,7 +750,11 @@ int bitmap_parse(const char *start, unsiif (!chunks--)return -EOVERFLOW ; - end =bitmap_get_x32_reverse (start, end, bitmap++); +#if defined(CONFIG_64BIT ) && defined(__BIG_ENDIAN) + end =bitmap_get_x32_reverse (start, end, &bitmap[chunk ^1 ]); +#else + end =bitmap_get_x32_reverse (start, end, &bitmap[chunk]); +#endif if (IS_ERR (end))return PTR_ERR (end); }
Greg Kroah-Hartman
maintainerPATCH 85/161 spi: dw: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit ca8b19d61e3fce5d2d7790cde27a0b57bcb3f341 upstream.
The Designware SPI driver uses devm_spi_register_controller() on bind. As a consequence, on unbind, __device_release_driver() first invokes dw_spi_remove_host() before unregistering the SPI controller via devres_release_all().
This order is incorrect: dw_spi_remove_host() shuts down the chip, rendering the SPI bus inaccessible even though the SPI controller is still registered. When the SPI controller is subsequently unregistered, it unbinds all its slave devices. Because their drivers cannot access the SPI bus, e.g. to quiesce interrupts, the slave devices may be left in an improper state.
As a rule, devm_spi_register_controller() must not be used if the ->remove() hook performs teardown steps which shall be performed after unregistering the controller and specifically after unbinding of slaves.
Fix by reverting to the non-devm variant of spi_register_controller().
An alternative approach would be to use device-managed functions for all steps in dw_spi_remove_host(), e.g. by calling devm_add_action_or_reset() on probe. However that approach would add more LoC to the driver and it wouldn't lend itself as well to backporting to stable.
--- drivers/spi/spi-dw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-dw.c +3 -1
@@ -534,7 +534,7 @@ int dw_spi_add_host(struct device *dev, } } - ret =devm_spi_register_controller (dev, master); + ret =spi_register_controller (master);if (ret) {dev_err (&master->dev,"problem registering spi master\n" ); goto err_dma_exit;
@@ -558,6 +558,8 @@ void dw_spi_remove_host(struct dw_spi *d {dw_spi_debugfs_remove (dws); +spi_unregister_controller (dws->master); +if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit (dws);
Greg Kroah-Hartman
maintainerPATCH 86/161 spi: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 84855678add8aba927faf76bc2f130a40f94b6f7 upstream.
When an SPI controller unregisters, it unbinds all its slave devices. For this, their drivers may need to access the SPI bus, e.g. to quiesce interrupts.
However since commit ffbbdd21329f ("spi: create a message queueing infrastructure"), spi_destroy_queue() is executed before unbinding the slaves. It sets ctlr->running = false, thereby preventing SPI bus access and causing unbinding of slave devices to fail.
Fix by unbinding slaves before calling spi_destroy_queue().
--- drivers/spi/spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi.c +2 -1
@@ -2768,6 +2768,8 @@ void spi_unregister_controller(struct spstruct spi_controller *found;int id = ctlr->bus_num; +device_for_each_child (&ctlr->dev,NULL , __unregister); +/* First make sure that this controller was ever added */ mutex_lock (&board_lock); found =idr_find (&spi_master_idr, id);
@@ -2780,7 +2782,6 @@ void spi_unregister_controller(struct splist_del (&ctlr->list);mutex_unlock (&board_lock); -device_for_each_child (&ctlr->dev,NULL , __unregister);device_unregister (&ctlr->dev);/* free bus id */ mutex_lock (&board_lock);
Greg Kroah-Hartman
maintainerPATCH 87/161 spi: pxa2xx: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 32e5b57232c0411e7dea96625c415510430ac079 upstream.
The PXA2xx SPI driver uses devm_spi_register_controller() on bind. As a consequence, on unbind, __device_release_driver() first invokes pxa2xx_spi_remove() before unregistering the SPI controller via devres_release_all().
This order is incorrect: pxa2xx_spi_remove() disables the chip, rendering the SPI bus inaccessible even though the SPI controller is still registered. When the SPI controller is subsequently unregistered, it unbinds all its slave devices. Because their drivers cannot access the SPI bus, e.g. to quiesce interrupts, the slave devices may be left in an improper state.
As a rule, devm_spi_register_controller() must not be used if the ->remove() hook performs teardown steps which shall be performed after unregistering the controller and specifically after unbinding of slaves.
Fix by reverting to the non-devm variant of spi_register_controller().
An alternative approach would be to use device-managed functions for all steps in pxa2xx_spi_remove(), e.g. by calling devm_add_action_or_reset() on probe. However that approach would add more LoC to the driver and it wouldn't lend itself as well to backporting to stable.
The improper use of devm_spi_register_controller() was introduced in 2013 by commit a807fcd090d6 ("spi: pxa2xx: use devm_spi_register_master()"), but all earlier versions of the driver going back to 2006 were likewise broken because they invoked spi_unregister_master() at the end of pxa2xx_spi_remove(), rather than at the beginning.
--- drivers/spi/spi-pxa2xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-pxa2xx.c +3 -1
@@ -1879,7 +1879,7 @@ static int pxa2xx_spi_probe(struct platf/* Register with the SPI framework */ platform_set_drvdata (pdev, drv_data); - status =devm_spi_register_controller (&pdev->dev, controller); + status =spi_register_controller (controller);if (status !=0 ) {dev_err (&pdev->dev,"problem registering spi controller\n" ); goto out_error_pm_runtime_enabled;
@@ -1915,6 +1915,8 @@ static int pxa2xx_spi_remove(struct platpm_runtime_get_sync (&pdev->dev); +spi_unregister_controller (drv_data->controller); +/* Disable the SSP at the peripheral and SOC level */ pxa2xx_spi_write (drv_data,SSCR0 ,0 );clk_disable_unprepare (ssp->clk);
Greg Kroah-Hartman
maintainerPATCH 88/161 spi: pxa2xx: Fix runtime PM ref imbalance on probe error
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 65e318e17358a3fd4fcb5a69d89b14016dee2f06 upstream.
The PXA2xx SPI driver releases a runtime PM ref in the probe error path even though it hasn't acquired a ref earlier.
Apparently commit e2b714afee32 ("spi: pxa2xx: Disable runtime PM if controller registration fails") sought to copy-paste the invocation of pm_runtime_disable() from pxa2xx_spi_remove(), but erroneously copied the call to pm_runtime_put_noidle() as well. Drop it.
--- drivers/spi/spi-pxa2xx.c | 1 - 1 file changed, 1 deletion(-)
drivers/spi/spi-pxa2xx.c +0 -1
@@ -1888,7 +1888,6 @@ static int pxa2xx_spi_probe(struct platfreturn status; out_error_pm_runtime_enabled: -pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev); out_error_clock_enabled:
Greg Kroah-Hartman
maintainerPATCH 89/161 spi: bcm2835: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 9dd277ff92d06f6aa95b39936ad83981d781f49b upstream.
The BCM2835 SPI driver uses devm_spi_register_controller() on bind. As a consequence, on unbind, __device_release_driver() first invokes bcm2835_spi_remove() before unregistering the SPI controller via devres_release_all().
This order is incorrect: bcm2835_spi_remove() tears down the DMA channels and turns off the SPI controller, including its interrupts and clock. The SPI controller is thus no longer usable.
When the SPI controller is subsequently unregistered, it unbinds all its slave devices. If their drivers need to access the SPI bus, e.g. to quiesce their interrupts, unbinding will fail.
As a rule, devm_spi_register_controller() must not be used if the ->remove() hook performs teardown steps which shall be performed after unbinding of slaves.
Fix by using the non-devm variant spi_register_controller(). Note that the struct spi_controller as well as the driver-private data are not freed until after bcm2835_spi_remove() has finished, so accessing them is safe.
--- drivers/spi/spi-bcm2835.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm2835.c +3 -1
@@ -1347,7 +1347,7 @@ static int bcm2835_spi_probe(struct plat goto out_dma_release; } - err =devm_spi_register_controller (&pdev->dev, ctlr); + err =spi_register_controller (ctlr);if (err) {dev_err (&pdev->dev,"could not register SPI controller: %d\n" , err);
@@ -1374,6 +1374,8 @@ static int bcm2835_spi_remove(struct plabcm2835_debugfs_remove (bs); +spi_unregister_controller (ctlr); +/* Clear FIFOs, and disable the HW block */ bcm2835_wr (bs,BCM2835_SPI_CS ,BCM2835_SPI_CS_CLEAR_RX |BCM2835_SPI_CS_CLEAR_TX );
Greg Kroah-Hartman
maintainerPATCH 90/161 spi: bcm2835aux: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit b9dd3f6d417258ad0beeb292a1bc74200149f15d upstream.
The BCM2835aux SPI driver uses devm_spi_register_master() on bind. As a consequence, on unbind, __device_release_driver() first invokes bcm2835aux_spi_remove() before unregistering the SPI controller via devres_release_all().
This order is incorrect: bcm2835aux_spi_remove() turns off the SPI controller, including its interrupts and clock. The SPI controller is thus no longer usable.
When the SPI controller is subsequently unregistered, it unbinds all its slave devices. If their drivers need to access the SPI bus, e.g. to quiesce their interrupts, unbinding will fail.
As a rule, devm_spi_register_master() must not be used if the ->remove() hook performs teardown steps which shall be performed after unbinding of slaves.
Fix by using the non-devm variant spi_register_master(). Note that the struct spi_master as well as the driver-private data are not freed until after bcm2835aux_spi_remove() has finished, so accessing them is safe.
--- drivers/spi/spi-bcm2835aux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm2835aux.c +3 -1
@@ -569,7 +569,7 @@ static int bcm2835aux_spi_probe(struct p goto out_clk_disable; } - err =devm_spi_register_master (&pdev->dev, master); + err =spi_register_master (master);if (err) {dev_err (&pdev->dev,"could not register SPI master: %d\n" , err); goto out_clk_disable;
@@ -593,6 +593,8 @@ static int bcm2835aux_spi_remove(structbcm2835aux_debugfs_remove (bs); +spi_unregister_master (master); +bcm2835aux_spi_reset_hw (bs);/* disable the HW block by releasing the clock */
Greg Kroah-Hartman
maintainerPATCH 91/161 spi: bcm-qspi: Handle clock probe deferral
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
commit 0392727c261bab65a35cd4f82ee9459bc237591d upstream.
The clock provider may not be ready by the time spi-bcm-qspi gets probed, handle probe deferral using devm_clk_get_optional().
--- drivers/spi/spi-bcm-qspi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-bcm-qspi.c +5 -7
@@ -1222,6 +1222,11 @@ int bcm_qspi_probe(struct platform_devic } qspi =spi_master_get_devdata (master); + + qspi->clk =devm_clk_get_optional (&pdev->dev,NULL ); +if (IS_ERR (qspi->clk)) +return PTR_ERR (qspi->clk); + qspi->pdev = pdev; qspi->trans_pos.trans =NULL ; qspi->trans_pos.byte =0 ;
@@ -1335,13 +1340,6 @@ int bcm_qspi_probe(struct platform_devic qspi->soc_intc =NULL ; } - qspi->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (qspi->clk)) { -dev_warn (dev,"unable to get clock\n" ); - ret =PTR_ERR (qspi->clk); - goto qspi_probe_err; - } - ret =clk_prepare_enable (qspi->clk);if (ret) {dev_err (dev,"failed to prepare clock\n" );
Greg Kroah-Hartman
maintainerPATCH 92/161 spi: bcm-qspi: when tx/rx buffer is NULL set to 0
In reply to Greg Kroah-HartmanFrom: Justin Chen <[email protected]>
commit 4df3bea7f9d2ddd9ac2c29ba945c7c4db2def29c upstream.
Currently we set the tx/rx buffer to 0xff when NULL. This causes problems with some spi slaves where 0xff is a valid command. Looking at other drivers, the tx/rx buffer is usually set to 0x00 when NULL. Following this convention solves the issue.
--- drivers/spi/spi-bcm-qspi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-bcm-qspi.c +4 -4
@@ -670,7 +670,7 @@ static void read_from_hw(struct bcm_qspiif (buf) buf[tp.byte] =read_rxram_slot_u8 (qspi, slot);dev_dbg (&qspi->pdev->dev,"RD %02x\n" , - buf ? buf[tp.byte] :0xff ); + buf ? buf[tp.byte] :0x0 ); }else {u16 *buf = tp.trans->rx_buf;
@@ -678,7 +678,7 @@ static void read_from_hw(struct bcm_qspi buf[tp.byte /2 ] =read_rxram_slot_u16 (qspi, slot);dev_dbg (&qspi->pdev->dev,"RD %04x\n" , - buf ? buf[tp.byte] :0xffff ); + buf ? buf[tp.byte /2 ] :0x0 ); } update_qspi_trans_byte_count(qspi, &tp,
@@ -733,13 +733,13 @@ static int write_to_hw(struct bcm_qspi *while (!tstatus && slot <MSPI_NUM_CDRAM ) {if (tp.trans->bits_per_word <=8 ) {const u8 *buf = tp.trans->tx_buf; -u8 val = buf ? buf[tp.byte] :0xff ; +u8 val = buf ? buf[tp.byte] :0x00 ;write_txram_slot_u8 (qspi, slot, val);dev_dbg (&qspi->pdev->dev,"WR %02x\n" , val); }else {const u16 *buf = tp.trans->tx_buf; -u16 val = buf ? buf[tp.byte /2 ] :0xffff ; +u16 val = buf ? buf[tp.byte /2 ] :0x0000 ;write_txram_slot_u16 (qspi, slot, val);dev_dbg (&qspi->pdev->dev,"WR %04x\n" , val);
Greg Kroah-Hartman
maintainerPATCH 93/161 PM: runtime: clk: Fix clk_pm_runtime_get() error path
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 64c7d7ea22d86cacb65d0c097cc447bc0e6d8abd upstream.
clk_pm_runtime_get() assumes that the PM-runtime usage counter will be dropped by pm_runtime_get_sync() on errors, which is not the case, so PM-runtime references to devices acquired by the former are leaked on errors returned by the latter.
Fix this by modifying clk_pm_runtime_get() to drop the reference if pm_runtime_get_sync() returns an error.
--- drivers/clk/clk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/clk.c +5 -1
@@ -114,7 +114,11 @@ static int clk_pm_runtime_get(struct clkreturn 0 ; ret =pm_runtime_get_sync (core->dev); -return ret <0 ? ret :0 ; +if (ret <0 ) { +pm_runtime_put_noidle (core->dev); +return ret; + } +return 0 ; }static void clk_pm_runtime_put (struct clk_core *core)
Greg Kroah-Hartman
maintainerPATCH 94/161 gup: document and work around "COW can break either way" issue
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 17839856fd588f4ab6b789f482ed3ffd7c403e1f upstream.
Doing a "get_user_pages()" on a copy-on-write page for reading can be
ambiguous: the page can be COW'ed at any time afterwards, and the direction of a COW event isn't defined.
Yes, whoever writes to it will generally do the COW, but if the thread that did the get_user_pages() unmapped the page before the write (and that could happen due to memory pressure in addition to any outright action), the writer could also just take over the old page instead.
End result: the get_user_pages() call might result in a page pointer that is no longer associated with the original VM, and is associated with - and controlled by - another VM having taken it over instead.
So when doing a get_user_pages() on a COW mapping, the only really safe thing to do would be to break the COW when getting the page, even when only getting it for reading.
At the same time, some users simply don't even care.
For example, the perf code wants to look up the page not because it cares about the page, but because the code simply wants to look up the physical address of the access for informational purposes, and doesn't really care about races when a page might be unmapped and remapped elsewhere.
This adds logic to force a COW event by setting FOLL_WRITE on any copy-on-write mapping when FOLL_GET (or FOLL_PIN) is used to get a page pointer as a result.
The current semantics end up being:
- __get_user_pages_fast(): no change. If you don't ask for a write, you won't break COW. You'd better know what you're doing.
- get_user_pages_fast(): the fast-case "look it up in the page tables without anything getting mmap_sem" now refuses to follow a read-only page, since it might need COW breaking. Which happens in the slow path - the fast path doesn't know if the memory might be COW or not.
- get_user_pages() (including the slow-path fallback for gup_fast()):
for a COW mapping, turn on FOLL_WRITE for FOLL_GET/FOLL_PIN, with very similar semantics to FOLL_FORCE.
If it turns out that we want finer granularity (ie "only break COW when it might actually matter" - things like the zero page are special and don't need to be broken) we might need to push these semantics deeper into the lookup fault path. So if people care enough, it's possible that we might end up adding a new internal FOLL_BREAK_COW flag to go with the internal FOLL_COW flag we already have for tracking "I had a COW".
Alternatively, if it turns out that different callers might want to explicitly control the forced COW break behavior, we might even want to make such a flag visible to the users of get_user_pages() instead of using the above default semantics.
But for now, this is mostly commentary on the issue (this commit message being a lot bigger than the patch, and that patch in turn is almost all comments), with that minimal "enable COW breaking early" logic using the existing FOLL_WRITE behavior.
[ It might be worth noting that we've always had this ambiguity, and it
could arguably be seen as a user-space issue.
You only get private COW mappings that could break either way in situations where user space is doing cooperative things (ie fork() before an execve() etc), but it _is_ surprising and very subtle, and fork() is supposed to give you independent address spaces.
So let's treat this as a kernel issue and make the semantics of get_user_pages() easier to understand. Note that obviously a true shared mapping will still get a page that can change under us, so this does _not_ mean that get_user_pages() somehow returns any "stable" page ]
--- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 +++++ mm/gup.c | 44 ++++++++++++++++++++++++---- mm/huge_memory.c | 7 +--- 3 files changed, 49 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +8 -0
@@ -600,6 +600,14 @@ static int i915_gem_userptr_get_pages(stGFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); +/* +* Using __get_user_pages_fast() with a read-only +* access is questionable. A read-only page may be +* COW-broken, and then this might end up giving +* the wrong side of the COW.. +* +* We may or may not care. +*/ if (pvec)/* defer to worker if malloc fails */ pinned = __get_user_pages_fast(obj->userptr.ptr, num_pages,
mm/gup.c +38 -6
85 lines not on this page · raw message
mm/huge_memory.c +3 -4
@@ -1465,13 +1465,12 @@ out_unlock: }/* -* FOLL_FORCE can write to even unwritable pmd's, but only -* after we've gone through a COW cycle and they are dirty. +* FOLL_FORCE or a forced COW break can write even to unwritable pmd's, +* but only after we've gone through a COW cycle and they are dirty. */ static inline bool can_follow_write_pmd (pmd_t pmd,unsigned int flags) { -return pmd_write (pmd) || - ((flags &FOLL_FORCE ) && (flags &FOLL_COW ) &&pmd_dirty (pmd)); +return pmd_write (pmd) || ((flags &FOLL_COW ) &&pmd_dirty (pmd)); } struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
Greg Kroah-Hartman
maintainerPATCH 95/161 crypto: cavium/nitrox - Fix nitrox_get_first_device() when ndevlist is fully iterated
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 320bdbd816156f9ca07e5fed7bfb449f2908dda7 upstream.
When a list is completely iterated with 'list_for_each_entry(x, ...)', x is not NULL at the end.
While at it, remove a useless initialization of the ndev variable. It is overridden by 'list_for_each_entry'.
--- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/cavium/nitrox/nitrox_main.c +2 -2
@@ -278,7 +278,7 @@ static void nitrox_remove_from_devlist(sstruct nitrox_device *nitrox_get_first_device (void ) { -struct nitrox_device *ndev =NULL ; +struct nitrox_device *ndev;mutex_lock (&devlist_lock);list_for_each_entry (ndev, &ndevlist, list) {
@@ -286,7 +286,7 @@ struct nitrox_device *nitrox_get_first_dbreak ; }mutex_unlock (&devlist_lock); -if (!ndev) +if (&ndev->list == &ndevlist)return NULL ;refcount_inc (&ndev->refcnt);
Greg Kroah-Hartman
maintainerPATCH 96/161 crypto: algapi - Avoid spurious modprobe on LOADED
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit beeb460cd12ac9b91640b484b6a52dcba9d9fc8f upstream.
Currently after any algorithm is registered and tested, there's an unnecessary request_module("cryptomgr") even if it's already loaded. Also, CRYPTO_MSG_ALG_LOADED is sent twice, and thus if the algorithm is "crct10dif", lib/crc-t10dif.c replaces the tfm twice rather than once.
This occurs because CRYPTO_MSG_ALG_LOADED is sent using crypto_probing_notify(), which tries to load "cryptomgr" if the notification is not handled (NOTIFY_DONE). This doesn't make sense because "cryptomgr" doesn't handle this notification.
Fix this by using crypto_notify() instead of crypto_probing_notify().
--- crypto/algapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/algapi.c +1 -1
@@ -403,7 +403,7 @@ static void crypto_wait_for_test(struct err =wait_for_completion_killable (&larval->completion);WARN_ON (err);if (!err) -crypto_probing_notify (CRYPTO_MSG_ALG_LOADED , larval); +crypto_notify (CRYPTO_MSG_ALG_LOADED , larval); out:crypto_larval_kill (&larval->alg);
Greg Kroah-Hartman
maintainerPATCH 97/161 crypto: drbg - fix error return code in drbg_alloc_state()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
commit e0664ebcea6ac5e16da703409fb4bd61f8cd37d9 upstream.
Fix to return negative error code -ENOMEM from the kzalloc error handling case instead of 0, as done elsewhere in this function.
--- crypto/drbg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/drbg.c +3 -1
@@ -1294,8 +1294,10 @@ static inline int drbg_alloc_state(strucif (IS_ENABLED (CONFIG_CRYPTO_FIPS )) { drbg->prev =kzalloc (drbg_sec_strength (drbg->core->flags),GFP_KERNEL ); -if (!drbg->prev) +if (!drbg->prev) { + ret = -ENOMEM ; goto fini; + } drbg->fips_primed = false; }
Greg Kroah-Hartman
maintainerPATCH 98/161 crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
In reply to Greg Kroah-HartmanFrom: Longpeng(Mike) <[email protected]>
commit d90ca42012db2863a9a30b564a2ace6016594bda upstream.
The src/dst length is not aligned with AES_BLOCK_SIZE(which is 16) in some testcases in tcrypto.ko.
For example, the src/dst length of one of cts(cbc(aes))'s testcase is 17, the crypto_virtio driver will set @src_data_len=16 but @dst_data_len=17 in this case and get a wrong at then end.
SRC: pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp (17 bytes)
EXP: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc pp (17 bytes)
DST: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00 (pollute the last bytes) (pp: plaintext cc:ciphertext)
Fix this issue by limit the length of dest buffer.
--- drivers/crypto/virtio/virtio_crypto_algs.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/virtio/virtio_crypto_algs.c +1 -0
@@ -402,6 +402,7 @@ __virtio_crypto_skcipher_do_req(struct v goto free; } + dst_len = min_t(unsigned int, req->cryptlen, dst_len);pr_debug ("virtio_crypto: src_len: %u, dst_len: %llu\n" , req->cryptlen, dst_len);
Greg Kroah-Hartman
maintainerPATCH 99/161 crypto: virtio: Fix use-after-free in virtio_crypto_skcipher_finalize_req()
In reply to Greg Kroah-HartmanFrom: Longpeng(Mike) <[email protected]>
commit 8c855f0720ff006d75d0a2512c7f6c4f60ff60ee upstream.
The system'll crash when the users insmod crypto/tcrypto.ko with mode=155 ( testing "authenc(hmac(sha1),cbc(aes))" ). It's caused by reuse the memory of request structure.
In crypto_authenc_init_tfm(), the reqsize is set to:
[PART 1] sizeof(authenc_request_ctx) +
[PART 2] ictx->reqoff +
[PART 3] MAX(ahash part, skcipher part)
and the 'PART 3' is used by both ahash and skcipher in turn.
When the virtio_crypto driver finish skcipher req, it'll call ->complete callback(in crypto_finalize_skcipher_request) and then free its resources whose pointers are recorded in 'skcipher parts'.
However, the ->complete is 'crypto_authenc_encrypt_done' in this case, it will use the 'ahash part' of the request and change its content, so virtio_crypto driver will get the wrong pointer after ->complete finish and mistakenly free some other's memory. So the system will crash when these memory will be used again.
The resources which need to be cleaned up are not used any more. But the pointers of these resources may be changed in the function "crypto_finalize_skcipher_request". Thus release specific resources before calling this function.
--- drivers/crypto/virtio/virtio_crypto_algs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/virtio/virtio_crypto_algs.c +3 -2
@@ -578,10 +578,11 @@ static void virtio_crypto_skcipher_finalscatterwalk_map_and_copy (req->iv, req->dst, req->cryptlen -AES_BLOCK_SIZE ,AES_BLOCK_SIZE ,0 ); -crypto_finalize_skcipher_request (vc_sym_req->base.dataq->engine, - req, err);kzfree (vc_sym_req->iv);virtcrypto_clear_request (&vc_sym_req->base); + +crypto_finalize_skcipher_request (vc_sym_req->base.dataq->engine, + req, err); }static struct virtio_crypto_algo virtio_crypto_algs[] = { {
Greg Kroah-Hartman
maintainerPATCH 100/161 crypto: virtio: Fix src/dst scatterlist calculation in __virtio_crypto_skcipher_do_req()
In reply to Greg Kroah-HartmanFrom: Longpeng(Mike) <[email protected]>
commit b02989f37fc5e865ceeee9070907e4493b3a21e2 upstream.
The system will crash when the users insmod crypto/tcrypt.ko with mode=38 ( testing "cts(cbc(aes))" ).
Usually the next entry of one sg will be @sg@ + 1, but if this sg element is part of a chained scatterlist, it could jump to the start of a new scatterlist array. Fix it by sg_next() on calculation of src/dst scatterlist.
--- drivers/crypto/virtio/virtio_crypto_algs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/crypto/virtio/virtio_crypto_algs.c +10 -5
@@ -350,13 +350,18 @@ __virtio_crypto_skcipher_do_req(struct vint err;unsigned long flags;struct scatterlist outhdr, iv_sg, status_sg, **sgs; -int i;u64 dst_len;unsigned int num_out =0 , num_in =0 ;int sg_total;uint8_t *iv; +struct scatterlist *sg; src_nents =sg_nents_for_len (req->src, req->cryptlen); +if (src_nents <0 ) { +pr_err ("Invalid number of src SG.\n" ); +return src_nents; + } + dst_nents =sg_nents (req->dst); pr_debug("virtio_crypto: Number of sgs (src_nents: %d, dst_nents: %d)\n",
@@ -443,12 +448,12 @@ __virtio_crypto_skcipher_do_req(struct v vc_sym_req->iv = iv;/* Source data */ -for (i =0 ; i < src_nents; i++) - sgs[num_out++] = &req->src[i]; +for (sg = req->src; src_nents; sg =sg_next (sg), src_nents--) + sgs[num_out++] = sg;/* Destination data */ -for (i =0 ; i < dst_nents; i++) - sgs[num_out + num_in++] = &req->dst[i]; +for (sg = req->dst; sg; sg =sg_next (sg)) + sgs[num_out + num_in++] = sg;/* Status */ sg_init_one (&status_sg, &vc_req->status,sizeof (vc_req->status));
Greg Kroah-Hartman
maintainerPATCH 101/161 io_uring: fix mismatched finish_wait() calls in io_uring_cancel_files()
In reply to Greg Kroah-HartmanFrom: Xiaoguang Wang <[email protected]>
commit d8f1b9716cfd1a1f74c0fedad40c5f65a25aa208 upstream.
The prepare_to_wait() and finish_wait() calls in io_uring_cancel_files() are mismatched. Currently I don't see any issues related this bug, just find it by learning codes.
--- fs/io_uring.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/io_uring.c +4 -5
@@ -6488,11 +6488,9 @@ static int io_uring_release(struct inodestatic void io_uring_cancel_files (struct io_ring_ctx *ctx,struct files_struct *files) { -struct io_kiocb *req; -DEFINE_WAIT (wait); -while (!list_empty_careful (&ctx->inflight_list)) { -struct io_kiocb *cancel_req =NULL ; +struct io_kiocb *cancel_req =NULL , *req; +DEFINE_WAIT (wait);spin_lock_irq (&ctx->inflight_lock);list_for_each_entry (req, &ctx->inflight_list, inflight_entry) {
@@ -6532,6 +6530,7 @@ static void io_uring_cancel_files(struct*/ if (refcount_sub_and_test (2 , &cancel_req->refs)) {io_put_req (cancel_req); +finish_wait (&ctx->inflight_wait, &wait);continue ; } }
@@ -6539,8 +6538,8 @@ static void io_uring_cancel_files(structio_wq_cancel_work (ctx->io_wq, &cancel_req->work);io_put_req (cancel_req);schedule (); +finish_wait (&ctx->inflight_wait, &wait); } -finish_wait (&ctx->inflight_wait, &wait); }static int io_uring_flush (struct file *file,void *data)
Greg Kroah-Hartman
maintainerPATCH 102/161 io_uring: fix flush req->refs underflow
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 4518a3cc273cf82efdd36522fb1f13baad173c70 upstream.
In io_uring_cancel_files(), after refcount_sub_and_test() leaves 0 req->refs, it calls io_put_req(), which would also put a ref. Call io_free_req() instead.
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -6529,7 +6529,7 @@ static void io_uring_cancel_files(struct* all we had, then we're done with this request. */ if (refcount_sub_and_test (2 , &cancel_req->refs)) { -io_put_req (cancel_req); +io_free_req (cancel_req);finish_wait (&ctx->inflight_wait, &wait);continue ; }
Greg Kroah-Hartman
maintainerPATCH 103/161 x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned
In reply to Greg Kroah-HartmanFrom: Tony Luck <[email protected]>
commit 17fae1294ad9d711b2c3dd0edef479d40c76a5e8 upstream.
An interesting thing happened when a guest Linux instance took a machine check. The VMM unmapped the bad page from guest physical space and passed the machine check to the guest.
Linux took all the normal actions to offline the page from the process that was using it. But then guest Linux crashed because it said there was a second machine check inside the kernel with this stack trace:
do_memory_failure
set_mce_nospec
set_memory_uc
_set_memory_uc
change_page_attr_set_clr
cpa_flush
clflush_cache_range_opt
This was odd, because a CLFLUSH instruction shouldn't raise a machine check (it isn't consuming the data). Further investigation showed that the VMM had passed in another machine check because is appeared that the guest was accessing the bad page.
Fix is to check the scope of the poison by checking the MCi_MISC register. If the entire page is affected, then unmap the page. If only part of the page is affected, then mark the page as uncacheable.
This assumes that VMMs will do the logical thing and pass in the "whole page scope" via the MCi_MISC register (since they unmapped the entire page).
[ bp: Adjust to x86/entry changes. ]
--- arch/x86/include/asm/set_memory.h | 19 +++++++++++++------ arch/x86/kernel/cpu/mce/core.c | 11 +++++++++-- include/linux/set_memory.h | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-)
arch/x86/include/asm/set_memory.h +13 -6
@@ -83,28 +83,35 @@ int set_direct_map_default_noflush(strucextern int kernel_set_to_readonly;#ifdef CONFIG_X86_64 -static inline int set_mce_nospec (unsigned long pfn) +/* +* Prevent speculative access to the page by either unmapping +* it (if we do not require access to any part of the page) or +* marking it uncacheable (if we want to try to retrieve data +* from non-poisoned lines in the page). +*/ +static inline int set_mce_nospec (unsigned long pfn,bool unmap) {unsigned long decoy_addr;int rc;/* -* Mark the linear address as UC to make sure we don't log more -* errors because of speculative access to the page. * We would like to just call: -* set_memory_uc((unsigned long)pfn_to_kaddr(pfn), 1); +* set_memory_XX((unsigned long)pfn_to_kaddr(pfn), 1); * but doing that would radically increase the odds of a * speculative access to the poison page because we'd have * the virtual address of the kernel 1:1 mapping sitting * around in registers. * Instead we get tricky. We create a non-canonical address * that looks just like the one we want, but has bit 63 flipped. -* This relies on set_memory_uc() properly sanitizing any __pa() +* This relies on set_memory_XX() properly sanitizing any __pa() * results with __PHYSICAL_MASK or PTE_PFN_MASK. */ decoy_addr = (pfn <<PAGE_SHIFT ) + (PAGE_OFFSET ^BIT (63 )); - rc =set_memory_uc (decoy_addr,1 ); +if (unmap) + rc =set_memory_np (decoy_addr,1 ); +else + rc =set_memory_uc (decoy_addr,1 );if (rc)pr_warn ("Could not invalidate pfn=0x%lx from 1:1 map\n" , pfn);return rc;
arch/x86/kernel/cpu/mce/core.c +9 -2
@@ -527,6 +527,13 @@ bool mce_is_memory_error(struct mce *m) }EXPORT_SYMBOL_GPL (mce_is_memory_error); +static bool whole_page (struct mce *m) +{ +if (!mca_cfg.ser || !(m->status &MCI_STATUS_MISCV )) +return true; +return MCI_MISC_ADDR_LSB (m->misc) >=PAGE_SHIFT ; +} +bool mce_is_correctable (struct mce *m) {if (m->cpuvendor ==X86_VENDOR_AMD && m->status &MCI_STATUS_DEFERRED )
@@ -598,7 +605,7 @@ static int uc_decode_notifier(struct not pfn = mce->addr >>PAGE_SHIFT ;if (!memory_failure (pfn,0 )) -set_mce_nospec (pfn); +set_mce_nospec (pfn,whole_page (mce));return NOTIFY_OK ; }
@@ -1096,7 +1103,7 @@ static int do_memory_failure(struct mceif (ret)pr_err ("Memory error not recovered" );else -set_mce_nospec (m->addr >>PAGE_SHIFT ); +set_mce_nospec (m->addr >>PAGE_SHIFT ,whole_page (m));return ret; }
include/linux/set_memory.h +1 -1
@@ -26,7 +26,7 @@ static inline int set_direct_map_default#endif #ifndef set_mce_nospec -static inline int set_mce_nospec (unsigned long pfn) +static inline int set_mce_nospec (unsigned long pfn,bool unmap) {return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 104/161 firmware: imx-scu: Support one TX and one RX
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit f25a066d1a07affb7bea4e5d9c179c3338338e23 ]
Current imx-scu requires four TX and four RX to communicate with SCU. This is low efficient and causes lots of mailbox interrupts.
With imx-mailbox driver could support one TX to use all four transmit registers and one RX to use all four receive registers, imx-scu could use one TX and one RX.
--- drivers/firmware/imx/imx-scu.c | 54 +++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 11 deletions(-)
drivers/firmware/imx/imx-scu.c +43 -11
@@ -38,6 +38,7 @@ struct imx_sc_ipc {struct device *dev;struct mutex lock;struct completion done; +bool fast_ipc;/* temporarily store the SCU msg */ u32 *msg;
@@ -115,6 +116,7 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg)struct imx_sc_ipc *sc_ipc = sc_chan->sc_ipc;struct imx_sc_rpc_msg *hdr;u32 *data = msg; +int i;if (!sc_ipc->msg) { dev_warn(sc_ipc->dev, "unexpected rx idx %d 0x%08x, ignore!\n",
@@ -122,6 +124,19 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg)return ; } +if (sc_ipc->fast_ipc) { + hdr = msg; + sc_ipc->rx_size = hdr->size; + sc_ipc->msg[0 ] = *data++; + +for (i =1 ; i < sc_ipc->rx_size; i++) + sc_ipc->msg[i] = *data++; + +complete (&sc_ipc->done); + +return ; + } +if (sc_chan->idx ==0 ) { hdr = msg; sc_ipc->rx_size = hdr->size;
@@ -147,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)struct imx_sc_chan *sc_chan;u32 *data = msg;int ret; +int size;int i;/* Check size */
@@ -156,7 +172,8 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)dev_dbg (sc_ipc->dev,"RPC SVC %u FUNC %u SIZE %u\n" , hdr->svc, hdr->func, hdr->size); -for (i =0 ; i < hdr->size; i++) { + size = sc_ipc->fast_ipc ?1 : hdr->size; +for (i =0 ; i < size; i++) { sc_chan = &sc_ipc->chans[i %4 ];/*
@@ -168,8 +185,10 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)* Wait for tx_done before every send to ensure that no * queueing happens at the mailbox channel level. */ -wait_for_completion (&sc_chan->tx_done); -reinit_completion (&sc_chan->tx_done); +if (!sc_ipc->fast_ipc) { +wait_for_completion (&sc_chan->tx_done); +reinit_completion (&sc_chan->tx_done); + } ret =mbox_send_message (sc_chan->ch, &data[i]);if (ret <0 )
@@ -246,6 +265,8 @@ static int imx_scu_probe(struct platform_device *pdev)struct imx_sc_chan *sc_chan;struct mbox_client *cl;char *chan_name; +struct of_phandle_args args; +int num_channel;int ret;int i;
@@ -253,11 +274,20 @@ static int imx_scu_probe(struct platform_device *pdev)if (!sc_ipc)return -ENOMEM ; -for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { -if (i <4 ) + ret =of_parse_phandle_with_args (pdev->dev.of_node,"mboxes" , +"#mbox-cells" ,0 , &args); +if (ret) +return ret; + + sc_ipc->fast_ipc =of_device_is_compatible (args.np,"fsl,imx8-mu-scu" ); + + num_channel = sc_ipc->fast_ipc ?2 :SCU_MU_CHAN_NUM ; +for (i =0 ; i < num_channel; i++) { +if (i < num_channel /2 ) chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i);else - chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , + i - num_channel /2 );if (!chan_name)return -ENOMEM ;
@@ -269,13 +299,15 @@ static int imx_scu_probe(struct platform_device *pdev) cl->knows_txdone = true; cl->rx_callback = imx_scu_rx_callback; -/* Initial tx_done completion as "done" */ - cl->tx_done = imx_scu_tx_done; -init_completion (&sc_chan->tx_done); -complete (&sc_chan->tx_done); +if (!sc_ipc->fast_ipc) { +/* Initial tx_done completion as "done" */ + cl->tx_done = imx_scu_tx_done; +init_completion (&sc_chan->tx_done); +complete (&sc_chan->tx_done); + } sc_chan->sc_ipc = sc_ipc; - sc_chan->idx = i %4 ; + sc_chan->idx = i % (num_channel /2 ); sc_chan->ch =mbox_request_channel_byname (cl, chan_name);if (IS_ERR (sc_chan->ch)) { ret =PTR_ERR (sc_chan->ch);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 105/161 firmware: imx: scu: Fix corruption of header
In reply to Greg Kroah-HartmanFrom: Franck LENORMAND <[email protected]>
[ Upstream commit f5f27b79eab80de0287c243a22169e4876b08d5e ]
The header of the message to send can be changed if the response is longer than the request:
- 1st word, the header is sent
- the remaining words of the message are sent
- the response is received asynchronously during the execution of the loop, changing the size field in the header
- the for loop test the termination condition using the corrupted header
It is the case for the API build_info which has just a header as request but 3 words in response.
This issue is fixed storing the header locally instead of using a pointer on it.
--- drivers/firmware/imx/imx-scu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/firmware/imx/imx-scu.c +5 -5
@@ -158,7 +158,7 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg)static int imx_scu_ipc_write (struct imx_sc_ipc *sc_ipc,void *msg) { -struct imx_sc_rpc_msg *hdr = msg; +struct imx_sc_rpc_msg hdr = *(struct imx_sc_rpc_msg *)msg;struct imx_sc_chan *sc_chan;u32 *data = msg;int ret;
@@ -166,13 +166,13 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)int i;/* Check size */ -if (hdr->size >IMX_SC_RPC_MAX_MSG ) +if (hdr.size >IMX_SC_RPC_MAX_MSG )return -EINVAL ; -dev_dbg (sc_ipc->dev,"RPC SVC %u FUNC %u SIZE %u\n" , hdr->svc, - hdr->func, hdr->size); +dev_dbg (sc_ipc->dev,"RPC SVC %u FUNC %u SIZE %u\n" , hdr.svc, + hdr.func, hdr.size); - size = sc_ipc->fast_ipc ?1 : hdr->size; + size = sc_ipc->fast_ipc ?1 : hdr.size;for (i =0 ; i < size; i++) { sc_chan = &sc_ipc->chans[i %4 ];
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 106/161 dccp: Fix possible memleak in dccp_init and dccp_fini
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit c96b6acc8f89a4a7f6258dfe1d077654c11415be ]
There are some memory leaks in dccp_init() and dccp_fini().
In dccp_fini() and the error handling path in dccp_init(), free lhash2 is missing. Add inet_hashinfo2_free_mod() to do it.
If inet_hashinfo2_init_mod() failed in dccp_init(), percpu_counter_destroy() should be called to destroy dccp_orphan_count. It need to goto out_free_percpu when inet_hashinfo2_init_mod() failed.
--- include/net/inet_hashtables.h | 6 ++++++ net/dccp/proto.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
include/net/inet_hashtables.h +6 -0
@@ -185,6 +185,12 @@ static inline spinlock_t *inet_ehash_locint inet_ehash_locks_alloc (struct inet_hashinfo *hashinfo); +static inline void inet_hashinfo2_free_mod (struct inet_hashinfo *h) +{ +kfree (h->lhash2); + h->lhash2 =NULL ; +} +static inline void inet_ehash_locks_free (struct inet_hashinfo *hashinfo) {kvfree (hashinfo->ehash_locks);
net/dccp/proto.c +5 -2
@@ -1139,14 +1139,14 @@ static int __init dccp_init(void)inet_hashinfo_init (&dccp_hashinfo); rc =inet_hashinfo2_init_mod (&dccp_hashinfo);if (rc) - goto out_fail; + goto out_free_percpu; rc = -ENOBUFS ; dccp_hashinfo.bind_bucket_cachep =kmem_cache_create ("dccp_bind_bucket" ,sizeof (struct inet_bind_bucket ),0 ,SLAB_HWCACHE_ALIGN ,NULL );if (!dccp_hashinfo.bind_bucket_cachep) - goto out_free_percpu; + goto out_free_hashinfo2;/* * Size and allocate the main established and bind bucket
@@ -1242,6 +1242,8 @@ out_free_dccp_ehash:free_pages ((unsigned long )dccp_hashinfo.ehash, ehash_order); out_free_bind_bucket_cachep:kmem_cache_destroy (dccp_hashinfo.bind_bucket_cachep); +out_free_hashinfo2: +inet_hashinfo2_free_mod (&dccp_hashinfo); out_free_percpu:percpu_counter_destroy (&dccp_orphan_count); out_fail:
@@ -1265,6 +1267,7 @@ static void __exit dccp_fini(void)kmem_cache_destroy (dccp_hashinfo.bind_bucket_cachep);dccp_ackvec_exit ();dccp_sysctl_exit (); +inet_hashinfo2_free_mod (&dccp_hashinfo);percpu_counter_destroy (&dccp_orphan_count); }
Greg Kroah-Hartman
maintainerPATCH 107/161 net: mvneta: do not redirect frames during reconfiguration
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 62a502cc91f97e3ffd312d9b42e8d01a137c63ff ]
Disable frames injection in mvneta_xdp_xmit routine during hw re-configuration in order to avoid hardware hangs
--- drivers/net/ethernet/marvell/mvneta.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +13 -0
@@ -418,11 +418,17 @@ struct mvneta_pcpu_port {u32 cause_rx_tx; }; +enum { + __MVNETA_DOWN, +}; +struct mvneta_port {u8 id;struct mvneta_pcpu_port __percpu *ports;struct mvneta_pcpu_stats __percpu *stats; +unsigned long state; +int pkt_size;void __iomem *base;struct mvneta_rx_queue *rxqs;
@@ -2066,6 +2072,9 @@ mvneta_xdp_xmit(struct net_device *dev,int i, drops =0 ;u32 ret; +if (unlikely (test_bit (__MVNETA_DOWN, &pp->state))) +return -ENETDOWN ; +if (unlikely (flags & ~XDP_XMIT_FLAGS_MASK ))return -EINVAL ;
@@ -3489,12 +3498,16 @@ static void mvneta_start_dev(struct mvnephylink_start (pp->phylink);netif_tx_start_all_queues (pp->dev); + +clear_bit (__MVNETA_DOWN, &pp->state); }static void mvneta_stop_dev (struct mvneta_port *pp) {unsigned int cpu; +set_bit (__MVNETA_DOWN, &pp->state); +phylink_stop (pp->phylink);if (!pp->neta_armada3700) {
Greg Kroah-Hartman
maintainerPATCH 108/161 selftests/net: in rxtimestamp getopt_long needs terminating null entry
In reply to Greg Kroah-HartmanFrom: tannerlove <[email protected]>
[ Upstream commit 865a6cbb2288f8af7f9dc3b153c61b7014fdcf1e ]
getopt_long requires the last element to be filled with zeros. Otherwise, passing an unrecognized option can cause a segfault.
--- tools/testing/selftests/networking/timestamping/rxtimestamp.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/networking/timestamping/rxtimestamp.c +1 -0
@@ -115,6 +115,7 @@ static struct option long_options[] = { { "tcp", no_argument, 0, 't' }, { "udp", no_argument, 0, 'u' }, { "ip", no_argument, 0, 'i' }, + { NULL, 0, NULL, 0 }, };static int next_port =19999 ;
Greg Kroah-Hartman
maintainerPATCH 109/161 net/mlx5: drain health workqueue in case of driver load error
In reply to Greg Kroah-HartmanFrom: Shay Drory <[email protected]>
[ Upstream commit 42ea9f1b5c625fad225d4ac96a7e757dd4199d9c ]
In case there is a work in the health WQ when we teardown the driver, in driver load error flow, the health work will try to read dev->iseg, which was already unmap in mlx5_pci_close().
Fix it by draining the health workqueue first thing in mlx5_pci_close().
Trace of the error:
BUG: unable to handle page fault for address: ffffb5b141c18014 PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 1fe95d067 P4D 1fe95d067 PUD 1fe95e067 PMD 1b7823067 PTE 0 Oops: 0000 [#1] SMP PTI CPU: 3 PID: 6755 Comm: kworker/u128:2 Not tainted 5.2.0-net-next-mlx5-hv_stats-over-last-worked-hyperv #1 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090006 04/28/2016 Workqueue: mlx5_healtha050:00:02.0 mlx5_fw_fatal_reporter_err_work [mlx5_core] RIP: 0010:ioread32be+0x30/0x40 Code: 00 77 27 48 81 ff 00 00 01 00 76 07 0f b7 d7 ed 0f c8 c3 55 48 c7 c6 3b ee d5 9f 48 89 e5 e8 67 fc ff ff b8 ff ff ff ff 5d c3 <8b> 07 0f c8 c3 66 66 2e 0f 1f 84 00 00 00 00 00 48 81 fe ff ff 03 RSP: 0018:ffffb5b14c56fd78 EFLAGS: 00010292 RAX: ffffb5b141c18000 RBX: ffff8e9f78a801c0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8e9f7ecd7628 RDI: ffffb5b141c18014 RBP: ffffb5b14c56fd90 R08: 0000000000000001 R09: 0000000000000000 R10: ffff8e9f372a2c30 R11: ffff8e9f87f4bc40 R12: ffff8e9f372a1fc0 R13: ffff8e9f78a80000 R14: ffffffffc07136a0 R15: ffff8e9f78ae6f20 FS: 0000000000000000(0000) GS:ffff8e9f7ecc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffb5b141c18014 CR3: 00000001c8f82006 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? mlx5_health_try_recover+0x4d/0x270 [mlx5_core] mlx5_fw_fatal_reporter_recover+0x16/0x20 [mlx5_core] devlink_health_reporter_recover+0x1c/0x50 devlink_health_report+0xfb/0x240 mlx5_fw_fatal_reporter_err_work+0x65/0xd0 [mlx5_core] process_one_work+0x1fb/0x4e0 ? process_one_work+0x16b/0x4e0 worker_thread+0x4f/0x3d0 kthread+0x10d/0x140 ? process_one_work+0x4e0/0x4e0 ? kthread_cancel_delayed_work_sync+0x20/0x20 ret_from_fork+0x1f/0x30 Modules linked in: nfsv3 rpcsec_gss_krb5 nfsv4 nfs fscache 8021q garp mrp stp llc ipmi_devintf ipmi_msghandler rpcrdma rdma_ucm ib_iser rdma_cm ib_umad iw_cm ib_ipoib libiscsi scsi_transport_iscsi ib_cm mlx5_ib ib_uverbs ib_core mlx5_core sb_edac crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 mlxfw crypto_simd cryptd glue_helper input_leds hyperv_fb intel_rapl_perf joydev serio_raw pci_hyperv pci_hyperv_mini mac_hid hv_balloon nfsd auth_rpcgss nfs_acl lockd grace sunrpc sch_fq_codel ip_tables x_tables autofs4 hv_utils hid_generic hv_storvsc ptp hid_hyperv hid hv_netvsc hyperv_keyboard pps_core scsi_transport_fc psmouse hv_vmbus i2c_piix4 floppy pata_acpi CR2: ffffb5b141c18014 ---[ end trace b12c5503157cad24 ]--- RIP: 0010:ioread32be+0x30/0x40 Code: 00 77 27 48 81 ff 00 00 01 00 76 07 0f b7 d7 ed 0f c8 c3 55 48 c7 c6 3b ee d5 9f 48 89 e5 e8 67 fc ff ff b8 ff ff ff ff 5d c3 <8b> 07 0f c8 c3 66 66 2e 0f 1f 84 00 00 00 00 00 48 81 fe ff ff 03 RSP: 0018:ffffb5b14c56fd78 EFLAGS: 00010292 RAX: ffffb5b141c18000 RBX: ffff8e9f78a801c0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8e9f7ecd7628 RDI: ffffb5b141c18014 RBP: ffffb5b14c56fd90 R08: 0000000000000001 R09: 0000000000000000 R10: ffff8e9f372a2c30 R11: ffff8e9f87f4bc40 R12: ffff8e9f372a1fc0 R13: ffff8e9f78a80000 R14: ffffffffc07136a0 R15: ffff8e9f78ae6f20 FS: 0000000000000000(0000) GS:ffff8e9f7ecc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffb5b141c18014 CR3: 00000001c8f82006 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 BUG: sleeping function called from invalid context at ./include/linux/percpu-rwsem.h:38 in_atomic(): 0, irqs_disabled(): 1, pid: 6755, name: kworker/u128:2 INFO: lockdep is turned off. CPU: 3 PID: 6755 Comm: kworker/u128:2 Tainted: G D 5.2.0-net-next-mlx5-hv_stats-over-last-worked-hyperv #1 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090006 04/28/2016 Workqueue: mlx5_healtha050:00:02.0 mlx5_fw_fatal_reporter_err_work [mlx5_core] Call Trace: dump_stack+0x63/0x88 ___might_sleep+0x10a/0x130 __might_sleep+0x4a/0x80 exit_signals+0x33/0x230 ? blocking_notifier_call_chain+0x16/0x20 do_exit+0xb1/0xc30 ? kthread+0x10d/0x140 ? process_one_work+0x4e0/0x4e0
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/main.c +5 -0
@@ -794,6 +794,11 @@ err_disable:static void mlx5_pci_close (struct mlx5_core_dev *dev) { +/* health work might still be active, and it needs pci bar in +* order to know the NIC state. Therefore, drain the health WQ +* before removing the pci bars +*/ +mlx5_drain_health_wq (dev);iounmap (dev->iseg);pci_clear_master (dev->pdev);release_bar (dev->pdev);
Greg Kroah-Hartman
maintainerPATCH 110/161 net/mlx5: Fix fatal error handling during device load
In reply to Greg Kroah-HartmanFrom: Shay Drory <[email protected]>
[ Upstream commit b6e0b6bebe0732d5cac51f0791f269d2413b8980 ]
Currently, in case of fatal error during mlx5_load_one(), we cannot enter error state until mlx5_load_one() is finished, what can take several minutes until commands will get timeouts, because these commands can't be processed due to the fatal error.
Fix it by setting dev->state as MLX5_DEVICE_STATE_INTERNAL_ERROR before requesting the lock.
--- drivers/net/ethernet/mellanox/mlx5/core/health.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/health.c +11 -3
@@ -193,15 +193,23 @@ static bool reset_fw_if_needed(struct mlvoid mlx5_enter_error_state (struct mlx5_core_dev *dev,bool force) { +bool err_detected = false; + +/* Mark the device as fatal in order to abort FW commands */ +if ((check_fatal_sensors (dev) || force) && + dev->state ==MLX5_DEVICE_STATE_UP ) { + dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ; + err_detected = true; + }mutex_lock (&dev->intf_state_mutex); -if (dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR ) - goto unlock; +if (!err_detected && dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR ) + goto unlock;/* a previous error is still being handled */ if (dev->state ==MLX5_DEVICE_STATE_UNINITIALIZED ) { dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ; goto unlock; } -if (check_fatal_sensors (dev) || force) { +if (check_fatal_sensors (dev) || force) {/* protected state setting */ dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ;mlx5_cmd_flush (dev); }
Greg Kroah-Hartman
maintainerPATCH 111/161 net/mlx5e: Fix repeated XSK usage on one channel
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 36d45fb9d2fdf348d778bfe73f0427db1c6f9bc7 ]
After an XSK is closed, the relevant structures in the channel are not zeroed. If an XSK is opened the second time on the same channel without recreating channels, the stray values in the structures will lead to incorrect operation of queues, which causes CQE errors, and the new socket doesn't work at all.
This patch fixes the issue by explicitly zeroing XSK-related structs in the channel on XSK close. Note that those structs are zeroed on channel creation, and usually a configuration change (XDP program is set) happens on XSK open, which leads to recreating channels, so typical XSK usecases don't suffer from this issue. However, if XSKs are opened and closed on the same channel without removing the XDP program, this bug reproduces.
--- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +4 -0
@@ -152,6 +152,10 @@ void mlx5e_close_xsk(struct mlx5e_channemlx5e_close_cq (&c->xskicosq.cq);mlx5e_close_xdpsq (&c->xsksq);mlx5e_close_cq (&c->xsksq.cq); + +memset (&c->xskrq,0 ,sizeof (c->xskrq)); +memset (&c->xsksq,0 ,sizeof (c->xsksq)); +memset (&c->xskicosq,0 ,sizeof (c->xskicosq)); }void mlx5e_activate_xsk (struct mlx5e_channel *c)
Greg Kroah-Hartman
maintainerPATCH 112/161 net: cadence: macb: disable NAPI on error
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 014406babc1f5f887a08737566b5b356c7018242 ]
When the PHY is not working, the macb driver crash on a second try to setup it.
[ 78.545994] macb e000b000.ethernet eth0: Could not attach PHY (-19) ifconfig: SIOCSIFFLAGS: No such device [ 78.655457] ------------[ cut here ]------------ [ 78.656014] kernel BUG at /linux-next/include/linux/netdevice.h:521! [ 78.656504] Internal error: Oops - BUG: 0 [#1] SMP ARM [ 78.657079] Modules linked in: [ 78.657795] CPU: 0 PID: 122 Comm: ifconfig Not tainted 5.7.0-next-20200609 #1 [ 78.658202] Hardware name: Xilinx Zynq Platform [ 78.659632] PC is at macb_open+0x220/0x294 [ 78.660160] LR is at 0x0 [ 78.660373] pc : [<c0b0a634>] lr : [<00000000>] psr: 60000013 [ 78.660716] sp : c89ffd70 ip : c8a28800 fp : c199bac0 [ 78.661040] r10: 00000000 r9 : c8838540 r8 : c8838568 [ 78.661362] r7 : 00000001 r6 : c8838000 r5 : c883c000 r4 : 00000000 [ 78.661724] r3 : 00000010 r2 : 00000000 r1 : 00000000 r0 : 00000000 [ 78.662187] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 78.662635] Control: 10c5387d Table: 08b64059 DAC: 00000051 [ 78.663035] Process ifconfig (pid: 122, stack limit = 0x(ptrval)) [ 78.663476] Stack: (0xc89ffd70 to 0xc8a00000) [ 78.664121] fd60: 00000000 c89fe000 c8838000 c89fe000 [ 78.664866] fd80: 00000000 c11ff9ac c8838028 00000000 00000000 c0de6f2c 00000001 c1804eec [ 78.665579] fda0: c19b8178 c8838000 00000000 ca760866 c8838000 00000001 00001043 c89fe000 [ 78.666355] fdc0: 00001002 c0de72f4 c89fe000 c0de8dc0 00008914 c89fe000 c199bac0 ca760866 [ 78.667111] fde0: c89ffddc c8838000 00001002 00000000 c8838138 c881010c 00008914 c0de7364 [ 78.667862] fe00: 00000000 c89ffe70 c89fe000 ffffffff c881010c c0e8bd48 00000003 00000000 [ 78.668601] fe20: c8838000 c8810100 39c1118f 00039c11 c89a0960 00001043 00000000 000a26d0 [ 78.669343] fe40: b6f43000 ca760866 c89a0960 00000051 befe6c50 00008914 c8b2a3c0 befe6c50 [ 78.670086] fe60: 00000003 ee610500 00000000 c0e8ef58 30687465 00000000 00000000 00000000 [ 78.670865] fe80: 00001043 00000000 000a26d0 b6f43000 c89a0600 ee40ae7c c8870d00 c0ddabf4 [ 78.671593] fea0: c89ffeec c0ddabf4 c89ffeec c199bac0 00008913 c0ddac48 c89ffeec c89fe000 [ 78.672324] fec0: befe6c50 ca760866 befe6c50 00008914 c89fe000 befe6c50 c8b2a3c0 c0dc00e4 [ 78.673088] fee0: c89a0480 00000201 00000cc0 30687465 00000000 00000000 00000000 00001002 [ 78.673822] ff00: 00000000 000a26d0 b6f43000 ca760866 00008914 c8b2a3c0 000a0ec4 c8b2a3c0 [ 78.674576] ff20: befe6c50 c04b21bc 000d5004 00000817 c89a0480 c0315f94 00000000 00000003 [ 78.675415] ff40: c19a2bc8 c8a3cc00 c89fe000 00000255 00000000 00000000 00000000 000d5000 [ 78.676182] ff60: 000f6000 c180b2a0 00000817 c0315e64 000d5004 c89fffb0 b6ec0c30 ca760866 [ 78.676928] ff80: 00000000 000b609b befe6c50 000a0ec4 00000036 c03002c4 c89fe000 00000036 [ 78.677673] ffa0: 00000000 c03000c0 000b609b befe6c50 00000003 00008914 befe6c50 000b609b [ 78.678415] ffc0: 000b609b befe6c50 000a0ec4 00000036 befe6e0c befe6f1a 000d5150 00000000 [ 78.679154] ffe0: 000d41e4 befe6bf4 00019648 b6e4509c 20000010 00000003 00000000 00000000 [ 78.681059] [<c0b0a634>] (macb_open) from [<c0de6f2c>] (__dev_open+0xd0/0x154) [ 78.681571] [<c0de6f2c>] (__dev_open) from [<c0de72f4>] (__dev_change_flags+0x16c/0x1c4) [ 78.682015] [<c0de72f4>] (__dev_change_flags) from [<c0de7364>] (dev_change_flags+0x18/0x48) [ 78.682493] [<c0de7364>] (dev_change_flags) from [<c0e8bd48>] (devinet_ioctl+0x5e4/0x75c) [ 78.682945] [<c0e8bd48>] (devinet_ioctl) from [<c0e8ef58>] (inet_ioctl+0x1f0/0x3b4) [ 78.683381] [<c0e8ef58>] (inet_ioctl) from [<c0dc00e4>] (sock_ioctl+0x39c/0x664) [ 78.683818] [<c0dc00e4>] (sock_ioctl) from [<c04b21bc>] (ksys_ioctl+0x2d8/0x9c0) [ 78.684343] [<c04b21bc>] (ksys_ioctl) from [<c03000c0>] (ret_fast_syscall+0x0/0x54) [ 78.684789] Exception stack(0xc89fffa8 to 0xc89ffff0) [ 78.685346] ffa0: 000b609b befe6c50 00000003 00008914 befe6c50 000b609b [ 78.686106] ffc0: 000b609b befe6c50 000a0ec4 00000036 befe6e0c befe6f1a 000d5150 00000000 [ 78.686710] ffe0: 000d41e4 befe6bf4 00019648 b6e4509c [ 78.687582] Code: 9a000003 e5983078 e3130001 1affffef (e7f001f2) [ 78.688788] ---[ end trace e3f2f6ab69754eae ]---
This is due to NAPI left enabled if macb_phylink_connect() fail.
--- drivers/net/ethernet/cadence/macb_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +4 -1
@@ -2545,13 +2545,16 @@ static int macb_open(struct net_device * err =macb_phylink_connect (bp);if (err) - goto pm_exit; + goto napi_exit;netif_tx_start_all_queues (dev);if (bp->ptp_info) bp->ptp_info->ptp_init (dev); +napi_exit: +for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) +napi_disable (&queue->napi); pm_exit:if (err) {pm_runtime_put_sync (&bp->pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 113/161 net: macb: Only disable NAPI on the actual error path
In reply to Greg Kroah-HartmanFrom: Charles Keepax <[email protected]>
[ Upstream commit 939a5bf7c9b7a1ad9c5d3481c93766a522773531 ]
A recent change added a disable to NAPI into macb_open, this was intended to only happen on the error path but accidentally applies to all paths. This causes NAPI to be disabled on the success path, which leads to the network to no longer functioning.
--- drivers/net/ethernet/cadence/macb_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +4 -5
@@ -2552,15 +2552,14 @@ static int macb_open(struct net_device *if (bp->ptp_info) bp->ptp_info->ptp_init (dev); +return 0 ; + napi_exit:for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue)napi_disable (&queue->napi); pm_exit: -if (err) { -pm_runtime_put_sync (&bp->pdev->dev); -return err; - } -return 0 ; +pm_runtime_put_sync (&bp->pdev->dev); +return err; }static int macb_close (struct net_device *dev)
Greg Kroah-Hartman
maintainerPATCH 114/161 net/mlx5: Disable reload while removing the device
In reply to Greg Kroah-HartmanFrom: Parav Pandit <[email protected]>
[ Upstream commit 60904cd349abc98cb888fc28d1ca55a8e2cf87b3 ]
While unregistration is in progress, user might be reloading the interface.
This can race with unregistration in below flow which uses the resources which are getting disabled by reload flow.
Hence, disable the devlink reloading first when removing the device.
CPU0 CPU1
---- ----local_pci_remove() devlink_mutex
remove_one() devlink_nl_cmd_reload()
mlx5_unregister_device() devlink_reload()
ops->reload_down()
mlx5_unload_one()--- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 2 -- drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +0 -2
@@ -256,7 +256,6 @@ int mlx5_devlink_register(struct devlink goto params_reg_err;mlx5_devlink_set_params_init_values (devlink);devlink_params_publish (devlink); -devlink_reload_enable (devlink);return 0 ; params_reg_err:
@@ -266,7 +265,6 @@ params_reg_err:void mlx5_devlink_unregister (struct devlink *devlink) { -devlink_reload_disable (devlink);devlink_params_unregister (devlink, mlx5_devlink_params,ARRAY_SIZE (mlx5_devlink_params));devlink_unregister (devlink);
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -0
@@ -1371,6 +1371,7 @@ static int init_one(struct pci_dev *pdevdev_err (&pdev->dev,"mlx5_crdump_enable failed with error code %d\n" , err);pci_save_state (pdev); +devlink_reload_enable (devlink);return 0 ; err_load_one:
@@ -1388,6 +1389,7 @@ static void remove_one(struct pci_dev *pstruct mlx5_core_dev *dev =pci_get_drvdata (pdev);struct devlink *devlink =priv_to_devlink (dev); +devlink_reload_disable (devlink);mlx5_crdump_disable (dev);mlx5_devlink_unregister (devlink);
Greg Kroah-Hartman
maintainerPATCH 115/161 ovl: fix out of bounds access warning in ovl_check_fb_len()
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
commit 522f6e6cba6880a038e2bd88e10390b84cd3febd upstream.
syzbot reported out of bounds memory access from open_by_handle_at() with a crafted file handle that looks like this:
{ .handle_bytes = 2, .handle_type = OVL_FILEID_V1 }
handle_bytes gets rounded down to 0 and we end up calling:
ovl_check_fh_len(fh, 0) => ovl_check_fb_len(fh + 3, -3)
But fh buffer is only 2 bytes long, so accessing struct ovl_fb at fh + 3 is illegal.
--- fs/overlayfs/overlayfs.h | 3 +++ 1 file changed, 3 insertions(+)
fs/overlayfs/overlayfs.h +3 -0
@@ -339,6 +339,9 @@ int ovl_check_fb_len(struct ovl_fb *fb,static inline int ovl_check_fh_len (struct ovl_fh *fh,int fh_len) { +if (fh_len <sizeof (struct ovl_fh )) +return -EINVAL ; +return ovl_check_fb_len (&fh->fb, fh_len -OVL_FH_WIRE_OFFSET ); }
Greg Kroah-Hartman
maintainerPATCH 116/161 ovl: initialize error in ovl_copy_xattr
In reply to Greg Kroah-HartmanFrom: Yuxuan Shui <[email protected]>
commit 520da69d265a91c6536c63851cbb8a53946974f0 upstream.
In ovl_copy_xattr, if all the xattrs to be copied are overlayfs private xattrs, the copy loop will terminate without assigning anything to the error variable, thus returning an uninitialized value.
If ovl_copy_xattr is called from ovl_clear_empty, this uninitialized error value is put into a pointer by ERR_PTR(), causing potential invalid memory accesses down the line.
This commit initialize error with 0. This is the correct value because when there's no xattr to copy, because all xattrs are private, ovl_copy_xattr should succeed.
This bug is discovered with the help of INIT_STACK_ALL and clang.
--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/copy_up.c +1 -1
@@ -40,7 +40,7 @@ int ovl_copy_xattr(struct dentry *old, s {ssize_t list_size, size, value_size =0 ;char *buf, *name, *value =NULL ; -int uninitialized_var (error ); +int error =0 ;size_t slen; if (!(old->d_inode->i_opflags & IOP_XATTR) ||
Greg Kroah-Hartman
maintainerPATCH 117/161 proc: Use new_inode not new_inode_pseudo
In reply to Greg Kroah-HartmanFrom: Eric W. Biederman <[email protected]>
commit ef1548adada51a2f32ed7faef50aa465e1b4c5da upstream.
Recently syzbot reported that unmounting proc when there is an ongoing inotify watch on the root directory of proc could result in a use after free when the watch is removed after the unmount of proc when the watcher exits.
Commit 69879c01a0c3 ("proc: Remove the now unnecessary internal mount of proc") made it easier to unmount proc and allowed syzbot to see the problem, but looking at the code it has been around for a long time.
Looking at the code the fsnotify watch should have been removed by fsnotify_sb_delete in generic_shutdown_super. Unfortunately the inode was allocated with new_inode_pseudo instead of new_inode so the inode was not on the sb->s_inodes list. Which prevented fsnotify_unmount_inodes from finding the inode and removing the watch as well as made it so the "VFS: Busy inodes after unmount" warning could not find the inodes to warn about them.
Make all of the inodes in proc visible to generic_shutdown_super, and fsnotify_sb_delete by using new_inode instead of new_inode_pseudo. The only functional difference is that new_inode places the inodes on the sb->s_inodes list.
I wrote a small test program and I can verify that without changes it can trigger this issue, and by replacing new_inode_pseudo with new_inode the issues goes away.
--- fs/proc/inode.c | 2 +- fs/proc/self.c | 2 +- fs/proc/thread_self.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
fs/proc/inode.c +1 -1
@@ -448,7 +448,7 @@ const struct inode_operations proc_link_struct inode *proc_get_inode (struct super_block *sb,struct proc_dir_entry *de) { -struct inode *inode =new_inode_pseudo (sb); +struct inode *inode =new_inode (sb);if (inode) { inode->i_ino = de->low_ino;
fs/proc/self.c +1 -1
@@ -43,7 +43,7 @@ int proc_setup_self(struct super_block *inode_lock (root_inode); self =d_alloc_name (s->s_root,"self" );if (self) { -struct inode *inode =new_inode_pseudo (s); +struct inode *inode =new_inode (s);if (inode) { inode->i_ino = self_inum; inode->i_mtime = inode->i_atime = inode->i_ctime =current_time (inode);
fs/proc/thread_self.c +1 -1
@@ -43,7 +43,7 @@ int proc_setup_thread_self(struct super_inode_lock (root_inode); thread_self =d_alloc_name (s->s_root,"thread-self" );if (thread_self) { -struct inode *inode =new_inode_pseudo (s); +struct inode *inode =new_inode (s);if (inode) { inode->i_ino = thread_self_inum; inode->i_mtime = inode->i_atime = inode->i_ctime =current_time (inode);
Greg Kroah-Hartman
maintainerPATCH 118/161 remoteproc: Fall back to using parent memory pool if no dedicated available
In reply to Greg Kroah-HartmanFrom: Tero Kristo <[email protected]>
commit db9178a4f8c4e523f824892cb8bab00961b07385 upstream.
In some cases, like with OMAP remoteproc, we are not creating dedicated memory pool for the virtio device. Instead, we use the same memory pool for all shared memories. The current virtio memory pool handling forces a split between these two, as a separate device is created for it, causing memory to be allocated from bad location if the dedicated pool is not available. Fix this by falling back to using the parent device memory pool if dedicated is not available.
--- drivers/remoteproc/remoteproc_virtio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +12 -0
@@ -375,6 +375,18 @@ int rproc_add_virtio_dev(struct rproc_vd goto out; } } + }else { +struct device_node *np = rproc->dev.parent->of_node; + +/* +* If we don't have dedicated buffer, just attempt to re-assign +* the reserved memory from our parent. A default memory-region +* at index 0 from the parent's memory-regions is assigned for +* the rvdev dev to allocate from. Failure is non-critical and +* the allocations will fall back to global pools, so don't +* check return value either. +*/ +of_reserved_mem_device_init_by_idx (dev, np,0 ); }/* Allocate virtio device */
Greg Kroah-Hartman
maintainerPATCH 119/161 remoteproc: Fix and restore the parenting hierarchy for vdev
In reply to Greg Kroah-HartmanFrom: Suman Anna <[email protected]>
commit c774ad010873bb89dcc0cdcb1e96aef6664d8caf upstream.
The commit 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool") has introduced a new vdev subdevice for each vdev declared in the firmware resource table and made it as the parent for the created virtio rpmsg devices instead of the previous remoteproc device. This changed the overall parenting hierarchy for the rpmsg devices, which were children of virtio devices, and does not allow the corresponding rpmsg drivers to retrieve the parent rproc device through the rproc_get_by_child() API.
Fix this by restoring the remoteproc device as the parent. The new vdev subdevice can continue to inherit the DMA attributes from the remoteproc's parent device (actual platform device).
--- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
@@ -510,7 +510,7 @@ static int rproc_handle_vdev(struct rpro/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); - rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.parent = &rproc->dev; rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);
Greg Kroah-Hartman
maintainerPATCH 120/161 cpufreq: Fix up cpufreq_boost_set_sw()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 552abb884e97d26589964e5a8c7e736f852f95f0 upstream.
After commit 18c49926c4bf ("cpufreq: Add QoS requests for userspace constraints") the return value of freq_qos_update_request(), that can be 1, passed by cpufreq_boost_set_sw() to its caller sometimes confuses the latter, which only expects to see 0 or negative error codes, so notice that cpufreq_boost_set_sw() can return an error code (which should not be -EINVAL for that matter) as soon as the first policy without a frequency table is found (because either all policies have a frequency table or none of them have it) and rework it to meet its caller's expectations.
--- drivers/cpufreq/cpufreq.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/cpufreq/cpufreq.c +6 -5
@@ -2515,26 +2515,27 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits)static int cpufreq_boost_set_sw (int state) {struct cpufreq_policy *policy; -int ret = -EINVAL ;for_each_active_policy (policy) { +int ret; +if (!policy->freq_table) -continue ; +return -ENXIO ; ret =cpufreq_frequency_table_cpuinfo (policy, policy->freq_table);if (ret) {pr_err ("%s: Policy frequency update failed\n" , __func__); -break ; +return ret; } ret =freq_qos_update_request (policy->max_freq_req, policy->max);if (ret <0 ) -break ; +return ret; } -return ret; +return 0 ; }int cpufreq_boost_trigger_state (int state)
Greg Kroah-Hartman
maintainerPATCH 121/161 EDAC/skx: Use the mcmtr register to retrieve close_pg/bank_xor_enable
In reply to Greg Kroah-HartmanFrom: Qiuxu Zhuo <[email protected]>
commit 1032095053b34d474aa20f2625d97dd306e0991b upstream.
The skx_edac driver wrongly uses the mtr register to retrieve two fields close_pg and bank_xor_enable. Fix it by using the correct mcmtr register to get the two fields.
--- drivers/edac/i10nm_base.c | 2 +- drivers/edac/skx_base.c | 20 ++++++++------------ drivers/edac/skx_common.c | 6 +++--- drivers/edac/skx_common.h | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-)
drivers/edac/i10nm_base.c +1 -1
@@ -161,7 +161,7 @@ static int i10nm_get_dimm_config(struct mtr, mcddrtcfg, imc->mc, i, j);if (IS_DIMM_PRESENT (mtr)) - ndimms +=skx_get_dimm_info (mtr,0 , dimm, + ndimms +=skx_get_dimm_info (mtr,0 ,0 , dimm, imc, i, j);else if (IS_NVDIMM_PRESENT (mcddrtcfg, j)) ndimms += skx_get_nvdimm_info(dimm, imc, i, j,
drivers/edac/skx_base.c +8 -12
@@ -163,27 +163,23 @@ static const struct x86_cpu_id skx_cpuid };MODULE_DEVICE_TABLE (x86cpu, skx_cpuids); -#define SKX_GET_MTMTR (dev, reg) \ - pci_read_config_dword((dev), 0x87c, &(reg)) - -static bool skx_check_ecc (struct pci_dev *pdev) +static bool skx_check_ecc (u32 mcmtr) { -u32 mtmtr; - -SKX_GET_MTMTR (pdev, mtmtr); - -return !!GET_BITFIELD (mtmtr,2 ,2 ); +return !!GET_BITFIELD (mcmtr,2 ,2 ); }static int skx_get_dimm_config (struct mem_ctl_info *mci) {struct skx_pvt *pvt = mci->pvt_info; +u32 mtr, mcmtr, amap, mcddrtcfg;struct skx_imc *imc = pvt->imc; -u32 mtr, amap, mcddrtcfg;struct dimm_info *dimm;int i, j;int ndimms; +/* Only the mcmtr on the first channel is effective */ +pci_read_config_dword (imc->chan[0 ].cdev,0x87c , &mcmtr); +for (i =0 ; i <SKX_NUM_CHANNELS ; i++) { ndimms =0 ;pci_read_config_dword (imc->chan[i].cdev,0x8C , &amap);
@@ -193,14 +189,14 @@ static int skx_get_dimm_config(struct mepci_read_config_dword (imc->chan[i].cdev,0x80 +4 * j, &mtr);if (IS_DIMM_PRESENT (mtr)) { - ndimms +=skx_get_dimm_info (mtr, amap, dimm, imc, i, j); + ndimms +=skx_get_dimm_info (mtr, mcmtr, amap, dimm, imc, i, j); }else if (IS_NVDIMM_PRESENT (mcddrtcfg, j)) { ndimms +=skx_get_nvdimm_info (dimm, imc, i, j,EDAC_MOD_STR ); nvdimm_count++; } } -if (ndimms && !skx_check_ecc (imc->chan[0 ].cdev)) { +if (ndimms && !skx_check_ecc (mcmtr)) {skx_printk (KERN_ERR ,"ECC is disabled on imc %d\n" , imc->mc);return -ENODEV ; }
drivers/edac/skx_common.c +3 -3
@@ -304,7 +304,7 @@ static int skx_get_dimm_attr(u32 reg, in#define numrow (reg) skx_get_dimm_attr(reg, 2, 4, 12, 1, 6, "rows")#define numcol (reg) skx_get_dimm_attr(reg, 0, 1, 10, 0, 2, "cols") -int skx_get_dimm_info (u32 mtr,u32 amap,struct dimm_info *dimm, +int skx_get_dimm_info (u32 mtr,u32 mcmtr,u32 amap,struct dimm_info *dimm,struct skx_imc *imc,int chan,int dimmno) {int banks =16 , ranks, rows, cols, npages;
@@ -324,8 +324,8 @@ int skx_get_dimm_info(u32 mtr, u32 amap, imc->mc, chan, dimmno, size, npages, banks, 1 << ranks, rows, cols); - imc->chan[chan].dimms[dimmno].close_pg =GET_BITFIELD (mtr,0 ,0 ); - imc->chan[chan].dimms[dimmno].bank_xor_enable =GET_BITFIELD (mtr,9 ,9 ); + imc->chan[chan].dimms[dimmno].close_pg =GET_BITFIELD (mcmtr,0 ,0 ); + imc->chan[chan].dimms[dimmno].bank_xor_enable =GET_BITFIELD (mcmtr,9 ,9 ); imc->chan[chan].dimms[dimmno].fine_grain_bank =GET_BITFIELD (amap,0 ,0 ); imc->chan[chan].dimms[dimmno].rowbits = rows; imc->chan[chan].dimms[dimmno].colbits = cols;
drivers/edac/skx_common.h +1 -1
@@ -128,7 +128,7 @@ int skx_get_all_bus_mappings(unsigned inint skx_get_hi_lo (unsigned int did,int off[],u64 *tolm,u64 *tohm); -int skx_get_dimm_info (u32 mtr,u32 amap,struct dimm_info *dimm, +int skx_get_dimm_info (u32 mtr,u32 mcmtr,u32 amap,struct dimm_info *dimm,struct skx_imc *imc,int chan,int dimmno); int skx_get_nvdimm_info(struct dimm_info *dimm, struct skx_imc *imc,
Greg Kroah-Hartman
maintainerPATCH 122/161 video: vt8500lcdfb: fix fallthrough warning
In reply to Greg Kroah-HartmanFrom: Sam Ravnborg <[email protected]>
commit 1c49f35e9e9156273124a0cfd38b57f7a7d4828f upstream.
Fix following warning:vt8500lcdfb.c: In function 'vt8500lcd_blank':
vt8500lcdfb.c:229:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR ||
^
vt8500lcdfb.c:233:2: note: here
case FB_BLANK_UNBLANK:
^~~~Adding a simple "fallthrough;" fixed the warning.
The fix was build tested.
--- drivers/video/fbdev/vt8500lcdfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/vt8500lcdfb.c +1 -0
@@ -230,6 +230,7 @@ static int vt8500lcd_blank(int blank, st info->fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)for (i =0 ; i <256 ; i++)vt8500lcd_setcolreg (i,0 ,0 ,0 ,0 , info); + fallthrough;case FB_BLANK_UNBLANK :if (info->fix.visual ==FB_VISUAL_PSEUDOCOLOR || info->fix.visual ==FB_VISUAL_STATIC_PSEUDOCOLOR )
Greg Kroah-Hartman
maintainerPATCH 123/161 video: fbdev: w100fb: Fix a potential double free.
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 18722d48a6bb9c2e8d046214c0a5fd19d0a7c9f6 upstream.
Some memory is vmalloc'ed in the 'w100fb_save_vidmem' function and freed in the 'w100fb_restore_vidmem' function. (these functions are called respectively from the 'suspend' and the 'resume' functions)
However, it is also freed in the 'remove' function.
In order to avoid a potential double free, set the corresponding pointer to NULL once freed in the 'w100fb_restore_vidmem' function.
--- drivers/video/fbdev/w100fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/w100fb.c +2 -0
@@ -588,6 +588,7 @@ static void w100fb_restore_vidmem(struct memsize=par->mach->mem->size;memcpy_toio (remapped_fbuf + (W100_FB_BASE -MEM_WINDOW_BASE ), par->saved_extmem, memsize);vfree (par->saved_extmem); + par->saved_extmem =NULL ; }if (par->saved_intmem) { memsize=MEM_INT_SIZE ;
@@ -596,6 +597,7 @@ static void w100fb_restore_vidmem(structelse memcpy_toio (remapped_fbuf + (W100_FB_BASE -MEM_WINDOW_BASE ), par->saved_intmem, memsize);vfree (par->saved_intmem); + par->saved_intmem =NULL ; } }
Greg Kroah-Hartman
maintainerPATCH 124/161 media: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size
In reply to Greg Kroah-HartmanFrom: Tomi Valkeinen <[email protected]>
commit 0d9668721311607353d4861e6c32afeb272813dc upstream.
Commit 9495b7e92f716ab2bd6814fab5e97ab4a39adfdd ("driver core: platform:
Initialize dma_parms for platform devices") in v5.7-rc5 causes vb2_dma_contig_clear_max_seg_size() to kfree memory that was not allocated by vb2_dma_contig_set_max_seg_size().
The assumption in vb2_dma_contig_set_max_seg_size() seems to be that dev->dma_parms is always NULL when the driver is probed, and the case where dev->dma_parms has bee initialized by someone else than the driver (by calling vb2_dma_contig_set_max_seg_size) will cause a failure.
All the current users of these functions are platform devices, which now always have dma_parms set by the driver core. To fix the issue for v5.7, make vb2_dma_contig_set_max_seg_size() return an error if dma_parms is NULL to be on the safe side, and remove the kfree code from vb2_dma_contig_clear_max_seg_size().
For v5.8 we should remove the two functions and move the dma_set_max_seg_size() calls into the drivers.
--- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 20 +----------------- include/media/videobuf2-dma-contig.h | 2 - 2 files changed, 3 insertions(+), 19 deletions(-)
drivers/media/common/videobuf2/videobuf2-dma-contig.c +2 -18
@@ -726,9 +726,8 @@ EXPORT_SYMBOL_GPL(vb2_dma_contig_memops)int vb2_dma_contig_set_max_seg_size (struct device *dev,unsigned int size) {if (!dev->dma_parms) { - dev->dma_parms =kzalloc (sizeof (*dev->dma_parms),GFP_KERNEL ); -if (!dev->dma_parms) -return -ENOMEM ; +dev_err (dev,"Failed to set max_seg_size: dma_parms is NULL\n" ); +return -ENODEV ; }if (dma_get_max_seg_size (dev) < size)return dma_set_max_seg_size (dev, size);
@@ -737,21 +736,6 @@ int vb2_dma_contig_set_max_seg_size(stru }EXPORT_SYMBOL_GPL (vb2_dma_contig_set_max_seg_size); -/* -* vb2_dma_contig_clear_max_seg_size() - release resources for DMA parameters -* @dev: device for configuring DMA parameters -* -* This function releases resources allocated to configure DMA parameters -* (see vb2_dma_contig_set_max_seg_size() function). It should be called from -* device drivers on driver remove. -*/ -void vb2_dma_contig_clear_max_seg_size (struct device *dev) -{ -kfree (dev->dma_parms); - dev->dma_parms =NULL ; -} -EXPORT_SYMBOL_GPL (vb2_dma_contig_clear_max_seg_size); -MODULE_DESCRIPTION ("DMA-contig memory handling routines for videobuf2" );MODULE_AUTHOR ("Pawel Osciak <[email protected]>" );MODULE_LICENSE ("GPL" );
include/media/videobuf2-dma-contig.h +1 -1
@@ -25,7 +25,7 @@ vb2_dma_contig_plane_dma_addr(struct vb2 }int vb2_dma_contig_set_max_seg_size (struct device *dev,unsigned int size); -void vb2_dma_contig_clear_max_seg_size (struct device *dev); +static inline void vb2_dma_contig_clear_max_seg_size (struct device *dev) { }extern const struct vb2_mem_ops vb2_dma_contig_memops;
Greg Kroah-Hartman
maintainerPATCH 125/161 KVM: nVMX: Skip IBPB when switching between vmcs01 and vmcs02
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 5c911beff20aa8639e7a1f28988736c13e03ed54 upstream.
Skip the Indirect Branch Prediction Barrier that is triggered on a VMCS switch when running with spectre_v2_user=on/auto if the switch is between two VMCSes in the same guest, i.e. between vmcs01 and vmcs02. The IBPB is intended to prevent one guest from attacking another, which is unnecessary in the nested case as it's the same guest from KVM's perspective.
This all but eliminates the overhead observed for nested VMX transitions when running with CONFIG_RETPOLINE=y and spectre_v2_user=on/auto, which can be significant, e.g. roughly 3x on current systems.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/vmx.c | 18 ++++++++++++++---- arch/x86/kvm/vmx/vmx.h | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx/nested.c +1 -1
@@ -303,7 +303,7 @@ static void vmx_switch_vmcs(struct kvm_v cpu =get_cpu (); prev = vmx->loaded_vmcs; vmx->loaded_vmcs = vmcs; -vmx_vcpu_load_vmcs (vcpu, cpu); +vmx_vcpu_load_vmcs (vcpu, cpu, prev);vmx_sync_vmcs_host_state (vmx, prev);put_cpu ();
arch/x86/kvm/vmx/vmx.c +14 -4
@@ -1314,10 +1314,12 @@ after_clear_sn:pi_set_on (pi_desc); } -void vmx_vcpu_load_vmcs (struct kvm_vcpu *vcpu,int cpu) +void vmx_vcpu_load_vmcs (struct kvm_vcpu *vcpu,int cpu, +struct loaded_vmcs *buddy) {struct vcpu_vmx *vmx =to_vmx (vcpu);bool already_loaded = vmx->loaded_vmcs->cpu == cpu; +struct vmcs *prev;if (!already_loaded) {loaded_vmcs_clear (vmx->loaded_vmcs);
@@ -1336,10 +1338,18 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpulocal_irq_enable (); } -if (per_cpu (current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { + prev =per_cpu (current_vmcs, cpu); +if (prev != vmx->loaded_vmcs->vmcs) {per_cpu (current_vmcs, cpu) = vmx->loaded_vmcs->vmcs;vmcs_load (vmx->loaded_vmcs->vmcs); -indirect_branch_prediction_barrier (); + +/* +* No indirect branch prediction barrier needed when switching +* the active VMCS within a guest, e.g. on nested VM-Enter. +* The L1 VMM can protect itself with retpolines, IBPB or IBRS. +*/ +if (!buddy ||WARN_ON_ONCE (buddy->vmcs != prev)) +indirect_branch_prediction_barrier (); }if (!already_loaded) {
@@ -1376,7 +1386,7 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu {struct vcpu_vmx *vmx =to_vmx (vcpu); -vmx_vcpu_load_vmcs (vcpu, cpu); +vmx_vcpu_load_vmcs (vcpu, cpu,NULL );vmx_vcpu_pi_load (vcpu, cpu);
arch/x86/kvm/vmx/vmx.h +2 -1
@@ -320,7 +320,8 @@ struct kvm_vmx { };bool nested_vmx_allowed (struct kvm_vcpu *vcpu); -void vmx_vcpu_load_vmcs (struct kvm_vcpu *vcpu,int cpu); +void vmx_vcpu_load_vmcs (struct kvm_vcpu *vcpu,int cpu, +struct loaded_vmcs *buddy);void vmx_vcpu_load (struct kvm_vcpu *vcpu,int cpu);int allocate_vpid (void );void free_vpid (int vpid);
Greg Kroah-Hartman
maintainerPATCH 126/161 KVM: nSVM: fix condition for filtering async PF
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit a3535be731c2a343912578465021f50937f7b099 upstream.
Async page faults have to be trapped in the host (L1 in this case), since the APF reason was passed from L0 to L1 and stored in the L1 APF data page. This was completely reversed: the page faults were passed to the guest, a L2 hypervisor.
--- arch/x86/kvm/svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/svm.c +2 -2
@@ -3236,8 +3236,8 @@ static int nested_svm_exit_special(strucreturn NESTED_EXIT_HOST ;break ;case SVM_EXIT_EXCP_BASE +PF_VECTOR : -/* When we're shadowing, trap PFs, but not async PF */ -if (!npt_enabled && svm->vcpu.arch.apf.host_apf_reason ==0 ) +/* Trap async PF even if not shadowing */ +if (!npt_enabled || svm->vcpu.arch.apf.host_apf_reason)return NESTED_EXIT_HOST ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 127/161 KVM: nSVM: leave ASID aside in copy_vmcb_control_area
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 6c0238c4a62b3a0b1201aeb7e33a4636d552a436 upstream.
Restoring the ASID from the hsave area on VMEXIT is wrong, because its value depends on the handling of TLB flushes. Just skipping the field in copy_vmcb_control_area will do.
--- arch/x86/kvm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm.c +1 -1
@@ -3326,7 +3326,7 @@ static inline void copy_vmcb_control_are dst->iopm_base_pa = from->iopm_base_pa; dst->msrpm_base_pa = from->msrpm_base_pa; dst->tsc_offset = from->tsc_offset; - dst->asid = from->asid; +/* asid not copied, it is handled manually for svm->vmcb. */ dst->tlb_ctl = from->tlb_ctl; dst->int_ctl = from->int_ctl; dst->int_vector = from->int_vector;
Greg Kroah-Hartman
maintainerPATCH 128/161 KVM: nVMX: Consult only the "basic" exit reason when routing nested exit
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 2ebac8bb3c2d35f5135466490fc8eeaf3f3e2d37 upstream.
Consult only the basic exit reason, i.e. bits 15:0 of vmcs.EXIT_REASON, when determining whether a nested VM-Exit should be reflected into L1 or handled by KVM in L0.
For better or worse, the switch statement in nested_vmx_exit_reflected() currently defaults to "true", i.e. reflects any nested VM-Exit without dedicated logic. Because the case statements only contain the basic exit reason, any VM-Exit with modifier bits set will be reflected to L1, even if KVM intended to handle it in L0.
Practically speaking, this only affects EXIT_REASON_MCE_DURING_VMENTRY, i.e. a #MC that occurs on nested VM-Enter would be incorrectly routed to L1, as "failed VM-Entry" is the only modifier that KVM can currently encounter. The SMM modifiers will never be generated as KVM doesn't support/employ a SMI Transfer Monitor. Ditto for "exit from enclave", as KVM doesn't yet support virtualizing SGX, i.e. it's impossible to enter an enclave in a KVM guest (L1 or L2).
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +1 -1
@@ -5562,7 +5562,7 @@ bool nested_vmx_exit_reflected(struct kvvmcs_read32 (VM_EXIT_INTR_ERROR_CODE ), KVM_ISA_VMX); -switch (exit_reason) { +switch ((u16 )exit_reason) {case EXIT_REASON_EXCEPTION_NMI :if (is_nmi (intr_info))return false;
Greg Kroah-Hartman
maintainerPATCH 129/161 KVM: MIPS: Define KVM_ENTRYHI_ASID to cpu_asid_mask(&boot_cpu_data)
In reply to Greg Kroah-HartmanFrom: Xing Li <[email protected]>
commit fe2b73dba47fb6d6922df1ad44e83b1754d5ed4d upstream.
The code in decode_config4() of arch/mips/kernel/cpu-probe.c
asid_mask = MIPS_ENTRYHI_ASID;
if (config4 & MIPS_CONF4_AE)
asid_mask |= MIPS_ENTRYHI_ASIDX;
set_cpu_asid_mask(c, asid_mask);set asid_mask to cpuinfo->asid_mask.
So in order to support variable ASID_MASK, KVM_ENTRYHI_ASID should also be changed to cpu_asid_mask(&boot_cpu_data).
Message-Id: <[email protected]>
--- arch/mips/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/kvm_host.h +1 -1
@@ -275,7 +275,7 @@ enum emulation_result {#define MIPS3_PG_FRAME 0x3fffffc0#define VPN2_MASK 0xffffe000 -#define KVM_ENTRYHI_ASID MIPS_ENTRYHI_ASID +#define KVM_ENTRYHI_ASID cpu_asid_mask(&boot_cpu_data)#define TLB_IS_GLOBAL (x) ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G)#define TLB_VPN2 (x) ((x).tlb_hi & VPN2_MASK)#define TLB_ASID (x) ((x).tlb_hi & KVM_ENTRYHI_ASID)
Greg Kroah-Hartman
maintainerPATCH 130/161 KVM: MIPS: Fix VPN2_MASK definition for variable cpu_vmbits
In reply to Greg Kroah-HartmanFrom: Xing Li <[email protected]>
commit 5816c76dea116a458f1932eefe064e35403248eb upstream.
If a CPU support more than 32bit vmbits (which is true for 64bit CPUs), VPN2_MASK set to fixed 0xffffe000 will lead to a wrong EntryHi in some functions such as _kvm_mips_host_tlb_inv().
The cpu_vmbits definition of 32bit CPU in cpu-features.h is 31, so we still use the old definition.
Message-Id: <[email protected]>
--- arch/mips/include/asm/kvm_host.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/mips/include/asm/kvm_host.h +4 -0
@@ -274,7 +274,11 @@ enum emulation_result {#define MIPS3_PG_SHIFT 6#define MIPS3_PG_FRAME 0x3fffffc0 +#if defined(CONFIG_64BIT ) +#define VPN2_MASK GENMASK(cpu_vmbits - 1, 13) +#else #define VPN2_MASK 0xffffe000 +#endif #define KVM_ENTRYHI_ASID cpu_asid_mask(&boot_cpu_data)#define TLB_IS_GLOBAL (x) ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G)#define TLB_VPN2 (x) ((x).tlb_hi & VPN2_MASK)
Greg Kroah-Hartman
maintainerPATCH 131/161 KVM: arm64: Stop writing aarch32s CSSELR into ACTLR
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 7c582bf4ed84f3eb58bdd1f63024a14c17551e7d upstream.
aarch32 has pairs of registers to access the high and low parts of 64bit registers. KVM has a union of 64bit sys_regs[] and 32bit copro[]. The 32bit accessors read the high or low part of the 64bit sys_reg[] value through the union.
Both sys_reg_descs[] and cp15_regs[] list access_csselr() as the accessor for CSSELR{,_EL1}. access_csselr() is only aware of the 64bit sys_regs[], and expects r->reg to be 'CSSELR_EL1' in the enum, index 2 of the 64bit array.
cp15_regs[] uses the 32bit copro[] alias of sys_regs[]. Here CSSELR is c0_CSSELR which is the same location in sys_reg[]. r->reg is 'c0_CSSELR', index 4 in the 32bit array.
access_csselr() uses the 32bit r->reg value to access the 64bit array, so reads and write the wrong value. sys_regs[4], is ACTLR_EL1, which is subsequently save/restored when we enter the guest.
ACTLR_EL1 is supposed to be read-only for the guest. This register only affects execution at EL1, and the host's value is restored before we return to host EL1.
Convert the 32bit register index back to the 64bit version.
--- arch/arm64/kvm/sys_regs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm64/kvm/sys_regs.c +8 -2
@@ -1280,10 +1280,16 @@ static bool access_clidr(struct kvm_vcpustatic bool access_csselr (struct kvm_vcpu *vcpu,struct sys_reg_params *p,const struct sys_reg_desc *r) { +int reg = r->reg; + +/* See the 32bit mapping in kvm_host.h */ +if (p->is_aarch32) + reg = r->reg /2 ; +if (p->is_write) -vcpu_write_sys_reg (vcpu, p->regval, r->reg); +vcpu_write_sys_reg (vcpu, p->regval, reg);else - p->regval =vcpu_read_sys_reg (vcpu, r->reg); + p->regval =vcpu_read_sys_reg (vcpu, reg);return true; }
Greg Kroah-Hartman
maintainerPATCH 132/161 KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 3204be4109ad681523e3461ce64454c79278450a upstream.
AArch32 CP1x registers are overlayed on their AArch64 counterparts in the vcpu struct. This leads to an interesting problem as they are stored in their CPU-local format, and thus a CP1x register doesn't "hit" the lower 32bit portion of the AArch64 register on a BE host.
To workaround this unfortunate situation, introduce a bias trick in the vcpu_cp1x() accessors which picks the correct half of the 64bit register.
--- arch/arm64/include/asm/kvm_host.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/include/asm/kvm_host.h +4 -2
@@ -404,8 +404,10 @@ void vcpu_write_sys_reg(struct kvm_vcpu* CP14 and CP15 live in the same array, as they are backed by the * same system registers. */ -#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r)]) -#define vcpu_cp15 (v,r) ((v)->arch.ctxt.copro[(r)]) +#define CPx_BIAS IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) + +#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS]) +#define vcpu_cp15 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])struct kvm_vm_stat {ulong remote_tlb_flush;
Greg Kroah-Hartman
maintainerPATCH 133/161 scsi: megaraid_sas: TM command refire leads to controller firmware crash
In reply to Greg Kroah-HartmanFrom: Sumit Saxena <[email protected]>
commit 6fd8525a70221c26823b1c7e912fb21f218fb0c5 upstream.
When TM command times out, driver invokes the controller reset. Post reset, driver re-fires pended TM commands which leads to firmware crash.
Post controller reset, return pended TM commands back to OS.
--- drivers/scsi/megaraid/megaraid_sas_fusion.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_fusion.c +6 -1
@@ -4238,6 +4238,7 @@ void megasas_refire_mgmt_cmd(struct megastruct fusion_context *fusion;struct megasas_cmd *cmd_mfi;union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc; +struct MPI2_RAID_SCSI_IO_REQUEST *scsi_io_req;u16 smid;bool refire_cmd =0 ;u8 result;
@@ -4305,6 +4306,11 @@ void megasas_refire_mgmt_cmd(struct mega result =COMPLETE_CMD ; } + scsi_io_req = (struct MPI2_RAID_SCSI_IO_REQUEST *) + cmd_fusion->io_request; +if (scsi_io_req->Function ==MPI2_FUNCTION_SCSI_TASK_MGMT ) + result =RETURN_CMD ; +switch (result) {case REFIRE_CMD :megasas_fire_cmd_fusion (instance, req_desc);
@@ -4533,7 +4539,6 @@ megasas_issue_tm(struct megasas_instanceif (!timeleft) {dev_err (&instance->pdev->dev,"task mgmt type 0x%x timed out\n" , type); - cmd_mfi->flags |=DRV_DCMD_SKIP_REFIRE ;mutex_unlock (&instance->reset_mutex); rc =megasas_reset_fusion (instance->host,MFI_IO_TIMEOUT_OCR );mutex_lock (&instance->reset_mutex);
Greg Kroah-Hartman
maintainerPATCH 134/161 scsi: lpfc: Fix negation of else clause in lpfc_prep_node_fc4type
In reply to Greg Kroah-HartmanFrom: Dick Kennedy <[email protected]>
commit f809da6db68a8be49e317f0ccfbced1af9258839 upstream.
Implementation of a previous patch added a condition to an if check that always end up with the if test being true. Execution of the else clause was inadvertently negated. The additional condition check was incorrect and unnecessary after the other modifications had been done in that patch.
Remove the check from the if series.
--- drivers/scsi/lpfc/lpfc_ct.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/lpfc/lpfc_ct.c +0 -1
@@ -462,7 +462,6 @@ lpfc_prep_node_fc4type(struct lpfc_vportstruct lpfc_nodelist *ndlp;if ((vport->port_type !=LPFC_NPIV_PORT ) || - (fc4_type ==FC_TYPE_FCP ) || !(vport->ct_flags &FC_CT_RFF_ID ) || !vport->cfg_restrict_login) { ndlp =lpfc_setup_disc_node (vport, Did);
Greg Kroah-Hartman
maintainerPATCH 135/161 scsi: megaraid_sas: Replace undefined MFI_BIG_ENDIAN macro with __BIG_ENDIAN_BITFIELD macro
In reply to Greg Kroah-HartmanFrom: Shivasharan S <[email protected]>
commit b9d5e3e7f370a817c742fb089ac1a86dfe8947dc upstream.
MFI_BIG_ENDIAN macro used in drivers structure bitfield to check the CPU big endianness is undefined which would break the code on big endian machine. __BIG_ENDIAN_BITFIELD kernel macro should be used in places of MFI_BIG_ENDIAN macro.
--- drivers/scsi/megaraid/megaraid_sas.h | 4 ++-- drivers/scsi/megaraid/megaraid_sas_fusion.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/megaraid/megaraid_sas.h +2 -2
@@ -511,7 +511,7 @@ union MR_PROGRESS {*/ struct MR_PD_PROGRESS {struct { -#ifndef MFI_BIG_ENDIAN +#ifndef __BIG_ENDIAN_BITFIELDu32 rbld:1 ;u32 patrol:1 ;u32 clear:1 ;
@@ -537,7 +537,7 @@ struct MR_PD_PROGRESS { };struct { -#ifndef MFI_BIG_ENDIAN +#ifndef __BIG_ENDIAN_BITFIELDu32 rbld:1 ;u32 patrol:1 ;u32 clear:1 ;
drivers/scsi/megaraid/megaraid_sas_fusion.h +3 -3
@@ -774,7 +774,7 @@ struct MR_SPAN_BLOCK_INFO { struct MR_CPU_AFFINITY_MASK { union { struct { -#ifndef MFI_BIG_ENDIAN +#ifndef __BIG_ENDIAN_BITFIELD u8 hw_path:1; u8 cpu0:1; u8 cpu1:1;
@@ -866,7 +866,7 @@ struct MR_LD_RAID {__le16 seqNum;struct { -#ifndef MFI_BIG_ENDIAN +#ifndef __BIG_ENDIAN_BITFIELDu32 ldSyncRequired:1 ;u32 regTypeReqOnReadIsValid:1 ;u32 isEPD:1 ;
@@ -889,7 +889,7 @@ struct {/* 0x30 - 0x33, Logical block size for the LD */ u32 logical_block_length;struct { -#ifndef MFI_BIG_ENDIAN +#ifndef __BIG_ENDIAN_BITFIELD/* 0x34, P_I_EXPONENT from READ CAPACITY 16 */ u32 ld_pi_exp:4 ;/* 0x34, LOGICAL BLOCKS PER PHYSICAL
Greg Kroah-Hartman
maintainerPATCH 136/161 selftests/ftrace: Return unsupported if no error_log file
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 619ee76f5c9f6a1d601d1a056a454d62bf676ae4 upstream.
Check whether error_log file exists in tracing/error_log testcase and return UNSUPPORTED if no error_log file.
This can happen if we run the ftracetest on the older stable kernel.
--- tools/testing/selftests/ftrace/test.d/ftrace/tracing-error-log.tc | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/ftrace/test.d/ftrace/tracing-error-log.tc +2 -0
@@ -14,6 +14,8 @@ if [ ! -f set_event ]; then exit_unsupported fi +[ -f error_log ] || exit_unsupported + ftrace_errlog_check 'event filter parse error' '((sig >= 10 && sig < 15) || dsig ^== 17) && comm != bash' 'events/signal/signal_generate/filter' exit 0
Greg Kroah-Hartman
maintainerPATCH 137/161 ath9k: Fix use-after-free Read in htc_connect_service
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit ced21a4c726bdc60b1680c050a284b08803bc64c upstream.
The skb is consumed by htc_send_epid, so it needn't release again.
The case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
usb 1-1: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested usb 1-1: ath9k_htc: Transferred FW: ath9k_htc/htc_9271-1.4.0.fw, size:
51008
usb 1-1: Service connection timeout for: 256
==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:26 [inline] BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:134 [inline] BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:1042 [inline] BUG: KASAN: use-after-free in kfree_skb+0x32/0x3d0 net/core/skbuff.c:692 Read of size 4 at addr ffff8881d0957994 by task kworker/1:2/83 Call Trace: kfree_skb+0x32/0x3d0 net/core/skbuff.c:692 htc_connect_service.cold+0xa9/0x109 drivers/net/wireless/ath/ath9k/htc_hst.c:282 ath9k_wmi_connect+0xd2/0x1a0 drivers/net/wireless/ath/ath9k/wmi.c:265 ath9k_init_htc_services.constprop.0+0xb4/0x650
drivers/net/wireless/ath/ath9k/htc_drv_init.c:146ath9k_htc_probe_device+0x25a/0x1d80drivers/net/wireless/ath/ath9k/htc_drv_init.c:959ath9k_htc_hw_init+0x31/0x60drivers/net/wireless/ath/ath9k/htc_hst.c:501ath9k_hif_usb_firmware_cb+0x26b/0x500drivers/net/wireless/ath/ath9k/hif_usb.c:1187request_firmware_work_func+0x126/0x242drivers/base/firmware_loader/main.c:976
process_one_work+0x94b/0x1620 kernel/workqueue.c:2264 worker_thread+0x96/0xe20 kernel/workqueue.c:2410 kthread+0x318/0x420 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 83: kmem_cache_alloc_node+0xdc/0x330 mm/slub.c:2814 __alloc_skb+0xba/0x5a0 net/core/skbuff.c:198 alloc_skb include/linux/skbuff.h:1081 [inline] htc_connect_service+0x2cc/0x840 drivers/net/wireless/ath/ath9k/htc_hst.c:257 ath9k_wmi_connect+0xd2/0x1a0 drivers/net/wireless/ath/ath9k/wmi.c:265 ath9k_init_htc_services.constprop.0+0xb4/0x650
drivers/net/wireless/ath/ath9k/htc_drv_init.c:146ath9k_htc_probe_device+0x25a/0x1d80drivers/net/wireless/ath/ath9k/htc_drv_init.c:959ath9k_htc_hw_init+0x31/0x60drivers/net/wireless/ath/ath9k/htc_hst.c:501ath9k_hif_usb_firmware_cb+0x26b/0x500drivers/net/wireless/ath/ath9k/hif_usb.c:1187request_firmware_work_func+0x126/0x242drivers/base/firmware_loader/main.c:976
process_one_work+0x94b/0x1620 kernel/workqueue.c:2264 worker_thread+0x96/0xe20 kernel/workqueue.c:2410 kthread+0x318/0x420 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 0: kfree_skb+0x102/0x3d0 net/core/skbuff.c:690 ath9k_htc_txcompletion_cb+0x1f8/0x2b0 drivers/net/wireless/ath/ath9k/htc_hst.c:356 hif_usb_regout_cb+0x10b/0x1b0 drivers/net/wireless/ath/ath9k/hif_usb.c:90 __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786 __do_softirq+0x21e/0x950 kernel/softirq.c:292
--- drivers/net/wireless/ath/ath9k/htc_hst.c | 3 --- drivers/net/wireless/ath/ath9k/wmi.c | 1 - 2 files changed, 4 deletions(-)
drivers/net/wireless/ath/ath9k/htc_hst.c +0 -3
@@ -170,7 +170,6 @@ static int htc_config_pipe_credits(struc time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC credit config timeout\n" ); -kfree_skb (skb);return -ETIMEDOUT ; }
@@ -206,7 +205,6 @@ static int htc_setup_complete(struct htc time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC start timeout\n" ); -kfree_skb (skb);return -ETIMEDOUT ; }
@@ -279,7 +277,6 @@ int htc_connect_service(struct htc_targeif (!time_left) {dev_err (target->dev,"Service connection timeout for: %d\n" , service_connreq->service_id); -kfree_skb (skb);return -ETIMEDOUT ; }
drivers/net/wireless/ath/ath9k/wmi.c +0 -1
@@ -336,7 +336,6 @@ int ath9k_wmi_cmd(struct wmi *wmi, enumath_dbg (common,WMI ,"Timeout waiting for WMI command: %s\n" ,wmi_cmd_to_name (cmd_id));mutex_unlock (&wmi->op_mutex); -kfree_skb (skb);return -ETIMEDOUT ; }
Greg Kroah-Hartman
maintainerPATCH 138/161 ath9k: Fix use-after-free Read in ath9k_wmi_ctrl_rx
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit abeaa85054ff8cfe8b99aafc5c70ea067e5d0908 upstream.
Free wmi later after cmd urb has been killed, as urb cb will access wmi.
the case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
BUG: KASAN: use-after-free in ath9k_wmi_ctrl_rx+0x416/0x500 drivers/net/wireless/ath/ath9k/wmi.c:215 Read of size 1 at addr ffff8881cef1417c by task swapper/1/0 Call Trace: <IRQ> ath9k_wmi_ctrl_rx+0x416/0x500 drivers/net/wireless/ath/ath9k/wmi.c:215 ath9k_htc_rx_msg+0x2da/0xaf0 drivers/net/wireless/ath/ath9k/htc_hst.c:459 ath9k_hif_usb_reg_in_cb+0x1ba/0x630 drivers/net/wireless/ath/ath9k/hif_usb.c:718 __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++-- drivers/net/wireless/ath/ath9k/hif_usb.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_init.c | 10 +++++++--- drivers/net/wireless/ath/ath9k/wmi.c | 5 ++++- drivers/net/wireless/ath/ath9k/wmi.h | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +3 -2
@@ -973,7 +973,7 @@ err:return -ENOMEM ; } -static void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev) +void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev) {usb_kill_anchored_urbs (&hif_dev->regout_submitted);ath9k_hif_usb_dealloc_reg_in_urbs (hif_dev);
@@ -1341,8 +1341,9 @@ static void ath9k_hif_usb_disconnect(strif (hif_dev->flags &HIF_USB_READY ) {ath9k_htc_hw_deinit (hif_dev->htc_handle, unplugged); -ath9k_htc_hw_free (hif_dev->htc_handle);ath9k_hif_usb_dev_deinit (hif_dev); +ath9k_destoy_wmi (hif_dev->htc_handle->drv_priv); +ath9k_htc_hw_free (hif_dev->htc_handle); }usb_set_intfdata (interface,NULL );
drivers/net/wireless/ath/ath9k/hif_usb.h +1 -0
@@ -133,5 +133,6 @@ struct hif_device_usb {int ath9k_hif_usb_init (void );void ath9k_hif_usb_exit (void ); +void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev);#endif /* HTC_USB_H */
drivers/net/wireless/ath/ath9k/htc_drv_init.c +7 -3
@@ -931,8 +931,9 @@ err_init:int ath9k_htc_probe_device (struct htc_target *htc_handle,struct device *dev,u16 devid,char *product,u32 drv_info) { -struct ieee80211_hw *hw; +struct hif_device_usb *hif_dev;struct ath9k_htc_priv *priv; +struct ieee80211_hw *hw;int ret; hw =ieee80211_alloc_hw (sizeof (struct ath9k_htc_priv ), &ath9k_htc_ops);
@@ -967,7 +968,10 @@ int ath9k_htc_probe_device(struct htc_tareturn 0 ; err_init: -ath9k_deinit_wmi (priv); +ath9k_stop_wmi (priv); + hif_dev = (struct hif_device_usb *)htc_handle->hif_dev; +ath9k_hif_usb_dealloc_urbs (hif_dev); +ath9k_destoy_wmi (priv); err_free:ieee80211_free_hw (hw);return ret;
@@ -982,7 +986,7 @@ void ath9k_htc_disconnect_device(struct htc_handle->drv_priv->ah->ah_flags |=AH_UNPLUGGED ;ath9k_deinit_device (htc_handle->drv_priv); -ath9k_deinit_wmi (htc_handle->drv_priv); +ath9k_stop_wmi (htc_handle->drv_priv);ieee80211_free_hw (htc_handle->drv_priv->hw); } }
drivers/net/wireless/ath/ath9k/wmi.c +4 -1
@@ -112,14 +112,17 @@ struct wmi *ath9k_init_wmi(struct ath9k_return wmi; } -void ath9k_deinit_wmi (struct ath9k_htc_priv *priv) +void ath9k_stop_wmi (struct ath9k_htc_priv *priv) {struct wmi *wmi = priv->wmi;mutex_lock (&wmi->op_mutex); wmi->stopped = true;mutex_unlock (&wmi->op_mutex); +} +void ath9k_destoy_wmi (struct ath9k_htc_priv *priv) +{kfree (priv->wmi); }
drivers/net/wireless/ath/ath9k/wmi.h +2 -1
@@ -179,7 +179,6 @@ struct wmi { };struct wmi *ath9k_init_wmi (struct ath9k_htc_priv *priv); -void ath9k_deinit_wmi (struct ath9k_htc_priv *priv);int ath9k_wmi_connect (struct htc_target *htc,struct wmi *wmi,enum htc_endpoint_id *wmi_ctrl_epid); int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
@@ -189,6 +188,8 @@ int ath9k_wmi_cmd(struct wmi *wmi, enumvoid ath9k_wmi_event_tasklet (unsigned long data);void ath9k_fatal_work (struct work_struct *work);void ath9k_wmi_event_drain (struct ath9k_htc_priv *priv); +void ath9k_stop_wmi (struct ath9k_htc_priv *priv); +void ath9k_destoy_wmi (struct ath9k_htc_priv *priv);#define WMI_CMD (_wmi_cmd) \ do { \
Greg Kroah-Hartman
maintainerPATCH 139/161 ath9k: Fix use-after-free Write in ath9k_htc_rx_msg
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit e4ff08a4d727146bb6717a39a8d399d834654345 upstream.
Write out of slab bounds. We should check epid.
The case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
BUG: KASAN: use-after-free in htc_process_conn_rsp drivers/net/wireless/ath/ath9k/htc_hst.c:131 [inline] BUG: KASAN: use-after-free in ath9k_htc_rx_msg+0xa25/0xaf0 drivers/net/wireless/ath/ath9k/htc_hst.c:443 Write of size 2 at addr ffff8881cea291f0 by task swapper/1/0 Call Trace: htc_process_conn_rsp drivers/net/wireless/ath/ath9k/htc_hst.c:131
[inline]ath9k_htc_rx_msg+0xa25/0xaf0drivers/net/wireless/ath/ath9k/htc_hst.c:443ath9k_hif_usb_reg_in_cb+0x1ba/0x630drivers/net/wireless/ath/ath9k/hif_usb.c:718
__usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786
--- drivers/net/wireless/ath/ath9k/htc_hst.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/htc_hst.c +3 -0
@@ -113,6 +113,9 @@ static void htc_process_conn_rsp(structif (svc_rspmsg->status ==HTC_SERVICE_SUCCESS ) { epid = svc_rspmsg->endpoint_id; +if (epid <0 || epid >=ENDPOINT_MAX ) +return ; + service_id =be16_to_cpu (svc_rspmsg->service_id); max_msglen =be16_to_cpu (svc_rspmsg->max_msg_len); endpoint = &target->endpoint[epid];
Greg Kroah-Hartman
maintainerPATCH 140/161 ath9x: Fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit 19d6c375d671ce9949a864fb9a03e19f5487b4d3 upstream.
Add barrier to accessing the stack array skb_pool.
The case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
BUG: KASAN: stack-out-of-bounds in ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:626 [inline] BUG: KASAN: stack-out-of-bounds in ath9k_hif_usb_rx_cb+0xdf6/0xf70 drivers/net/wireless/ath/ath9k/hif_usb.c:666 Write of size 8 at addr ffff8881db309a28 by task swapper/1/0 Call Trace: ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:626 [inline] ath9k_hif_usb_rx_cb+0xdf6/0xf70 drivers/net/wireless/ath/ath9k/hif_usb.c:666 __usb_hcd_giveback_urb+0x1f2/0x470 drivers/usb/core/hcd.c:1648 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1713 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +5 -0
@@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(stru hif_dev->remain_skb = nskb;spin_unlock (&hif_dev->rx_lock); }else { +if (pool_index ==MAX_PKT_NUM_IN_TRANSFER ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: over RX MAX_PKT_NUM\n" ); + goto err; + } nskb =__dev_alloc_skb (pkt_len +32 ,GFP_ATOMIC );if (!nskb) { dev_err(&hif_dev->udev->dev,
Greg Kroah-Hartman
maintainerPATCH 141/161 ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit 2bbcaaee1fcbd83272e29f31e2bb7e70d8c49e05 upstream.
In ath9k_hif_usb_rx_cb interface number is assumed to be 0. usb_ifnum_to_if(urb->dev, 0)
But it isn't always true.
The case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
usb 2-1: new high-speed USB device number 2 using dummy_hcd usb 2-1: config 1 has an invalid interface number: 2 but max is 0 usb 2-1: config 1 has no interface number 0
usb 2-1: New USB device found, idVendor=0cf3, idProduct=9271, bcdDevice= 1.08
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
general protection fault, probably for non-canonical address 0xdffffc0000000015: 0000 [#1] SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0-rc5-syzkaller #0
Call Trace
__usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786 __do_softirq+0x21e/0x950 kernel/softirq.c:292 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0x178/0x1a0 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:546 [inline] smp_apic_timer_interrupt+0x141/0x540 arch/x86/kernel/apic/apic.c:1146 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 48 +++++++++++++++++++++++-------- drivers/net/wireless/ath/ath9k/hif_usb.h | 5 +++ 2 files changed, 42 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +37 -11
@@ -643,9 +643,9 @@ err:static void ath9k_hif_usb_rx_cb (struct urb *urb) { -struct sk_buff *skb = (struct sk_buff *) urb->context; -struct hif_device_usb *hif_dev = -usb_get_intfdata (usb_ifnum_to_if (urb->dev,0 )); +struct rx_buf *rx_buf = (struct rx_buf *)urb->context; +struct hif_device_usb *hif_dev = rx_buf->hif_dev; +struct sk_buff *skb = rx_buf->skb;int ret;if (!skb)
@@ -685,14 +685,15 @@ resubmit:return ; free:kfree_skb (skb); +kfree (rx_buf); }static void ath9k_hif_usb_reg_in_cb (struct urb *urb) { -struct sk_buff *skb = (struct sk_buff *) urb->context; +struct rx_buf *rx_buf = (struct rx_buf *)urb->context; +struct hif_device_usb *hif_dev = rx_buf->hif_dev; +struct sk_buff *skb = rx_buf->skb;struct sk_buff *nskb; -struct hif_device_usb *hif_dev = -usb_get_intfdata (usb_ifnum_to_if (urb->dev,0 ));int ret;if (!skb)
@@ -750,6 +751,7 @@ resubmit:return ; free:kfree_skb (skb); +kfree (rx_buf); urb->context =NULL ; }
@@ -795,7 +797,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(sinit_usb_anchor (&hif_dev->mgmt_submitted);for (i =0 ; i <MAX_TX_URB_NUM ; i++) { - tx_buf =kzalloc (sizeof (struct tx_buf ),GFP_KERNEL ); + tx_buf =kzalloc (sizeof (*tx_buf),GFP_KERNEL );if (!tx_buf) goto err;
@@ -832,8 +834,9 @@ static void ath9k_hif_usb_dealloc_rx_urbstatic int ath9k_hif_usb_alloc_rx_urbs (struct hif_device_usb *hif_dev) { -struct urb *urb =NULL ; +struct rx_buf *rx_buf =NULL ;struct sk_buff *skb =NULL ; +struct urb *urb =NULL ;int i, ret;init_usb_anchor (&hif_dev->rx_submitted);
@@ -841,6 +844,12 @@ static int ath9k_hif_usb_alloc_rx_urbs(sfor (i =0 ; i <MAX_RX_URB_NUM ; i++) { + rx_buf =kzalloc (sizeof (*rx_buf),GFP_KERNEL ); +if (!rx_buf) { + ret = -ENOMEM ; + goto err_rxb; + } +/* Allocate URB */ urb =usb_alloc_urb (0 ,GFP_KERNEL );if (urb ==NULL ) {
@@ -855,11 +864,14 @@ static int ath9k_hif_usb_alloc_rx_urbs(s goto err_skb; } + rx_buf->hif_dev = hif_dev; + rx_buf->skb = skb; +usb_fill_bulk_urb (urb, hif_dev->udev,usb_rcvbulkpipe (hif_dev->udev,USB_WLAN_RX_PIPE ), skb->data,MAX_RX_BUF_SIZE , - ath9k_hif_usb_rx_cb, skb); + ath9k_hif_usb_rx_cb, rx_buf);/* Anchor URB */ usb_anchor_urb (urb, &hif_dev->rx_submitted);
@@ -885,6 +897,8 @@ err_submit: err_skb:usb_free_urb (urb); err_urb: +kfree (rx_buf); +err_rxb:ath9k_hif_usb_dealloc_rx_urbs (hif_dev);return ret; }
@@ -896,14 +910,21 @@ static void ath9k_hif_usb_dealloc_reg_instatic int ath9k_hif_usb_alloc_reg_in_urbs (struct hif_device_usb *hif_dev) { -struct urb *urb =NULL ; +struct rx_buf *rx_buf =NULL ;struct sk_buff *skb =NULL ; +struct urb *urb =NULL ;int i, ret;init_usb_anchor (&hif_dev->reg_in_submitted);for (i =0 ; i <MAX_REG_IN_URB_NUM ; i++) { + rx_buf =kzalloc (sizeof (*rx_buf),GFP_KERNEL ); +if (!rx_buf) { + ret = -ENOMEM ; + goto err_rxb; + } +/* Allocate URB */ urb =usb_alloc_urb (0 ,GFP_KERNEL );if (urb ==NULL ) {
@@ -918,11 +939,14 @@ static int ath9k_hif_usb_alloc_reg_in_ur goto err_skb; } + rx_buf->hif_dev = hif_dev; + rx_buf->skb = skb; +usb_fill_int_urb (urb, hif_dev->udev,usb_rcvintpipe (hif_dev->udev,USB_REG_IN_PIPE ), skb->data,MAX_REG_IN_BUF_SIZE , - ath9k_hif_usb_reg_in_cb, skb,1 ); + ath9k_hif_usb_reg_in_cb, rx_buf,1 );/* Anchor URB */ usb_anchor_urb (urb, &hif_dev->reg_in_submitted);
@@ -948,6 +972,8 @@ err_submit: err_skb:usb_free_urb (urb); err_urb: +kfree (rx_buf); +err_rxb:ath9k_hif_usb_dealloc_reg_in_urbs (hif_dev);return ret; }
drivers/net/wireless/ath/ath9k/hif_usb.h +5 -0
@@ -86,6 +86,11 @@ struct tx_buf {struct list_head list; }; +struct rx_buf { +struct sk_buff *skb; +struct hif_device_usb *hif_dev; +}; +#define HIF_USB_TX_STOP BIT(0)#define HIF_USB_TX_FLUSH BIT(1)
Greg Kroah-Hartman
maintainerPATCH 142/161 Smack: slab-out-of-bounds in vsscanf
In reply to Greg Kroah-HartmanFrom: Casey Schaufler <[email protected]>
commit 84e99e58e8d1e26f04c097f4266e431a33987f36 upstream.
Add barrier to soob. Return -EOVERFLOW if the buffer is exceeded.
--- security/smack/smackfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
security/smack/smackfs.c +10 -0
@@ -878,11 +878,21 @@ static ssize_t smk_set_cipso(struct fileelse rule +=strlen (skp->smk_known) +1 ; +if (rule > data + count) { + rc = -EOVERFLOW ; + goto out; + } + ret =sscanf (rule,"%d" , &maplevel);if (ret !=1 || maplevel >SMACK_CIPSO_MAXLEVEL ) goto out; rule +=SMK_DIGITLEN ; +if (rule > data + count) { + rc = -EOVERFLOW ; + goto out; + } + ret =sscanf (rule,"%d" , &catlen);if (ret !=1 || catlen >SMACK_CIPSO_MAXCATNUM ) goto out;
Greg Kroah-Hartman
maintainerPATCH 143/161 drm/vkms: Hold gem object while still in-use
In reply to Greg Kroah-HartmanFrom: Ezequiel Garcia <[email protected]>
commit 0ea2ea42b31abc1141f2fd3911f952a97d401fcb upstream.
We need to keep the reference to the drm_gem_object until the last access by vkms_dumb_create.
Therefore, the put the object after it is used.
This fixes a use-after-free issue reported by syzbot.
While here, change vkms_gem_create() symbol to static.
--- drivers/gpu/drm/vkms/vkms_drv.h | 5 ----- drivers/gpu/drm/vkms/vkms_gem.c | 11 ++++++----- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.h +0 -5
@@ -121,11 +121,6 @@ struct drm_plane *vkms_plane_init(struct enum drm_plane_type type, int index);/* Gem stuff */ -struct drm_gem_object *vkms_gem_create (struct drm_device *dev, -struct drm_file *file, -u32 *handle, -u64 size); -vm_fault_t vkms_gem_fault (struct vm_fault *vmf); int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
drivers/gpu/drm/vkms/vkms_gem.c +6 -5
@@ -97,10 +97,10 @@ vm_fault_t vkms_gem_fault(struct vm_faulreturn ret; } -struct drm_gem_object *vkms_gem_create (struct drm_device *dev, -struct drm_file *file, -u32 *handle, -u64 size) +static struct drm_gem_object *vkms_gem_create (struct drm_device *dev, +struct drm_file *file, +u32 *handle, +u64 size) {struct vkms_gem_object *obj;int ret;
@@ -113,7 +113,6 @@ struct drm_gem_object *vkms_gem_create(sreturn ERR_CAST (obj); ret =drm_gem_handle_create (file, &obj->gem, handle); -drm_gem_object_put_unlocked (&obj->gem);if (ret)return ERR_PTR (ret);
@@ -142,6 +141,8 @@ int vkms_dumb_create(struct drm_file *fi args->size = gem_obj->size; args->pitch = pitch; +drm_gem_object_put_unlocked (gem_obj); +DRM_DEBUG_DRIVER ("Created object of size %lld\n" , size);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 144/161 mm/slub: fix a memory leak in sysfs_slab_add()
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
commit dde3c6b72a16c2db826f54b2d49bdea26c3534a2 upstream.
syzkaller reports for memory leak when kobject_init_and_add() returns an error in the function sysfs_slab_add() [1]
When this happened, the function kobject_put() is not called for the corresponding kobject, which potentially leads to memory leak.
This patch fixes the issue by calling kobject_put() even if kobject_init_and_add() fails.
[1]
BUG: memory leak
unreferenced object 0xffff8880a6d4be88 (size 8):
comm "syz-executor.3", pid 946, jiffies 4295772514 (age 18.396s)
hex dump (first 8 bytes):
70 69 64 5f 33 00 ff ff pid_3...
backtrace:
kstrdup+0x35/0x70 mm/util.c:60
kstrdup_const+0x3d/0x50 mm/util.c:82
kvasprintf_const+0x112/0x170 lib/kasprintf.c:48
kobject_set_name_vargs+0x55/0x130 lib/kobject.c:289
kobject_add_varg lib/kobject.c:384 [inline]
kobject_init_and_add+0xd8/0x170 lib/kobject.c:473
sysfs_slab_add+0x1d8/0x290 mm/slub.c:5811
__kmem_cache_create+0x50a/0x570 mm/slub.c:4384
create_cache+0x113/0x1e0 mm/slab_common.c:407
kmem_cache_create_usercopy+0x1a1/0x260 mm/slab_common.c:505
kmem_cache_create+0xd/0x10 mm/slab_common.c:564
create_pid_cachep kernel/pid_namespace.c:54 [inline]
create_pid_namespace kernel/pid_namespace.c:96 [inline]
copy_pid_ns+0x77c/0x8f0 kernel/pid_namespace.c:148
create_new_namespaces+0x26b/0xa30 kernel/nsproxy.c:95
unshare_nsproxy_namespaces+0xa7/0x1e0 kernel/nsproxy.c:229
ksys_unshare+0x3d2/0x770 kernel/fork.c:2969
__do_sys_unshare kernel/fork.c:3037 [inline]
__se_sys_unshare kernel/fork.c:3035 [inline]
__x64_sys_unshare+0x2d/0x40 kernel/fork.c:3035
do_syscall_64+0xa1/0x530 arch/x86/entry/common.c:295--- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/slub.c +3 -1
@@ -5778,8 +5778,10 @@ static int sysfs_slab_add(struct kmem_ca s->kobj.kset = kset; err =kobject_init_and_add (&s->kobj, &slab_ktype,NULL ,"%s" , name); -if (err) +if (err) { +kobject_put (&s->kobj); goto out; + } err =sysfs_create_group (&s->kobj, &slab_attr_group);if (err)
Greg Kroah-Hartman
maintainerPATCH 145/161 fat: dont allow to mount if the FAT length == 0
In reply to Greg Kroah-HartmanFrom: OGAWA Hirofumi <[email protected]>
commit b1b65750b8db67834482f758fc385bfa7560d228 upstream.
If FAT length == 0, the image doesn't have any data. And it can be the cause of overlapping the root dir and FAT entries.
Also Windows treats it as invalid format.
--- fs/fat/inode.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/fat/inode.c +6 -0
@@ -1520,6 +1520,12 @@ static int fat_read_bpb(struct super_blo goto out; } +if (bpb->fat_fat_length ==0 && bpb->fat32_length ==0 ) { +if (!silent) +fat_msg (sb,KERN_ERR ,"bogus number of FAT sectors" ); + goto out; + } + error =0 ; out:
Greg Kroah-Hartman
maintainerPATCH 146/161 perf: Add cond_resched() to task_function_call()
In reply to Greg Kroah-HartmanFrom: Barret Rhoden <[email protected]>
commit 2ed6edd33a214bca02bd2b45e3fc3038a059436b upstream.
Under rare circumstances, task_function_call() can repeatedly fail and cause a soft lockup.
There is a slight race where the process is no longer running on the cpu we targeted by the time remote_function() runs. The code will simply try again. If we are very unlucky, this will continue to fail, until a watchdog fires. This can happen in a heavily loaded, multi-core virtual machine.
--- kernel/events/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
kernel/events/core.c +14 -9
@@ -93,11 +93,11 @@ static void remote_function(void *data)* @info: the function call argument * * Calls the function @func when the task is currently running. This might -* be on the current CPU, which just calls the function directly +* be on the current CPU, which just calls the function directly. This will +* retry due to any failures in smp_call_function_single(), such as if the +* task_cpu() goes offline concurrently. * -* returns: @func return value, or -* -ESRCH - when the process isn't running -* -EAGAIN - when the process moved away +* returns @func return value or -ESRCH when the process isn't running */ static int task_function_call (struct task_struct *p,remote_function_f func,void *info)
@@ -110,11 +110,16 @@ task_function_call(struct task_struct *p };int ret; -do { - ret =smp_call_function_single (task_cpu (p), remote_function, &data,1 ); -if (!ret) - ret = data.ret; - }while (ret == -EAGAIN ); +for (;;) { + ret =smp_call_function_single (task_cpu (p), remote_function, + &data,1 ); + ret = !ret ? data.ret : -EAGAIN ; + +if (ret != -EAGAIN ) +break ; + +cond_resched (); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 147/161 agp/intel: Reinforce the barrier after GTT updates
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit f30d3ced9fafa03e4855508929b5b6334907f45e upstream.
After changing the timing between GTT updates and execution on the GPU, we started seeing sporadic failures on Ironlake. These were narrowed down to being an insufficiently strong enough barrier/delay after updating the GTT and scheduling execution on the GPU. By forcing the uncached read, and adding the missing barrier for the singular insert_page (relocation paths), the sporadic failures go away.
--- drivers/char/agp/intel-gtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/agp/intel-gtt.c +3 -1
@@ -846,6 +846,7 @@ void intel_gtt_insert_page(dma_addr_t ad unsigned int flags) { intel_private.driver->write_entry (addr, pg, flags); +readl (intel_private.gtt + pg);if (intel_private.driver->chipset_flush) intel_private.driver->chipset_flush (); }
@@ -871,7 +872,7 @@ void intel_gtt_insert_sg_entries(struct j++; } } -wmb (); +readl (intel_private.gtt + j -1 );if (intel_private.driver->chipset_flush) intel_private.driver->chipset_flush (); }
@@ -1105,6 +1106,7 @@ static void i9xx_cleanup(void)static void i9xx_chipset_flush (void ) { +wmb ();if (intel_private.i9xx_flush_page)writel (1 , intel_private.i9xx_flush_page); }
Greg Kroah-Hartman
maintainerPATCH 148/161 mmc: sdhci-msm: Clear tuning done flag while hs400 tuning
In reply to Greg Kroah-HartmanFrom: Veerabhadrarao Badiganti <[email protected]>
commit 9253d71011c349d5f5cc0cebdf68b4a80811b92d upstream.
Clear tuning_done flag while executing tuning to ensure vendor specific HS400 settings are applied properly when the controller is re-initialized in HS400 mode.
Without this, re-initialization of the qcom SDHC in HS400 mode fails while resuming the driver from runtime-suspend or system-suspend.
--- drivers/mmc/host/sdhci-msm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci-msm.c +6 -0
@@ -1118,6 +1118,12 @@ static int sdhci_msm_execute_tuning(stru msm_host->use_cdr = true;/* +* Clear tuning_done flag before tuning to ensure proper +* HS400 settings. +*/ + msm_host->tuning_done =0 ; + +/* * For HS400 tuning in HS200 timing requires: * - select MCLK/2 in VENDOR_SPEC * - program MCLK to 400MHz (or nearest supported) in GCC
Greg Kroah-Hartman
maintainerPATCH 149/161 mmc: sdhci-of-at91: fix CALCR register being rewritten
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
commit dbdea70f71d672c12bc4454e7c258a8f78194d74 upstream.
When enabling calibration at reset, the CALCR register was completely rewritten. This may cause certain bits being deleted unintentedly. Fix by issuing a read-modify-write operation.
--- drivers/mmc/host/sdhci-of-at91.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +5 -2
@@ -136,9 +136,12 @@ static void sdhci_at91_reset(struct sdhc || mmc_gpio_get_cd(host->mmc) >= 0)sdhci_at91_set_force_card_detect (host); -if (priv->cal_always_on && (mask &SDHCI_RESET_ALL )) -sdhci_writel (host,SDMMC_CALCR_ALWYSON |SDMMC_CALCR_EN , +if (priv->cal_always_on && (mask &SDHCI_RESET_ALL )) { +u32 calcr =sdhci_readl (host,SDMMC_CALCR ); + +sdhci_writel (host, calcr |SDMMC_CALCR_ALWYSON |SDMMC_CALCR_EN ,SDMMC_CALCR ); + } }static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
Greg Kroah-Hartman
maintainerPATCH 150/161 mmc: mmci_sdmmc: fix DMA API warning overlapping mappings
In reply to Greg Kroah-HartmanFrom: Ludovic Barre <[email protected]>
commit fe8d33bd33d527dee3155d2bccd714a655f37334 upstream.
Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning:
WARNING: CPU: 1 PID: 20 at kernel/dma/debug.c:500 add_dma_entry+0x16c/0x17c DMA-API: exceeded 7 overlapping mappings of cacheline 0x031d2645 Modules linked in: CPU: 1 PID: 20 Comm: kworker/1:1 Not tainted 5.5.0-rc2-00021-gdeda30999c2b-dirty #49 Hardware name: STM32 (Device Tree Support) Workqueue: events_freezable mmc_rescan [<c03138c0>] (unwind_backtrace) from [<c030d760>] (show_stack+0x10/0x14) [<c030d760>] (show_stack) from [<c0f2eb28>] (dump_stack+0xc0/0xd4) [<c0f2eb28>] (dump_stack) from [<c034a14c>] (__warn+0xd0/0xf8) [<c034a14c>] (__warn) from [<c034a530>] (warn_slowpath_fmt+0x94/0xb8) [<c034a530>] (warn_slowpath_fmt) from [<c03bca0c>] (add_dma_entry+0x16c/0x17c) [<c03bca0c>] (add_dma_entry) from [<c03bdf54>] (debug_dma_map_sg+0xe4/0x3d4) [<c03bdf54>] (debug_dma_map_sg) from [<c0d09244>] (sdmmc_idma_prep_data+0x94/0xf8) [<c0d09244>] (sdmmc_idma_prep_data) from [<c0d05a2c>] (mmci_prep_data+0x2c/0xb0) [<c0d05a2c>] (mmci_prep_data) from [<c0d073ec>] (mmci_start_data+0x134/0x2f0) [<c0d073ec>] (mmci_start_data) from [<c0d078d0>] (mmci_request+0xe8/0x154) [<c0d078d0>] (mmci_request) from [<c0cecb44>] (mmc_start_request+0x94/0xbc)
DMA api debug brings to light leaking dma-mappings, dma_map_sg and dma_unmap_sg are not correctly balanced.
If a request is prepared, the dma_map/unmap are done in asynchronous call pre_req (prep_data) and post_req (unprep_data). In this case the dma-mapping is right balanced.
But if the request was not prepared, the data->host_cookie is define to zero and the dma_map/unmap must be done in the request. The dma_map is called by mmci_dma_start (prep_data), but there is no dma_unmap in this case.
This patch adds dma_unmap_sg when the dma is finalized and the data cookie is zero (request not prepared).
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -0
@@ -162,6 +162,9 @@ static int sdmmc_idma_start(struct mmci_static void sdmmc_idma_finalize (struct mmci_host *host,struct mmc_data *data) {writel_relaxed (0 , host->base +MMCI_STM32_IDMACTRLR ); + +if (!data->host_cookie) +sdmmc_idma_unprep_data (host, data,0 ); }static void mmci_sdmmc_set_clkreg (struct mmci_host *host,unsigned int desired)
Greg Kroah-Hartman
maintainerPATCH 151/161 mmc: tmio: Further fixup runtime PM management at remove
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 4bd784411aca022622e484eb262f5a0540ae732c upstream.
Before calling tmio_mmc_host_probe(), the caller is required to enable clocks for its device, as to make it accessible when reading/writing registers during probe.
Therefore, the responsibility to disable these clocks, in the error path of ->probe() and during ->remove(), is better managed outside tmio_mmc_host_remove(). As a matter of fact, callers of tmio_mmc_host_remove() already expects this to be the behaviour.
However, there's a problem with tmio_mmc_host_remove() when the Kconfig option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then disable the clock via runtime PM, which leads to clock enable/disable imbalance problems, when the caller of tmio_mmc_host_remove() also tries to disable the same clocks.
To solve the problem, let's make sure tmio_mmc_host_remove() leaves the device with clocks enabled, but also make sure to disable the IRQs, as we normally do at ->runtime_suspend().
--- drivers/mmc/host/tmio_mmc_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +4 -2
@@ -1286,12 +1286,14 @@ void tmio_mmc_host_remove(struct tmio_mmcancel_work_sync (&host->done);cancel_delayed_work_sync (&host->delayed_reset_work);tmio_mmc_release_dma (host); +tmio_mmc_disable_mmc_irqs (host,TMIO_MASK_ALL ); -pm_runtime_dont_use_autosuspend (&pdev->dev);if (host->native_hotplug)pm_runtime_put_noidle (&pdev->dev); -pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); }EXPORT_SYMBOL_GPL (tmio_mmc_host_remove);
Greg Kroah-Hartman
maintainerPATCH 152/161 mmc: uniphier-sd: call devm_request_irq() after tmio_mmc_host_probe()
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 5d1f42e14b135773c0cc1d82e904c5b223783a9d upstream.
Currently, tmio_mmc_irq() handler is registered before the host is fully initialized by tmio_mmc_host_probe(). I did not previously notice this problem.
The boot ROM of a new Socionext SoC unmasks interrupts (CTL_IRQ_MASK) somehow. The handler is invoked before tmio_mmc_host_probe(), then emits noisy call trace.
Move devm_request_irq() below tmio_mmc_host_probe().
--- drivers/mmc/host/uniphier-sd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/host/uniphier-sd.c +7 -5
@@ -610,11 +610,6 @@ static int uniphier_sd_probe(struct plat } } - ret =devm_request_irq (dev, irq, tmio_mmc_irq,IRQF_SHARED , -dev_name (dev), host); -if (ret) - goto free_host; -if (priv->caps &UNIPHIER_SD_CAP_EXTENDED_IP ) host->dma_ops = &uniphier_sd_internal_dma_ops;else
@@ -642,8 +637,15 @@ static int uniphier_sd_probe(struct platif (ret) goto free_host; + ret =devm_request_irq (dev, irq, tmio_mmc_irq,IRQF_SHARED , +dev_name (dev), host); +if (ret) + goto remove_host; +return 0 ; +remove_host: +tmio_mmc_host_remove (host); free_host:tmio_mmc_host_free (host);
Greg Kroah-Hartman
maintainerPATCH 153/161 ARM: dts: at91: sama5d2_ptc_ek: fix sdmmc0 node description
In reply to Greg Kroah-HartmanFrom: Ludovic Desroches <[email protected]>
commit a1af7f36c70369b971ee1cf679dd68368dad23f0 upstream.
Remove non-removable and mmc-ddr-1_8v properties from the sdmmc0 node which come probably from an unchecked copy/paste.
--- arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts | 2 -- 1 file changed, 2 deletions(-)
arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts +0 -2
@@ -125,8 +125,6 @@ bus-width = <8>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sdmmc0_default>; - non-removable; - mmc-ddr-1_8v; status = "okay"; };
Greg Kroah-Hartman
maintainerPATCH 154/161 mmc: sdio: Fix potential NULL pointer error in mmc_sdio_init_card()
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit f04086c225da11ad16d7f9a2fbca6483ab16dded upstream.
During some scenarios mmc_sdio_init_card() runs a retry path for the UHS-I specific initialization, which leads to removal of the previously allocated card. A new card is then re-allocated while retrying.
However, in one of the corresponding error paths we may end up to remove an already removed card, which likely leads to a NULL pointer exception. So, let's fix this.
--- drivers/mmc/core/sdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/core/sdio.c +1 -2
@@ -718,9 +718,8 @@ try_again:/* Retry init sequence, but without R4_18V_PRESENT. */ retries =0 ; goto try_again; - }else { - goto remove; } +return err; }/*