4.18.13-stable review
Subsystems (8)
Greg Kroah-Hartman
maintainercover 4.18.13-stable review
This is the start of the stable review cycle for the 4.18.13 release. There are 168 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 Wed Oct 10 17:55:44 UTC 2018. 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/v4.x/stable-review/patch-4.18.13-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-4.18.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.18.13-rc1
Song Liu <[email protected]>
ixgbe: check return value of napi_complete_done()
Anisse Astier <[email protected]>
HID: i2c-hid: disable runtime PM operations on hantick touchpad
Ashish Samant <[email protected]>
ocfs2: fix locking for res->tracking and dlm->tracking_list
Jann Horn <[email protected]>
proc: restrict kernel stack dumps to root
Vitaly Kuznetsov <[email protected]>
tools: hv: fcopy: set 'error' in case an unknown operation was requested
Dexuan Cui <[email protected]>
Drivers: hv: vmbus: Use get/put_cpu() in vmbus_connect()
Ricardo Ribalda Delgado <[email protected]>
gpiolib: Free the last requested descriptor
Horia Geantă <[email protected]>
crypto: caam/jr - fix ablkcipher_edesc pointer arithmetic
Leonard Crestez <[email protected]>
crypto: mxs-dcp - Fix wait logic on chan threads
Harsh Jain <[email protected]>
crypto: chelsio - Fix memory corruption in DMA Mapped buffers.
Waiman Long <[email protected]>
crypto: qat - Fix KASAN stack-out-of-bounds bug in adf_probe()
Kai-Heng Feng <[email protected]>
ALSA: hda/realtek - Cannot adjust speaker's volume on Dell XPS 27 7760
Singh, Brijesh <[email protected]>
iommu/amd: Clear memory encryption mask from physical address
Aurelien Aptel <[email protected]>
smb2: fix missing files in root share directory listing
Nathan Chancellor <[email protected]>
cpufreq: qcom-kryo: Fix section annotations
Bjorn Andersson <[email protected]>
firmware: Always initialize the fw_priv list object
Rishabh Bhatnagar <[email protected]>
firmware: Fix security issue with request_firmware_into_buf()
Larry Finger <[email protected]>
b43: fix DMA error related regression with proprietary firmware
Andreas Gruenbacher <[email protected]>
sysfs: Do not return POSIX ACL xattrs via listxattr
Miklos Szeredi <[email protected]>
ovl: fix format of setxattr debug
Amir Goldstein <[email protected]>
ovl: fix memory leak on unlink of indexed file
Amir Goldstein <[email protected]>
ovl: fix access beyond unterminated strings
Miklos Szeredi <[email protected]>
ovl: set I_CREATING on inode being created
Miklos Szeredi <[email protected]>
vfs: don't evict uninitialized inode
Al Viro <[email protected]>
new primitive: discard_new_inode()
Randy Dunlap <[email protected]>
x86/APM: Fix build warning when PROC_FS is not enabled
Josh Abraham <[email protected]>
xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage
Olaf Hering <[email protected]>
xen: avoid crash in disable_hotplug_cpu
Vitaly Kuznetsov <[email protected]>
xen/manage: don't complain about an empty value in control/sysrq node
Andrew Murray <[email protected]>
asm-generic: io: Fix ioport_map() for !CONFIG_GENERIC_IOMAP && CONFIG_INDIRECT_PIO
Dan Carpenter <[email protected]>
cifs: read overflow in is_valid_oplock_break()
Julian Wiedmann <[email protected]>
s390/qeth: don't dump past end of unknown HW header
Wenjia Zhang <[email protected]>
s390/qeth: use vzalloc for QUERY OAT buffer
Kai-Heng Feng <[email protected]>
r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED
Christian König <[email protected]>
drm/amdgpu: fix error handling in amdgpu_cs_user_fence_chunk
Miguel Ojeda <[email protected]>
arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto"
Tao Zhou <[email protected]>
drm/amdgpu: Fix SDMA hang in prt mode v2
Randy Dunlap <[email protected]>
hexagon: modify ffs() and fls() to return int
Randy Dunlap <[email protected]>
arch/hexagon: fix kernel/dma.c build warning
Cong Wang <[email protected]>
netfilter: xt_hashlimit: use s->file instead of s->private
Michal 'vorner' Vaner <[email protected]>
netfilter: nfnetlink_queue: Solve the NFQUEUE/conntrack clash for NF_REPEAT
Pablo Neira Ayuso <[email protected]>
netfilter: conntrack: timeout interface depend on CONFIG_NF_CONNTRACK_TIMEOUT
Joe Thornber <[email protected]>
dm thin metadata: try to avoid ever aborting transactions
Srikar Dronamraju <[email protected]>
sched/topology: Set correct NUMA topology type
Jacek Tomaka <[email protected]>
perf/x86/intel: Add support/quirk for the MISPREDICT bit on Knights Landing CPUs
Netanel Belgazal <[email protected]>
net: ena: fix missing calls to READ_ONCE
Netanel Belgazal <[email protected]>
net: ena: fix missing lock during device destruction
Netanel Belgazal <[email protected]>
net: ena: fix potential double ena_destroy_device()
Netanel Belgazal <[email protected]>
net: ena: fix device destruction to gracefully free resources
Netanel Belgazal <[email protected]>
net: ena: fix driver when PAGE_SIZE == 64kB
Netanel Belgazal <[email protected]>
net: ena: fix surprise unplug NULL dereference kernel crash
Stephen Rothwell <[email protected]>
fs/cifs: suppress a string overflow warning
Maciej S. Szmigiero <[email protected]>
r8169: set TxConfig register after TX / RX is enabled, just like RxConfig
Heinz Mauelshagen <[email protected]>
dm raid: fix RAID leg rebuild errors
Heinz Mauelshagen <[email protected]>
dm raid: fix rebuild of specific devices by updating superblock
Heinz Mauelshagen <[email protected]>
dm raid: fix stripe adding reshape deadlock
Ben Skeggs <[email protected]>
drm/nouveau/disp/gm200-: enforce identity-mapped SOR assignment for LVDS/eDP panels
Ben Skeggs <[email protected]>
drm/nouveau/disp: fix DP disable race
Ben Skeggs <[email protected]>
drm/nouveau/TBDdevinit: don't fail when PMU/PRE_OS is missing from VBIOS
Ben Skeggs <[email protected]>
drm/nouveau/mmu: don't attempt to dereference vmm without valid instance pointer
Ben Skeggs <[email protected]>
drm/nouveau: fix oops in client init failure path
Heinz Mauelshagen <[email protected]>
dm raid: fix reshape race on small devices
Kai-Heng Feng <[email protected]>
HID: i2c-hid: Don't reset device upon system resume
Daniel Jurgens <[email protected]>
net/mlx5: Consider PCI domain in search for next dev
Somnath Kotur <[email protected]>
bnxt_re: Fix couple of memory leaks that could lead to IOMMU call traces
Sagi Grimberg <[email protected]>
nvmet-rdma: fix possible bogus dereference under heavy load
Ben Hutchings <[email protected]>
USB: yurex: Check for truncation in yurex_read()
Anurag Kumar Vulisha <[email protected]>
usb: host: xhci-plat: Iterate over parent nodes for finding quirks
Hans de Goede <[email protected]>
HID: sensor-hub: Restore fixup for Lenovo ThinkPad Helix 2 sensor hub report
Guenter Roeck <[email protected]>
riscv: Do not overwrite initrd_start and initrd_end
Jann Horn <[email protected]>
RDMA/ucma: check fd type in ucma_migrate_id()
Lorenzo Bianconi <[email protected]>
iio: imu: st_lsm6dsx: take into account ts samples in wm configuration
Matt Ranostay <[email protected]>
Revert "iio: temperature: maxim_thermocouple: add MAX31856 part"
Taehee Yoo <[email protected]>
netfilter: nf_tables: release chain in flushing set
Florian Westphal <[email protected]>
netfilter: kconfig: nat related expression depend on nftables core
Kim Phillips <[email protected]>
perf annotate: Fix parsing aarch64 branch instructions after objdump update
Sandipan Das <[email protected]>
perf probe powerpc: Ignore SyS symbols irrespective of endianness
Chris Phlipot <[email protected]>
perf util: Fix bad memory access in trace info.
Hisao Tanabe <[email protected]>
perf evsel: Fix potential null pointer dereference in perf_evsel__new_idx()
Martin Liška <[email protected]>
perf annotate: Properly interpret indirect call
Nilesh Javali <[email protected]>
scsi: qedi: Add the CRC size within iSCSI NVM image
Mike Christie <[email protected]>
scsi: iscsi: target: Fix conn_ops double free
Vincent Pelletier <[email protected]>
scsi: iscsi: target: Set conn->sess to NULL when iscsi_login_set_conn_values fails
Harry Mallon <[email protected]>
HID: hid-saitek: Add device ID for RAT 7 Contagion
Stephen Boyd <[email protected]>
pinctrl: msm: Really mask level interrupts to prevent latching
Anton Vasilyev <[email protected]>
usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
Sean O'Brien <[email protected]>
HID: add support for Apple Magic Keyboards
Andreas Bosch <[email protected]>
HID: intel-ish-hid: Enable Sunrise Point-H ish driver
Florian Westphal <[email protected]>
netfilter: xt_checksum: ignore gso skbs
Martin Willi <[email protected]>
netfilter: xt_cluster: add dependency on conntrack module
Jann Horn <[email protected]>
bpf: 32-bit RSH verification must truncate input before the ALU op
Daniel Black <[email protected]>
mm: madvise(MADV_DODUMP): allow hugetlbfs pages
David Howells <[email protected]>
afs: Fix cell specification to permit an empty address list
Sudeep Holla <[email protected]>
firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero
Ilya Dryomov <[email protected]>
ceph: avoid a use-after-free in ceph_destroy_options()
Greentime Hu <[email protected]>
nds32: linker script: GCOV kernel may refers data in __exit
Naoya Horiguchi <[email protected]>
tools/vm/page-types.c: fix "defined but not used" warning
Naoya Horiguchi <[email protected]>
tools/vm/slabinfo.c: fix sign-compare warning
Greentime Hu <[email protected]>
nds32: fix build error because of wrong semicolon
Zong Li <[email protected]>
nds32: Fix get_user/put_user macro expand pointer problem
Zong Li <[email protected]>
nds32: Fix empty call trace
YueHaibing <[email protected]>
nds32: add NULL entry to the end of_device_id array
Greentime Hu <[email protected]>
nds32: fix logic for module
Ivan Mikhaylov <[email protected]>
net/ibm/emac: wrong emac_calc_base call was used by typo
Amir Goldstein <[email protected]>
fsnotify: fix ignore mask logic in fsnotify()
Emmanuel Grumbach <[email protected]>
mac80211: shorten the IBSS debug messages
Emmanuel Grumbach <[email protected]>
mac80211: don't Tx a deauth frame if the AP forbade Tx
Ilan Peer <[email protected]>
mac80211: Fix station bandwidth setting after channel switch
Emmanuel Grumbach <[email protected]>
mac80211: fix a race between restart and CSA flows
Dreyfuss, Haim <[email protected]>
mac80211: fix WMM TXOP calculation
Dan Carpenter <[email protected]>
cfg80211: fix a type issue in ieee80211_chandef_to_operating_class()
Lorenzo Bianconi <[email protected]>
mac80211: fix an off-by-one issue in A-MSDU max_subframe computation
Jon Kuhn <[email protected]>
fs/cifs: don't translate SFM_SLASH (U+F026) to backslash
Jia-Ju Bai <[email protected]>
net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
Masahiro Yamada <[email protected]>
i2c: uniphier-f: issue STOP only for last message or I2C_M_STOP
Masahiro Yamada <[email protected]>
i2c: uniphier: issue STOP only for last message or I2C_M_STOP
John Fastabend <[email protected]>
bpf: avoid misuse of psock when TCP_ULP_BPF collides with another ULP
Tushar Dave <[email protected]>
bpf: Fix bpf_msg_pull_data()
Thomas Falcon <[email protected]>
ibmvnic: Include missing return code checks in reset function
Sabrina Dubroca <[email protected]>
selftests: pmtu: detect correct binary to ping ipv6 addresses
Sabrina Dubroca <[email protected]>
selftests: pmtu: maximum MTU for vti4 is 2^16-1-20
Xiao Ni <[email protected]>
RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0
Shaohua Li <[email protected]>
md/raid5-cache: disable reshape completely
Dennis Zhou (Facebook) <[email protected]>
Revert "blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()"
Will Deacon <[email protected]>
ARC: atomics: unbork atomic_fetch_##op()
Vincent Whitchurch <[email protected]>
gpio: Fix crash due to registration race
Stefan Raspl <[email protected]>
tools/kvm_stat: fix updates for dead guests
Stefan Raspl <[email protected]>
tools/kvm_stat: fix handling of invalid paths in debugfs provider
Stefan Raspl <[email protected]>
tools/kvm_stat: fix python3 issues
Johannes Berg <[email protected]>
mac80211: always account for A-MSDU header changes
Lorenzo Bianconi <[email protected]>
mac80211: do not convert to A-MSDU if frag/subframe limited
Arunk Khandavalli <[email protected]>
cfg80211: nl80211_update_ft_ies() to validate NL80211_ATTR_IE
Paolo Abeni <[email protected]>
tc-testing: add test-cases for numeric and invalid control action
Baruch Siach <[email protected]>
net: mvpp2: initialize port of_node pointer
Chris Brandt <[email protected]>
sh_eth: Add R7S9210 support
Peng Li <[email protected]>
net: hns: add netif_carrier_off before change speed and duplex
Peng Li <[email protected]>
net: hns: add the code for cleaning pkt in chip
Cong Wang <[email protected]>
tipc: switch to rhashtable iterator
Daniel Borkmann <[email protected]>
bpf: fix sg shift repair start offset in bpf_msg_pull_data
Daniel Borkmann <[email protected]>
bpf: fix shift upon scatterlist ring wrap-around in bpf_msg_pull_data
Daniel Borkmann <[email protected]>
bpf: fix msg->data/data_end after sg shift repair in bpf_msg_pull_data
Alexey Khoroshilov <[email protected]>
gpio: dwapb: Fix error handling in dwapb_gpio_probe()
Hans de Goede <[email protected]>
gpiolib-acpi: Register GpioInt ACPI event handlers from a late_initcall
Andy Shevchenko <[email protected]>
gpiolib: acpi: Switch to cansleep version of GPIO library call
Sara Sharon <[email protected]>
mac80211: avoid kernel panic when building AMSDU from non-linear SKB
Yuan-Chi Pang <[email protected]>
mac80211: mesh: fix HWMP sequence numbering to follow standard
Michael Hennerich <[email protected]>
gpio: adp5588: Fix sleep-in-atomic-context bug
Daniel Borkmann <[email protected]>
bpf: fix several offset tests in bpf_msg_pull_data
Haim Dreyfuss <[email protected]>
nl80211: Pass center frequency in kHz instead of MHz
Haim Dreyfuss <[email protected]>
nl80211: Fix nla_put_u8 to u16 for NL80211_WMMR_TXOP
Jinbum Park <[email protected]>
mac80211_hwsim: Fix possible Spectre-v1 for hwsim_world_regdom_custom
Stanislaw Gruszka <[email protected]>
cfg80211: make wmm_rule part of the reg_rule structure
Danek Duvall <[email protected]>
mac80211_hwsim: correct use of IEEE80211_VHT_CAP_RXSTBC_X
Danek Duvall <[email protected]>
mac80211: correct use of IEEE80211_VHT_CAP_RXSTBC_X
John Fastabend <[email protected]>
bpf: sockmap, decrement copied count correctly in redirect error case
Daniel Borkmann <[email protected]>
bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg
Daniel Borkmann <[email protected]>
bpf, sockmap: fix potential use after free in bpf_tcp_close
Dan Carpenter <[email protected]>
scsi: aacraid: fix a signedness bug
Geert Uytterhoeven <[email protected]>
scsi: libata: Add missing newline at end of file
Varun Prakash <[email protected]>
scsi: csiostor: fix incorrect port capabilities
Varun Prakash <[email protected]>
scsi: csiostor: add a check for NULL pointer after kmalloc()
Anand Jain <[email protected]>
btrfs: btrfs_shrink_device should call commit transaction at the end
Johannes Berg <[email protected]>
cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
Paul Mackerras <[email protected]>
KVM: PPC: Book3S HV: Don't truncate HPTE index in xlate function
Robbie Ko <[email protected]>
Btrfs: fix unexpected failure of nocow buffered writes after snapshotting when low on space
Johannes Berg <[email protected]>
mac80211_hwsim: require at least one channel
Toke Høiland-Jørgensen <[email protected]>
mac80211: Run TXQ teardown code before de-registering interfaces
Mathieu Desnoyers <[email protected]>
rseq/selftests: fix parametrized test with -fpie
-------------
Diffstat:
Documentation/devicetree/bindings/net/sh_eth.txt | 1 + Makefile | 4 +- arch/arc/include/asm/atomic.h | 2 +- arch/arm64/include/asm/jump_label.h | 4 +- arch/hexagon/include/asm/bitops.h | 4 +- arch/hexagon/kernel/dma.c | 2 +- arch/nds32/include/asm/elf.h | 4 +- arch/nds32/include/asm/uaccess.h | 26 ++-- arch/nds32/kernel/atl2c.c | 3 +- arch/nds32/kernel/module.c | 4 +- arch/nds32/kernel/traps.c | 2 +- arch/nds32/kernel/vmlinux.lds.S | 12 ++ arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- arch/riscv/kernel/setup.c | 7 - arch/x86/events/intel/lbr.c | 4 + arch/x86/kernel/apm_32.c | 2 + block/blk-cgroup.c | 78 +++-------- drivers/ata/libata-core.c | 2 +- drivers/base/firmware_loader/main.c | 35 +++-- drivers/cpufreq/qcom-cpufreq-kryo.c | 4 +- drivers/crypto/caam/caamalg.c | 8 +- drivers/crypto/chelsio/chcr_algo.c | 32 +++-- drivers/crypto/chelsio/chcr_crypto.h | 2 + drivers/crypto/mxs-dcp.c | 53 ++++---- drivers/crypto/qat/qat_c3xxx/adf_drv.c | 6 +- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 6 +- drivers/crypto/qat/qat_c62x/adf_drv.c | 6 +- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 6 +- drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 6 +- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 6 +- drivers/firmware/arm_scmi/perf.c | 8 +- drivers/gpio/gpio-adp5588.c | 24 +++- drivers/gpio/gpio-dwapb.c | 1 + drivers/gpio/gpiolib-acpi.c | 86 +++++++----- drivers/gpio/gpiolib-of.c | 1 + drivers/gpio/gpiolib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 23 ++-- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 7 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 14 +- drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | 14 ++ drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c | 17 ++- drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h | 1 + drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c | 6 +- drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 17 ++- drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h | 4 +- .../gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c | 3 +- drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +- drivers/hid/hid-apple.c | 9 +- drivers/hid/hid-ids.h | 7 +- drivers/hid/hid-saitek.c | 2 + drivers/hid/hid-sensor-hub.c | 23 ++++ drivers/hid/i2c-hid/i2c-hid.c | 24 ++-- drivers/hid/intel-ish-hid/ipc/hw-ish.h | 1 + drivers/hid/intel-ish-hid/ipc/pci-ish.c | 1 + drivers/hv/connection.c | 8 +- drivers/i2c/busses/i2c-uniphier-f.c | 7 +- drivers/i2c/busses/i2c-uniphier.c | 7 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 13 +- drivers/iio/temperature/maxim_thermocouple.c | 1 - drivers/infiniband/core/ucma.c | 6 + drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 + drivers/infiniband/hw/bnxt_re/qplib_fp.c | 2 +- drivers/iommu/amd_iommu.c | 2 +- drivers/md/dm-raid.c | 144 ++++++++------------ drivers/md/dm-thin-metadata.c | 36 ++++- drivers/md/dm-thin.c | 73 ++++++++-- drivers/md/raid10.c | 5 +- drivers/md/raid5-log.h | 5 + drivers/md/raid5.c | 6 +- drivers/net/ethernet/amazon/ena/ena_com.c | 8 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 52 +++---- drivers/net/ethernet/amazon/ena/ena_netdev.h | 11 ++ drivers/net/ethernet/cadence/macb_main.c | 2 +- drivers/net/ethernet/hisilicon/hns/hnae.h | 2 + drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | 67 ++++++++- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 36 +++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 44 ++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h | 8 ++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 29 ++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | 3 + drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 23 ++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 1 + drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 23 ++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 1 + drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | 1 + drivers/net/ethernet/hisilicon/hns/hns_enet.c | 21 ++- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 + drivers/net/ethernet/ibm/emac/core.c | 6 +- drivers/net/ethernet/ibm/ibmvnic.c | 12 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 12 +- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/dev.c | 7 +- drivers/net/ethernet/realtek/r8169.c | 11 +- drivers/net/ethernet/renesas/sh_eth.c | 36 +++++ drivers/net/wireless/broadcom/b43/dma.c | 6 +- drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 50 +------ drivers/net/wireless/mac80211_hwsim.c | 12 +- drivers/nvme/target/rdma.c | 27 +++- drivers/pinctrl/qcom/pinctrl-msm.c | 24 ++++ drivers/s390/net/qeth_core_main.c | 5 +- drivers/s390/net/qeth_l2_main.c | 2 +- drivers/s390/net/qeth_l3_main.c | 2 +- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/csiostor/csio_hw.c | 71 +++++++--- drivers/scsi/csiostor/csio_hw.h | 1 + drivers/scsi/csiostor/csio_mb.c | 6 +- drivers/scsi/qedi/qedi.h | 7 +- drivers/scsi/qedi/qedi_main.c | 28 ++-- drivers/target/iscsi/iscsi_target.c | 9 +- drivers/target/iscsi/iscsi_target_login.c | 149 +++++++++++---------- drivers/target/iscsi/iscsi_target_login.h | 2 +- drivers/usb/gadget/udc/fotg210-udc.c | 15 ++- drivers/usb/host/xhci-plat.c | 27 ++-- drivers/usb/misc/yurex.c | 3 + drivers/xen/cpu_hotplug.c | 15 ++- drivers/xen/events/events_base.c | 2 +- drivers/xen/manage.c | 6 +- fs/afs/proc.c | 15 +-- fs/btrfs/ctree.h | 1 + fs/btrfs/disk-io.c | 1 + fs/btrfs/inode.c | 25 +--- fs/btrfs/ioctl.c | 16 +++ fs/btrfs/volumes.c | 7 +- fs/ceph/super.c | 16 ++- fs/cifs/cifs_unicode.c | 3 - fs/cifs/cifssmb.c | 11 +- fs/cifs/misc.c | 8 ++ fs/cifs/smb2ops.c | 2 +- fs/dcache.c | 2 +- fs/inode.c | 53 +++++++- fs/notify/fsnotify.c | 13 +- fs/ocfs2/dlm/dlmmaster.c | 4 +- fs/overlayfs/dir.c | 4 + fs/overlayfs/namei.c | 2 +- fs/overlayfs/overlayfs.h | 4 +- fs/overlayfs/util.c | 3 +- fs/proc/base.c | 14 ++ fs/xattr.c | 24 ++-- include/asm-generic/io.h | 3 +- include/linux/blk-cgroup.h | 1 - include/linux/fs.h | 6 +- include/net/cfg80211.h | 4 +- include/net/regulatory.h | 4 +- kernel/bpf/sockmap.c | 64 +++++---- kernel/bpf/verifier.c | 10 +- kernel/sched/topology.c | 5 +- mm/madvise.c | 2 +- net/core/filter.c | 57 ++++---- net/ipv4/netfilter/Kconfig | 8 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 8 +- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 8 +- net/mac80211/ibss.c | 22 +-- net/mac80211/main.c | 28 +++- net/mac80211/mesh_hwmp.c | 4 + net/mac80211/mlme.c | 70 +++++++++- net/mac80211/tx.c | 54 ++++---- net/mac80211/util.c | 11 +- net/netfilter/Kconfig | 12 +- net/netfilter/nf_conntrack_proto_dccp.c | 12 +- net/netfilter/nf_conntrack_proto_generic.c | 8 +- net/netfilter/nf_conntrack_proto_gre.c | 8 +- net/netfilter/nf_conntrack_proto_sctp.c | 14 +- net/netfilter/nf_conntrack_proto_tcp.c | 12 +- net/netfilter/nf_conntrack_proto_udp.c | 20 +-- net/netfilter/nf_tables_api.c | 1 + net/netfilter/nfnetlink_queue.c | 1 + net/netfilter/xt_CHECKSUM.c | 22 ++- net/netfilter/xt_cluster.c | 14 +- net/netfilter/xt_hashlimit.c | 18 +-- net/tipc/diag.c | 2 + net/tipc/netlink.c | 2 + net/tipc/socket.c | 76 +++++++---- net/tipc/socket.h | 2 + net/wireless/nl80211.c | 15 ++- net/wireless/reg.c | 91 ++----------- net/wireless/util.c | 2 +- sound/pci/hda/patch_realtek.c | 1 + tools/hv/hv_fcopy_daemon.c | 1 + tools/kvm/kvm_stat/kvm_stat | 25 +++- tools/perf/arch/powerpc/util/sym-handling.c | 4 +- tools/perf/util/annotate.c | 32 ++++- tools/perf/util/annotate.h | 1 + tools/perf/util/evsel.c | 5 +- tools/perf/util/trace-event-info.c | 2 +- tools/testing/selftests/net/pmtu.sh | 7 +- tools/testing/selftests/rseq/param_test.c | 19 +-- .../tc-testing/tc-tests/actions/police.json | 48 +++++++ tools/vm/page-types.c | 6 - tools/vm/slabinfo.c | 4 +- 189 files changed, 1892 insertions(+), 1029 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/168 rseq/selftests: fix parametrized test with -fpie
4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
commit ce01a1575f45bf319e374592656441021a7f5823 upstream.
On x86-64, the parametrized selftest code for rseq crashes with a segmentation fault when compiled with -fpie. This happens when the param_test binary is loaded at an address beyond 32-bit on x86-64.
The issue is caused by use of a 32-bit register to hold the address of the loop counter variable.
Fix this by using a 64-bit register to calculate the address of the loop counter variables as an offset from rip.
--- tools/testing/selftests/rseq/param_test.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
tools/testing/selftests/rseq/param_test.c +10 -9
@@ -56,15 +56,13 @@ unsigned int yield_mod_cnt, nr_abort; printf(fmt, ## __VA_ARGS__); \ } while (0) -#if defined(__x86_64__) || defined(__i386__) +#ifdef __i386__#define INJECT_ASM_REG "eax"#define RSEQ_INJECT_CLOBBER \ , INJECT_ASM_REG -#ifdef __i386__ -#define RSEQ_INJECT_ASM (n) \ "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" \ "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \
@@ -76,9 +74,16 @@ unsigned int yield_mod_cnt, nr_abort;#elif defined(__x86_64__) +#define INJECT_ASM_REG_P "rax" +#define INJECT_ASM_REG "eax" + +#define RSEQ_INJECT_CLOBBER \ + , INJECT_ASM_REG_P \ + , INJECT_ASM_REG +#define RSEQ_INJECT_ASM (n) \ - "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG "\n\t" \ - "mov (%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \ + "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG_P "\n\t" \ + "mov (%%" INJECT_ASM_REG_P "), %%" INJECT_ASM_REG "\n\t" \ "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \ "jz 333f\n\t" \ "222:\n\t" \
@@ -86,10 +91,6 @@ unsigned int yield_mod_cnt, nr_abort;"jnz 222b\n\t" \ "333:\n\t" -#else -#error "Unsupported architecture" -#endif -#elif defined(__ARMEL__)#define RSEQ_INJECT_INPUT \
Greg Kroah-Hartman
maintainerPATCH 2/168 mac80211: Run TXQ teardown code before de-registering interfaces
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Toke H�iland-J�rgensen" <[email protected]>
[ Upstream commit 77cfaf52eca5cac30ed029507e0cab065f888995 ]
The TXQ teardown code can reference the vif data structures that are stored in the netdev private memory area if there are still packets on the queue when it is being freed. Since the TXQ teardown code is run after the netdevs are freed, this can lead to a use-after-free. Fix this by moving the TXQ teardown code to earlier in ieee80211_unregister_hw().
--- net/mac80211/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/main.c +1 -1
@@ -1182,6 +1182,7 @@ void ieee80211_unregister_hw(struct ieee#if IS_ENABLED (CONFIG_IPV6 )unregister_inet6addr_notifier (&local->ifa6_notifier);#endif +ieee80211_txq_teardown_flows (local);rtnl_lock ();
@@ -1210,7 +1211,6 @@ void ieee80211_unregister_hw(struct ieeeskb_queue_purge (&local->skb_queue);skb_queue_purge (&local->skb_queue_unreliable);skb_queue_purge (&local->skb_queue_tdls_chsw); -ieee80211_txq_teardown_flows (local);destroy_workqueue (local->workqueue);wiphy_unregister (local->hw.wiphy);
Greg Kroah-Hartman
maintainerPATCH 3/168 mac80211_hwsim: require at least one channel
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 484004339d4514fde425f6e8a9f6a6cc979bb0c3 ]
Syzbot continues to try to create mac80211_hwsim radios, and manages to pass parameters that are later checked with WARN_ON in cfg80211 - catch another one in hwsim directly.
--- drivers/net/wireless/mac80211_hwsim.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/mac80211_hwsim.c +5 -0
@@ -3194,6 +3194,11 @@ static int hwsim_new_radio_nl(struct sk_if (info->attrs[HWSIM_ATTR_CHANNELS ]) param.channels =nla_get_u32 (info->attrs[HWSIM_ATTR_CHANNELS ]); +if (param.channels <1 ) { +GENL_SET_ERR_MSG (info,"must have at least one channel" ); +return -EINVAL ; + } +if (param.channels >CFG80211_MAX_NUM_DIFFERENT_CHANNELS ) {GENL_SET_ERR_MSG (info,"too many channels specified" );return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 4/168 Btrfs: fix unexpected failure of nocow buffered writes after snapshotting when low on space
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robbie Ko <[email protected]>
[ Upstream commit 8ecebf4d767e2307a946c8905278d6358eda35c3 ]
Commit e9894fd3e3b3 ("Btrfs: fix snapshot vs nocow writting") forced nocow writes to fallback to COW, during writeback, when a snapshot is created. This resulted in writes made before creating the snapshot to unexpectedly fail with ENOSPC during writeback when success (0) was returned to user space through the write system call.
The steps leading to this problem are:
1. When it's not possible to allocate data space for a write, the buffered write path checks if a NOCOW write is possible. If it is, it will not reserve space and success (0) is returned to user space.
2. Then when a snapshot is created, the root's will_be_snapshotted atomic is incremented and writeback is triggered for all inode's that belong to the root being snapshotted. Incrementing that atomic forces all previous writes to fallback to COW during writeback (running delalloc).
3. This results in the writeback for the inodes to fail and therefore setting the ENOSPC error in their mappings, so that a subsequent fsync on them will report the error to user space. So it's not a completely silent data loss (since fsync will report ENOSPC) but it's a very unexpected and undesirable behaviour, because if a clean shutdown/unmount of the filesystem happens without previous calls to fsync, it is expected to have the data present in the files after mounting the filesystem again.
So fix this by adding a new atomic named snapshot_force_cow to the root structure which prevents this behaviour and works the following way:
1. It is incremented when we start to create a snapshot after triggering writeback and before waiting for writeback to finish.
2. This new atomic is now what is used by writeback (running delalloc) to decide whether we need to fallback to COW or not. Because we incremented this new atomic after triggering writeback in the snapshot creation ioctl, we ensure that all buffered writes that happened before snapshot creation will succeed and not fallback to COW (which would make them fail with ENOSPC).
3. The existing atomic, will_be_snapshotted, is kept because it is used to force new buffered writes, that start after we started snapshotting, to reserve data space even when NOCOW is possible. This makes these writes fail early with ENOSPC when there's no available space to allocate, preventing the unexpected behaviour of writeback later failing with ENOSPC due to a fallback to COW mode.
--- fs/btrfs/ctree.h | 1 + fs/btrfs/disk-io.c | 1 + fs/btrfs/inode.c | 25 ++++--------------------- fs/btrfs/ioctl.c | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 21 deletions(-)
fs/btrfs/ctree.h +1 -0
@@ -1277,6 +1277,7 @@ struct btrfs_root {int send_in_progress;struct btrfs_subvolume_writers *subv_writers;atomic_t will_be_snapshotted; +atomic_t snapshot_force_cow;/* For qgroup metadata reserved space */ spinlock_t qgroup_meta_rsv_lock;
fs/btrfs/disk-io.c +1 -0
@@ -1217,6 +1217,7 @@ static void __setup_root(struct btrfs_roatomic_set (&root->log_batch,0 );refcount_set (&root->refs,1 );atomic_set (&root->will_be_snapshotted,0 ); +atomic_set (&root->snapshot_force_cow,0 ); root->log_transid =0 ; root->log_transid_committed =-1 ; root->last_log_commit =0 ;
fs/btrfs/inode.c +4 -21
@@ -1275,7 +1275,7 @@ static noinline int run_delalloc_nocow(su64 disk_num_bytes;u64 ram_bytes;int extent_type; -int ret, err; +int ret;int type;int nocow;int check_prev =1 ;
@@ -1407,11 +1407,8 @@ next_slot:* if there are pending snapshots for this root, * we fall into common COW way. */ -if (!nolock) { - err =btrfs_start_write_no_snapshotting (root); -if (!err) - goto out_check; - } +if (!nolock &&atomic_read (&root->snapshot_force_cow)) + goto out_check;/* * force cow if csum exists in the range. * this ensure that csum for a given extent are
@@ -1420,9 +1417,6 @@ next_slot: ret =csum_exist_in_range (fs_info, disk_bytenr, num_bytes);if (ret) { -if (!nolock) -btrfs_end_write_no_snapshotting (root); -/* * ret could be -EIO if the above fails to read * metadata.
@@ -1435,11 +1429,8 @@ next_slot:WARN_ON_ONCE (nolock); goto out_check; } -if (!btrfs_inc_nocow_writers (fs_info, disk_bytenr)) { -if (!nolock) -btrfs_end_write_no_snapshotting (root); +if (!btrfs_inc_nocow_writers (fs_info, disk_bytenr)) goto out_check; - } nocow =1 ; }else if (extent_type ==BTRFS_FILE_EXTENT_INLINE ) { extent_end = found_key.offset +
@@ -1453,8 +1444,6 @@ next_slot: out_check:if (extent_end <= start) { path->slots[0 ]++; -if (!nolock && nocow) -btrfs_end_write_no_snapshotting (root);if (nocow)btrfs_dec_nocow_writers (fs_info, disk_bytenr); goto next_slot;
@@ -1476,8 +1465,6 @@ out_check: end, page_started, nr_written,1 , NULL);if (ret) { -if (!nolock && nocow) -btrfs_end_write_no_snapshotting (root);if (nocow)btrfs_dec_nocow_writers (fs_info, disk_bytenr);
@@ -1497,8 +1484,6 @@ out_check: ram_bytes,BTRFS_COMPRESS_NONE , BTRFS_ORDERED_PREALLOC);if (IS_ERR (em)) { -if (!nolock && nocow) -btrfs_end_write_no_snapshotting (root);if (nocow)btrfs_dec_nocow_writers (fs_info, disk_bytenr);
@@ -1537,8 +1522,6 @@ out_check:EXTENT_CLEAR_DATA_RESV , PAGE_UNLOCK | PAGE_SET_PRIVATE2); -if (!nolock && nocow) -btrfs_end_write_no_snapshotting (root); cur_offset = extent_end;/*
fs/btrfs/ioctl.c +16 -0
@@ -761,6 +761,7 @@ static int create_snapshot(struct btrfs_struct btrfs_pending_snapshot *pending_snapshot;struct btrfs_trans_handle *trans;int ret; +bool snapshot_force_cow = false;if (!test_bit (BTRFS_ROOT_REF_COWS , &root->state))return -EINVAL ;
@@ -777,6 +778,11 @@ static int create_snapshot(struct btrfs_ goto free_pending; } +/* +* Force new buffered writes to reserve space even when NOCOW is +* possible. This is to avoid later writeback (running dealloc) to +* fallback to COW mode and unexpectedly fail with ENOSPC. +*/ atomic_inc (&root->will_be_snapshotted);smp_mb__after_atomic ();/* wait for no snapshot writes */
@@ -787,6 +793,14 @@ static int create_snapshot(struct btrfs_if (ret) goto dec_and_free; +/* +* All previous writes have started writeback in NOCOW mode, so now +* we force future writes to fallback to COW mode during snapshot +* creation. +*/ +atomic_inc (&root->snapshot_force_cow); + snapshot_force_cow = true; +btrfs_wait_ordered_extents (root,U64_MAX ,0 , (u64)-1 ); btrfs_init_block_rsv(&pending_snapshot->block_rsv,
@@ -851,6 +865,8 @@ static int create_snapshot(struct btrfs_ fail:btrfs_subvolume_release_metadata (fs_info, &pending_snapshot->block_rsv); dec_and_free: +if (snapshot_force_cow) +atomic_dec (&root->snapshot_force_cow);if (atomic_dec_and_test (&root->will_be_snapshotted))wake_up_var (&root->will_be_snapshotted); free_pending:
Greg Kroah-Hartman
maintainerPATCH 5/168 KVM: PPC: Book3S HV: Dont truncate HPTE index in xlate function
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
[ Upstream commit 46dec40fb741f00f1864580130779aeeaf24fb3d ]
This fixes a bug which causes guest virtual addresses to get translated to guest real addresses incorrectly when the guest is using the HPT MMU and has more than 256GB of RAM, or more specifically has a HPT larger than 2GB. This has showed up in testing as a failure of the host to emulate doorbell instructions correctly on POWER9 for HPT guests with more than 256GB of RAM.
The bug is that the HPTE index in kvmppc_mmu_book3s_64_hv_xlate() is stored as an int, and in forming the HPTE address, the index gets shifted left 4 bits as an int before being signed-extended to 64 bits. The simple fix is to make the variable a long int, matching the return type of kvmppc_hv_find_lock_hpte(), which is what calculates the index.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +1 -1
@@ -359,7 +359,7 @@ static int kvmppc_mmu_book3s_64_hv_xlateunsigned long pp, key;unsigned long v, orig_v, gr;__be64 *hptep; -int index; +long int index;int virtmode = vcpu->arch.shregs.msr & (data ?MSR_DR :MSR_IR );if (kvm_is_radix (vcpu->kvm))
Greg Kroah-Hartman
maintainerPATCH 6/168 cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 8a54d8fc160e67ad485d95a0322ce1221f80770a ]
Pointer arithmetic already adjusts by the size of the struct, so the sizeof() calculation is wrong. This is basically the same as Colin King's patch for similar code in the iwlwifi driver.
--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/wireless/reg.c +1 -2
@@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regcontinue ; regd->reg_rules[i].wmm_rule = d_wmm + - (src_regd->reg_rules[i].wmm_rule - s_wmm) / -sizeof (struct ieee80211_wmm_rule ); + (src_regd->reg_rules[i].wmm_rule - s_wmm); }return regd; }
Greg Kroah-Hartman
maintainerPATCH 7/168 btrfs: btrfs_shrink_device should call commit transaction at the end
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
[ Upstream commit 801660b040d132f67fac6a95910ad307c5929b49 ]
Test case btrfs/164 reports use-after-free:
[ 6712.084324] general protection fault: 0000 [#1] PREEMPT SMP .. [ 6712.195423] btrfs_update_commit_device_size+0x75/0xf0 [btrfs] [ 6712.201424] btrfs_commit_transaction+0x57d/0xa90 [btrfs] [ 6712.206999] btrfs_rm_device+0x627/0x850 [btrfs] [ 6712.211800] btrfs_ioctl+0x2b03/0x3120 [btrfs]
Reason for this is that btrfs_shrink_device adds the resized device to the fs_devices::resized_devices after it has called the last commit transaction.
So the list fs_devices::resized_devices is not empty when btrfs_shrink_device returns. Now the parent function btrfs_rm_device calls:
btrfs_close_bdev(device);
call_rcu(&device->rcu, free_device_rcu);and then does the transactio ncommit. It goes through the fs_devices::resized_devices in btrfs_update_commit_device_size and leads to use-after-free.
Fix this by making sure btrfs_shrink_device calls the last needed btrfs_commit_transaction before the return. This is consistent with what the grow counterpart does and this makes sure the on-disk state is persistent when the function returns.
--- fs/btrfs/volumes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +6 -1
@@ -4584,7 +4584,12 @@ again:/* Now btrfs_update_device() will change the on-disk size. */ ret =btrfs_update_device (trans, device); -btrfs_end_transaction (trans); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); +btrfs_end_transaction (trans); + }else { + ret =btrfs_commit_transaction (trans); + } done:btrfs_free_path (path);if (ret) {
Greg Kroah-Hartman
maintainerPATCH 8/168 scsi: csiostor: add a check for NULL pointer after kmalloc()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Varun Prakash <[email protected]>
[ Upstream commit 89809b028b6f54187b7d81a0c69b35d394c52e62 ]
--- drivers/scsi/csiostor/csio_hw.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/scsi/csiostor/csio_hw.c +9 -7
@@ -2275,8 +2275,8 @@ bye: }/* -* Returns -EINVAL if attempts to flash the firmware failed -* else returns 0, +* Returns -EINVAL if attempts to flash the firmware failed, +* -ENOMEM if memory allocation failed else returns 0, * if flashing was not attempted because the card had the * latest firmware ECANCELED is returned */
@@ -2304,6 +2304,13 @@ csio_hw_flash_fw(struct csio_hw *hw, intreturn -EINVAL ; } +/* allocate memory to read the header of the firmware on the +* card +*/ + card_fw =kmalloc (sizeof (*card_fw),GFP_KERNEL ); +if (!card_fw) +return -ENOMEM ; +if (csio_is_t5 (pci_dev->device &CSIO_HW_CHIP_MASK )) fw_bin_file =FW_FNAME_T5 ;else
@@ -2317,11 +2324,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int fw_size = fw->size; } -/* allocate memory to read the header of the firmware on the -* card -*/ - card_fw =kmalloc (sizeof (*card_fw),GFP_KERNEL ); -/* upgrade FW logic */ ret =csio_hw_prep_fw (hw, fw_info, fw_data, fw_size, card_fw, hw->fw_state, reset);
Greg Kroah-Hartman
maintainerPATCH 9/168 scsi: csiostor: fix incorrect port capabilities
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Varun Prakash <[email protected]>
[ Upstream commit 68bdc630721c40e908d22cffe07b5ca225a69f6e ]
- use be32_to_cpu() instead of ntohs() for 32 bit port capabilities.
- add a new function fwcaps32_to_caps16() to convert 32 bit port capabilities to 16 bit port capabilities.
--- drivers/scsi/csiostor/csio_hw.c | 55 ++++++++++++++++++++++++++++++++-------- drivers/scsi/csiostor/csio_hw.h | 1 drivers/scsi/csiostor/csio_mb.c | 6 ++-- 3 files changed, 48 insertions(+), 14 deletions(-)
drivers/scsi/csiostor/csio_hw.c +44 -11
@@ -1513,6 +1513,46 @@ fw_port_cap32_t fwcaps16_to_caps32(fw_po }/** +* fwcaps32_to_caps16 - convert 32-bit Port Capabilities to 16-bits +* @caps32: a 32-bit Port Capabilities value +* +* Returns the equivalent 16-bit Port Capabilities value. Note that +* not all 32-bit Port Capabilities can be represented in the 16-bit +* Port Capabilities and some fields/values may not make it. +*/ +fw_port_cap16_t fwcaps32_to_caps16 (fw_port_cap32_t caps32) +{ +fw_port_cap16_t caps16 =0 ; + +#define CAP32_TO_CAP16 (__cap) \ + do { \ + if (caps32 & FW_PORT_CAP32_##__cap) \ + caps16 |= FW_PORT_CAP_##__cap; \ + } while (0) + +CAP32_TO_CAP16 (SPEED_100M ); +CAP32_TO_CAP16 (SPEED_1G ); +CAP32_TO_CAP16 (SPEED_10G ); +CAP32_TO_CAP16 (SPEED_25G ); +CAP32_TO_CAP16 (SPEED_40G ); +CAP32_TO_CAP16 (SPEED_100G ); +CAP32_TO_CAP16 (FC_RX ); +CAP32_TO_CAP16 (FC_TX ); + CAP32_TO_CAP16(802_3_PAUSE); + CAP32_TO_CAP16(802_3_ASM_DIR); +CAP32_TO_CAP16 (ANEG ); +CAP32_TO_CAP16 (FORCE_PAUSE ); +CAP32_TO_CAP16 (MDIAUTO ); +CAP32_TO_CAP16 (MDISTRAIGHT ); +CAP32_TO_CAP16 (FEC_RS ); +CAP32_TO_CAP16 (FEC_BASER_RS ); + +#undef CAP32_TO_CAP16 + +return caps16; +} + +/** * lstatus_to_fwcap - translate old lstatus to 32-bit Port Capabilities * @lstatus: old FW_PORT_ACTION_GET_PORT_INFO lstatus value *
@@ -1670,7 +1710,7 @@ csio_enable_ports(struct csio_hw *hw) val =1 ;csio_mb_params (hw, mbp,CSIO_MB_DEFAULT_TMO , - hw->pfn,0 ,1 , ¶m, &val, false, + hw->pfn,0 ,1 , ¶m, &val, true,NULL );if (csio_mb_issue (hw, mbp)) {
@@ -1680,16 +1720,9 @@ csio_enable_ports(struct csio_hw *hw)return -EINVAL ; } -csio_mb_process_read_params_rsp (hw, mbp, &retval,1 , - &val); -if (retval !=FW_SUCCESS ) { -csio_err (hw,"FW_PARAMS_CMD(r) port:%d failed: 0x%x\n" , - portid, retval); -mempool_free (mbp, hw->mb_mempool); -return -EINVAL ; - } - - fw_caps = val; +csio_mb_process_read_params_rsp (hw, mbp, &retval, +0 ,NULL ); + fw_caps = retval ?FW_CAPS16 :FW_CAPS32 ; }/* Read PORT information */
drivers/scsi/csiostor/csio_hw.h +1 -0
@@ -639,6 +639,7 @@ int csio_handle_intr_status(struct csio_fw_port_cap32_t fwcap_to_fwspeed (fw_port_cap32_t acaps);fw_port_cap32_t fwcaps16_to_caps32 (fw_port_cap16_t caps16); +fw_port_cap16_t fwcaps32_to_caps16 (fw_port_cap32_t caps32);fw_port_cap32_t lstatus_to_fwcap (u32 lstatus);int csio_hw_start (struct csio_hw *);
drivers/scsi/csiostor/csio_mb.c +3 -3
@@ -368,7 +368,7 @@ csio_mb_port(struct csio_hw *hw, struct FW_CMD_LEN16_V(sizeof(*cmdp) / 16));if (fw_caps ==FW_CAPS16 ) - cmdp->u.l1cfg.rcap =cpu_to_be32 (fc); + cmdp->u.l1cfg.rcap =cpu_to_be32 (fwcaps32_to_caps16 (fc));else cmdp->u.l1cfg32.rcap32 =cpu_to_be32 (fc); }
@@ -395,8 +395,8 @@ csio_mb_process_read_port_rsp(struct csi *pcaps =fwcaps16_to_caps32 (ntohs (rsp->u.info.pcap)); *acaps =fwcaps16_to_caps32 (ntohs (rsp->u.info.acap)); }else { - *pcaps =ntohs (rsp->u.info32.pcaps32); - *acaps =ntohs (rsp->u.info32.acaps32); + *pcaps =be32_to_cpu (rsp->u.info32.pcaps32); + *acaps =be32_to_cpu (rsp->u.info32.acaps32); } } }
Greg Kroah-Hartman
maintainerPATCH 10/168 scsi: libata: Add missing newline at end of file
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 4e8065aa6c6f50765290be27ab8a64a4e44cb009 ]
With gcc 4.1.2:
drivers/ata/libata-core.c:7396:33: warning: no newline at end of file
--- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-core.c +1 -1
@@ -7403,4 +7403,4 @@ EXPORT_SYMBOL_GPL(ata_cable_unknown);EXPORT_SYMBOL_GPL (ata_cable_ignore);EXPORT_SYMBOL_GPL (ata_cable_sata);EXPORT_SYMBOL_GPL (ata_host_get); -EXPORT_SYMBOL_GPL (ata_host_put); +EXPORT_SYMBOL_GPL (ata_host_put);
Greg Kroah-Hartman
maintainerPATCH 11/168 scsi: aacraid: fix a signedness bug
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b9eb3b14f1dbf16bf27b6c1ffe6b8c00ec945c9b ]
The problem is that ->reset_state is a u8 but it can be set to -1 or -2 in aac_tmf_callback() and the error handling in aac_eh_target_reset() relies on it to be signed.
[mkp: fixed typo]
--- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aacraid/aacraid.h +1 -1
@@ -1346,7 +1346,7 @@ struct fib {struct aac_hba_map_info {__le32 rmw_nexus;/* nexus for native HBA devices */ u8 devtype;/* device type */ -u8 reset_state;/* 0 - no reset, 1..x - */ +s8 reset_state;/* 0 - no reset, 1..x - */ /* after xth TM LUN reset */ u16 qd_limit;u32 scan_counter;
Greg Kroah-Hartman
maintainerPATCH 12/168 bpf, sockmap: fix potential use after free in bpf_tcp_close
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit e06fa9c16ce4b740996189fa5610eabcee734e6c ]
bpf_tcp_close() we pop the psock linkage to a map via psock_map_pop(). A parallel update on the sock hash map can happen between psock_map_pop() and lookup_elem_raw() where we override the element under link->hash / link->key. In bpf_tcp_close()'s lookup_elem_raw() we subsequently only test whether an element is present, but we do not test whether the element is infact the element we were looking for.
We lock the sock in bpf_tcp_close() during that time, so do we hold the lock in sock_hash_update_elem(). However, the latter locks the sock which is newly updated, not the one we're purging from the hash table. This means that while one CPU is doing the lookup from bpf_tcp_close(), another CPU is doing the map update in parallel, dropped our sock from the hlist and released the psock.
Subsequently the first CPU will find the new sock and attempts to drop and release the old sock yet another time. Fix is that we need to check the elements for a match after lookup, similar as we do in the sock map. Note that the hash tab elems are freed via RCU, so access to their link->hash / link->key is fine since we're under RCU read side there.
--- kernel/bpf/sockmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/sockmap.c +1 -1
@@ -369,7 +369,7 @@ static void bpf_tcp_close(struct sock *s/* If another thread deleted this object skip deletion. * The refcnt on psock may or may not be zero. */ -if (l) { +if (l && l == link) {hlist_del_rcu (&link->hash_node);smap_release_sock (psock, link->sk);free_htab_elem (htab, link);
Greg Kroah-Hartman
maintainerPATCH 13/168 bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 15c480efab01197c965ce0562a43ffedd852b8f9 ]
In bpf_tcp_recvmsg() we first took a reference on the psock, however once we find that there are skbs in the normal socket's receive queue we return with processing them through tcp_recvmsg(). Problem is that we leak the taken reference on the psock in that path. Given we don't really do anything with the psock at this point, move the skb_queue_empty() test before we fetch the psock to fix this case.
--- kernel/bpf/sockmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/bpf/sockmap.c +2 -3
@@ -915,6 +915,8 @@ static int bpf_tcp_recvmsg(struct sock *if (unlikely (flags &MSG_ERRQUEUE ))return inet_recv_error (sk, msg, len, addr_len); +if (!skb_queue_empty (&sk->sk_receive_queue)) +return tcp_recvmsg (sk, msg, len, nonblock, flags, addr_len);rcu_read_lock (); psock =smap_psock_sk (sk);
@@ -925,9 +927,6 @@ static int bpf_tcp_recvmsg(struct sock * goto out;rcu_read_unlock (); -if (!skb_queue_empty (&sk->sk_receive_queue)) -return tcp_recvmsg (sk, msg, len, nonblock, flags, addr_len); -lock_sock (sk); bytes_ready:while (copied != len) {
Greg Kroah-Hartman
maintainerPATCH 14/168 bpf: sockmap, decrement copied count correctly in redirect error case
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Fastabend <[email protected]>
[ Upstream commit 501ca81760c204ec59b73e4a00bee5971fc0f1b1 ]
Currently, when a redirect occurs in sockmap and an error occurs in the redirect call we unwind the scatterlist once in the error path of bpf_tcp_sendmsg_do_redirect() and then again in sendmsg(). Then in the error path of sendmsg we decrement the copied count by the send size.
However, its possible we partially sent data before the error was generated. This can happen if do_tcp_sendpages() partially sends the scatterlist before encountering a memory pressure error. If this happens we need to decrement the copied value (the value tracking how many bytes were actually sent to TCP stack) by the number of remaining bytes _not_ the entire send size. Otherwise we risk confusing userspace.
Also we don't need two calls to free the scatterlist one is good enough. So remove the one in bpf_tcp_sendmsg_do_redirect() and then properly reduce copied by the number of remaining bytes which may in fact be the entire send size if no bytes were sent.
To do this use bool to indicate if free_start_sg() should do mem accounting or not.
--- kernel/bpf/sockmap.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
kernel/bpf/sockmap.c +22 -23
@@ -236,7 +236,7 @@ static int bpf_tcp_init(struct sock *sk) }static void smap_release_sock (struct smap_psock *psock,struct sock *sock); -static int free_start_sg (struct sock *sk,struct sk_msg_buff *md); +static int free_start_sg (struct sock *sk,struct sk_msg_buff *md,bool charge);static void bpf_tcp_release (struct sock *sk) {
@@ -248,7 +248,7 @@ static void bpf_tcp_release(struct sock goto out;if (psock->cork) { -free_start_sg (psock->sock, psock->cork); +free_start_sg (psock->sock, psock->cork, true);kfree (psock->cork); psock->cork =NULL ; }
@@ -330,14 +330,14 @@ static void bpf_tcp_close(struct sock *s close_fun = psock->save_close;if (psock->cork) { -free_start_sg (psock->sock, psock->cork); +free_start_sg (psock->sock, psock->cork, true);kfree (psock->cork); psock->cork =NULL ; }list_for_each_entry_safe (md, mtmp, &psock->ingress, list) {list_del (&md->list); -free_start_sg (psock->sock, md); +free_start_sg (psock->sock, md, true);kfree (md); }
@@ -570,14 +570,16 @@ static void free_bytes_sg(struct sock *s md->sg_start = i; } -static int free_sg (struct sock *sk,int start,struct sk_msg_buff *md) +static int free_sg (struct sock *sk,int start, +struct sk_msg_buff *md,bool charge) {struct scatterlist *sg = md->sg_data;int i = start, free =0 ;while (sg[i].length) { free += sg[i].length; -sk_mem_uncharge (sk, sg[i].length); +if (charge) +sk_mem_uncharge (sk, sg[i].length);if (!md->skb)put_page (sg_page (&sg[i])); sg[i].length =0 ;
@@ -594,9 +596,9 @@ static int free_sg(struct sock *sk, intreturn free; } -static int free_start_sg (struct sock *sk,struct sk_msg_buff *md) +static int free_start_sg (struct sock *sk,struct sk_msg_buff *md,bool charge) { -int free =free_sg (sk, md->sg_start, md); +int free =free_sg (sk, md->sg_start, md, charge); md->sg_start = md->sg_end;return free;
@@ -604,7 +606,7 @@ static int free_start_sg(struct sock *skstatic int free_curr_sg (struct sock *sk,struct sk_msg_buff *md) { -return free_sg (sk, md->sg_curr, md); +return free_sg (sk, md->sg_curr, md, true); }static int bpf_map_msg_verdict (int _rc,struct sk_msg_buff *md)
@@ -718,7 +720,7 @@ static int bpf_tcp_ingress(struct sock *list_add_tail (&r->list, &psock->ingress); sk->sk_data_ready (sk); }else { -free_start_sg (sk, r); +free_start_sg (sk, r, true);kfree (r); }
@@ -755,14 +757,10 @@ static int bpf_tcp_sendmsg_do_redirect(srelease_sock (sk); }smap_release_sock (psock, sk); -if (unlikely (err)) - goto out; -return 0 ; +return err; out_rcu:rcu_read_unlock (); -out: -free_bytes_sg (NULL , send, md, false); -return err; +return 0 ; }static inline void bpf_md_init (struct smap_psock *psock)
@@ -825,7 +823,7 @@ more_data:case __SK_PASS: err =bpf_tcp_push (sk, send, m, flags, true);if (unlikely (err)) { - *copied -=free_start_sg (sk, m); + *copied -=free_start_sg (sk, m, true);break ; }
@@ -848,16 +846,17 @@ more_data:lock_sock (sk);if (unlikely (err <0 )) { -free_start_sg (sk, m); +int free =free_start_sg (sk, m, false); + psock->sg_size =0 ;if (!cork) - *copied -= send; + *copied -= free; }else { psock->sg_size -= send; }if (cork) { -free_start_sg (sk, m); +free_start_sg (sk, m, true); psock->sg_size =0 ;kfree (m); m =NULL ;
@@ -1124,7 +1123,7 @@ wait_for_memory: err =sk_stream_wait_memory (sk, &timeo);if (err) {if (m && m != psock->cork) -free_start_sg (sk, m); +free_start_sg (sk, m, true); goto out_err; } }
@@ -1583,13 +1582,13 @@ static void smap_gc_work(struct work_strbpf_prog_put (psock->bpf_tx_msg);if (psock->cork) { -free_start_sg (psock->sock, psock->cork); +free_start_sg (psock->sock, psock->cork, true);kfree (psock->cork); }list_for_each_entry_safe (md, mtmp, &psock->ingress, list) {list_del (&md->list); -free_start_sg (psock->sock, md); +free_start_sg (psock->sock, md, true);kfree (md); }
Greg Kroah-Hartman
maintainerPATCH 15/168 mac80211: correct use of IEEE80211_VHT_CAP_RXSTBC_X
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danek Duvall <[email protected]>
[ Upstream commit 67d1ba8a6dc83d90cd58b89fa6cbf9ae35a0cf7f ]
The mod mask for VHT capabilities intends to say that you can override the number of STBC receive streams, and it does, but only by accident. The IEEE80211_VHT_CAP_RXSTBC_X aren't bits to be set, but values (albeit left-shifted). ORing the bits together gets the right answer, but we should use the _MASK macro here instead.
--- net/mac80211/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/mac80211/main.c +1 -4
@@ -470,10 +470,7 @@ static const struct ieee80211_vht_cap ma cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC | IEEE80211_VHT_CAP_SHORT_GI_80 | IEEE80211_VHT_CAP_SHORT_GI_160 | - IEEE80211_VHT_CAP_RXSTBC_1 | - IEEE80211_VHT_CAP_RXSTBC_2 | - IEEE80211_VHT_CAP_RXSTBC_3 | - IEEE80211_VHT_CAP_RXSTBC_4 | + IEEE80211_VHT_CAP_RXSTBC_MASK | IEEE80211_VHT_CAP_TXSTBC | IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
Greg Kroah-Hartman
maintainerPATCH 16/168 mac80211_hwsim: correct use of IEEE80211_VHT_CAP_RXSTBC_X
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danek Duvall <[email protected]>
[ Upstream commit d7c863a2f65e48f442379f4ee1846d52e0c5d24d ]
The mac80211_hwsim driver intends to say that it supports up to four STBC receive streams, but instead it ends up saying something undefined. The IEEE80211_VHT_CAP_RXSTBC_X macros aren't independent bits that can be ORed together, but values. In this case, _4 is the appropriate one to use.
--- drivers/net/wireless/mac80211_hwsim.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +0 -3
@@ -2699,9 +2699,6 @@ static int mac80211_hwsim_new_radio(struIEEE80211_VHT_CAP_SHORT_GI_80 |IEEE80211_VHT_CAP_SHORT_GI_160 |IEEE80211_VHT_CAP_TXSTBC | -IEEE80211_VHT_CAP_RXSTBC_1 | -IEEE80211_VHT_CAP_RXSTBC_2 | -IEEE80211_VHT_CAP_RXSTBC_3 |IEEE80211_VHT_CAP_RXSTBC_4 |IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK ; sband->vht_cap.vht_mcs.rx_mcs_map =
Greg Kroah-Hartman
maintainerPATCH 17/168 cfg80211: make wmm_rule part of the reg_rule structure
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
[ Upstream commit 38cb87ee47fb825f6c9d645c019f75b3905c0ab2 ]
Make wmm_rule be part of the reg_rule structure. This simplifies the code a lot at the cost of having bigger memory usage. However in most cases we have only few reg_rule's and when we do have many like in iwlwifi we do not save memory as it allocates a separate wmm_rule for each channel anyway.
This also fixes a bug reported in various places where somewhere the pointers were corrupted and we ended up doing a null-dereference.
--- drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 50 +---------- include/net/cfg80211.h | 4 include/net/regulatory.h | 4 net/mac80211/util.c | 8 - net/wireless/nl80211.c | 10 +- net/wireless/reg.c | 92 +++------------------ 6 files changed, 32 insertions(+), 136 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +5 -45
@@ -877,15 +877,12 @@ iwl_parse_nvm_mcc_info(struct device *deconst u8 *nvm_chan = cfg->nvm_type ==IWL_NVM_EXT ? iwl_ext_nvm_channels : iwl_nvm_channels;struct ieee80211_regdomain *regd, *copy_rd; -int size_of_regd, regd_to_copy, wmms_to_copy; -int size_of_wmms =0 ; +int size_of_regd, regd_to_copy;struct ieee80211_reg_rule *rule; -struct ieee80211_wmm_rule *wmm_rule, *d_wmm, *s_wmm;struct regdb_ptrs *regdb_ptrs;enum nl80211_band band;int center_freq, prev_center_freq =0 ; -int valid_rules =0 , n_wmms =0 ; -int i; +int valid_rules =0 ;bool new_rule;int max_num_ch = cfg->nvm_type ==IWL_NVM_EXT ?IWL_NVM_NUM_CHANNELS_EXT :IWL_NVM_NUM_CHANNELS ;
@@ -904,11 +901,7 @@ iwl_parse_nvm_mcc_info(struct device *desizeof (struct ieee80211_regdomain ) + num_of_ch *sizeof (struct ieee80211_reg_rule ); -if (geo_info &GEO_WMM_ETSI_5GHZ_INFO ) - size_of_wmms = - num_of_ch *sizeof (struct ieee80211_wmm_rule ); - - regd =kzalloc (size_of_regd + size_of_wmms,GFP_KERNEL ); + regd =kzalloc (size_of_regd,GFP_KERNEL );if (!regd)return ERR_PTR (-ENOMEM );
@@ -922,8 +915,6 @@ iwl_parse_nvm_mcc_info(struct device *de regd->alpha2[0 ] = fw_mcc >>8 ; regd->alpha2[1 ] = fw_mcc &0xff ; - wmm_rule = (struct ieee80211_wmm_rule *)((u8 *)regd + size_of_regd); -for (ch_idx =0 ; ch_idx < num_of_ch; ch_idx++) { ch_flags = (u16 )__le32_to_cpup (channels + ch_idx); band = (ch_idx < NUM_2GHZ_CHANNELS) ?
@@ -977,26 +968,10 @@ iwl_parse_nvm_mcc_info(struct device *de band == NL80211_BAND_2GHZ)continue ; -if (!reg_query_regdb_wmm (regd->alpha2, center_freq, - ®db_ptrs[n_wmms].token, wmm_rule)) { -/* Add only new rules */ -for (i =0 ; i < n_wmms; i++) { -if (regdb_ptrs[i].token == - regdb_ptrs[n_wmms].token) { - rule->wmm_rule = regdb_ptrs[i].rule; -break ; - } - } -if (i == n_wmms) { - rule->wmm_rule = wmm_rule; - regdb_ptrs[n_wmms++].rule = wmm_rule; - wmm_rule++; - } - } +reg_query_regdb_wmm (regd->alpha2, center_freq, rule); } regd->n_reg_rules = valid_rules; - regd->n_wmm_rules = n_wmms;/* * Narrow down regdom for unused regulatory rules to prevent hole
@@ -1005,28 +980,13 @@ iwl_parse_nvm_mcc_info(struct device *de regd_to_copy =sizeof (struct ieee80211_regdomain ) + valid_rules *sizeof (struct ieee80211_reg_rule ); - wmms_to_copy =sizeof (struct ieee80211_wmm_rule ) * n_wmms; - - copy_rd =kzalloc (regd_to_copy + wmms_to_copy,GFP_KERNEL ); + copy_rd =kzalloc (regd_to_copy,GFP_KERNEL );if (!copy_rd) { copy_rd =ERR_PTR (-ENOMEM ); goto out; }memcpy (copy_rd, regd, regd_to_copy); -memcpy ((u8 *)copy_rd + regd_to_copy, (u8 *)regd + size_of_regd, - wmms_to_copy); - - d_wmm = (struct ieee80211_wmm_rule *)((u8 *)copy_rd + regd_to_copy); - s_wmm = (struct ieee80211_wmm_rule *)((u8 *)regd + size_of_regd); - -for (i =0 ; i < regd->n_reg_rules; i++) { -if (!regd->reg_rules[i].wmm_rule) -continue ; - - copy_rd->reg_rules[i].wmm_rule = d_wmm + - (regd->reg_rules[i].wmm_rule - s_wmm); - } out:kfree (regdb_ptrs);
include/net/cfg80211.h +2 -2
@@ -4763,8 +4763,8 @@ const char *reg_initiator_name(enum nl80* * Return: 0 on success. -ENODATA. */ -int reg_query_regdb_wmm (char *alpha2,int freq,u32 *ptr, -struct ieee80211_wmm_rule *rule); +int reg_query_regdb_wmm (char *alpha2,int freq, +struct ieee80211_reg_rule *rule);/* * callbacks for asynchronous cfg80211 methods, notification
include/net/regulatory.h +2 -2
@@ -217,15 +217,15 @@ struct ieee80211_wmm_rule {struct ieee80211_reg_rule {struct ieee80211_freq_range freq_range;struct ieee80211_power_rule power_rule; -struct ieee80211_wmm_rule *wmm_rule; +struct ieee80211_wmm_rule wmm_rule;u32 flags;u32 dfs_cac_ms; +bool has_wmm; };struct ieee80211_regdomain {struct rcu_head rcu_head;u32 n_reg_rules; -u32 n_wmm_rules;char alpha2[3 ];enum nl80211_dfs_regions dfs_region;struct ieee80211_reg_rule reg_rules[];
net/mac80211/util.c +4 -4
@@ -1120,7 +1120,7 @@ void ieee80211_regulatory_limit_wmm_para {struct ieee80211_chanctx_conf *chanctx_conf;const struct ieee80211_reg_rule *rrule; -struct ieee80211_wmm_ac *wmm_ac; +const struct ieee80211_wmm_ac *wmm_ac;u16 center_freq =0 ; if (sdata->vif.type != NL80211_IFTYPE_AP &&
@@ -1139,15 +1139,15 @@ void ieee80211_regulatory_limit_wmm_para rrule =freq_reg_info (sdata->wdev.wiphy,MHZ_TO_KHZ (center_freq)); -if (IS_ERR_OR_NULL (rrule) || !rrule->wmm_rule) { +if (IS_ERR_OR_NULL (rrule) || !rrule->has_wmm) {rcu_read_unlock ();return ; }if (sdata->vif.type ==NL80211_IFTYPE_AP ) - wmm_ac = &rrule->wmm_rule->ap[ac]; + wmm_ac = &rrule->wmm_rule.ap[ac];else - wmm_ac = &rrule->wmm_rule->client[ac]; + wmm_ac = &rrule->wmm_rule.client[ac]; qparam->cw_min =max_t (u16, qparam->cw_min, wmm_ac->cw_min); qparam->cw_max =max_t (u16, qparam->cw_max, wmm_ac->cw_max); qparam->aifs =max_t (u8, qparam->aifs, wmm_ac->aifsn);
net/wireless/nl80211.c +5 -5
@@ -667,13 +667,13 @@ static int nl80211_msg_put_wmm_rules(str goto nla_put_failure;if (nla_put_u16 (msg,NL80211_WMMR_CW_MIN , - rule->wmm_rule->client[j].cw_min) || + rule->wmm_rule.client[j].cw_min) ||nla_put_u16 (msg,NL80211_WMMR_CW_MAX , - rule->wmm_rule->client[j].cw_max) || + rule->wmm_rule.client[j].cw_max) ||nla_put_u8 (msg,NL80211_WMMR_AIFSN , - rule->wmm_rule->client[j].aifsn) || + rule->wmm_rule.client[j].aifsn) ||nla_put_u8 (msg,NL80211_WMMR_TXOP , - rule->wmm_rule->client[j].cot)) + rule->wmm_rule.client[j].cot)) goto nla_put_failure;nla_nest_end (msg, nl_wmm_rule);
@@ -766,7 +766,7 @@ static int nl80211_msg_put_channel(strucconst struct ieee80211_reg_rule *rule =freq_reg_info (wiphy, chan->center_freq); -if (!IS_ERR (rule) && rule->wmm_rule) { +if (!IS_ERR_OR_NULL (rule) && rule->has_wmm) {if (nl80211_msg_put_wmm_rules (msg, rule)) goto nla_put_failure; }
net/wireless/reg.c +14 -78
174 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 18/168 mac80211_hwsim: Fix possible Spectre-v1 for hwsim_world_regdom_custom
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinbum Park <[email protected]>
[ Upstream commit 3a2af7cccbbaf2362db9053a946a6084e12bfa73 ]
User controls @idx which to be used as index of hwsim_world_regdom_custom. So, It can be exploited via Spectre-like attack. (speculative execution)
This kind of attack leaks address of hwsim_world_regdom_custom, It leads an attacker to bypass security mechanism such as KASLR.
So sanitize @idx before using it to prevent attack.
I leveraged strategy [1] to find and exploit this gadget.
[1] https://github.com/jinb-park/linux-exploit/tree/master/exploit-remaining-spectre-gadget/
--- drivers/net/wireless/mac80211_hwsim.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/mac80211_hwsim.c +4 -0
@@ -33,6 +33,7 @@#include <net/net_namespace.h> #include <net/netns/generic.h> #include <linux/rhashtable.h> +#include <linux/nospec.h> #include "mac80211_hwsim.h" #define WARN_QUEUE 100
@@ -3229,6 +3230,9 @@ static int hwsim_new_radio_nl(struct sk_kfree (hwname);return -EINVAL ; } + + idx =array_index_nospec (idx, +ARRAY_SIZE (hwsim_world_regdom_custom)); param.regd = hwsim_world_regdom_custom[idx]; }
Greg Kroah-Hartman
maintainerPATCH 19/168 nl80211: Fix nla_put_u8 to u16 for NL80211_WMMR_TXOP
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haim Dreyfuss <[email protected]>
[ Upstream commit d3c89bbc7491d5e288ca2993e999d24ba9ff52ad ]
TXOP (also known as Channel Occupancy Time) is u16 and should be added using nla_put_u16 instead of u8, fix that.
--- net/wireless/nl80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/wireless/nl80211.c +2 -2
@@ -672,8 +672,8 @@ static int nl80211_msg_put_wmm_rules(str rule->wmm_rule.client[j].cw_max) ||nla_put_u8 (msg,NL80211_WMMR_AIFSN , rule->wmm_rule.client[j].aifsn) || -nla_put_u8 (msg,NL80211_WMMR_TXOP , - rule->wmm_rule.client[j].cot)) +nla_put_u16 (msg,NL80211_WMMR_TXOP , + rule->wmm_rule.client[j].cot)) goto nla_put_failure;nla_nest_end (msg, nl_wmm_rule);
Greg Kroah-Hartman
maintainerPATCH 20/168 nl80211: Pass center frequency in kHz instead of MHz
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haim Dreyfuss <[email protected]>
[ Upstream commit b88d26d97c41680f7327e5fb8061ad0037877f40 ]
freq_reg_info expects to get the frequency in kHz. Instead we accidently pass it in MHz. Thus, currently the function always return ERR rule. Fix that.
--- net/wireless/nl80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/nl80211.c +1 -1
@@ -764,7 +764,7 @@ static int nl80211_msg_put_channel(strucif (large) {const struct ieee80211_reg_rule *rule = -freq_reg_info (wiphy, chan->center_freq); +freq_reg_info (wiphy,MHZ_TO_KHZ (chan->center_freq));if (!IS_ERR_OR_NULL (rule) && rule->has_wmm) {if (nl80211_msg_put_wmm_rules (msg, rule))
Greg Kroah-Hartman
maintainerPATCH 21/168 bpf: fix several offset tests in bpf_msg_pull_data
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 5b24109b0563d45094c470684c1f8cea1af269f8 ]
While recently going over bpf_msg_pull_data(), I noticed three issues which are fixed in here:
1) When we attempt to find the first scatterlist element (sge) for the start offset, we add len to the offset before we check for start < offset + len, whereas it should come after when we iterate to the next sge to accumulate the offsets. For example, given a start offset of 12 with a sge length of 8 for the first sge in the list would lead us to determine this sge as the first sge thinking it covers first 16 bytes where start is located, whereas start sits in subsequent sges so we would end up pulling in the wrong data.
2) After figuring out the starting sge, we have a short-cut test in !msg->sg_copy[i] && bytes <= len. This checks whether it's not needed to make the page at the sge private where we can just exit by updating msg->data and msg->data_end. However, the length test is not fully correct. bytes <= len checks whether the requested bytes (end - start offsets) fit into the sge's length. The part that is missing is that start must not be sge length aligned. Meaning, the start offset into the sge needs to be accounted as well on top of the requested bytes as otherwise we can access the sge out of bounds. For example the sge could have length of 8, our requested bytes could have length of 8, but at a start offset of 4, so we also would need to pull in 4 bytes of the next sge, when we jump to the out label we do set msg->data to sg_virt(&sg[i]) + start - offset and msg->data_end to msg->data + bytes which would be oob.
3) The subsequent bytes < copy test for finding the last sge has the same issue as in point 2) but also it tests for less than rather than less or equal to. Meaning if the sge length is of 8 and requested bytes of 8 while having the start aligned with the sge, we would unnecessarily go and pull in the next sge as well to make it private.
--- net/core/filter.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
net/core/filter.c +9 -5
@@ -2276,10 +2276,10 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg_buff *, msg, u32, start, u32, end, u64, flags) { unsigned int len = 0, offset = 0, copy = 0; +int bytes = end - start, bytes_sg_total;struct scatterlist *sg = msg->sg_data;int first_sg, last_sg, i, shift;unsigned char *p, *to, *from; -int bytes = end - start;struct page *page;if (unlikely (flags || end <= start))
@@ -2289,9 +2289,9 @@ BPF_CALL_4(bpf_msg_pull_data, i = msg->sg_start; do { len = sg[i].length; - offset += len; if (start < offset + len) break; + offset += len; i++; if (i == MAX_SKB_FRAGS) i = 0;
@@ -2300,7 +2300,11 @@ BPF_CALL_4(bpf_msg_pull_data,if (unlikely (start >= offset + len))return -EINVAL ; -if (!msg->sg_copy[i] && bytes <= len) +/* The start may point into the sg element so we need to also +* account for the headroom. +*/ + bytes_sg_total = start - offset + bytes; +if (!msg->sg_copy[i] && bytes_sg_total <= len) goto out; first_sg = i;
@@ -2320,12 +2324,12 @@ BPF_CALL_4(bpf_msg_pull_data, i++;if (i ==MAX_SKB_FRAGS ) i =0 ; -if (bytes < copy) +if (bytes_sg_total <= copy)break ; }while (i != msg->sg_end); last_sg = i; -if (unlikely (copy < end - start)) +if (unlikely (bytes_sg_total > copy))return -EINVAL ; page =alloc_pages (__GFP_NOWARN |GFP_ATOMIC ,get_order (copy));
Greg Kroah-Hartman
maintainerPATCH 22/168 gpio: adp5588: Fix sleep-in-atomic-context bug
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Hennerich <[email protected]>
[ Upstream commit 6537886cdc9a637711fd6da980dbb87c2c87c9aa ]
This fixes:
[BUG] gpio: gpio-adp5588: A possible sleep-in-atomic-context bug
in adp5588_gpio_write()
[BUG] gpio: gpio-adp5588: A possible sleep-in-atomic-context bug
in adp5588_gpio_direction_input()--- drivers/gpio/gpio-adp5588.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/gpio/gpio-adp5588.c +20 -4
@@ -41,6 +41,8 @@ struct adp5588_gpio {uint8_t int_en[3 ];uint8_t irq_mask[3 ];uint8_t irq_stat[3 ]; +uint8_t int_input_en[3 ]; +uint8_t int_lvl_cached[3 ]; };static int adp5588_gpio_read (struct i2c_client *client,u8 reg)
@@ -173,12 +175,28 @@ static void adp5588_irq_bus_sync_unlock(struct adp5588_gpio *dev =irq_data_get_irq_chip_data (d);int i; -for (i =0 ; i <=ADP5588_BANK (ADP5588_MAXGPIO ); i++) +for (i =0 ; i <=ADP5588_BANK (ADP5588_MAXGPIO ); i++) { +if (dev->int_input_en[i]) { +mutex_lock (&dev->lock); + dev->dir[i] &= ~dev->int_input_en[i]; + dev->int_input_en[i] =0 ; +adp5588_gpio_write (dev->client,GPIO_DIR1 + i, + dev->dir[i]); +mutex_unlock (&dev->lock); + } + +if (dev->int_lvl_cached[i] != dev->int_lvl[i]) { + dev->int_lvl_cached[i] = dev->int_lvl[i]; +adp5588_gpio_write (dev->client,GPIO_INT_LVL1 + i, + dev->int_lvl[i]); + } +if (dev->int_en[i] ^ dev->irq_mask[i]) { dev->int_en[i] = dev->irq_mask[i];adp5588_gpio_write (dev->client,GPIO_INT_EN1 + i, dev->int_en[i]); } + }mutex_unlock (&dev->irq_lock); }
@@ -221,9 +239,7 @@ static int adp5588_irq_set_type(struct ielse return -EINVAL ; -adp5588_gpio_direction_input (&dev->gpio_chip, gpio); -adp5588_gpio_write (dev->client,GPIO_INT_LVL1 + bank, - dev->int_lvl[bank]); + dev->int_input_en[bank] |= bit;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 23/168 mac80211: mesh: fix HWMP sequence numbering to follow standard
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan-Chi Pang <[email protected]>
[ Upstream commit 1f631c3201fe5491808df143d8fcba81b3197ffd ]
IEEE 802.11-2016 14.10.8.3 HWMP sequence numbering says:
If it is a target mesh STA, it shall update its own HWMP SN to maximum (current HWMP SN, target HWMP SN in the PREQ element) + 1 immediately before it generates a PREP element in response to a PREQ element.
--- net/mac80211/mesh_hwmp.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/mesh_hwmp.c +4 -0
@@ -572,6 +572,10 @@ static void hwmp_preq_frame_process(stru forward = false; reply = true; target_metric =0 ; + +if (SN_GT (target_sn, ifmsh->sn)) + ifmsh->sn = target_sn; +if (time_after (jiffies, ifmsh->last_sn_update +net_traversal_jiffies (sdata)) ||time_before (jiffies, ifmsh->last_sn_update)) {
Greg Kroah-Hartman
maintainerPATCH 24/168 mac80211: avoid kernel panic when building AMSDU from non-linear SKB
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sara Sharon <[email protected]>
[ Upstream commit 166ac9d55b0ab70b644e429be1f217fe8393cbd7 ]
When building building AMSDU from non-linear SKB, we hit a kernel panic when trying to push the padding to the tail. Instead, put the padding at the head of the next subframe. This also fixes the A-MSDU subframes to not have the padding accounted in the length field and not have pad at all for the last subframe, both required by the spec.
--- net/mac80211/tx.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
net/mac80211/tx.c +21 -17
@@ -3073,27 +3073,18 @@ void ieee80211_clear_fast_xmit(struct st }static bool ieee80211_amsdu_realloc_pad (struct ieee80211_local *local, -struct sk_buff *skb,int headroom, -int *subframe_len) +struct sk_buff *skb,int headroom) { -int amsdu_len = *subframe_len +sizeof (struct ethhdr ); -int padding = (4 - amsdu_len) &3 ; - -if (skb_headroom (skb) < headroom ||skb_tailroom (skb) < padding) { +if (skb_headroom (skb) < headroom) {I802_DEBUG_INC (local->tx_expand_skb_head); -if (pskb_expand_head (skb, headroom, padding,GFP_ATOMIC )) { +if (pskb_expand_head (skb, headroom,0 ,GFP_ATOMIC )) {wiphy_debug (local->hw.wiphy,"failed to reallocate TX buffer\n" );return false; } } -if (padding) { - *subframe_len += padding; -skb_put_zero (skb, padding); - } -return true; }
@@ -3117,8 +3108,7 @@ static bool ieee80211_amsdu_prepare_headif (info->control.flags &IEEE80211_TX_CTRL_AMSDU )return true; -if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (*amsdu_hdr), - &subframe_len)) +if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (*amsdu_hdr)))return false; data =skb_push (skb,sizeof (*amsdu_hdr));
@@ -3184,7 +3174,8 @@ static bool ieee80211_amsdu_aggregate(stvoid *data;bool ret = false;unsigned int orig_len; -int n =1 , nfrags; +int n =1 , nfrags, pad =0 ; +u16 hdrlen;if (!ieee80211_hw_check (&local->hw,TX_AMSDU ))return false;
@@ -3235,8 +3226,19 @@ static bool ieee80211_amsdu_aggregate(stif (max_frags && nfrags > max_frags) goto out; -if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (rfc1042_header) +2 , - &subframe_len)) +/* +* Pad out the previous subframe to a multiple of 4 by adding the +* padding to the next one, that's being added. Note that head->len +* is the length of the full A-MSDU, but that works since each time +* we add a new subframe we pad out the previous one to a multiple +* of 4 and thus it no longer matters in the next round. +*/ + hdrlen = fast_tx->hdr_len -sizeof (rfc1042_header); +if ((head->len - hdrlen) &3 ) + pad =4 - ((head->len - hdrlen) &3 ); + +if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (rfc1042_header) + +2 + pad)) goto out; ret = true;
@@ -3248,6 +3250,8 @@ static bool ieee80211_amsdu_aggregate(stmemcpy (data, &len,2 );memcpy (data +2 , rfc1042_header,sizeof (rfc1042_header)); +memset (skb_push (skb, pad),0 , pad); + head->len += skb->len; head->data_len += skb->len; *frag_tail = skb;
Greg Kroah-Hartman
maintainerPATCH 25/168 gpiolib: acpi: Switch to cansleep version of GPIO library call
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 993b9bc5c47fda86f8ab4e53d68c6fea5ff2764a ]
The commit ca876c7483b6
("gpiolib-acpi: make sure we trigger edge events at least once on boot")
added a initial value check for pin which is about to be locked as IRQ. Unfortunately, not all GPIO drivers can do that atomically. Thus, switch to cansleep version of the call. Otherwise we have a warning:
...
WARNING: CPU: 2 PID: 1408 at drivers/gpio/gpiolib.c:2883 gpiod_get_value+0x46/0x50 ... RIP: 0010:gpiod_get_value+0x46/0x50
...
The change tested on Intel Broxton with Whiskey Cove PMIC GPIO controller.
--- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +1 -1
@@ -186,7 +186,7 @@ static acpi_status acpi_gpiochip_requestgpiod_direction_input (desc); - value =gpiod_get_value (desc); + value =gpiod_get_value_cansleep (desc); ret =gpiochip_lock_as_irq (chip, pin);if (ret) {
Greg Kroah-Hartman
maintainerPATCH 26/168 gpiolib-acpi: Register GpioInt ACPI event handlers from a late_initcall
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit 78d3a92edbfb02e8cb83173cad84c3f2d5e1f070 ]
GpioInt ACPI event handlers may see there IRQ triggered immediately after requesting the IRQ (esp. level triggered ones). This means that they may run before any other (builtin) drivers have had a chance to register their OpRegion handlers, leading to errors like this:
[ 1.133274] ACPI Error: No handler for Region [PMOP] ((____ptrval____)) [UserDefinedRegion] (20180531/evregion-132) [ 1.133286] ACPI Error: Region UserDefinedRegion (ID=141) has no handler (20180531/exfldio-265) [ 1.133297] ACPI Error: Method parse/execution failed \_SB.GPO2._L01, AE_NOT_EXIST (20180531/psparse-516)
We already defer the manual initial trigger of edge triggered interrupts by running it from a late_initcall handler, this commit replaces this with deferring the entire acpi_gpiochip_request_interrupts() call till then, fixing the problem of some OpRegions not being registered yet.
Note that this removes the need to have a list of edge triggered handlers which need to run, since the entire acpi_gpiochip_request_interrupts() call is now delayed, acpi_gpiochip_request_interrupt() can call these directly now.
--- drivers/gpio/gpiolib-acpi.c | 84 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 35 deletions(-)
drivers/gpio/gpiolib-acpi.c +49 -35
@@ -25,7 +25,6 @@struct acpi_gpio_event {struct list_head node; -struct list_head initial_sync_list;acpi_handle handle;unsigned int pin;unsigned int irq;
@@ -49,10 +48,19 @@ struct acpi_gpio_chip {struct mutex conn_lock;struct gpio_chip *chip;struct list_head events; +struct list_head deferred_req_irqs_list_entry; }; -static LIST_HEAD (acpi_gpio_initial_sync_list); -static DEFINE_MUTEX (acpi_gpio_initial_sync_list_lock); +/* +* For gpiochips which call acpi_gpiochip_request_interrupts() before late_init +* (so builtin drivers) we register the ACPI GpioInt event handlers from a +* late_initcall_sync handler, so that other builtin drivers can register their +* OpRegions before the event handlers can run. This list contains gpiochips +* for which the acpi_gpiochip_request_interrupts() has been deferred. +*/ +static DEFINE_MUTEX (acpi_gpio_deferred_req_irqs_lock); +static LIST_HEAD (acpi_gpio_deferred_req_irqs_list); +static bool acpi_gpio_deferred_req_irqs_done;static int acpi_gpiochip_find (struct gpio_chip *gc,void *data) {
@@ -89,21 +97,6 @@ static struct gpio_desc *acpi_get_gpiod(return gpiochip_get_desc (chip, pin); } -static void acpi_gpio_add_to_initial_sync_list (struct acpi_gpio_event *event) -{ -mutex_lock (&acpi_gpio_initial_sync_list_lock); -list_add (&event->initial_sync_list, &acpi_gpio_initial_sync_list); -mutex_unlock (&acpi_gpio_initial_sync_list_lock); -} - -static void acpi_gpio_del_from_initial_sync_list (struct acpi_gpio_event *event) -{ -mutex_lock (&acpi_gpio_initial_sync_list_lock); -if (!list_empty (&event->initial_sync_list)) -list_del_init (&event->initial_sync_list); -mutex_unlock (&acpi_gpio_initial_sync_list_lock); -} -static irqreturn_t acpi_gpio_irq_handler (int irq,void *data) {struct acpi_gpio_event *event = data;
@@ -229,7 +222,6 @@ static acpi_status acpi_gpiochip_request event->irq = irq; event->pin = pin; event->desc = desc; -INIT_LIST_HEAD (&event->initial_sync_list); ret =request_threaded_irq (event->irq,NULL , handler, irqflags,"ACPI:Event" , event);
@@ -251,10 +243,9 @@ static acpi_status acpi_gpiochip_request* may refer to OperationRegions from other (builtin) drivers which * may be probed after us. */ -if (handler == acpi_gpio_irq_handler && - (((irqflags &IRQF_TRIGGER_RISING ) && value ==1 ) || - ((irqflags &IRQF_TRIGGER_FALLING ) && value ==0 ))) -acpi_gpio_add_to_initial_sync_list (event); +if (((irqflags &IRQF_TRIGGER_RISING ) && value ==1 ) || + ((irqflags &IRQF_TRIGGER_FALLING ) && value ==0 )) +handler (event->irq, event);return AE_OK ;
@@ -283,6 +274,7 @@ void acpi_gpiochip_request_interrupts(ststruct acpi_gpio_chip *acpi_gpio;acpi_handle handle;acpi_status status; +bool defer;if (!chip->parent || !chip->to_irq)return ;
@@ -295,6 +287,16 @@ void acpi_gpiochip_request_interrupts(stif (ACPI_FAILURE (status))return ; +mutex_lock (&acpi_gpio_deferred_req_irqs_lock); + defer = !acpi_gpio_deferred_req_irqs_done; +if (defer) +list_add (&acpi_gpio->deferred_req_irqs_list_entry, + &acpi_gpio_deferred_req_irqs_list); +mutex_unlock (&acpi_gpio_deferred_req_irqs_lock); + +if (defer) +return ; +acpi_walk_resources (handle,"_AEI" , acpi_gpiochip_request_interrupt, acpi_gpio); }
@@ -325,11 +327,14 @@ void acpi_gpiochip_free_interrupts(strucif (ACPI_FAILURE (status))return ; +mutex_lock (&acpi_gpio_deferred_req_irqs_lock); +if (!list_empty (&acpi_gpio->deferred_req_irqs_list_entry)) +list_del_init (&acpi_gpio->deferred_req_irqs_list_entry); +mutex_unlock (&acpi_gpio_deferred_req_irqs_lock); +list_for_each_entry_safe_reverse (event, ep, &acpi_gpio->events, node) {struct gpio_desc *desc; -acpi_gpio_del_from_initial_sync_list (event); -if (irqd_is_wakeup_set (irq_get_irq_data (event->irq)))disable_irq_wake (event->irq);
@@ -1049,6 +1054,7 @@ void acpi_gpiochip_add(struct gpio_chip acpi_gpio->chip = chip;INIT_LIST_HEAD (&acpi_gpio->events); +INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {
@@ -1195,20 +1201,28 @@ bool acpi_can_fallback_to_crs(struct acpreturn con_id ==NULL ; } -/* Sync the initial state of handlers after all builtin drivers have probed */ -static int acpi_gpio_initial_sync (void ) +/* Run deferred acpi_gpiochip_request_interrupts() */ +static int acpi_gpio_handle_deferred_request_interrupts (void ) { -struct acpi_gpio_event *event, *ep; +struct acpi_gpio_chip *acpi_gpio, *tmp; + +mutex_lock (&acpi_gpio_deferred_req_irqs_lock); +list_for_each_entry_safe (acpi_gpio, tmp, + &acpi_gpio_deferred_req_irqs_list, + deferred_req_irqs_list_entry) { +acpi_handle handle; -mutex_lock (&acpi_gpio_initial_sync_list_lock); -list_for_each_entry_safe (event, ep, &acpi_gpio_initial_sync_list, - initial_sync_list) { -acpi_evaluate_object (event->handle,NULL ,NULL ,NULL ); -list_del_init (&event->initial_sync_list); + handle =ACPI_HANDLE (acpi_gpio->chip->parent); +acpi_walk_resources (handle,"_AEI" , + acpi_gpiochip_request_interrupt, acpi_gpio); + +list_del_init (&acpi_gpio->deferred_req_irqs_list_entry); } -mutex_unlock (&acpi_gpio_initial_sync_list_lock); + + acpi_gpio_deferred_req_irqs_done = true; +mutex_unlock (&acpi_gpio_deferred_req_irqs_lock);return 0 ; }/* We must use _sync so that this runs after the first deferred_probe run */ -late_initcall_sync (acpi_gpio_initial_sync); +late_initcall_sync (acpi_gpio_handle_deferred_request_interrupts);
Greg Kroah-Hartman
maintainerPATCH 27/168 gpio: dwapb: Fix error handling in dwapb_gpio_probe()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
[ Upstream commit a618cf4800970d260871c159b7eec014a1da2e81 ]
If dwapb_gpio_add_port() fails in dwapb_gpio_probe(), gpio->clk is left undisabled.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/gpio/gpio-dwapb.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-dwapb.c +1 -0
@@ -726,6 +726,7 @@ static int dwapb_gpio_probe(struct platf out_unregister:dwapb_gpio_unregister (gpio);dwapb_irq_teardown (gpio); +clk_disable_unprepare (gpio->clk);return err; }
Greg Kroah-Hartman
maintainerPATCH 28/168 bpf: fix msg->data/data_end after sg shift repair in bpf_msg_pull_data
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 0e06b227c5221dd51b5569de93f3b9f532be4a32 ]
In the current code, msg->data is set as sg_virt(&sg[i]) + start - offset and msg->data_end relative to it as msg->data + bytes. Using iterator i to point to the updated starting scatterlist element holds true for some cases, however not for all where we'd end up pointing out of bounds. It is /correct/ for these ones:
1) When first finding the starting scatterlist element (sge) where we find that the page is already privately owned by the msg and where the requested bytes and headroom fit into the sge's length.
However, it's /incorrect/ for the following ones:
2) After we made the requested area private and updated the newly allocated page into first_sg slot of the scatterlist ring; when we find that no shift repair of the ring is needed where we bail out updating msg->data and msg->data_end. At that point i will point to last_sg, which in this case is the next elem of first_sg in the ring. The sge at that point might as well be invalid (e.g. i == msg->sg_end), which we use for setting the range of sg_virt(&sg[i]). The correct one would have been first_sg.
3) Similar as in 2) but when we find that a shift repair of the ring is needed. In this case we fix up all sges and stop once we've reached the end. In this case i will point to will point to the new msg->sg_end, and the sge at that point will be invalid. Again here the requested range sits in first_sg.
--- net/core/filter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/core/filter.c +2 -3
@@ -2300,6 +2300,7 @@ BPF_CALL_4(bpf_msg_pull_data,if (unlikely (start >= offset + len))return -EINVAL ; + first_sg = i;/* The start may point into the sg element so we need to also * account for the headroom. */
@@ -2307,8 +2308,6 @@ BPF_CALL_4(bpf_msg_pull_data,if (!msg->sg_copy[i] && bytes_sg_total <= len) goto out; - first_sg = i; -/* At this point we need to linearize multiple scatterlist * elements or a single shared page. Either way we need to * copy into a linear buffer exclusively owned by BPF. Then
@@ -2390,7 +2389,7 @@ BPF_CALL_4(bpf_msg_pull_data,if (msg->sg_end <0 ) msg->sg_end +=MAX_SKB_FRAGS ; out: - msg->data =sg_virt (&sg[i]) + start - offset; + msg->data =sg_virt (&sg[first_sg]) + start - offset; msg->data_end = msg->data + bytes;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 29/168 bpf: fix shift upon scatterlist ring wrap-around in bpf_msg_pull_data
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 2e43f95dd8ee62bc8bf57f2afac37fbd70c8d565 ]
If first_sg and last_sg wraps around in the scatterlist ring, then we need to account for that in the shift as well. E.g. crafting such msgs where this is the case leads to a hang as shift becomes negative. E.g. consider the following scenario:
first_sg := 14 |=> shift := -12 msg->sg_start := 10 last_sg := 3 | msg->sg_end := 5
round 1: i := 15, move_from := 3, sg[15] := sg[ 3] round 2: i := 0, move_from := -12, sg[ 0] := sg[-12] round 3: i := 1, move_from := -11, sg[ 1] := sg[-11] round 4: i := 2, move_from := -10, sg[ 2] := sg[-10] [...] round 13: i := 11, move_from := -1, sg[ 2] := sg[ -1] round 14: i := 12, move_from := 0, sg[ 2] := sg[ 0] round 15: i := 13, move_from := 1, sg[ 2] := sg[ 1] round 16: i := 14, move_from := 2, sg[ 2] := sg[ 2] round 17: i := 15, move_from := 3, sg[ 2] := sg[ 3]
[...]
This means we will loop forever and never hit the msg->sg_end condition to break out of the loop. When we see that the ring wraps around, then the shift should be MAX_SKB_FRAGS - first_sg + last_sg - 1. Meaning, the remainder slots from the tail of the ring and the head until last_sg combined.
--- net/core/filter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/filter.c +4 -1
@@ -2360,7 +2360,10 @@ BPF_CALL_4(bpf_msg_pull_data,* had a single entry though we can just replace it and * be done. Otherwise walk the ring and shift the entries. */ - shift = last_sg - first_sg -1 ; +WARN_ON_ONCE (last_sg == first_sg); + shift = last_sg > first_sg ? + last_sg - first_sg -1 : +MAX_SKB_FRAGS - first_sg + last_sg -1 ;if (!shift) goto out;
Greg Kroah-Hartman
maintainerPATCH 30/168 bpf: fix sg shift repair start offset in bpf_msg_pull_data
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit a8cf76a9023bc6709b1361d06bb2fae5227b9d68 ]
When we perform the sg shift repair for the scatterlist ring, we currently start out at i = first_sg + 1. However, this is not correct since the first_sg could point to the sge sitting at slot MAX_SKB_FRAGS - 1, and a subsequent i = MAX_SKB_FRAGS will access the scatterlist ring (sg) out of bounds. Add the sk_msg_iter_var() helper for iterating through the ring, and apply the same rule for advancing to the next ring element as we do elsewhere. Later work will use this helper also in other places.
--- net/core/filter.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
net/core/filter.c +13 -13
@@ -2272,6 +2272,13 @@ static const struct bpf_func_proto bpf_m .arg2_type = ARG_ANYTHING, }; +#define sk_msg_iter_var (var) \ + do { \ + var++; \ + if (var == MAX_SKB_FRAGS) \ + var = 0; \ + } while (0) +BPF_CALL_4 (bpf_msg_pull_data, struct sk_msg_buff *, msg, u32, start, u32, end, u64, flags) {
@@ -2292,9 +2299,7 @@ BPF_CALL_4(bpf_msg_pull_data,if (start < offset + len)break ; offset += len; - i++; -if (i ==MAX_SKB_FRAGS ) - i =0 ; +sk_msg_iter_var (i); }while (i != msg->sg_end);if (unlikely (start >= offset + len))
@@ -2320,9 +2325,7 @@ BPF_CALL_4(bpf_msg_pull_data,*/ do { copy += sg[i].length; - i++; -if (i ==MAX_SKB_FRAGS ) - i =0 ; +sk_msg_iter_var (i);if (bytes_sg_total <= copy)break ; }while (i != msg->sg_end);
@@ -2348,9 +2351,7 @@ BPF_CALL_4(bpf_msg_pull_data, sg[i].length =0 ;put_page (sg_page (&sg[i])); - i++; -if (i ==MAX_SKB_FRAGS ) - i =0 ; +sk_msg_iter_var (i); }while (i != last_sg); sg[first_sg].length = copy;
@@ -2367,7 +2368,8 @@ BPF_CALL_4(bpf_msg_pull_data,if (!shift) goto out; - i = first_sg +1 ; + i = first_sg; +sk_msg_iter_var (i); do { int move_from;
@@ -2384,9 +2386,7 @@ BPF_CALL_4(bpf_msg_pull_data, sg[move_from].page_link =0 ; sg[move_from].offset =0 ; - i++; -if (i ==MAX_SKB_FRAGS ) - i =0 ; +sk_msg_iter_var (i); }while (1 ); msg->sg_end -= shift;if (msg->sg_end <0 )
Greg Kroah-Hartman
maintainerPATCH 31/168 tipc: switch to rhashtable iterator
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 9a07efa9aea2f4a59f35da0785a4e6a6b5a96192 ]
syzbot reported a use-after-free in tipc_group_fill_sock_diag(), where tipc_group_fill_sock_diag() still reads tsk->group meanwhile tipc_group_delete() just deletes it in tipc_release().
tipc_nl_sk_walk() aims to lock this sock when walking each sock in the hash table to close race conditions with sock changes like this one, by acquiring tsk->sk.sk_lock.slock spinlock, unfortunately this doesn't work at all. All non-BH call path should take lock_sock() instead to make it work.
tipc_nl_sk_walk() brutally iterates with raw rht_for_each_entry_rcu() where RCU read lock is required, this is the reason why lock_sock() can't be taken on this path. This could be resolved by switching to rhashtable iterator API's, where taking a sleepable lock is possible. Also, the iterator API's are friendly for restartable calls like diag dump, the last position is remembered behind the scence, all we need to do here is saving the iterator into cb->args[].
I tested this with parallel tipc diag dump and thousands of tipc socket creation and release, no crash or memory leak.
--- net/tipc/diag.c | 2 + net/tipc/netlink.c | 2 + net/tipc/socket.c | 76 ++++++++++++++++++++++++++++++++++------------------- net/tipc/socket.h | 2 + 4 files changed, 56 insertions(+), 26 deletions(-)
net/tipc/diag.c +2 -0
@@ -84,7 +84,9 @@ static int tipc_sock_diag_handler_dump(sif (h->nlmsg_flags &NLM_F_DUMP ) {struct netlink_dump_control c = { + .start = tipc_dump_start, .dump = tipc_diag_dump, + .done = tipc_dump_done, };netlink_dump_start (net->diag_nlsk, skb, h, &c);return 0 ;
net/tipc/netlink.c +2 -0
@@ -167,7 +167,9 @@ static const struct genl_ops tipc_genl_v }, { .cmd = TIPC_NL_SOCK_GET, + .start = tipc_dump_start, .dumpit = tipc_nl_sk_dump, + .done = tipc_dump_done, .policy = tipc_nl_policy, }, {
net/tipc/socket.c +50 -26
95 lines not on this page · raw message
net/tipc/socket.h +2 -0
@@ -68,4 +68,6 @@ int tipc_nl_sk_walk(struct sk_buff *skb,int (*skb_handler)(struct sk_buff *skb,struct netlink_callback *cb, struct tipc_sock *tsk)); +int tipc_dump_start (struct netlink_callback *cb); +int tipc_dump_done (struct netlink_callback *cb);#endif
Greg Kroah-Hartman
maintainerPATCH 32/168 net: hns: add the code for cleaning pkt in chip
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Li <[email protected]>
[ Upstream commit 31fabbee8f5c658c3fa1603c66e9e4f51ea8c2c6 ]
If there are packets in hardware when changing the speed or duplex, it may cause hardware hang up.
This patch adds the code for waiting chip to clean the all pkts(TX & RX) in chip when the driver uses the function named "adjust link".
This patch cleans the pkts as follows:
1) close rx of chip, close tx of protocol stack.
2) wait rcb, ppe, mac to clean.
3) adjust link
4) open rx of chip, open tx of protocol stack.
--- drivers/net/ethernet/hisilicon/hns/hnae.h | 2 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | 67 ++++++++++++++++++++- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 36 +++++++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 44 +++++++++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h | 8 ++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 29 +++++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | 3 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 23 +++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 1 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 23 +++++++ drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 1 drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | 1 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 21 +++++- 13 files changed, 255 insertions(+), 4 deletions(-)
drivers/net/ethernet/hisilicon/hns/hnae.h +2 -0
@@ -486,6 +486,8 @@ struct hnae_ae_ops { u8 *auto_neg, u16 *speed, u8 *duplex);void (*toggle_ring_irq)(struct hnae_ring *ring,u32 val);void (*adjust_link)(struct hnae_handle *handle,int speed,int duplex); +bool (*need_adjust_link)(struct hnae_handle *handle, +int speed,int duplex);int (*set_loopback)(struct hnae_handle *handle,enum hnae_loop loop_mode,int en); void (*get_ring_bdnum_limit)(struct hnae_queue *queue,
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c +66 -1
90 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c +36 -0
@@ -257,6 +257,16 @@ static void hns_gmac_get_pausefrm_cfg(vo *tx_pause_en =dsaf_get_bit (pause_en,GMAC_PAUSE_EN_TX_FDFC_B ); } +static bool hns_gmac_need_adjust_link (void *mac_drv,enum mac_speed speed, +int duplex) +{ +struct mac_driver *drv = (struct mac_driver *)mac_drv; +struct hns_mac_cb *mac_cb = drv->mac_cb; + +return (mac_cb->speed != speed) || + (mac_cb->half_duplex == duplex); +} +static int hns_gmac_adjust_link (void *mac_drv,enum mac_speed speed,u32 full_duplex) {
@@ -309,6 +319,30 @@ static void hns_gmac_set_promisc(void *mhns_gmac_set_uc_match (mac_drv, en); } +int hns_gmac_wait_fifo_clean (void *mac_drv) +{ +struct mac_driver *drv = (struct mac_driver *)mac_drv; +int wait_cnt; +u32 val; + + wait_cnt =0 ; +while (wait_cnt++ <HNS_MAX_WAIT_CNT ) { + val =dsaf_read_dev (drv,GMAC_FIFO_STATE_REG ); +/* bit5~bit0 is not send complete pkts */ +if ((val &0x3f ) ==0 ) +break ; +usleep_range (100 ,200 ); + } + +if (wait_cnt >=HNS_MAX_WAIT_CNT ) { +dev_err (drv->dev, +"hns ge %d fifo was not idle.\n" , drv->mac_id); +return -EBUSY ; + } + +return 0 ; +} +static void hns_gmac_init (void *mac_drv) {u32 port;
@@ -690,6 +724,7 @@ void *hns_gmac_config(struct hns_mac_cb mac_drv->mac_disable = hns_gmac_disable; mac_drv->mac_free = hns_gmac_free; mac_drv->adjust_link = hns_gmac_adjust_link; + mac_drv->need_adjust_link = hns_gmac_need_adjust_link; mac_drv->set_tx_auto_pause_frames = hns_gmac_set_tx_auto_pause_frames; mac_drv->config_max_frame_length = hns_gmac_config_max_frame_length; mac_drv->mac_pausefrm_cfg = hns_gmac_pause_frm_cfg;
@@ -717,6 +752,7 @@ void *hns_gmac_config(struct hns_mac_cb mac_drv->get_strings = hns_gmac_get_strings; mac_drv->update_stats = hns_gmac_update_stats; mac_drv->set_promiscuous = hns_gmac_set_promisc; + mac_drv->wait_fifo_clean = hns_gmac_wait_fifo_clean;return (void *)mac_drv; }
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +44 -0
62 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h +8 -0
@@ -356,6 +356,9 @@ struct mac_driver {/*adjust mac mode of port,include speed and duplex*/ int (*adjust_link)(void *mac_drv,enum mac_speed speed,u32 full_duplex); +/* need adjust link */ +bool (*need_adjust_link)(void *mac_drv,enum mac_speed speed, +int duplex);/* config autoegotaite mode of port*/ void (*set_an_mode)(void *mac_drv,u8 enable);/* config loopbank mode */
@@ -394,6 +397,7 @@ struct mac_driver {void (*get_info)(void *mac_drv,struct mac_info *mac_info);void (*update_stats)(void *mac_drv); +int (*wait_fifo_clean)(void *mac_drv);enum mac_mode mac_mode;u8 mac_id;
@@ -427,6 +431,7 @@ void *hns_xgmac_config(struct hns_mac_cbint hns_mac_init (struct dsaf_device *dsaf_dev);void mac_adjust_link (struct net_device *net_dev); +bool hns_mac_need_adjust_link (struct hns_mac_cb *mac_cb,int speed,int duplex);void hns_mac_get_link_status (struct hns_mac_cb *mac_cb,u32 *link_status);int hns_mac_change_vf_addr (struct hns_mac_cb *mac_cb,u32 vmid,char *addr); int hns_mac_set_multi(struct hns_mac_cb *mac_cb,
@@ -463,5 +468,8 @@ int hns_mac_add_uc_addr(struct hns_mac_cint hns_mac_rm_uc_addr (struct hns_mac_cb *mac_cb,u8 vf_id,const unsigned char *addr);int hns_mac_clr_multicast (struct hns_mac_cb *mac_cb,int vfn); +void hns_mac_enable (struct hns_mac_cb *mac_cb,enum mac_commom_mode mode); +void hns_mac_disable (struct hns_mac_cb *mac_cb,enum mac_commom_mode mode); +int hns_mac_wait_fifo_clean (struct hns_mac_cb *mac_cb);#endif /* _HNS_DSAF_MAC_H */
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +29 -0
@@ -2733,6 +2733,35 @@ void hns_dsaf_set_promisc_tcam(struct ds soft_mac_entry->index = enable ? entry_index :DSAF_INVALID_ENTRY_IDX ; } +int hns_dsaf_wait_pkt_clean (struct dsaf_device *dsaf_dev,int port) +{ +u32 val, val_tmp; +int wait_cnt; + +if (port >=DSAF_SERVICE_NW_NUM ) +return 0 ; + + wait_cnt =0 ; +while (wait_cnt++ <HNS_MAX_WAIT_CNT ) { + val =dsaf_read_dev (dsaf_dev,DSAF_VOQ_IN_PKT_NUM_0_REG + + (port +DSAF_XGE_NUM ) *0x40 ); + val_tmp =dsaf_read_dev (dsaf_dev,DSAF_VOQ_OUT_PKT_NUM_0_REG + + (port +DSAF_XGE_NUM ) *0x40 ); +if (val == val_tmp) +break ; + +usleep_range (100 ,200 ); + } + +if (wait_cnt >=HNS_MAX_WAIT_CNT ) { +dev_err (dsaf_dev->dev,"hns dsaf clean wait timeout(%u - %u).\n" , + val, val_tmp); +return -EBUSY ; + } + +return 0 ; +} +/** * dsaf_probe - probo dsaf dev * @pdev: dasf platform device
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h +3 -0
@@ -44,6 +44,8 @@ struct hns_mac_cb;#define DSAF_ROCE_CREDIT_CHN 8#define DSAF_ROCE_CHAN_MODE 3 +#define HNS_MAX_WAIT_CNT 10000 +enum dsaf_roce_port_mode {DSAF_ROCE_6PORT_MODE ,DSAF_ROCE_4PORT_MODE ,
@@ -463,5 +465,6 @@ int hns_dsaf_rm_mac_addr(int hns_dsaf_clr_mac_mc_port (struct dsaf_device *dsaf_dev,u8 mac_id,u8 port_num); +int hns_dsaf_wait_pkt_clean (struct dsaf_device *dsaf_dev,int port);#endif /* __HNS_DSAF_MAIN_H__ */
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c +23 -0
@@ -274,6 +274,29 @@ static void hns_ppe_exc_irq_en(struct hndsaf_write_dev (ppe_cb,PPE_INTEN_REG , msk_vlue & vld_msk); } +int hns_ppe_wait_tx_fifo_clean (struct hns_ppe_cb *ppe_cb) +{ +int wait_cnt; +u32 val; + + wait_cnt =0 ; +while (wait_cnt++ <HNS_MAX_WAIT_CNT ) { + val =dsaf_read_dev (ppe_cb,PPE_CURR_TX_FIFO0_REG ) &0x3ffU ; +if (!val) +break ; + +usleep_range (100 ,200 ); + } + +if (wait_cnt >=HNS_MAX_WAIT_CNT ) { +dev_err (ppe_cb->dev,"hns ppe tx fifo clean wait timeout, still has %u pkt.\n" , + val); +return -EBUSY ; + } + +return 0 ; +} +/** * ppe_init_hw - init ppe * @ppe_cb: ppe device
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h +1 -0
@@ -100,6 +100,7 @@ struct ppe_common_cb { }; +int hns_ppe_wait_tx_fifo_clean (struct hns_ppe_cb *ppe_cb);int hns_ppe_init (struct dsaf_device *dsaf_dev);void hns_ppe_uninit (struct dsaf_device *dsaf_dev);
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c +23 -0
@@ -66,6 +66,29 @@ void hns_rcb_wait_fbd_clean(struct hnae_ "queue(%d) wait fbd(%d) clean fail!!\n", i, fbd_num); } +int hns_rcb_wait_tx_ring_clean (struct hnae_queue *qs) +{ +u32 head, tail; +int wait_cnt; + + tail =dsaf_read_dev (&qs->tx_ring,RCB_REG_TAIL ); + wait_cnt =0 ; +while (wait_cnt++ <HNS_MAX_WAIT_CNT ) { + head =dsaf_read_dev (&qs->tx_ring,RCB_REG_HEAD ); +if (tail == head) +break ; + +usleep_range (100 ,200 ); + } + +if (wait_cnt >=HNS_MAX_WAIT_CNT ) { +dev_err (qs->dev->dev,"rcb wait timeout, head not equal to tail.\n" ); +return -EBUSY ; + } + +return 0 ; +} +/** *hns_rcb_reset_ring_hw - ring reset *@q: ring struct pointer
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h +1 -0
@@ -136,6 +136,7 @@ void hns_rcbv2_int_clr_hw(struct hnae_quvoid hns_rcb_init_hw (struct ring_pair_cb *ring);void hns_rcb_reset_ring_hw (struct hnae_queue *q);void hns_rcb_wait_fbd_clean (struct hnae_queue **qs,int q_num,u32 flag); +int hns_rcb_wait_tx_ring_clean (struct hnae_queue *qs);u32 hns_rcb_get_rx_coalesced_frames (struct rcb_common_cb *rcb_common,u32 port_idx); u32 hns_rcb_get_tx_coalesced_frames(
drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h +1 -0
@@ -464,6 +464,7 @@#define RCB_RING_INTMSK_TX_OVERTIME_REG 0x000C4#define RCB_RING_INTSTS_TX_OVERTIME_REG 0x000C8 +#define GMAC_FIFO_STATE_REG 0x0000UL#define GMAC_DUPLEX_TYPE_REG 0x0008UL#define GMAC_FD_FC_TYPE_REG 0x000CUL#define GMAC_TX_WATER_LINE_REG 0x0010UL
drivers/net/ethernet/hisilicon/hns/hns_enet.c +18 -3
@@ -1212,11 +1212,26 @@ static void hns_nic_adjust_link(struct nstruct hnae_handle *h = priv->ae_handle;int state =1 ; +/* If there is no phy, do not need adjust link */ if (ndev->phydev) { - h->dev->ops->adjust_link (h, ndev->phydev->speed, - ndev->phydev->duplex); - state = ndev->phydev->link; +/* When phy link down, do nothing */ +if (ndev->phydev->link ==0 ) +return ; + +if (h->dev->ops->need_adjust_link (h, ndev->phydev->speed, + ndev->phydev->duplex)) { +/* because Hi161X chip don't support to change gmac +* speed and duplex with traffic. Delay 200ms to +* make sure there is no more data in chip FIFO. +*/ +netif_carrier_off (ndev); +msleep (200 ); + h->dev->ops->adjust_link (h, ndev->phydev->speed, + ndev->phydev->duplex); +netif_carrier_on (ndev); + } } + state = state && h->dev->ops->get_status (h);if (state != priv->link) {
Greg Kroah-Hartman
maintainerPATCH 33/168 net: hns: add netif_carrier_off before change speed and duplex
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Li <[email protected]>
[ Upstream commit 455c4401fe7a538facaffb35b906ce19f1ece474 ]
If there are packets in hardware when changing the speed or duplex, it may cause hardware hang up.
This patch adds netif_carrier_off before change speed and duplex in ethtool_ops.set_link_ksettings, and adds netif_carrier_on after complete the change.
--- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +2 -0
@@ -243,7 +243,9 @@ static int hns_nic_set_link_ksettings(st }if (h->dev->ops->adjust_link) { +netif_carrier_off (net_dev); h->dev->ops->adjust_link (h, (int )speed, cmd->base.duplex); +netif_carrier_on (net_dev);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 34/168 sh_eth: Add R7S9210 support
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Brandt <[email protected]>
[ Upstream commit 6e0bb04d0e4f597d8d8f4f21401a9636f2809fd1 ]
Add support for the R7S9210 which is part of the RZ/A2 series.
--- Documentation/devicetree/bindings/net/sh_eth.txt | 1 drivers/net/ethernet/renesas/sh_eth.c | 36 +++++++++++++++++++++++ 2 files changed, 37 insertions(+)
Documentation/devicetree/bindings/net/sh_eth.txt +1 -0
@@ -16,6 +16,7 @@ Required properties: "renesas,ether-r8a7794" if the device is a part of R8A7794 SoC. "renesas,gether-r8a77980" if the device is a part of R8A77980 SoC. "renesas,ether-r7s72100" if the device is a part of R7S72100 SoC. + "renesas,ether-r7s9210" if the device is a part of R7S9210 SoC. "renesas,rcar-gen1-ether" for a generic R-Car Gen1 device. "renesas,rcar-gen2-ether" for a generic R-Car Gen2 or RZ/G1 device.
drivers/net/ethernet/renesas/sh_eth.c +36 -0
@@ -807,6 +807,41 @@ static struct sh_eth_cpu_data r8a77980_d .magic = 1, .cexcr = 1, }; + +/* R7S9210 */ +static struct sh_eth_cpu_data r7s9210_data = { + .soft_reset = sh_eth_soft_reset, + + .set_duplex = sh_eth_set_duplex, + .set_rate = sh_eth_set_rate_rcar, + + .register_type =SH_ETH_REG_FAST_SH4 , + + .edtrr_trns =EDTRR_TRNS_ETHER , + .ecsr_value =ECSR_ICD , + .ecsipr_value =ECSIPR_ICDIP , + .eesipr_value =EESIPR_TWBIP |EESIPR_TABTIP |EESIPR_RABTIP | +EESIPR_RFCOFIP |EESIPR_ECIIP |EESIPR_FTCIP | +EESIPR_TDEIP |EESIPR_TFUFIP |EESIPR_FRIP | +EESIPR_RDEIP |EESIPR_RFOFIP |EESIPR_CNDIP | +EESIPR_DLCIP |EESIPR_CDIP |EESIPR_TROIP | +EESIPR_RMAFIP |EESIPR_RRFIP |EESIPR_RTLFIP | +EESIPR_RTSFIP |EESIPR_PREIP |EESIPR_CERFIP , + + .tx_check =EESR_FTC |EESR_CND |EESR_DLC |EESR_CD |EESR_TRO , + .eesr_err_check =EESR_TWB |EESR_TABT |EESR_RABT |EESR_RFE | +EESR_RDE |EESR_RFRMER |EESR_TFE |EESR_TDE , + + .fdr_value =0x0000070f , + + .apr =1 , + .mpr =1 , + .tpauser =1 , + .hw_swap =1 , + .rpadir =1 , + .no_ade =1 , + .xdfar_rw =1 , +};#endif /* CONFIG_OF */ static void sh_eth_set_rate_sh7724 (struct net_device *ndev)
@@ -3131,6 +3166,7 @@ static const struct of_device_id sh_eth_ { .compatible = "renesas,ether-r8a7794", .data = &rcar_gen2_data }, { .compatible = "renesas,gether-r8a77980", .data = &r8a77980_data }, { .compatible = "renesas,ether-r7s72100", .data = &r7s72100_data }, + { .compatible = "renesas,ether-r7s9210", .data = &r7s9210_data }, { .compatible = "renesas,rcar-gen1-ether", .data = &rcar_gen1_data }, { .compatible = "renesas,rcar-gen2-ether", .data = &rcar_gen2_data }, { }
Greg Kroah-Hartman
maintainerPATCH 35/168 net: mvpp2: initialize port of_node pointer
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baruch Siach <[email protected]>
[ Upstream commit c4053ef322081554765e1b708d6cdd8855e1d72d ]
Without a valid of_node in struct device we can't find the mvpp2 port device by its DT node. Specifically, this breaks of_find_net_device_by_node().
For example, the Armada 8040 based Clearfog GT-8K uses Marvell 88E6141 switch connected to the &cp1_eth2 port:
&cp1_mdio {
...
switch0: switch0@4 {
compatible = "marvell,mv88e6085";
...
ports {
...
port@5 {
reg = <5>;
label = "cpu";
ethernet = <&cp1_eth2>;
};
};
};
};Without this patch, dsa_register_switch() returns -EPROBE_DEFER because of_find_net_device_by_node() can't find the device_node of the &cp1_eth2 device.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
@@ -4685,6 +4685,7 @@ static int mvpp2_port_probe(struct platf dev->min_mtu =ETH_MIN_MTU ;/* 9704 == 9728 - 20 and rounding to 8 */ dev->max_mtu =MVPP2_BM_JUMBO_PKT_SIZE ; + dev->dev.of_node = port_node;/* Phylink isn't used w/ ACPI as of now */ if (port_node) {
Greg Kroah-Hartman
maintainerPATCH 36/168 tc-testing: add test-cases for numeric and invalid control action
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 25a8238f4cc8425d4aade4f9041be468d0e8aa2e ]
Only the police action allows us to specify an arbitrary numeric value for the control action. This change introduces an explicit test case for the above feature and then leverage it for testing the kernel behavior for invalid control actions (reject).
--- tools/testing/selftests/tc-testing/tc-tests/actions/police.json | 48 ++++++++++ 1 file changed, 48 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/actions/police.json +48 -0
@@ -313,6 +313,54 @@ ] }, { + "id": "6aaf", + "name": "Add police actions with conform-exceed control pass/pipe [with numeric values]", + "category": [ + "actions", + "police" + ], + "setup": [ + [ + "$TC actions flush action police", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 0/3 index 1", + "expExitCode": "0", + "verifyCmd": "$TC actions get action police index 1", + "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action pass/pipe", + "matchCount": "1", + "teardown": [ + "$TC actions flush action police" + ] + }, + { + "id": "29b1", + "name": "Add police actions with conform-exceed control <invalid>/drop", + "category": [ + "actions", + "police" + ], + "setup": [ + [ + "$TC actions flush action police", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 10/drop index 1", + "expExitCode": "255", + "verifyCmd": "$TC actions ls action police", + "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action ", + "matchCount": "0", + "teardown": [ + "$TC actions flush action police" + ] + }, + { "id": "c26f", "name": "Add police action with invalid peakrate value", "category": [
Greg Kroah-Hartman
maintainerPATCH 37/168 cfg80211: nl80211_update_ft_ies() to validate NL80211_ATTR_IE
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arunk Khandavalli <[email protected]>
[ Upstream commit 4f0223bfe9c3e62d8f45a85f1ef1b18a8a263ef9 ]
nl80211_update_ft_ies() tried to validate NL80211_ATTR_IE with is_valid_ie_attr() before dereferencing it, but that helper function returns true in case of NULL pointer (i.e., attribute not included). This can result to dereferencing a NULL pointer. Fix that by explicitly checking that NL80211_ATTR_IE is included.
--- net/wireless/nl80211.c | 1 + 1 file changed, 1 insertion(+)
net/wireless/nl80211.c +1 -0
@@ -12099,6 +12099,7 @@ static int nl80211_update_ft_ies(structreturn -EOPNOTSUPP ;if (!info->attrs[NL80211_ATTR_MDID ] || + !info->attrs[NL80211_ATTR_IE ] || !is_valid_ie_attr (info->attrs[NL80211_ATTR_IE ]))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 38/168 mac80211: do not convert to A-MSDU if frag/subframe limited
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 1eb507903665442360a959136dfa3234c43db085 ]
Do not start to aggregate packets in a A-MSDU frame (converting the first subframe to A-MSDU, adding the header) if max_tx_fragments or max_amsdu_subframes limits are already exceeded by it. In particular, this happens when drivers set the limit to 1 to avoid A-MSDUs at all.
--- net/mac80211/tx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/mac80211/tx.c +3 -3
@@ -3208,9 +3208,6 @@ static bool ieee80211_amsdu_aggregate(stif (skb->len + head->len > max_amsdu_len) goto out; -if (!ieee80211_amsdu_prepare_head (sdata, fast_tx, head)) - goto out; - nfrags =1 +skb_shinfo (skb)->nr_frags; nfrags +=1 +skb_shinfo (head)->nr_frags; frag_tail = &skb_shinfo (head)->frag_list;
@@ -3226,6 +3223,9 @@ static bool ieee80211_amsdu_aggregate(stif (max_frags && nfrags > max_frags) goto out; +if (!ieee80211_amsdu_prepare_head (sdata, fast_tx, head)) + goto out; +/* * Pad out the previous subframe to a multiple of 4 by adding the * padding to the next one, that's being added. Note that head->len
Greg Kroah-Hartman
maintainerPATCH 39/168 mac80211: always account for A-MSDU header changes
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit aa58acf325b4aadeecae2bfc90658273b47dbace ]
In the error path of changing the SKB headroom of the second A-MSDU subframe, we would not account for the already-changed length of the first frame that just got converted to be in A-MSDU format and thus is a bit longer now.
Fix this by doing the necessary accounting.
It would be possible to reorder the operations, but that would make the code more complex (to calculate the necessary pad), and the headroom expansion should not fail frequently enough to make that worthwhile.
--- net/mac80211/tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/mac80211/tx.c +7 -5
@@ -3239,7 +3239,7 @@ static bool ieee80211_amsdu_aggregate(stif (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (rfc1042_header) +2 + pad)) - goto out; + goto out_recalc; ret = true; data =skb_push (skb,ETH_ALEN +2 );
@@ -3256,11 +3256,13 @@ static bool ieee80211_amsdu_aggregate(st head->data_len += skb->len; *frag_tail = skb; - flow->backlog += head->len - orig_len; - tin->backlog_bytes += head->len - orig_len; - -fq_recalc_backlog (fq, tin, flow); +out_recalc: +if (head->len != orig_len) { + flow->backlog += head->len - orig_len; + tin->backlog_bytes += head->len - orig_len; +fq_recalc_backlog (fq, tin, flow); + } out:spin_unlock_bh (&fq->lock);
Greg Kroah-Hartman
maintainerPATCH 40/168 tools/kvm_stat: fix python3 issues
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Raspl <[email protected]>
[ Upstream commit 58f33cfe73076b6497bada4f7b5bda961ed68083 ]
Python3 returns a float for a regular division - switch to a division operator that returns an integer.
Furthermore, filters return a generator object instead of the actual list - wrap result in yet another list, which makes it still work in both, Python2 and 3.
--- tools/kvm/kvm_stat/kvm_stat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/kvm/kvm_stat/kvm_stat +3 -3
@@ -759,7 +759,7 @@ class DebugfsProvider(Provider): if len(vms) == 0: self.do_read = False - self.paths = filter(lambda x: "{}-".format(pid) in x, vms) + self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms)) else: self.paths = []
@@ -1219,10 +1219,10 @@ class Tui(object): (x, term_width) = self.screen.getmaxyx() row = 2 for line in text: - start = (term_width - len(line)) / 2 + start = (term_width - len(line)) // 2 self.screen.addstr(row, start, line) row += 1 - self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint, + self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint, curses.A_STANDOUT) self.screen.getkey()
Greg Kroah-Hartman
maintainerPATCH 41/168 tools/kvm_stat: fix handling of invalid paths in debugfs provider
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Raspl <[email protected]>
[ Upstream commit 617c66b9f236d20f11cecbb3f45e6d5675b2fae1 ]
When filtering by guest, kvm_stat displays garbage when the guest is destroyed - see sample output below.
We add code to remove the invalid paths from the providers, so at least no more garbage is displayed.
Here's a sample output to illustrate:
kvm statistics - pid 13986 (foo)
Event Total %Total CurAvg/s
diagnose_258 -2 0.0 0 deliver_program_interruption -3 0.0 0 diagnose_308 -4 0.0 0 halt_poll_invalid -91 0.0 -6 deliver_service_signal -244 0.0 -16 halt_successful_poll -250 0.1 -17 exit_pei -285 0.1 -19 exit_external_request -312 0.1 -21 diagnose_9c -328 0.1 -22 userspace_handled -713 0.1 -47 halt_attempted_poll -939 0.2 -62 deliver_emergency_signal -3126 0.6 -208 halt_wakeup -7199 1.5 -481 exit_wait_state -7379 1.5 -493 diagnose_500 -56499 11.5 -3757 exit_null -85491 17.4 -5685 diagnose_44 -133300 27.1 -8874 exit_instruction -195898 39.8 -13037
Total -492063
--- tools/kvm/kvm_stat/kvm_stat | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/kvm/kvm_stat/kvm_stat +8 -0
@@ -766,6 +766,13 @@ class DebugfsProvider(Provider): self.do_read = True self.reset() + def _verify_paths(self): + """Remove invalid paths""" + for path in self.paths: + if not os.path.exists(os.path.join(PATH_DEBUGFS_KVM, path)): + self.paths.remove(path) + continue + def read(self, reset=0, by_guest=0): """Returns a dict with format:'file name / field -> current value'.
@@ -780,6 +787,7 @@ class DebugfsProvider(Provider): # If no debugfs filtering support is available, then don't read. if not self.do_read: return results + self._verify_paths() paths = self.paths if self._pid == 0:
Greg Kroah-Hartman
maintainerPATCH 42/168 tools/kvm_stat: fix updates for dead guests
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Raspl <[email protected]>
[ Upstream commit 710ab11ad9329d2d4b044405e328c994b19a2aa9 ]
With pid filtering active, when a guest is removed e.g. via virsh shutdown, successive updates produce garbage.
Therefore, we add code to detect this case and prevent further body updates. Note that when displaying the help dialog via 'h' in this case, once we exit we're stuck with the 'Collecting data...' message till we remove the filter.
--- tools/kvm/kvm_stat/kvm_stat | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tools/kvm/kvm_stat/kvm_stat +10 -1
@@ -1170,6 +1170,9 @@ class Tui(object): return sorted_items + if not self._is_running_guest(self.stats.pid_filter): + # leave final data on screen + return row = 3 self.screen.move(row, 0) self.screen.clrtobot()
@@ -1327,6 +1330,12 @@ class Tui(object): msg = '"' + str(val) + '": Invalid value' self._refresh_header() + def _is_running_guest(self, pid): + """Check if pid is still a running process.""" + if not pid: + return True + return os.path.isdir(os.path.join('/proc/', str(pid))) + def _show_vm_selection_by_guest(self): """Draws guest selection mask.
@@ -1354,7 +1363,7 @@ class Tui(object): if not guest or guest == '0': break if guest.isdigit(): - if not os.path.isdir(os.path.join('/proc/', guest)): + if not self._is_running_guest(guest): msg = '"' + guest + '": Not a running process' continue pid = int(guest)
Greg Kroah-Hartman
maintainerPATCH 43/168 gpio: Fix crash due to registration race
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Whitchurch <[email protected]>
[ Upstream commit d49b48f088c323dbacae44dfbe56d9c985c8a2a1 ]
gpiochip_add_data_with_key() adds the gpiochip to the gpio_devices list before of_gpiochip_add() is called, but it's only the latter which sets the ->of_xlate function pointer. gpiochip_find() can be called by someone else between these two actions, and it can find the chip and call of_gpiochip_match_node_and_xlate() which leads to the following crash due to a NULL ->of_xlate().
Unhandled prefetch abort: page domain fault (0x01b) at 0x00000000
Modules linked in: leds_gpio(+) gpio_generic(+) CPU: 0 PID: 830 Comm: insmod Not tainted 4.18.0+ #43 Hardware name: ARM-Versatile Express PC is at (null) LR is at of_gpiochip_match_node_and_xlate+0x2c/0x38 Process insmod (pid: 830, stack limit = 0x(ptrval)) (of_gpiochip_match_node_and_xlate) from (gpiochip_find+0x48/0x84) (gpiochip_find) from (of_get_named_gpiod_flags+0xa8/0x238) (of_get_named_gpiod_flags) from (gpiod_get_from_of_node+0x2c/0xc8) (gpiod_get_from_of_node) from (devm_fwnode_get_index_gpiod_from_child+0xb8/0x144) (devm_fwnode_get_index_gpiod_from_child) from (gpio_led_probe+0x208/0x3c4 [leds_gpio]) (gpio_led_probe [leds_gpio]) from (platform_drv_probe+0x48/0x9c) (platform_drv_probe) from (really_probe+0x1d0/0x3d4) (really_probe) from (driver_probe_device+0x78/0x1c0) (driver_probe_device) from (__driver_attach+0x120/0x13c) (__driver_attach) from (bus_for_each_dev+0x68/0xb4) (bus_for_each_dev) from (bus_add_driver+0x1a8/0x268) (bus_add_driver) from (driver_register+0x78/0x10c) (driver_register) from (do_one_initcall+0x54/0x1fc) (do_one_initcall) from (do_init_module+0x64/0x1f4) (do_init_module) from (load_module+0x2198/0x26ac) (load_module) from (sys_finit_module+0xe0/0x110) (sys_finit_module) from (ret_fast_syscall+0x0/0x54)
One way to fix this would be to rework the hairy registration sequence in gpiochip_add_data_with_key(), but since I'd probably introduce a couple of new bugs if I attempted that, simply add a check for a non-NULL of_xlate function pointer in of_gpiochip_match_node_and_xlate(). This works since the driver looking for the gpio will simply fail to find the gpio and defer its probe and be reprobed when the driver which is registering the gpiochip has fully completed its probe.
--- drivers/gpio/gpiolib-of.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpiolib-of.c +1 -0
@@ -31,6 +31,7 @@ static int of_gpiochip_match_node_and_xlstruct of_phandle_args *gpiospec = data;return chip->gpiodev->dev.of_node == gpiospec->np && + chip->of_xlate && chip->of_xlate (chip, gpiospec,NULL ) >=0 ; }
Greg Kroah-Hartman
maintainerPATCH 44/168 ARC: atomics: unbork atomic_fetch_##op()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 3fcbb8260a87efb691d837e8cd24e81f65b3eb70 ]
In 4.19-rc1, Eugeniy reported weird boot and IO errors on ARC HSDK
| INFO: task syslogd:77 blocked for more than 10 seconds. | Not tainted 4.19.0-rc1-00007-gf213acea4e88 #40 | "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this | message. | syslogd D 0 77 76 0x00000000 | | Stack Trace: | __switch_to+0x0/0xac | __schedule+0x1b2/0x730 | io_schedule+0x5c/0xc0 | __lock_page+0x98/0xdc | find_lock_entry+0x38/0x100 | shmem_getpage_gfp.isra.3+0x82/0xbfc | shmem_fault+0x46/0x138 | handle_mm_fault+0x5bc/0x924 | do_page_fault+0x100/0x2b8 | ret_from_exception+0x0/0x8
He bisected to 84c6591103db ("locking/atomics, asm-generic/bitops/lock.h: Rewrite using atomic_fetch_*()")
This commit however only unmasked the real issue introduced by commit 4aef66c8ae9 ("locking/atomic, arch/arc: Fix build") which missed the retry-if-scond-failed branch in atomic_fetch_##op() macros.
The bisected commit started using atomic_fetch_##op() macros for building the rest of atomics.
--- arch/arc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/include/asm/atomic.h +1 -1
@@ -84,7 +84,7 @@ static inline int atomic_fetch_##op(int"1: llock %[orig], [%[ctr]] \n" \ " " #asm_op " %[val], %[orig], %[i] \n" \ " scond %[val], [%[ctr]] \n" \ - " \n" \ + " bnz 1b \n" \ : [val] "=&r" (val), \ [orig] "=&r" (orig) \ : [ctr] "r" (&v->counter), \
Greg Kroah-Hartman
maintainerPATCH 45/168 Revert "blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Dennis Zhou (Facebook)" <[email protected]>
[ Upstream commit 6b06546206868f723f2061d703a3c3c378dcbf4c ]
This reverts commit 4c6994806f708559c2812b73501406e21ae5dcd0.
Destroying blkgs is tricky because of the nature of the relationship. A blkg should go away when either a blkcg or a request_queue goes away. However, blkg's pin the blkcg to ensure they remain valid. To break this cycle, when a blkcg is offlined, blkgs put back their css ref. This eventually lets css_free() get called which frees the blkcg.
The above commit (4c6994806f70) breaks this order of events by trying to destroy blkgs in css_free(). As the blkgs still hold references to the blkcg, css_free() is never called.
The race between blkcg_bio_issue_check() and cgroup_rmdir() will be addressed in the following patch by delaying destruction of a blkg until all writeback associated with the blkcg has been finished.
--- block/blk-cgroup.c | 78 +++++++++------------------------------------ include/linux/blk-cgroup.h | 1 2 files changed, 16 insertions(+), 63 deletions(-)
block/blk-cgroup.c +16 -62
@@ -307,28 +307,11 @@ struct blkcg_gq *blkg_lookup_create(stru } } -static void blkg_pd_offline (struct blkcg_gq *blkg) -{ -int i; - -lockdep_assert_held (blkg->q->queue_lock); -lockdep_assert_held (&blkg->blkcg->lock); - -for (i =0 ; i <BLKCG_MAX_POLS ; i++) { -struct blkcg_policy *pol = blkcg_policy[i]; - -if (blkg->pd[i] && !blkg->pd[i]->offline && - pol->pd_offline_fn) { - pol->pd_offline_fn (blkg->pd[i]); - blkg->pd[i]->offline = true; - } - } -} -static void blkg_destroy (struct blkcg_gq *blkg) {struct blkcg *blkcg = blkg->blkcg;struct blkcg_gq *parent = blkg->parent; +int i;lockdep_assert_held (blkg->q->queue_lock);lockdep_assert_held (&blkcg->lock);
@@ -337,6 +320,13 @@ static void blkg_destroy(struct blkcg_gqWARN_ON_ONCE (list_empty (&blkg->q_node));WARN_ON_ONCE (hlist_unhashed (&blkg->blkcg_node)); +for (i =0 ; i <BLKCG_MAX_POLS ; i++) { +struct blkcg_policy *pol = blkcg_policy[i]; + +if (blkg->pd[i] && pol->pd_offline_fn) + pol->pd_offline_fn (blkg->pd[i]); + } +if (parent) {blkg_rwstat_add_aux (&parent->stat_bytes, &blkg->stat_bytes);blkg_rwstat_add_aux (&parent->stat_ios, &blkg->stat_ios);
@@ -379,7 +369,6 @@ static void blkg_destroy_all(struct requstruct blkcg *blkcg = blkg->blkcg;spin_lock (&blkcg->lock); -blkg_pd_offline (blkg);blkg_destroy (blkg);spin_unlock (&blkcg->lock); }
@@ -1006,54 +995,21 @@ static struct cftype blkcg_legacy_files[* @css: css of interest * * This function is called when @css is about to go away and responsible -* for offlining all blkgs pd and killing all wbs associated with @css. -* blkgs pd offline should be done while holding both q and blkcg locks. -* As blkcg lock is nested inside q lock, this function performs reverse -* double lock dancing. +* for shooting down all blkgs associated with @css. blkgs should be +* removed while holding both q and blkcg locks. As blkcg lock is nested +* inside q lock, this function performs reverse double lock dancing. * * This is the blkcg counterpart of ioc_release_fn(). */ static void blkcg_css_offline (struct cgroup_subsys_state *css) {struct blkcg *blkcg =css_to_blkcg (css); -struct blkcg_gq *blkg;spin_lock_irq (&blkcg->lock); -hlist_for_each_entry (blkg, &blkcg->blkg_list, blkcg_node) { -struct request_queue *q = blkg->q; - -if (spin_trylock (q->queue_lock)) { -blkg_pd_offline (blkg); -spin_unlock (q->queue_lock); - }else { -spin_unlock_irq (&blkcg->lock); -cpu_relax (); -spin_lock_irq (&blkcg->lock); - } - } - -spin_unlock_irq (&blkcg->lock); - -wb_blkcg_offline (blkcg); -} - -/** -* blkcg_destroy_all_blkgs - destroy all blkgs associated with a blkcg -* @blkcg: blkcg of interest -* -* This function is called when blkcg css is about to free and responsible for -* destroying all blkgs associated with @blkcg. -* blkgs should be removed while holding both q and blkcg locks. As blkcg lock -* is nested inside q lock, this function performs reverse double lock dancing. -*/ -static void blkcg_destroy_all_blkgs (struct blkcg *blkcg) -{ -spin_lock_irq (&blkcg->lock);while (!hlist_empty (&blkcg->blkg_list)) {struct blkcg_gq *blkg =hlist_entry (blkcg->blkg_list.first, - struct blkcg_gq, - blkcg_node); + struct blkcg_gq, blkcg_node);struct request_queue *q = blkg->q;if (spin_trylock (q->queue_lock)) {
@@ -1065,7 +1021,10 @@ static void blkcg_destroy_all_blkgs(struspin_lock_irq (&blkcg->lock); } } +spin_unlock_irq (&blkcg->lock); + +wb_blkcg_offline (blkcg); }static void blkcg_css_free (struct cgroup_subsys_state *css)
@@ -1073,8 +1032,6 @@ static void blkcg_css_free(struct cgroupstruct blkcg *blkcg =css_to_blkcg (css);int i; -blkcg_destroy_all_blkgs (blkcg); -mutex_lock (&blkcg_pol_mutex);list_del (&blkcg->all_blkcgs_node);
@@ -1412,11 +1369,8 @@ void blkcg_deactivate_policy(struct requlist_for_each_entry (blkg, &q->blkg_list, q_node) {if (blkg->pd[pol->plid]) { -if (!blkg->pd[pol->plid]->offline && - pol->pd_offline_fn) { +if (pol->pd_offline_fn) pol->pd_offline_fn (blkg->pd[pol->plid]); - blkg->pd[pol->plid]->offline = true; - } pol->pd_free_fn (blkg->pd[pol->plid]); blkg->pd[pol->plid] =NULL ; }
include/linux/blk-cgroup.h +0 -1
@@ -88,7 +88,6 @@ struct blkg_policy_data {/* the blkg and policy id this per-policy data belongs to */ struct blkcg_gq *blkg;int plid; -bool offline; };/*
Greg Kroah-Hartman
maintainerPATCH 46/168 md/raid5-cache: disable reshape completely
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaohua Li <[email protected]>
[ Upstream commit e254de6bcf3f5b6e78a92ac95fb91acef8adfe1a ]
We don't support reshape yet if an array supports log device. Previously we determine the fact by checking ->log. However, ->log could be NULL after a log device is removed, but the array is still marked to support log device. Don't allow reshape in this case too. User can disable log device support by setting 'consistency_policy' to 'resync' then do reshape.
--- drivers/md/raid5-log.h | 5 +++++ drivers/md/raid5.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/md/raid5-log.h +5 -0
@@ -46,6 +46,11 @@ extern int ppl_modify_log(struct r5confextern void ppl_quiesce (struct r5conf *conf,int quiesce);extern int ppl_handle_flush_request (struct r5l_log *log,struct bio *bio); +static inline bool raid5_has_log (struct r5conf *conf) +{ +return test_bit (MD_HAS_JOURNAL , &conf->mddev->flags); +} +static inline bool raid5_has_ppl (struct r5conf *conf) {return test_bit (MD_HAS_PPL , &conf->mddev->flags);
drivers/md/raid5.c +3 -3
@@ -735,7 +735,7 @@ static bool stripe_can_batch(struct stri {struct r5conf *conf = sh->raid_conf; -if (conf->log ||raid5_has_ppl (conf)) +if (raid5_has_log (conf) ||raid5_has_ppl (conf))return false;return test_bit (STRIPE_BATCH_READY , &sh->state) && !test_bit(STRIPE_BITMAP_PENDING, &sh->state) &&
@@ -7739,7 +7739,7 @@ static int raid5_resize(struct mddev *mdsector_t newsize;struct r5conf *conf = mddev->private; -if (conf->log ||raid5_has_ppl (conf)) +if (raid5_has_log (conf) ||raid5_has_ppl (conf))return -EINVAL ; sectors &= ~((sector_t )conf->chunk_sectors -1 ); newsize =raid5_size (mddev, sectors, mddev->raid_disks);
@@ -7790,7 +7790,7 @@ static int check_reshape(struct mddev *m {struct r5conf *conf = mddev->private; -if (conf->log ||raid5_has_ppl (conf)) +if (raid5_has_log (conf) ||raid5_has_ppl (conf))return -EINVAL ; if (mddev->delta_disks == 0 && mddev->new_layout == mddev->layout &&
Greg Kroah-Hartman
maintainerPATCH 47/168 RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiao Ni <[email protected]>
[ Upstream commit 1d0ffd264204eba1861865560f1f7f7a92919384 ]
In raid10 reshape_request it gets max_sectors in read_balance. If the underlayer disks have bad blocks, the max_sectors is less than last. It will call goto read_more many times. It calls raise_barrier(conf, sectors_done != 0) every time. In this condition sectors_done is not 0. So the value passed to the argument force of raise_barrier is true.
In raise_barrier it checks conf->barrier when force is true. If force is true and conf->barrier is 0, it panic. In this case reshape_request submits bio to under layer disks. And in the callback function of the bio it calls lower_barrier. If the bio finishes before calling raise_barrier again, it can trigger the BUG_ON.
Add one pair of raise_barrier/lower_barrier to fix this bug.
--- drivers/md/raid10.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/raid10.c +4 -1
@@ -4531,11 +4531,12 @@ static sector_t reshape_request(struct mallow_barrier (conf); } +raise_barrier (conf,0 ); read_more:/* Now schedule reads for blocks from sector_nr to last */ r10_bio =raid10_alloc_init_r10buf (conf); r10_bio->state =0 ; -raise_barrier (conf, sectors_done !=0 ); +raise_barrier (conf,1 );atomic_set (&r10_bio->remaining,0 ); r10_bio->mddev = mddev; r10_bio->sector = sector_nr;
@@ -4631,6 +4632,8 @@ read_more:if (sector_nr <= last) goto read_more; +lower_barrier (conf); +/* Now that we have done the whole section we can * update reshape_progress */
Greg Kroah-Hartman
maintainerPATCH 48/168 selftests: pmtu: maximum MTU for vti4 is 2^16-1-20
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 902b5417f28d955cdb4898df6ffaab15f56c5cff ]
Since commit 82612de1c98e ("ip_tunnel: restore binding to ifaces with a large mtu"), the maximum MTU for vti4 is based on IP_MAX_MTU instead of the mysterious constant 0xFFF8. This makes this selftest fail.
--- tools/testing/selftests/net/pmtu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/pmtu.sh +1 -1
@@ -334,7 +334,7 @@ test_pmtu_vti4_link_add_mtu() { fail=0 min=68 - max=$((65528 - 20)) + max=$((65535 - 20)) # Check invalid values first for v in $((min - 1)) $((max + 1)); do ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null
Greg Kroah-Hartman
maintainerPATCH 49/168 selftests: pmtu: detect correct binary to ping ipv6 addresses
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit c81c7012e0c769b5704c2b07bd5224965e76fb70 ]
Some systems don't have the ping6 binary anymore, and use ping for everything. Detect the absence of ping6 and try to use ping instead.
--- tools/testing/selftests/net/pmtu.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/net/pmtu.sh +4 -1
@@ -46,6 +46,9 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +# Some systems don't have a ping6 binary anymore +which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping) + tests=" pmtu_vti6_exception vti6: PMTU exceptions pmtu_vti4_exception vti4: PMTU exceptions
@@ -274,7 +277,7 @@ test_pmtu_vti6_exception() { mtu "${ns_b}" veth_b 4000 mtu "${ns_a}" vti6_a 5000 mtu "${ns_b}" vti6_b 5000 - ${ns_a} ping6 -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null + ${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null # Check that exception was created if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then
Greg Kroah-Hartman
maintainerPATCH 50/168 ibmvnic: Include missing return code checks in reset function
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Falcon <[email protected]>
[ Upstream commit f611a5b4a51fa36a0aa792be474f5d6aacaef7e3 ]
Check the return codes of these functions and halt reset in case of failure. The driver will remain in a dormant state until the next reset event, when device initialization will be re-attempted.
--- drivers/net/ethernet/ibm/ibmvnic.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +9 -3
@@ -1841,11 +1841,17 @@ static int do_reset(struct ibmvnic_adapt adapter->map_id =1 ;release_rx_pools (adapter);release_tx_pools (adapter); -init_rx_pools (netdev); -init_tx_pools (netdev); + rc =init_rx_pools (netdev); +if (rc) +return rc; + rc =init_tx_pools (netdev); +if (rc) +return rc;release_napi (adapter); -init_napi (adapter); + rc =init_napi (adapter); +if (rc) +return rc; }else { rc =reset_tx_pools (adapter);if (rc)
Greg Kroah-Hartman
maintainerPATCH 51/168 bpf: Fix bpf_msg_pull_data()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tushar Dave <[email protected]>
[ Upstream commit 9db39f4d4f94b61e4b64b077f6ddb2bdfb533a88 ]
Helper bpf_msg_pull_data() mistakenly reuses variable 'offset' while linearizing multiple scatterlist elements. Variable 'offset' is used to find first starting scatterlist element
i.e. msg->data = sg_virt(&sg[first_sg]) + start - offset"
Use different variable name while linearizing multiple scatterlist elements so that value contained in variable 'offset' won't get overwritten.
--- net/core/filter.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/core/filter.c +3 -4
@@ -2282,7 +2282,7 @@ static const struct bpf_func_proto bpf_mBPF_CALL_4 (bpf_msg_pull_data, struct sk_msg_buff *, msg, u32, start, u32, end, u64, flags) { -unsigned int len =0 , offset =0 , copy =0 ; +unsigned int len =0 , offset =0 , copy =0 , poffset =0 ;int bytes = end - start, bytes_sg_total;struct scatterlist *sg = msg->sg_data;int first_sg, last_sg, i, shift;
@@ -2338,16 +2338,15 @@ BPF_CALL_4(bpf_msg_pull_data,if (unlikely (!page))return -ENOMEM ; p =page_address (page); - offset =0 ; i = first_sg; do { from = sg_virt(&sg[i]); len = sg[i].length; - to = p + offset; + to = p + poffset; memcpy(to, from, len); - offset += len; + poffset += len; sg[i].length = 0; put_page(sg_page(&sg[i]));
Greg Kroah-Hartman
maintainerPATCH 52/168 bpf: avoid misuse of psock when TCP_ULP_BPF collides with another ULP
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Fastabend <[email protected]>
[ Upstream commit 597222f72a94118f593e4f32bf58ae7e049a0df1 ]
Currently we check sk_user_data is non NULL to determine if the sk exists in a map. However, this is not sufficient to ensure the psock or the ULP ops are not in use by another user, such as kcm or TLS. To avoid this when adding a sock to a map also verify it is of the correct ULP type. Additionally, when releasing a psock verify that it is the TCP_ULP_BPF type before releasing the ULP. The error case where we abort an update due to ULP collision can cause this error path.
For example,
__sock_map_ctx_update_elem()
[...]
err = tcp_set_ulp_id(sock, TCP_ULP_BPF) <- collides with TLS
if (err) <- so err out here
goto out_free
[...]
out_free:
smap_release_sock() <- calling tcp_cleanup_ulp releases the
TLS ULP incorrectly.
--- kernel/bpf/sockmap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/bpf/sockmap.c +11 -1
@@ -1465,10 +1465,16 @@ static void smap_destroy_psock(struct rcschedule_work (&psock->gc_work); } +static bool psock_is_smap_sk (struct sock *sk) +{ +return inet_csk (sk)->icsk_ulp_ops == &bpf_tcp_ulp_ops; +} +static void smap_release_sock (struct smap_psock *psock,struct sock *sock) {if (refcount_dec_and_test (&psock->refcnt)) { -tcp_cleanup_ulp (sock); +if (psock_is_smap_sk (sock)) +tcp_cleanup_ulp (sock);write_lock_bh (&sock->sk_callback_lock);smap_stop_sock (psock, sock);write_unlock_bh (&sock->sk_callback_lock);
@@ -1895,6 +1901,10 @@ static int __sock_map_ctx_update_elem(st* doesn't update user data. */ if (psock) { +if (!psock_is_smap_sk (sock)) { + err = -EBUSY ; + goto out_progs; + }if (READ_ONCE (psock->bpf_parse) && parse) { err = -EBUSY ; goto out_progs;
Greg Kroah-Hartman
maintainerPATCH 53/168 i2c: uniphier: issue STOP only for last message or I2C_M_STOP
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 38f5d8d8cbb2ffa2b54315118185332329ec891c ]
This driver currently emits a STOP if the next message is not I2C_MD_RD. It should not do it because it disturbs the I2C_RDWR ioctl, where read/write transactions are combined without STOP between.
Issue STOP only when the message is the last one _or_ flagged with I2C_M_STOP.
--- drivers/i2c/busses/i2c-uniphier.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-uniphier.c +2 -5
@@ -248,11 +248,8 @@ static int uniphier_i2c_master_xfer(strureturn ret;for (msg = msgs; msg < emsg; msg++) { -/* If next message is read, skip the stop condition */ -bool stop = !(msg +1 < emsg && msg[1 ].flags &I2C_M_RD ); -/* but, force it if I2C_M_STOP is set */ -if (msg->flags &I2C_M_STOP ) - stop = true; +/* Emit STOP if it is the last message or I2C_M_STOP is set. */ +bool stop = (msg +1 == emsg) || (msg->flags &I2C_M_STOP ); ret =uniphier_i2c_master_xfer_one (adap, msg, stop);if (ret)
Greg Kroah-Hartman
maintainerPATCH 54/168 i2c: uniphier-f: issue STOP only for last message or I2C_M_STOP
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 4c85609b08c4761eca0a40fd7beb06bc650f252d ]
This driver currently emits a STOP if the next message is not I2C_MD_RD. It should not do it because it disturbs the I2C_RDWR ioctl, where read/write transactions are combined without STOP between.
Issue STOP only when the message is the last one _or_ flagged with I2C_M_STOP.
--- drivers/i2c/busses/i2c-uniphier-f.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-uniphier-f.c +2 -5
@@ -401,11 +401,8 @@ static int uniphier_fi2c_master_xfer(strreturn ret;for (msg = msgs; msg < emsg; msg++) { -/* If next message is read, skip the stop condition */ -bool stop = !(msg +1 < emsg && msg[1 ].flags &I2C_M_RD ); -/* but, force it if I2C_M_STOP is set */ -if (msg->flags &I2C_M_STOP ) - stop = true; +/* Emit STOP if it is the last message or I2C_M_STOP is set. */ +bool stop = (msg +1 == emsg) || (msg->flags &I2C_M_STOP ); ret =uniphier_fi2c_master_xfer_one (adap, msg, stop);if (ret)
Greg Kroah-Hartman
maintainerPATCH 55/168 net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia-Ju Bai <[email protected]>
[ Upstream commit 16fe10cf92783ed9ceb182d6ea2b8adf5e8ec1b8 ]
The kernel module may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.16 are:
[FUNC] usleep_range drivers/net/ethernet/cadence/macb_main.c, 648:
usleep_range in macb_halt_txdrivers/net/ethernet/cadence/macb_main.c, 730:
macb_halt_tx in macb_tx_error_taskdrivers/net/ethernet/cadence/macb_main.c, 721:
_raw_spin_lock_irqsave in macb_tx_error_task
To fix this bug, usleep_range() is replaced with udelay().
This bug is found by my static analysis tool DSAC.
--- drivers/net/ethernet/cadence/macb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -648,7 +648,7 @@ static int macb_halt_tx(struct macb *bp)if (!(status &MACB_BIT (TGO )))return 0 ; -usleep_range (10 ,250 ); +udelay (250 ); }while (time_before (halt_time, timeout));return -ETIMEDOUT ;
Greg Kroah-Hartman
maintainerPATCH 56/168 fs/cifs: dont translate SFM_SLASH (U+F026) to backslash
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Kuhn <[email protected]>
[ Upstream commit c15e3f19a6d5c89b1209dc94b40e568177cb0921 ]
When a Mac client saves an item containing a backslash to a file server the backslash is represented in the CIFS/SMB protocol as as U+F026. Before this change, listing a directory containing an item with a backslash in its name will return that item with the backslash represented with a true backslash character (U+005C) because convert_sfm_character mapped U+F026 to U+005C when interpretting the CIFS/SMB protocol response. However, attempting to open or stat the path using a true backslash will result in an error because convert_to_sfm_char does not map U+005C back to U+F026 causing the CIFS/SMB request to be made with the backslash represented as U+005C.
This change simply prevents the U+F026 to U+005C conversion from happenning. This is analogous to how the code does not do any translation of UNI_SLASH (U+F000).
--- fs/cifs/cifs_unicode.c | 3 --- 1 file changed, 3 deletions(-)
fs/cifs/cifs_unicode.c +0 -3
@@ -105,9 +105,6 @@ convert_sfm_char(const __u16 src_char, ccase SFM_LESSTHAN : *target ='<' ;break ; -case SFM_SLASH : - *target ='\\' ; -break ;case SFM_SPACE : *target =' ' ;break ;
Greg Kroah-Hartman
maintainerPATCH 57/168 mac80211: fix an off-by-one issue in A-MSDU max_subframe computation
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 66eb02d839e8495ae6b612e2d09ff599374b80e2 ]
Initialize 'n' to 2 in order to take into account also the first packet in the estimation of max_subframe limit for a given A-MSDU since frag_tail pointer is NULL when ieee80211_amsdu_aggregate routine analyzes the second frame.
--- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tx.c +1 -1
@@ -3174,7 +3174,7 @@ static bool ieee80211_amsdu_aggregate(stvoid *data;bool ret = false;unsigned int orig_len; -int n =1 , nfrags, pad =0 ; +int n =2 , nfrags, pad =0 ;u16 hdrlen;if (!ieee80211_hw_check (&local->hw,TX_AMSDU ))
Greg Kroah-Hartman
maintainerPATCH 58/168 cfg80211: fix a type issue in ieee80211_chandef_to_operating_class()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8442938c3a2177ba16043b3a935f2c78266ad399 ]
The "chandef->center_freq1" variable is a u32 but "freq" is a u16 so we are truncating away the high bits. I noticed this bug because in commit 9cf0a0b4b64a ("cfg80211: Add support for 60GHz band channels 5 and 6") we made "freq <= 56160 + 2160 * 6" a valid requency when before it was only "freq <= 56160 + 2160 * 4" that was valid. It introduces a static checker warning:
net/wireless/util.c:1571 ieee80211_chandef_to_operating_class()
warn: always true condition '(freq <= 56160 + 2160 * 6) => (0-u16max <= 69120)'But really we probably shouldn't have been truncating the high bits away to begin with.
--- net/wireless/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/util.c +1 -1
@@ -1374,7 +1374,7 @@ bool ieee80211_chandef_to_operating_clas u8 *op_class) {u8 vht_opclass; -u16 freq = chandef->center_freq1; +u32 freq = chandef->center_freq1;if (freq >=2412 && freq <=2472 ) {if (chandef->width >NL80211_CHAN_WIDTH_40 )
Greg Kroah-Hartman
maintainerPATCH 59/168 mac80211: fix WMM TXOP calculation
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Dreyfuss, Haim" <[email protected]>
[ Upstream commit abd76d255d69d70206c01b9cb19ba36a9c1df6a1 ]
In commit 9236c4523e5b ("mac80211: limit wmm params to comply with ETSI requirements"), we have limited the WMM parameters to comply with 802.11 and ETSI standard. Mistakenly the TXOP value was caluclated wrong. Fix it by taking the minimum between 802.11 to ETSI to make sure we are not violating both.
--- net/mac80211/util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mac80211/util.c +1 -2
@@ -1151,8 +1151,7 @@ void ieee80211_regulatory_limit_wmm_para qparam->cw_min =max_t (u16, qparam->cw_min, wmm_ac->cw_min); qparam->cw_max =max_t (u16, qparam->cw_max, wmm_ac->cw_max); qparam->aifs =max_t (u8, qparam->aifs, wmm_ac->aifsn); - qparam->txop = !qparam->txop ? wmm_ac->cot /32 : -min_t (u16, qparam->txop, wmm_ac->cot /32 ); + qparam->txop =min_t (u16, qparam->txop, wmm_ac->cot /32 );rcu_read_unlock (); }
Greg Kroah-Hartman
maintainerPATCH 60/168 mac80211: fix a race between restart and CSA flows
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit f3ffb6c3a28963657eb8b02a795d75f2ebbd5ef4 ]
We hit a problem with iwlwifi that was caused by a bug in mac80211. A bug in iwlwifi caused the firwmare to crash in certain cases in channel switch. Because of that bug, drv_pre_channel_switch would fail and trigger the restart flow.
Now we had the hw restart worker which runs on the system's workqueue and the csa_connection_drop_work worker that runs on mac80211's workqueue that can run together. This is obviously problematic since the restart work wants to reconfigure the connection, while the csa_connection_drop_work worker does the exact opposite: it tries to disconnect.
Fix this by cancelling the csa_connection_drop_work worker in the restart worker.
Note that this can sound racy: we could have:
driver iface_work CSA_work restart_work
+++++++++++++++++++++++++++++++++++++++++++++
|
<--drv_cs ---|
<FW CRASH!>
-CS FAILED-->
| |
| cancel_work(CSA)
schedule |
CSA work |
| |Race between those 2
But this is not possible because we flush the workqueue in the restart worker before we cancel the CSA worker. That would be bullet proof if we could guarantee that we schedule the CSA worker only from the iface_work which runs on the workqueue (and not on the system's workqueue), but unfortunately we do have an instance in which we schedule the CSA work outside the context of the workqueue (ieee80211_chswitch_done).
Note also that we should probably cancel other workers like beacon_connection_loss_work and possibly others for different types of interfaces, at the very least, IBSS should suffer from the exact same problem, but for now, do the minimum to fix the actual bug that was actually experienced and reproduced.
--- net/mac80211/main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
net/mac80211/main.c +20 -1
@@ -255,8 +255,27 @@ static void ieee80211_restart_work(strucflush_work (&local->radar_detected_work);rtnl_lock (); -list_for_each_entry (sdata, &local->interfaces, list) +list_for_each_entry (sdata, &local->interfaces, list) { +/* +* XXX: there may be more work for other vif types and even +* for station mode: a good thing would be to run most of +* the iface type's dependent _stop (ieee80211_mg_stop, +* ieee80211_ibss_stop) etc... +* For now, fix only the specific bug that was seen: race +* between csa_connection_drop_work and us. +*/ +if (sdata->vif.type ==NL80211_IFTYPE_STATION ) { +/* +* This worker is scheduled from the iface worker that +* runs on mac80211's workqueue, so we can't be +* scheduling this worker after the cancel right here. +* The exception is ieee80211_chswitch_done. +* Then we can have a race... +*/ +cancel_work_sync (&sdata->u.mgd.csa_connection_drop_work); + }flush_delayed_work (&sdata->dec_tailroom_needed_wk); + }ieee80211_scan_cancel (local);/* make sure any new ROC will consider local->in_reconfig */
Greg Kroah-Hartman
maintainerPATCH 61/168 mac80211: Fix station bandwidth setting after channel switch
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Peer <[email protected]>
[ Upstream commit 0007e94355fdb71a1cf5dba0754155cba08f0666 ]
When performing a channel switch flow for a managed interface, the flow did not update the bandwidth of the AP station and the rate scale algorithm. In case of a channel width downgrade, this would result with the rate scale algorithm using a bandwidth that does not match the interface channel configuration.
Fix this by updating the AP station bandwidth and rate scaling algorithm before the actual channel change in case of a bandwidth downgrade, or after the actual channel change in case of a bandwidth upgrade.
--- net/mac80211/mlme.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
net/mac80211/mlme.c +53 -0
@@ -978,6 +978,10 @@ static void ieee80211_chswitch_work(stru*/ if (sdata->reserved_chanctx) { +struct ieee80211_supported_band *sband =NULL ; +struct sta_info *mgd_sta =NULL ; +enum ieee80211_sta_rx_bandwidth bw =IEEE80211_STA_RX_BW_20 ; +/* * with multi-vif csa driver may call ieee80211_csa_finish() * many times while waiting for other interfaces to use their
@@ -986,6 +990,48 @@ static void ieee80211_chswitch_work(struif (sdata->reserved_ready) goto out; +if (sdata->vif.bss_conf.chandef.width != + sdata->csa_chandef.width) { +/* +* For managed interface, we need to also update the AP +* station bandwidth and align the rate scale algorithm +* on the bandwidth change. Here we only consider the +* bandwidth of the new channel definition (as channel +* switch flow does not have the full HT/VHT/HE +* information), assuming that if additional changes are +* required they would be done as part of the processing +* of the next beacon from the AP. +*/ +switch (sdata->csa_chandef.width) { +case NL80211_CHAN_WIDTH_20_NOHT : +case NL80211_CHAN_WIDTH_20 : +default : + bw =IEEE80211_STA_RX_BW_20 ; +break ; +case NL80211_CHAN_WIDTH_40 : + bw =IEEE80211_STA_RX_BW_40 ; +break ; +case NL80211_CHAN_WIDTH_80 : + bw =IEEE80211_STA_RX_BW_80 ; +break ; +case NL80211_CHAN_WIDTH_80P80 : +case NL80211_CHAN_WIDTH_160 : + bw =IEEE80211_STA_RX_BW_160 ; +break ; + } + + mgd_sta =sta_info_get (sdata, ifmgd->bssid); + sband = + local->hw.wiphy->bands[sdata->csa_chandef.chan->band]; + } + +if (sdata->vif.bss_conf.chandef.width > + sdata->csa_chandef.width) { + mgd_sta->sta.bandwidth = bw; +rate_control_rate_update (local, sband, mgd_sta, +IEEE80211_RC_BW_CHANGED ); + } + ret =ieee80211_vif_use_reserved_context (sdata);if (ret) { sdata_info(sdata,
@@ -996,6 +1042,13 @@ static void ieee80211_chswitch_work(stru goto out; } +if (sdata->vif.bss_conf.chandef.width < + sdata->csa_chandef.width) { + mgd_sta->sta.bandwidth = bw; +rate_control_rate_update (local, sband, mgd_sta, +IEEE80211_RC_BW_CHANGED ); + } + goto out; }
Greg Kroah-Hartman
maintainerPATCH 62/168 mac80211: dont Tx a deauth frame if the AP forbade Tx
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit 6c18b27d6e5c6a7206364eae2b47bc8d8b2fa68f ]
If the driver fails to properly prepare for the channel switch, mac80211 will disconnect. If the CSA IE had mode set to 1, it means that the clients are not allowed to send any Tx on the current channel, and that includes the deauthentication frame.
Make sure that we don't send the deauthentication frame in this case.
In iwlwifi, this caused a failure to flush queues since the firmware already closed the queues after having parsed the CSA IE. Then mac80211 would wait until the deauthentication frame would go out (drv_flush(drop=false)) and that would never happen.
--- net/mac80211/mlme.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +15 -2
@@ -1270,6 +1270,16 @@ ieee80211_sta_process_chanswitch(struct cbss->beacon_interval));return ; drop_connection: +/* +* This is just so that the disconnect flow will know that +* we were trying to switch channel and failed. In case the +* mode is 1 (we are not allowed to Tx), we will know not to +* send a deauthentication frame. Those two fields will be +* reset when the disconnection worker runs. +*/ + sdata->vif.csa_active = true; + sdata->csa_block_tx = csa_ie.mode; +ieee80211_queue_work (&local->hw, &ifmgd->csa_connection_drop_work);mutex_unlock (&local->chanctx_mtx);mutex_unlock (&local->mtx);
@@ -2453,6 +2463,7 @@ static void __ieee80211_disconnect(strucstruct ieee80211_local *local = sdata->local;struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN ]; +bool tx;sdata_lock (sdata);if (!ifmgd->associated) {
@@ -2460,6 +2471,8 @@ static void __ieee80211_disconnect(strucreturn ; } + tx = !sdata->csa_block_tx; +/* AP is probably out of range (or not reachable for another reason) so * remove the bss struct for that AP. */
@@ -2467,7 +2480,7 @@ static void __ieee80211_disconnect(strucieee80211_set_disassoc (sdata,IEEE80211_STYPE_DEAUTH ,WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY , - true, frame_buf); + tx, frame_buf);mutex_lock (&local->mtx); sdata->vif.csa_active = false; ifmgd->csa_waiting_bcn = false;
@@ -2478,7 +2491,7 @@ static void __ieee80211_disconnect(struc }mutex_unlock (&local->mtx); -ieee80211_report_disconnect (sdata, frame_buf,sizeof (frame_buf), true, +ieee80211_report_disconnect (sdata, frame_buf,sizeof (frame_buf), tx,WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY );sdata_unlock (sdata);
Greg Kroah-Hartman
maintainerPATCH 63/168 mac80211: shorten the IBSS debug messages
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit c6e57b3896fc76299913b8cfd82d853bee8a2c84 ]
When tracing is enabled, all the debug messages are recorded and must not exceed MAX_MSG_LEN (100) columns. Longer debug messages grant the user with:
WARNING: CPU: 3 PID: 32642 at /tmp/wifi-core-20180806094828/src/iwlwifi-stack-dev/net/mac80211/./trace_msg.h:32 trace_event_raw_event_mac80211_msg_event+0xab/0xc0 [mac80211] Workqueue: phy1 ieee80211_iface_work [mac80211] RIP: 0010:trace_event_raw_event_mac80211_msg_event+0xab/0xc0 [mac80211] Call Trace: __sdata_dbg+0xbd/0x120 [mac80211] ieee80211_ibss_rx_queued_mgmt+0x15f/0x510 [mac80211] ieee80211_iface_work+0x21d/0x320 [mac80211]
--- net/mac80211/ibss.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/mac80211/ibss.c +11 -11
@@ -947,8 +947,8 @@ static void ieee80211_rx_mgmt_deauth_ibsif (len <IEEE80211_DEAUTH_FRAME_LEN )return ; -ibss_dbg (sdata,"RX DeAuth SA=%pM DA=%pM BSSID=%pM (reason: %d)\n" , - mgmt->sa, mgmt->da, mgmt->bssid, reason); +ibss_dbg (sdata,"RX DeAuth SA=%pM DA=%pM\n" , mgmt->sa, mgmt->da); +ibss_dbg (sdata,"\tBSSID=%pM (reason: %d)\n" , mgmt->bssid, reason);sta_info_destroy_addr (sdata, mgmt->sa); }
@@ -966,9 +966,9 @@ static void ieee80211_rx_mgmt_auth_ibss( auth_alg =le16_to_cpu (mgmt->u.auth.auth_alg); auth_transaction =le16_to_cpu (mgmt->u.auth.auth_transaction); -ibss_dbg (sdata, -"RX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=%d)\n" , - mgmt->sa, mgmt->da, mgmt->bssid, auth_transaction); +ibss_dbg (sdata,"RX Auth SA=%pM DA=%pM\n" , mgmt->sa, mgmt->da); +ibss_dbg (sdata,"\tBSSID=%pM (auth_transaction=%d)\n" , + mgmt->bssid, auth_transaction);if (auth_alg !=WLAN_AUTH_OPEN || auth_transaction !=1 )return ;
@@ -1175,10 +1175,10 @@ static void ieee80211_rx_bss_info(struct rx_timestamp =drv_get_tsf (local, sdata); } -ibss_dbg (sdata, -"RX beacon SA=%pM BSSID=%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n" , +ibss_dbg (sdata,"RX beacon SA=%pM BSSID=%pM TSF=0x%llx\n" , mgmt->sa, mgmt->bssid, - (unsigned long long )rx_timestamp, + (unsigned long long )rx_timestamp); +ibss_dbg (sdata,"\tBCN=0x%llx diff=%lld @%lu\n" , (unsigned long long )beacon_timestamp, (unsigned long long )(rx_timestamp - beacon_timestamp), jiffies);
@@ -1537,9 +1537,9 @@ static void ieee80211_rx_mgmt_probe_req( tx_last_beacon =drv_tx_last_beacon (local); -ibss_dbg (sdata, -"RX ProbeReq SA=%pM DA=%pM BSSID=%pM (tx_last_beacon=%d)\n" , - mgmt->sa, mgmt->da, mgmt->bssid, tx_last_beacon); +ibss_dbg (sdata,"RX ProbeReq SA=%pM DA=%pM\n" , mgmt->sa, mgmt->da); +ibss_dbg (sdata,"\tBSSID=%pM (tx_last_beacon=%d)\n" , + mgmt->bssid, tx_last_beacon);if (!tx_last_beacon &&is_multicast_ether_addr (mgmt->da))return ;
Greg Kroah-Hartman
maintainerPATCH 64/168 fsnotify: fix ignore mask logic in fsnotify()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
[ Upstream commit 9bdda4e9cf2dcecb60a0683b10ffb8cd7e5f2f45 ]
Commit 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group()") acknoledges the use case of ignoring an event on an inode mark, because of an ignore mask on a mount mark of the same group (i.e. I want to get all events on this file, except for the events that came from that mount).
This change depends on correctly merging the inode marks and mount marks group lists, so that the mount mark ignore mask would be tested in send_to_group(). Alas, the merging of the lists did not take into account the case where event in question is not in the mask of any of the mount marks.
To fix this, completely remove the tests for inode and mount event masks from the lists merging code.
--- fs/notify/fsnotify.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
fs/notify/fsnotify.c +3 -10
@@ -351,16 +351,9 @@ int fsnotify(struct inode *to_tell, __u3 iter_info.srcu_idx =srcu_read_lock (&fsnotify_mark_srcu); -if ((mask &FS_MODIFY ) || - (test_mask & to_tell->i_fsnotify_mask)) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); - } - -if (mnt && ((mask &FS_MODIFY ) || - (test_mask & mnt->mnt_fsnotify_mask))) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); + iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = +fsnotify_first_mark (&to_tell->i_fsnotify_marks); +if (mnt) { iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT ] =fsnotify_first_mark (&mnt->mnt_fsnotify_marks); }
Greg Kroah-Hartman
maintainerPATCH 65/168 net/ibm/emac: wrong emac_calc_base call was used by typo
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Mikhaylov <[email protected]>
[ Upstream commit bf68066fccb10fce6bbffdda24ee2ae314c9c5b2 ]
__emac_calc_base_mr1 was used instead of __emac4_calc_base_mr1 by copy-paste mistake for emac4syn.
--- drivers/net/ethernet/ibm/emac/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +3 -3
@@ -494,9 +494,6 @@ static u32 __emac_calc_base_mr1(struct ecase 16384 : ret |=EMAC_MR1_RFS_16K ;break ; -case 8192 : - ret |=EMAC4_MR1_RFS_8K ; -break ;case 4096 : ret |=EMAC_MR1_RFS_4K ;break ;
@@ -537,6 +534,9 @@ static u32 __emac4_calc_base_mr1(structcase 16384 : ret |=EMAC4_MR1_RFS_16K ;break ; +case 8192 : + ret |=EMAC4_MR1_RFS_8K ; +break ;case 4096 : ret |=EMAC4_MR1_RFS_4K ;break ;
Greg Kroah-Hartman
maintainerPATCH 66/168 nds32: fix logic for module
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greentime Hu <[email protected]>
[ Upstream commit 1dfdf99106668679b0de5a62fd4f42c1a11c9445 ]
This bug is report by Dan Carpenter. We shall use ~loc_mask instead of !loc_mask because we need to and(&) the bits of ~loc_mask.
--- arch/nds32/kernel/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/nds32/kernel/module.c +2 -2
@@ -40,7 +40,7 @@ void do_reloc16(unsigned int val, unsign tmp2 = tmp & loc_mask;if (partial_in_place) { - tmp &= (!loc_mask); + tmp &= (~loc_mask); tmp = tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask); }else {
@@ -70,7 +70,7 @@ void do_reloc32(unsigned int val, unsign tmp2 = tmp & loc_mask;if (partial_in_place) { - tmp &= (!loc_mask); + tmp &= (~loc_mask); tmp = tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask); }else {
Greg Kroah-Hartman
maintainerPATCH 67/168 nds32: add NULL entry to the end of_device_id array
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: YueHaibing <[email protected]>
[ Upstream commit 1944a50859ec2b570b42b459ac25d607fc7c31f0 ]
Make sure of_device_id tables are NULL terminated. Found by coccinelle spatch "misc/of_table.cocci"
--- arch/nds32/kernel/atl2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/nds32/kernel/atl2c.c +2 -1
@@ -9,7 +9,8 @@void __iomem *atl2c_base;static const struct of_device_id atl2c_ids[]__initconst = { - {.compatible ="andestech,atl2c" ,} + {.compatible ="andestech,atl2c" ,}, + {} };static int __init atl2c_of_init (void )
Greg Kroah-Hartman
maintainerPATCH 68/168 nds32: Fix empty call trace
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zong Li <[email protected]>
[ Upstream commit c17df7960534357fb74074c2f514c831d4a9cf5a ]
The compiler predefined macro 'NDS32_ABI_2' had been removed, it should use the '__NDS32_ABI_2' here.
--- arch/nds32/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/nds32/kernel/traps.c +1 -1
@@ -137,7 +137,7 @@ static void __dump(struct task_struct *t !((unsigned long)base_reg & 0x3) && ((unsigned long)base_reg >= TASK_SIZE)) {unsigned long next_fp; -#if !defined(NDS32_ABI_2 ) +#if !defined(__NDS32_ABI_2) ret_addr = base_reg[0 ]; next_fp = base_reg[1 ];#else
Greg Kroah-Hartman
maintainerPATCH 69/168 nds32: Fix get_user/put_user macro expand pointer problem
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zong Li <[email protected]>
[ Upstream commit 6cce95a6c7d288ac2126eee4b95df448b9015b84 ]
The pointer argument of macro need to be taken out once first, and then use the new pointer in the macro body.
In kernel/trace/trace.c, get_user(ch, ubuf++) causes the unexpected increment after expand the macro.
--- arch/nds32/include/asm/uaccess.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
arch/nds32/include/asm/uaccess.h +14 -12
@@ -78,8 +78,9 @@ static inline void set_fs(mm_segment_t f#define get_user (x,p) \ ({ \ long __e = -EFAULT; \ - if(likely(access_ok(VERIFY_READ, p, sizeof(*p)))) { \ - __e = __get_user(x,p); \ + const __typeof__(*(p)) __user *__p = (p); \ + if(likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \ + __e = __get_user(x, __p); \ } else \ x = 0; \ __e; \
@@ -99,10 +100,10 @@ static inline void set_fs(mm_segment_t f#define __get_user_err (x,ptr,err) \ do { \ - unsigned long __gu_addr = (unsigned long)(ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ unsigned long __gu_val; \ - __chk_user_ptr(ptr); \ - switch (sizeof(*(ptr))) { \ + __chk_user_ptr(__gu_addr); \ + switch (sizeof(*(__gu_addr))) { \ case 1: \ __get_user_asm("lbi",__gu_val,__gu_addr,err); \ break; \
@@ -119,7 +120,7 @@ do { \BUILD_BUG (); \break ; \ } \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__typeof__ (*(__gu_addr )))__gu_val; \ }while (0 ) #define __get_user_asm(inst,x,addr,err) \
@@ -169,8 +170,9 @@ do { \#define put_user (x,p) \ ({ \ long __e = -EFAULT; \ - if(likely(access_ok(VERIFY_WRITE, p, sizeof(*p)))) { \ - __e = __put_user(x,p); \ + __typeof__(*(p)) __user *__p = (p); \ + if(likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \ + __e = __put_user(x, __p); \ } \ __e; \ })
@@ -189,10 +191,10 @@ do { \#define __put_user_err (x,ptr,err) \ do { \ - unsigned long __pu_addr = (unsigned long)(ptr); \ - __typeof__(*(ptr)) __pu_val = (x); \ - __chk_user_ptr(ptr); \ - switch (sizeof(*(ptr))) { \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ + __typeof__(*(__pu_addr)) __pu_val = (x); \ + __chk_user_ptr(__pu_addr); \ + switch (sizeof(*(__pu_addr))) { \ case 1: \ __put_user_asm("sbi",__pu_val,__pu_addr,err); \ break; \
Greg Kroah-Hartman
maintainerPATCH 70/168 nds32: fix build error because of wrong semicolon
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greentime Hu <[email protected]>
[ Upstream commit ec865393292f5ad8d52da20788b3685ebce44c48 ]
It shall be removed in the define usage. We shall not put a semicolon there.
/kisskb/src/arch/nds32/include/asm/elf.h:126:29: error: expected '}' before ';' token
#define ELF_DATA ELFDATA2LSB;
^
/kisskb/src/fs/proc/kcore.c:318:17: note: in expansion of macro 'ELF_DATA'
[EI_DATA] = ELF_DATA,
^~~~~~~~
/kisskb/src/fs/proc/kcore.c:312:15: note: to match this '{'
.e_ident = {
^/kisskb/src/scripts/Makefile.build:307: recipe for target 'fs/proc/kcore.o' failed
--- arch/nds32/include/asm/elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/nds32/include/asm/elf.h +2 -2
@@ -121,9 +121,9 @@ struct elf32_hdr;*/ #define ELF_CLASS ELFCLASS32#ifdef __NDS32_EB__ -#define ELF_DATA ELFDATA2MSB; +#define ELF_DATA ELFDATA2MSB#else -#define ELF_DATA ELFDATA2LSB; +#define ELF_DATA ELFDATA2LSB#endif #define ELF_ARCH EM_NDS32#define USE_ELF_CORE_DUMP
Greg Kroah-Hartman
maintainerPATCH 71/168 tools/vm/slabinfo.c: fix sign-compare warning
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naoya Horiguchi <[email protected]>
[ Upstream commit 904506562e0856f2535d876407d087c9459d345b ]
Currently we get the following compiler warning:
slabinfo.c:854:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (s->object_size < min_objsize)
^due to the mismatch of signed/unsigned comparison. ->object_size and ->slab_size are never expected to be negative, so let's define them as unsigned int.
--- tools/vm/slabinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/vm/slabinfo.c +2 -2
@@ -30,8 +30,8 @@ struct slabinfo {int alias;int refs;int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; -int hwcache_align, object_size, objs_per_slab; -int sanity_checks, slab_size, store_user, trace; +unsigned int hwcache_align, object_size, objs_per_slab; +unsigned int sanity_checks, slab_size, store_user, trace;int order, poison, reclaim_account, red_zone;unsigned long partial, objects, slabs, objects_partial, objects_total;unsigned long alloc_fastpath, alloc_slowpath;
Greg Kroah-Hartman
maintainerPATCH 72/168 tools/vm/page-types.c: fix "defined but not used" warning
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naoya Horiguchi <[email protected]>
[ Upstream commit 7ab660f8baecfe26c1c267fa8e64d2073feae2bb ]
debugfs_known_mountpoints[] is not used any more, so let's remove it.
--- tools/vm/page-types.c | 6 ------ 1 file changed, 6 deletions(-)
tools/vm/page-types.c +0 -6
@@ -156,12 +156,6 @@ static const char * const page_flag_name }; -static const char *const debugfs_known_mountpoints[] = { -"/sys/kernel/debug" , -"/debug" , -0 , -}; -/* * data structures */
Greg Kroah-Hartman
maintainerPATCH 73/168 nds32: linker script: GCOV kernel may refers data in __exit
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greentime Hu <[email protected]>
[ Upstream commit 3350139c0ff3c95724b784f7109987d533cb3ecd ]
This patch is used to fix nds32 allmodconfig/allyesconfig build error because GCOV kernel embeds counters in the kernel for each line and a part of that embed in __exit text. So we need to keep the EXIT_TEXT and EXIT_DATA if CONFIG_GCOV_KERNEL=y.
--- arch/nds32/kernel/vmlinux.lds.S | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/nds32/kernel/vmlinux.lds.S +12 -0
@@ -13,14 +13,26 @@ OUTPUT_ARCH(nds32) ENTRY(_stext_lma) jiffies = jiffies_64; +#if defined(CONFIG_GCOV_KERNEL) +#define NDS32_EXIT_KEEP(x) x +#else +#define NDS32_EXIT_KEEP(x) +#endif + SECTIONS { _stext_lma = TEXTADDR - LOAD_OFFSET; . = TEXTADDR; __init_begin = .; HEAD_TEXT_SECTION + .exit.text : { + NDS32_EXIT_KEEP(EXIT_TEXT) + } INIT_TEXT_SECTION(PAGE_SIZE) INIT_DATA_SECTION(16) + .exit.data : { + NDS32_EXIT_KEEP(EXIT_DATA) + } PERCPU_SECTION(L1_CACHE_BYTES) __init_end = .;
Greg Kroah-Hartman
maintainerPATCH 74/168 ceph: avoid a use-after-free in ceph_destroy_options()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
[ Upstream commit 8aaff15168cfbc7c8980fdb0e8a585f1afe56ec0 ]
syzbot reported a use-after-free in ceph_destroy_options(), called from ceph_mount(). The problem was that create_fs_client() consumed the opt pointer on some errors, but not on all of them. Make sure it always consumes both libceph and ceph options.
--- fs/ceph/super.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/ceph/super.c +11 -5
@@ -603,6 +603,8 @@ static int extra_mon_dispatch(struct cep/* * create a new fs client +* +* Success or not, this function consumes @fsopt and @opt. */ static struct ceph_fs_client *create_fs_client (struct ceph_mount_options *fsopt,struct ceph_options *opt)
@@ -610,17 +612,20 @@ static struct ceph_fs_client *create_fs_struct ceph_fs_client *fsc;int page_count;size_t size; -int err = -ENOMEM ; +int err; fsc =kzalloc (sizeof (*fsc),GFP_KERNEL ); -if (!fsc) -return ERR_PTR (-ENOMEM ); +if (!fsc) { + err = -ENOMEM ; + goto fail; + } fsc->client =ceph_create_client (opt, fsc);if (IS_ERR (fsc->client)) { err =PTR_ERR (fsc->client); goto fail; } + opt =NULL ;/* fsc->client now owns this */ fsc->client->extra_mon_dispatch = extra_mon_dispatch; fsc->client->osdc.abort_on_full = true;
@@ -678,6 +683,9 @@ fail_client:ceph_destroy_client (fsc->client); fail:kfree (fsc); +if (opt) +ceph_destroy_options (opt); +destroy_mount_options (fsopt);return ERR_PTR (err); }
@@ -1042,8 +1050,6 @@ static struct dentry *ceph_mount(struct fsc =create_fs_client (fsopt, opt);if (IS_ERR (fsc)) { res =ERR_CAST (fsc); -destroy_mount_options (fsopt); -ceph_destroy_options (opt); goto out_final; }
Greg Kroah-Hartman
maintainerPATCH 75/168 firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 96d529bac562574600eda85726fcfa3eef6dde8e ]
Firmware can provide zero as values for sustained performance level and corresponding sustained frequency in kHz in order to hide the actual frequencies and provide only abstract values. It may endup with divide by zero scenario resulting in kernel panic.
Let's set the multiplication factor to one if either one or both of them (sustained_perf_level and sustained_freq) are set to zero.
--- drivers/firmware/arm_scmi/perf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/perf.c +7 -1
@@ -166,7 +166,13 @@ scmi_perf_domain_attributes_get(const stle32_to_cpu (attr->sustained_freq_khz); dom_info->sustained_perf_level =le32_to_cpu (attr->sustained_perf_level); - dom_info->mult_factor = (dom_info->sustained_freq_khz *1000 ) / +if (!dom_info->sustained_freq_khz || + !dom_info->sustained_perf_level) +/* CPUFreq converts to kHz, hence default 1000 */ + dom_info->mult_factor =1000 ; +else + dom_info->mult_factor = + (dom_info->sustained_freq_khz *1000 ) / dom_info->sustained_perf_level;memcpy (dom_info->name, attr->name,SCMI_MAX_STR_SIZE ); }
Greg Kroah-Hartman
maintainerPATCH 76/168 afs: Fix cell specification to permit an empty address list
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit ecfe951f0c1b169ea4b7dd6f3a404dfedd795bc2 ]
Fix the cell specification mechanism to allow cells to be pre-created without having to specify at least one address (the addresses will be upcalled for).
This allows the cell information preload service to avoid the need to issue loads of DNS lookups during boot to get the addresses for each cell (500+ lookups for the 'standard' cell list[*]). The lookups can be done later as each cell is accessed through the filesystem.
Also remove the print statement that prints a line every time a new cell is added.
[*] There are 144 cells in the list. Each cell is first looked up for an
SRV record, and if that fails, for an AFSDB record. These get a list of server names, each of which then has to be looked up to get the addresses for that server. E.g.:
dig srv _afs3-vlserver._udp.grand.central.org
--- fs/afs/proc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/afs/proc.c +7 -8
@@ -98,13 +98,13 @@ static int afs_proc_cells_write(struct f goto inval; args =strchr (name,' ' ); -if (!args) - goto inval; -do { - *args++ =0 ; - }while (*args ==' ' ); -if (!*args) - goto inval; +if (args) { +do { + *args++ =0 ; + }while (*args ==' ' ); +if (!*args) + goto inval; + }/* determine command to perform */ _debug ("cmd=%s name=%s args=%s" , buf, name, args);
@@ -120,7 +120,6 @@ static int afs_proc_cells_write(struct fif (test_and_set_bit (AFS_CELL_FL_NO_GC , &cell->flags))afs_put_cell (net, cell); -printk ("kAFS: Added new cell '%s'\n" , name); }else { goto inval; }
Greg Kroah-Hartman
maintainerPATCH 77/168 mm: madvise(MADV_DODUMP): allow hugetlbfs pages
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Black <[email protected]>
commit d41aa5252394c065d1f04d1ceea885b70d00c9c6 upstream.
Reproducer, assuming 2M of hugetlbfs available:
Hugetlbfs mounted, size=2M and option user=testuser
# mount | grep ^hugetlbfs hugetlbfs on /dev/hugepages type hugetlbfs (rw,pagesize=2M,user=dan) # sysctl vm.nr_hugepages=1 vm.nr_hugepages = 1 # grep Huge /proc/meminfo AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 1 HugePages_Free: 1 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 2048 kB
Code:
#include <sys/mman.h>
#include <stddef.h>
#define SIZE 2*1024*1024
int main()
{
void *ptr;
ptr = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_HUGETLB | MAP_ANONYMOUS, -1, 0);
madvise(ptr, SIZE, MADV_DONTDUMP);
madvise(ptr, SIZE, MADV_DODUMP);
}Compile and strace:
mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB, -1, 0) = 0x7ff7c9200000 madvise(0x7ff7c9200000, 2097152, MADV_DONTDUMP) = 0
madvise(0x7ff7c9200000, 2097152, MADV_DODUMP) = -1 EINVAL (Invalid argument)
hugetlbfs pages have VM_DONTEXPAND in the VmFlags driver pages based on author testing with analysis from Florian Weimer[1].
The inclusion of VM_DONTEXPAND into the VM_SPECIAL defination was a consequence of the large useage of VM_DONTEXPAND in device drivers.
A consequence of [2] is that VM_DONTEXPAND marked pages are unable to be marked DODUMP.
A user could quite legitimately madvise(MADV_DONTDUMP) their hugetlbfs memory for a while and later request that madvise(MADV_DODUMP) on the same memory. We correct this omission by allowing madvice(MADV_DODUMP) on hugetlbfs pages.
[1] https://stackoverflow.com/questions/52548260/madvisedodump-on-the-same-ptr-size-as-a-successful-madvisedontdump-fails-wit
[2] commit 0103bd16fb90 ("mm: prepare VM_DONTDUMP for using in drivers")
--- mm/madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -1
@@ -96,7 +96,7 @@ static long madvise_behavior(struct vm_a new_flags |=VM_DONTDUMP ;break ;case MADV_DODUMP : -if (new_flags &VM_SPECIAL ) { +if (!is_vm_hugetlb_page (vma) && new_flags &VM_SPECIAL ) { error = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 78/168 bpf: 32-bit RSH verification must truncate input before the ALU op
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit b799207e1e1816b09e7a5920fbb2d5fcf6edd681 upstream.
When I wrote commit 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification"), I assumed that, in order to emulate 64-bit arithmetic with 32-bit logic, it is sufficient to just truncate the output to 32 bits; and so I just moved the register size coercion that used to be at the start of the function to the end of the function.
That assumption is true for almost every op, but not for 32-bit right shifts, because those can propagate information towards the least significant bit. Fix it by always truncating inputs for 32-bit ops to 32 bits.
Also get rid of the coerce_reg_to_size() after the ALU op, since that has no effect.
--- kernel/bpf/verifier.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +9 -1
@@ -2865,6 +2865,15 @@ static int adjust_scalar_min_max_vals(stu64 umin_val, umax_val;u64 insn_bitness = (BPF_CLASS (insn->code) ==BPF_ALU64 ) ?64 :32 ; +if (insn_bitness ==32 ) { +/* Relevant for 32-bit RSH: Information can propagate towards +* LSB, so it isn't sufficient to only truncate the output to +* 32 bits. +*/ +coerce_reg_to_size (dst_reg,4 ); +coerce_reg_to_size (&src_reg,4 ); + } + smin_val = src_reg.smin_value; smax_val = src_reg.smax_value; umin_val = src_reg.umin_value;
@@ -3100,7 +3109,6 @@ static int adjust_scalar_min_max_vals(stif (BPF_CLASS (insn->code) !=BPF_ALU64 ) {/* 32-bit ALU ops are (32,32)->32 */ coerce_reg_to_size (dst_reg,4 ); -coerce_reg_to_size (&src_reg,4 ); }__reg_deduce_bounds (dst_reg);
Greg Kroah-Hartman
maintainerPATCH 79/168 netfilter: xt_cluster: add dependency on conntrack module
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Willi <[email protected]>
[ Upstream commit c1dc2912059901f97345d9e10c96b841215fdc0f ]
The cluster match requires conntrack for matching packets. If the netns does not have conntrack hooks registered, the match does not work at all.
Implicitly load the conntrack hook for the family, exactly as many other extensions do. This ensures that the match works even if the hooks have not been registered by other means.
--- net/netfilter/xt_cluster.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
net/netfilter/xt_cluster.c +13 -1
@@ -125,6 +125,7 @@ xt_cluster_mt(const struct sk_buff *skb,static int xt_cluster_mt_checkentry (const struct xt_mtchk_param *par) {struct xt_cluster_match_info *info = par->matchinfo; +int ret;if (info->total_nodes >XT_CLUSTER_NODES_MAX ) { pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n",
@@ -135,7 +136,17 @@ static int xt_cluster_mt_checkentry(conspr_info_ratelimited ("node mask cannot exceed total number of nodes\n" );return -EDOM ; } -return 0 ; + + ret =nf_ct_netns_get (par->net, par->family); +if (ret <0 ) +pr_info_ratelimited ("cannot load conntrack support for proto=%u\n" , + par->family); +return ret; +} + +static void xt_cluster_mt_destroy (const struct xt_mtdtor_param *par) +{ +nf_ct_netns_put (par->net, par->family); }static struct xt_match xt_cluster_match__read_mostly = {
@@ -144,6 +155,7 @@ static struct xt_match xt_cluster_match .match = xt_cluster_mt, .checkentry = xt_cluster_mt_checkentry, .matchsize = sizeof(struct xt_cluster_match_info), + .destroy = xt_cluster_mt_destroy, .me = THIS_MODULE, };
Greg Kroah-Hartman
maintainerPATCH 80/168 netfilter: xt_checksum: ignore gso skbs
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 10568f6c5761db24249c610c94d6e44d5505a0ba ]
Satish Patel reports a skb_warn_bad_offload() splat caused by -j CHECKSUM rules:
-A POSTROUTING -p tcp -m tcp --sport 80 -j CHECKSUM
The CHECKSUM target has never worked with GSO skbs, and the above rule makes no sense as kernel will handle checksum updates on transmit.
Unfortunately, there are 3rd party tools that install such rules, so we cannot reject this from the config plane without potential breakage.
Amend Kconfig text to clarify that the CHECKSUM target is only useful in virtualized environments, where old dhcp clients that use AF_PACKET used to discard UDP packets with a 'bad' header checksum and add a one-time warning in case such rule isn't restricted to UDP.
v2: check IP6T_F_PROTO flag before cmp (Michal Kubecek)
--- net/netfilter/Kconfig | 12 ++++++------ net/netfilter/xt_CHECKSUM.c | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 7 deletions(-)
net/netfilter/Kconfig +6 -6
@@ -740,13 +740,13 @@ config NETFILTER_XT_TARGET_CHECKSUM depends on NETFILTER_ADVANCED ---help--- This option adds a `CHECKSUM' target, which can be used in the iptables mangle - table. + table to work around buggy DHCP clients in virtualized environments. - You can use this target to compute and fill in the checksum in - a packet that lacks a checksum. This is particularly useful, - if you need to work around old applications such as dhcp clients, - that do not work well with checksum offloads, but don't want to disable - checksum offload in your device. + Some old DHCP clients drop packets because they are not aware + that the checksum would normally be offloaded to hardware and + thus should be considered valid. + This target can be used to fill in the checksum using iptables + when such packets are sent via a virtual network device. To compile it as a module, choose M here. If unsure, say N.
net/netfilter/xt_CHECKSUM.c +21 -1
@@ -16,6 +16,9 @@#include <linux/netfilter/x_tables.h> #include <linux/netfilter/xt_CHECKSUM.h> +#include <linux/netfilter_ipv4/ip_tables.h> +#include <linux/netfilter_ipv6/ip6_tables.h> +MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Michael S. Tsirkin <[email protected]>" );MODULE_DESCRIPTION ("Xtables: checksum modification" );
@@ -25,7 +28,7 @@ MODULE_ALIAS("ip6t_CHECKSUM");static unsigned int checksum_tg (struct sk_buff *skb,const struct xt_action_param *par) { -if (skb->ip_summed ==CHECKSUM_PARTIAL ) +if (skb->ip_summed ==CHECKSUM_PARTIAL && !skb_is_gso (skb))skb_checksum_help (skb);return XT_CONTINUE ;
@@ -34,6 +37,8 @@ checksum_tg(struct sk_buff *skb, const sstatic int checksum_tg_check (const struct xt_tgchk_param *par) {const struct xt_CHECKSUM_info *einfo = par->targinfo; +const struct ip6t_ip6 *i6 = par->entryinfo; +const struct ipt_ip *i4 = par->entryinfo;if (einfo->operation & ~XT_CHECKSUM_OP_FILL ) { pr_info_ratelimited("unsupported CHECKSUM operation %x\n",
@@ -43,6 +48,21 @@ static int checksum_tg_check(const strucif (!einfo->operation)return -EINVAL ; +switch (par->family) { +case NFPROTO_IPV4 : +if (i4->proto ==IPPROTO_UDP && + (i4->invflags &XT_INV_PROTO ) ==0 ) +return 0 ; +break ; +case NFPROTO_IPV6 : +if ((i6->flags &IP6T_F_PROTO ) && + i6->proto ==IPPROTO_UDP && + (i6->invflags &XT_INV_PROTO ) ==0 ) +return 0 ; +break ; + } + +pr_warn_once ("CHECKSUM should be avoided. If really needed, restrict with \"-p udp\" and only use in OUTPUT\n" );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 81/168 HID: intel-ish-hid: Enable Sunrise Point-H ish driver
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Bosch <[email protected]>
[ Upstream commit e0ab8b26aa9661df0541a657e2b2416d90488809 ]
Added PCI ID for Sunrise Point-H ISH.
--- drivers/hid/intel-ish-hid/ipc/hw-ish.h | 1 + drivers/hid/intel-ish-hid/ipc/pci-ish.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/intel-ish-hid/ipc/hw-ish.h +1 -0
@@ -29,6 +29,7 @@#define CNL_Ax_DEVICE_ID 0x9DFC#define GLK_Ax_DEVICE_ID 0x31A2#define CNL_H_DEVICE_ID 0xA37C +#define SPT_H_DEVICE_ID 0xA135#define REVISION_ID_CHT_A0 0x6#define REVISION_ID_CHT_Ax_SI 0x0
drivers/hid/intel-ish-hid/ipc/pci-ish.c +1 -0
@@ -38,6 +38,7 @@ static const struct pci_device_id ish_pc {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, SPT_H_DEVICE_ID)}, {0, } };MODULE_DEVICE_TABLE (pci, ish_pci_tbl);
Greg Kroah-Hartman
maintainerPATCH 82/168 HID: add support for Apple Magic Keyboards
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean O'Brien <[email protected]>
[ Upstream commit ee345492437043a79db058a3d4f029ebcb52089a ]
USB device
Vendor 05ac (Apple)
Device 026c (Magic Keyboard with Numeric Keypad)
Bluetooth devices
Vendor 004c (Apple)
Device 0267 (Magic Keyboard)
Device 026c (Magic Keyboard with Numeric Keypad)
Support already exists for the Magic Keyboard over USB connection. Add support for the Magic Keyboard over Bluetooth connection, and for the Magic Keyboard with Numeric Keypad over Bluetooth and USB connection.
--- drivers/hid/hid-apple.c | 9 ++++++++- drivers/hid/hid-ids.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/hid/hid-apple.c +8 -1
@@ -335,7 +335,8 @@ static int apple_input_mapping(struct hi struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { + if (usage->hid == (HID_UP_CUSTOM | 0x0003) || + usage->hid == (HID_UP_MSVENDOR | 0x0003)) {/* The fn key on Apple USB keyboards */ set_bit(EV_REP, hi->input->evbit);hid_map_usage_clear (hi, usage, bit, max,EV_KEY ,KEY_FN );
@@ -472,6 +473,12 @@ static const struct hid_device_id apple_ .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), .driver_data = APPLE_HAS_FN }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), + .driver_data = APPLE_HAS_FN }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), + .driver_data = APPLE_HAS_FN }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), + .driver_data = APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), .driver_data = APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
drivers/hid/hid-ids.h +2 -0
@@ -88,6 +88,7 @@#define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101#define USB_VENDOR_ID_APPLE 0x05ac +#define BT_VENDOR_ID_APPLE 0x004c#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e
@@ -157,6 +158,7 @@#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267 +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
Greg Kroah-Hartman
maintainerPATCH 83/168 usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Vasilyev <[email protected]>
[ Upstream commit c37bd52836296ecc9a0fc8060b819089aebdbcde ]
There is no deallocation of fotg210->ep[i] elements, allocated at fotg210_udc_probe.
The patch adds deallocation of fotg210->ep array elements and simplifies error path of fotg210_udc_probe().
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/usb/gadget/udc/fotg210-udc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/fotg210-udc.c +10 -5
@@ -1063,12 +1063,15 @@ static const struct usb_gadget_ops fotg2static int fotg210_udc_remove (struct platform_device *pdev) {struct fotg210_udc *fotg210 =platform_get_drvdata (pdev); +int i;usb_del_gadget_udc (&fotg210->gadget);iounmap (fotg210->reg);free_irq (platform_get_irq (pdev,0 ), fotg210);fotg210_ep_free_request (&fotg210->ep[0 ]->ep, fotg210->ep0_req); +for (i =0 ; i <FOTG210_MAX_NUM_EP ; i++) +kfree (fotg210->ep[i]);kfree (fotg210);return 0 ;
@@ -1099,7 +1102,7 @@ static int fotg210_udc_probe(struct plat/* initialize udc */ fotg210 =kzalloc (sizeof (struct fotg210_udc ),GFP_KERNEL );if (fotg210 ==NULL ) - goto err_alloc; + goto err;for (i =0 ; i <FOTG210_MAX_NUM_EP ; i++) { _ep[i] =kzalloc (sizeof (struct fotg210_ep ),GFP_KERNEL );
@@ -1111,7 +1114,7 @@ static int fotg210_udc_probe(struct plat fotg210->reg =ioremap (res->start,resource_size (res));if (fotg210->reg ==NULL ) {pr_err ("ioremap error.\n" ); - goto err_map; + goto err_alloc; }spin_lock_init (&fotg210->lock);
@@ -1159,7 +1162,7 @@ static int fotg210_udc_probe(struct plat fotg210->ep0_req =fotg210_ep_alloc_request (&fotg210->ep[0 ]->ep,GFP_KERNEL );if (fotg210->ep0_req ==NULL ) - goto err_req; + goto err_map;fotg210_init (fotg210);
@@ -1187,12 +1190,14 @@ err_req:fotg210_ep_free_request (&fotg210->ep[0 ]->ep, fotg210->ep0_req); err_map: -if (fotg210->reg) -iounmap (fotg210->reg); +iounmap (fotg210->reg); err_alloc: +for (i =0 ; i <FOTG210_MAX_NUM_EP ; i++) +kfree (fotg210->ep[i]);kfree (fotg210); +err:return ret; }
Greg Kroah-Hartman
maintainerPATCH 84/168 pinctrl: msm: Really mask level interrupts to prevent latching
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
[ Upstream commit b55326dc969ea2d704a008d9a97583b128f54f4f ]
The interrupt controller hardware in this pin controller has two status enable bits. The first "normal" status enable bit enables or disables the summary interrupt line being raised when a gpio interrupt triggers and the "raw" status enable bit allows or prevents the hardware from latching an interrupt into the status register for a gpio interrupt. Currently we just toggle the "normal" status enable bit in the mask and unmask ops so that the summary irq interrupt going to the CPU's interrupt controller doesn't trigger for the masked gpio interrupt.
For a level triggered interrupt, the flow would be as follows: the pin controller sees the interrupt, latches the status into the status register, raises the summary irq to the CPU, summary irq handler runs and calls handle_level_irq(), handle_level_irq() masks and acks the gpio interrupt, the interrupt handler runs, and finally unmask the interrupt. When the interrupt handler completes, we expect that the interrupt line level will go back to the deasserted state so the genirq code can unmask the interrupt without it triggering again.
If we only mask the interrupt by clearing the "normal" status enable bit then we'll ack the interrupt but it will continue to show up as pending in the status register because the raw status bit is enabled, the hardware hasn't deasserted the line, and thus the asserted state latches into the status register again. When the hardware deasserts the interrupt the pin controller still thinks there is a pending unserviced level interrupt because it latched it earlier. This behavior causes software to see an extra interrupt for level type interrupts each time the interrupt is handled.
Let's fix this by clearing the raw status enable bit for level type interrupts so that the hardware stops latching the status of the interrupt after we ack it. We don't do this for edge type interrupts because it seems that toggling the raw status enable bit for edge type interrupts causes spurious edge interrupts.
--- drivers/pinctrl/qcom/pinctrl-msm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/pinctrl/qcom/pinctrl-msm.c +24 -0
@@ -634,6 +634,29 @@ static void msm_gpio_irq_mask(struct irqraw_spin_lock_irqsave (&pctrl->lock, flags); val =readl (pctrl->regs + g->intr_cfg_reg); +/* +* There are two bits that control interrupt forwarding to the CPU. The +* RAW_STATUS_EN bit causes the level or edge sensed on the line to be +* latched into the interrupt status register when the hardware detects +* an irq that it's configured for (either edge for edge type or level +* for level type irq). The 'non-raw' status enable bit causes the +* hardware to assert the summary interrupt to the CPU if the latched +* status bit is set. There's a bug though, the edge detection logic +* seems to have a problem where toggling the RAW_STATUS_EN bit may +* cause the status bit to latch spuriously when there isn't any edge +* so we can't touch that bit for edge type irqs and we have to keep +* the bit set anyway so that edges are latched while the line is masked. +* +* To make matters more complicated, leaving the RAW_STATUS_EN bit +* enabled all the time causes level interrupts to re-latch into the +* status register because the level is still present on the line after +* we ack it. We clear the raw status enable bit during mask here and +* set the bit on unmask so the interrupt can't latch into the hardware +* while it's masked. +*/ +if (irqd_get_trigger_type (d) &IRQ_TYPE_LEVEL_MASK ) + val &= ~BIT (g->intr_raw_status_bit); + val &= ~BIT (g->intr_enable_bit);writel (val, pctrl->regs + g->intr_cfg_reg);
@@ -655,6 +678,7 @@ static void msm_gpio_irq_unmask(struct iraw_spin_lock_irqsave (&pctrl->lock, flags); val =readl (pctrl->regs + g->intr_cfg_reg); + val |=BIT (g->intr_raw_status_bit); val |=BIT (g->intr_enable_bit);writel (val, pctrl->regs + g->intr_cfg_reg);
Greg Kroah-Hartman
maintainerPATCH 85/168 HID: hid-saitek: Add device ID for RAT 7 Contagion
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Mallon <[email protected]>
[ Upstream commit 43822c98f2ebb2cbd5e467ab72bbcdae7f0caa22 ]
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-saitek.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -951,6 +951,7 @@#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17#define USB_DEVICE_ID_SAITEK_PS1000 0x0621#define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb +#define USB_DEVICE_ID_SAITEK_RAT7_CONTAGION 0x0ccd#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7#define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0
drivers/hid/hid-saitek.c +2 -0
@@ -183,6 +183,8 @@ static const struct hid_device_id saitek .driver_data = SAITEK_RELEASE_MODE_RAT7 }, { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7), .driver_data = SAITEK_RELEASE_MODE_RAT7 }, + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_CONTAGION), + .driver_data = SAITEK_RELEASE_MODE_RAT7 }, { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9), .driver_data = SAITEK_RELEASE_MODE_RAT7 }, { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9),
Greg Kroah-Hartman
maintainerPATCH 86/168 scsi: iscsi: target: Set conn->sess to NULL when iscsi_login_set_conn_values fails
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Pelletier <[email protected]>
[ Upstream commit 7915919bb94e12460c58e27c708472e6f85f6699 ]
Fixes a use-after-free reported by KASAN when later iscsi_target_login_sess_out gets called and it tries to access conn->sess->se_sess:
Disabling lock debugging due to kernel taint
iSCSI Login timeout on Network Portal [::]:3260
iSCSI Login negotiation failed.
==================================================================
BUG: KASAN: use-after-free in
iscsi_target_login_sess_out.cold.12+0x58/0xff [iscsi_target_mod]
Read of size 8 at addr ffff880109d070c8 by task iscsi_np/980
CPU: 1 PID: 980 Comm: iscsi_np Tainted: G O
4.17.8kasan.sess.connops+ #4
Hardware name: To be filled by O.E.M. To be filled by O.E.M./Aptio CRB,
BIOS 5.6.5 05/19/2014
Call Trace:
dump_stack+0x71/0xac
print_address_description+0x65/0x22e
? iscsi_target_login_sess_out.cold.12+0x58/0xff [iscsi_target_mod]
kasan_report.cold.6+0x241/0x2fd
iscsi_target_login_sess_out.cold.12+0x58/0xff [iscsi_target_mod]
iscsi_target_login_thread+0x1086/0x1710 [iscsi_target_mod]
? __sched_text_start+0x8/0x8
? iscsi_target_login_sess_out+0x250/0x250 [iscsi_target_mod]
? __kthread_parkme+0xcc/0x100
? parse_args.cold.14+0xd3/0xd3
? iscsi_target_login_sess_out+0x250/0x250 [iscsi_target_mod]
kthread+0x1a0/0x1c0
? kthread_bind+0x30/0x30
ret_from_fork+0x35/0x40
Allocated by task 980:
kasan_kmalloc+0xbf/0xe0
kmem_cache_alloc_trace+0x112/0x210
iscsi_target_login_thread+0x816/0x1710 [iscsi_target_mod]
kthread+0x1a0/0x1c0
ret_from_fork+0x35/0x40
Freed by task 980:
__kasan_slab_free+0x125/0x170
kfree+0x90/0x1d0
iscsi_target_login_thread+0x1577/0x1710 [iscsi_target_mod]
kthread+0x1a0/0x1c0
ret_from_fork+0x35/0x40
The buggy address belongs to the object at ffff880109d06f00
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 456 bytes inside of
512-byte region [ffff880109d06f00, ffff880109d07100)
The buggy address belongs to the page:
page:ffffea0004274180 count:1 mapcount:0 mapping:0000000000000000
index:0x0 compound_mapcount: 0
flags: 0x17fffc000008100(slab|head)
raw: 017fffc000008100 0000000000000000 0000000000000000 00000001000c000c
raw: dead000000000100 dead000000000200 ffff88011b002e00 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff880109d06f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880109d07000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff880109d07080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff880109d07100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff880109d07180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================--- drivers/target/iscsi/iscsi_target_login.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/target/iscsi/iscsi_target_login.c +3 -5
@@ -310,11 +310,9 @@ static int iscsi_login_zero_tsih_s1(return -ENOMEM ; } - ret =iscsi_login_set_conn_values (sess, conn, pdu->cid); -if (unlikely (ret)) { -kfree (sess); -return ret; - } +if (iscsi_login_set_conn_values (sess, conn, pdu->cid)) + goto free_sess; + sess->init_task_tag = pdu->itt;memcpy (&sess->isid, pdu->isid,6 ); sess->exp_cmd_sn =be32_to_cpu (pdu->cmdsn);
Greg Kroah-Hartman
maintainerPATCH 87/168 scsi: iscsi: target: Fix conn_ops double free
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
[ Upstream commit 05a86e78ea9823ec25b3515db078dd8a76fc263c ]
If iscsi_login_init_conn fails it can free conn_ops. __iscsi_target_login_thread will then call iscsi_target_login_sess_out which will also free it.
This fixes the problem by organizing conn allocation/setup into parts that are needed through the life of the conn and parts that are only needed for the login. The free functions then release what was allocated in the alloc functions.
With this patch we have:
iscsit_alloc_conn/iscsit_free_conn - allocs/frees the conn we need for the entire life of the conn.
iscsi_login_init_conn/iscsi_target_nego_release - allocs/frees the parts of the conn that are only needed during login.
--- drivers/target/iscsi/iscsi_target.c | 9 - drivers/target/iscsi/iscsi_target_login.c | 141 +++++++++++++++--------------- drivers/target/iscsi/iscsi_target_login.h | 2 3 files changed, 77 insertions(+), 75 deletions(-)
drivers/target/iscsi/iscsi_target.c +1 -8
@@ -4211,22 +4211,15 @@ int iscsit_close_connection(crypto_free_ahash (tfm); } -free_cpumask_var (conn->conn_cpumask); - -kfree (conn->conn_ops); - conn->conn_ops =NULL ; -if (conn->sock)sock_release (conn->sock);if (conn->conn_transport->iscsit_free_conn) conn->conn_transport->iscsit_free_conn (conn); -iscsit_put_transport (conn->conn_transport); -pr_debug ("Moving to TARG_CONN_STATE_FREE.\n" ); conn->conn_state =TARG_CONN_STATE_FREE ; -kfree (conn); +iscsit_free_conn (conn);spin_lock_bh (&sess->conn_lock);atomic_dec (&sess->nconn);
drivers/target/iscsi/iscsi_target_login.c +75 -66
199 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_login.h +1 -1
@@ -19,7 +19,7 @@ extern int iscsi_target_setup_login_sockextern int iscsit_accept_np (struct iscsi_np *,struct iscsi_conn *);extern int iscsit_get_login_rx (struct iscsi_conn *,struct iscsi_login *);extern int iscsit_put_login_tx (struct iscsi_conn *,struct iscsi_login *,u32 ); -extern void iscsit_free_conn (struct iscsi_np *,struct iscsi_conn *); +extern void iscsit_free_conn (struct iscsi_conn *);extern int iscsit_start_kthreads (struct iscsi_conn *);extern void iscsi_post_login_handler (struct iscsi_np *,struct iscsi_conn *,u8 ); extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *,
Greg Kroah-Hartman
maintainerPATCH 88/168 scsi: qedi: Add the CRC size within iSCSI NVM image
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit c77a2fa3ff8f73d1a485e67e6f81c64823739d59 ]
The QED driver commit, 1ac4329a1cff ("qed: Add configuration information to register dump and debug data"), removes the CRC length validation causing nvm_get_image failure while loading qedi driver:
[qed_mcp_get_nvm_image:2700(host_10-0)]Image [0] is too big - 00006008 bytes where only 00006004 are available
[qedi_get_boot_info:2253]:10: Could not get NVM image. ret = -12
Hence add and adjust the CRC size to iSCSI NVM image to read boot info at qedi load time.
--- drivers/scsi/qedi/qedi.h | 7 ++++++- drivers/scsi/qedi/qedi_main.c | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-)
drivers/scsi/qedi/qedi.h +6 -1
@@ -77,6 +77,11 @@ enum qedi_nvm_tgts { QEDI_NVM_TGT_SEC, }; +struct qedi_nvm_iscsi_image { +struct nvm_iscsi_cfg iscsi_cfg; +u32 crc; +}; +struct qedi_uio_ctrl {/* meta data */ u32 uio_hsi_version;
@@ -294,7 +299,7 @@ struct qedi_ctx {void *bdq_pbl_list;dma_addr_t bdq_pbl_list_dma;u8 bdq_pbl_list_num_entries; -struct nvm_iscsi_cfg *iscsi_cfg; +struct qedi_nvm_iscsi_image *iscsi_image;dma_addr_t nvm_buf_dma;void __iomem *bdq_primary_prod;void __iomem *bdq_secondary_prod;
drivers/scsi/qedi/qedi_main.c +15 -13
@@ -1346,23 +1346,26 @@ exit_setup_int:static void qedi_free_nvm_iscsi_cfg (struct qedi_ctx *qedi) { -if (qedi->iscsi_cfg) +if (qedi->iscsi_image)dma_free_coherent (&qedi->pdev->dev, -sizeof (struct nvm_iscsi_cfg ), - qedi->iscsi_cfg, qedi->nvm_buf_dma); +sizeof (struct qedi_nvm_iscsi_image ), + qedi->iscsi_image, qedi->nvm_buf_dma); }static int qedi_alloc_nvm_iscsi_cfg (struct qedi_ctx *qedi) { - qedi->iscsi_cfg =dma_zalloc_coherent (&qedi->pdev->dev, -sizeof (struct nvm_iscsi_cfg ), - &qedi->nvm_buf_dma,GFP_KERNEL ); -if (!qedi->iscsi_cfg) { +struct qedi_nvm_iscsi_image nvm_image; + + qedi->iscsi_image =dma_zalloc_coherent (&qedi->pdev->dev, +sizeof (nvm_image), + &qedi->nvm_buf_dma, +GFP_KERNEL ); +if (!qedi->iscsi_image) {QEDI_ERR (&qedi->dbg_ctx,"Could not allocate NVM BUF.\n" );return -ENOMEM ; }QEDI_INFO (&qedi->dbg_ctx,QEDI_LOG_INFO , -"NVM BUF addr=0x%p dma=0x%llx.\n" , qedi->iscsi_cfg, +"NVM BUF addr=0x%p dma=0x%llx.\n" , qedi->iscsi_image, qedi->nvm_buf_dma);return 0 ;
@@ -1905,7 +1908,7 @@ qedi_get_nvram_block(struct qedi_ctx *qestruct nvm_iscsi_block *block; pf = qedi->dev_info.common.abs_pf_id; - block = &qedi->iscsi_cfg->block[0 ]; + block = &qedi->iscsi_image->iscsi_cfg.block[0 ];for (i =0 ; i <NUM_OF_ISCSI_PF_SUPPORTED ; i++, block++) { flags = ((block->id) &NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK ) >>NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET ;
@@ -2194,15 +2197,14 @@ static void qedi_boot_release(void *datastatic int qedi_get_boot_info (struct qedi_ctx *qedi) {int ret =1 ; -u16 len; - - len =sizeof (struct nvm_iscsi_cfg ); +struct qedi_nvm_iscsi_image nvm_image;QEDI_INFO (&qedi->dbg_ctx,QEDI_LOG_INFO ,"Get NVM iSCSI CFG image\n" ); ret = qedi_ops->common->nvm_get_image (qedi->cdev,QED_NVM_IMAGE_ISCSI_CFG , - (char *)qedi->iscsi_cfg, len); + (char *)qedi->iscsi_image, +sizeof (nvm_image));if (ret)QEDI_ERR (&qedi->dbg_ctx,"Could not get NVM image. ret = %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 89/168 perf annotate: Properly interpret indirect call
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Martin Liška" <[email protected]>
[ Upstream commit 1dc27f63303db58ce1b1a6932d1825305f86d574 ]
The patch changes the parsing of:
callq *0x8(%rbx)
from:
0.26 │ → callq *8
to:
0.26 │ → callq *0x8(%rbx)
in this case an address is followed by a register, thus one can't parse only the address.
Committer testing:
1) run 'perf record sleep 10'
2) before applying the patch, run:
perf annotate --stdio2 > /tmp/before
3) after applying the patch, run:
perf annotate --stdio2 > /tmp/after
4) diff /tmp/before /tmp/after:
# --- /tmp/before 2018-08-28 11:16:03.238384143 -0300 # +++ /tmp/after 2018-08-28 11:15:39.335341042 -0300 # @@ -13274,7 +13274,7 @@ # ↓ jle 128 # hash_value = hash_table->hash_func (key); # mov 0x8(%rsp),%rdi # - 0.91 → callq *30 # + 0.91 → callq *0x30(%r12) # mov $0x2,%r8d # cmp $0x2,%eax # node_hash = hash_table->hashes[node_index]; # @@ -13848,7 +13848,7 @@ # mov %r14,%rdi # sub %rbx,%r13 # mov %r13,%rdx # - → callq *38 # + → callq *0x38(%r15)
# cmp %rax,%r13
# 1.91 ↓ je 240
# 1b4: mov $0xffffffff,%r13d
# @@ -14026,7 +14026,7 @@
# mov %rcx,-0x500(%rbp) # mov %r15,%rsi # mov %r14,%rdi # - → callq *38 # + → callq *0x38(%rax) # mov -0x500(%rbp),%rcx # cmp %rax,%rcx
# ↓ jne 9b0
<SNIP tons of other such cases>
--- tools/perf/util/annotate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/annotate.c +8 -2
@@ -245,8 +245,14 @@ find_target: indirect_call: tok =strchr (endptr,'*' ); -if (tok !=NULL ) - ops->target.addr =strtoull (tok +1 ,NULL ,16 ); +if (tok !=NULL ) { + endptr++; + +/* Indirect call can use a non-rip register and offset: callq *0x8(%rbx). +* Do not parse such instruction. */ +if (strstr (endptr,"(%r" ) ==NULL ) + ops->target.addr =strtoull (endptr,NULL ,16 ); + } goto find_target; }
Greg Kroah-Hartman
maintainerPATCH 90/168 perf evsel: Fix potential null pointer dereference in perf_evsel__new_idx()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hisao Tanabe <[email protected]>
[ Upstream commit fd8d2702791a970c751f8b526a17d8e725a05b46 ]
If evsel is NULL, we should return NULL to avoid a NULL pointer dereference a bit later in the code.
LPU-Reference: [email protected]
--- tools/perf/util/evsel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +3 -2
@@ -251,8 +251,9 @@ struct perf_evsel *perf_evsel__new_idx(s {struct perf_evsel *evsel =zalloc (perf_evsel__object.size); -if (evsel !=NULL ) -perf_evsel__init (evsel, attr, idx); +if (!evsel) +return NULL ; +perf_evsel__init (evsel, attr, idx);if (perf_evsel__is_bpf_output (evsel)) { evsel->attr.sample_type |= (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
Greg Kroah-Hartman
maintainerPATCH 91/168 perf util: Fix bad memory access in trace info.
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Phlipot <[email protected]>
[ Upstream commit a72f64261359b7451f8478f2a2bf357b4e6c757f ]
In the write to the output_fd in the error condition of record_saved_cmdline(), we are writing 8 bytes from a memory location on the stack that contains a primitive that is only 4 bytes in size. Change the primitive to 8 bytes in size to match the size of the write in order to avoid reading unknown memory from the stack.
--- tools/perf/util/trace-event-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/trace-event-info.c +1 -1
@@ -377,7 +377,7 @@ out:static int record_saved_cmdline (void ) { -unsigned int size; +unsigned long long size;char *path;struct stat st;int ret, err =0 ;
Greg Kroah-Hartman
maintainerPATCH 92/168 perf probe powerpc: Ignore SyS symbols irrespective of endianness
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit fa694160cca6dbba17c57dc7efec5f93feaf8795 ]
This makes sure that the SyS symbols are ignored for any powerpc system, not just the big endian ones.
--- tools/perf/arch/powerpc/util/sym-handling.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/arch/powerpc/util/sym-handling.c +3 -1
@@ -22,15 +22,16 @@ bool elf__needs_adjust_symbols(GElf_Ehdr#endif -#if !defined(_CALL_ELF) || _CALL_ELF !=2 int arch__choose_best_symbol (struct symbol *syma,struct symbol *symb__maybe_unused ) {char *sym = syma->name; +#if !defined(_CALL_ELF) || _CALL_ELF !=2 /* Skip over any initial dot */ if (*sym =='.' ) sym++; +#endif /* Avoid "SyS" kernel syscall aliases */ if (strlen (sym) >=3 && !strncmp (sym,"SyS" ,3 ))
@@ -41,6 +42,7 @@ int arch__choose_best_symbol(struct symbreturn SYMBOL_A ; } +#if !defined(_CALL_ELF) || _CALL_ELF !=2 /* Allow matching against dot variants */ int arch__compare_symbol_names (const char *namea,const char *nameb) {
Greg Kroah-Hartman
maintainerPATCH 93/168 perf annotate: Fix parsing aarch64 branch instructions after objdump update
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <[email protected]>
[ Upstream commit 4e67b2a5df5d3f341776d12ee575e00ca3ef92de ]
Starting with binutils 2.28, aarch64 objdump adds comments to the disassembly output to show the alternative names of a condition code [1].
It is assumed that commas in objdump comments could occur in other arches now or in the future, so this fix is arch-independent.
The fix could have been done with arm64 specific jump__parse and jump__scnprintf functions, but the jump__scnprintf instruction would have to have its comment character be a literal, since the scnprintf functions cannot receive a struct arch easily.
This inconvenience also applies to the generic jump__scnprintf, which is why we add a raw_comment pointer to struct ins_operands, so the __parse function assigns it to be re-used by its corresponding __scnprintf function.
Example differences in 'perf annotate --stdio2' output on an aarch64 perf.data file:
BEFORE: ? b.cs ffff200008133d1c <unwind_frame+0x18c> // b.hs, dffff7ecc47b
AFTER : ? b.cs 18c
BEFORE: ? b.cc ffff200008d8d9cc <get_alloc_profile+0x31c> // b.lo, b.ul, dffff727295b
AFTER : ? b.cc 31c
The branch target labels 18c and 31c also now appear in the output:
BEFORE: add x26, x29, #0x80
AFTER : 18c: add x26, x29, #0x80
BEFORE: add x21, x21, #0x8
AFTER : 31c: add x21, x21, #0x8
The Fixes: tag below is added so stable branches will get the update; it doesn't necessarily mean that commit was broken at the time, rather it didn't withstand the aarch64 objdump update.
Tested no difference in output for sample x86_64, power arch perf.data files.
--- tools/perf/util/annotate.c | 22 +++++++++++++++++++++- tools/perf/util/annotate.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-)
tools/perf/util/annotate.c +21 -1
@@ -281,7 +281,19 @@ bool ins__is_call(const struct ins *ins)return ins->ops == &call_ops || ins->ops == &s390_call_ops; } -static int jump__parse (struct arch *arch__maybe_unused ,struct ins_operands *ops,struct map_symbol *ms) +/* +* Prevents from matching commas in the comment section, e.g.: +* ffff200008446e70: b.cs ffff2000084470f4 <generic_exec_single+0x314> // b.hs, b.nlast +*/ +static inline const char *validate_comma (const char *c,struct ins_operands *ops) +{ +if (ops->raw_comment && c > ops->raw_comment) +return NULL ; + +return c; +} + +static int jump__parse (struct arch *arch,struct ins_operands *ops,struct map_symbol *ms) {struct map *map = ms->map;struct symbol *sym = ms->sym;
@@ -290,6 +302,10 @@ static int jump__parse(struct arch *arch };const char *c =strchr (ops->raw,',' );u64 start, end; + + ops->raw_comment =strchr (ops->raw, arch->objdump.comment_char); + c =validate_comma (c, ops); +/* * Examples of lines to parse for the _cpp_lex_token@@Base * function:
@@ -309,6 +325,7 @@ static int jump__parse(struct arch *arch ops->target.addr =strtoull (c,NULL ,16 );if (!ops->target.addr) { c =strchr (c,',' ); + c =validate_comma (c, ops);if (c++ !=NULL ) ops->target.addr =strtoull (c,NULL ,16 ); }
@@ -366,9 +383,12 @@ static int jump__scnprintf(struct ins *ireturn scnprintf (bf, size,"%-6s %s" , ins->name, ops->target.sym->name); c =strchr (ops->raw,',' ); + c =validate_comma (c, ops); +if (c !=NULL ) {const char *c2 =strchr (c +1 ,',' ); + c2 =validate_comma (c2, ops);/* check for 3-op insn */ if (c2 !=NULL ) c = c2;
tools/perf/util/annotate.h +1 -0
@@ -21,6 +21,7 @@ struct ins {struct ins_operands {char *raw; +char *raw_comment;struct {char *raw;char *name;
Greg Kroah-Hartman
maintainerPATCH 94/168 netfilter: kconfig: nat related expression depend on nftables core
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit e0758412208960be9de11e6d2350c81ffd88410f ]
NF_TABLES_IPV4 is now boolean so it is possible to set
NF_TABLES=m
NF_TABLES_IPV4=y
NFT_CHAIN_NAT_IPV4=y
which causes:
nft_chain_nat_ipv4.c:(.text+0x6d): undefined reference to `nft_do_chain'
Wrap NFT_CHAIN_NAT_IPV4 and related nat expressions with NF_TABLES to restore the dependency.
--- net/ipv4/netfilter/Kconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/ipv4/netfilter/Kconfig +5 -3
@@ -122,6 +122,10 @@ config NF_NAT_IPV4 if NF_NAT_IPV4 +config NF_NAT_MASQUERADE_IPV4 + bool + +if NF_TABLES config NFT_CHAIN_NAT_IPV4 depends on NF_TABLES_IPV4 tristate "IPv4 nf_tables nat chain support"
@@ -131,9 +135,6 @@ config NFT_CHAIN_NAT_IPV4 packet transformations such as the source, destination address and source and destination ports. -config NF_NAT_MASQUERADE_IPV4 - bool - config NFT_MASQ_IPV4 tristate "IPv4 masquerading support for nf_tables" depends on NF_TABLES_IPV4
@@ -151,6 +152,7 @@ config NFT_REDIR_IPV4 help This is the expression that provides IPv4 redirect support for nf_tables. +endif # NF_TABLES config NF_NAT_SNMP_BASIC tristate "Basic SNMP-ALG support"
Greg Kroah-Hartman
maintainerPATCH 95/168 netfilter: nf_tables: release chain in flushing set
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taehee Yoo <[email protected]>
[ Upstream commit 7acfda539c0b9636a58bfee56abfb3aeee806d96 ]
When element of verdict map is deleted, the delete routine should release chain. however, flush element of verdict map routine doesn't release chain.
test commands:
%nft add table ip filter
%nft add chain ip filter c1
%nft add map ip filter map1 { type ipv4_addr : verdict \; } %nft add element ip filter map1 { 1 : jump c1 } %nft flush map ip filter map1
%nft flush ruleset
splat looks like:
[ 4895.170899] kernel BUG at net/netfilter/nf_tables_api.c:1415! [ 4895.178114] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 4895.178880] CPU: 0 PID: 1670 Comm: nft Not tainted 4.18.0+ #55 [ 4895.178880] RIP: 0010:nf_tables_chain_destroy.isra.28+0x39/0x220 [nf_tables] [ 4895.178880] Code: fc ff df 53 48 89 fb 48 83 c7 50 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 09 3c 03 7f 05 e8 3e 4c 25 e1 8b 43 50 85 c0 74 02 <0f> 0b 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 80 3c 02 [ 4895.228342] RSP: 0018:ffff88010b98f4c0 EFLAGS: 00010202 [ 4895.234841] RAX: 0000000000000001 RBX: ffff8801131c6968 RCX: ffff8801146585b0 [ 4895.234841] RDX: 1ffff10022638d37 RSI: ffff8801191a9348 RDI: ffff8801131c69b8 [ 4895.234841] RBP: ffff8801146585a8 R08: 1ffff1002323526a R09: 0000000000000000 [ 4895.234841] R10: 0000000000000000 R11: 0000000000000000 R12: dead000000000200 [ 4895.234841] R13: dead000000000100 R14: ffffffffa3638af8 R15: dffffc0000000000 [ 4895.234841] FS: 00007f6d188e6700(0000) GS:ffff88011b600000(0000) knlGS:0000000000000000 [ 4895.234841] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4895.234841] CR2: 00007ffe72b8df88 CR3: 000000010e2d4000 CR4: 00000000001006f0 [ 4895.234841] Call Trace: [ 4895.234841] nf_tables_commit+0x2704/0x2c70 [nf_tables] [ 4895.234841] ? nfnetlink_rcv_batch+0xa4f/0x11b0 [nfnetlink] [ 4895.234841] ? nf_tables_setelem_notify.constprop.48+0x1a0/0x1a0 [nf_tables] [ 4895.323824] ? __lock_is_held+0x9d/0x130 [ 4895.323824] ? kasan_unpoison_shadow+0x30/0x40 [ 4895.333299] ? kasan_kmalloc+0xa9/0xc0 [ 4895.333299] ? kmem_cache_alloc_trace+0x2c0/0x310 [ 4895.333299] ? nfnetlink_rcv_batch+0xa4f/0x11b0 [nfnetlink] [ 4895.333299] nfnetlink_rcv_batch+0xdb9/0x11b0 [nfnetlink] [ 4895.333299] ? debug_show_all_locks+0x290/0x290 [ 4895.333299] ? nfnetlink_net_init+0x150/0x150 [nfnetlink] [ 4895.333299] ? sched_clock_cpu+0xe5/0x170 [ 4895.333299] ? sched_clock_local+0xff/0x130 [ 4895.333299] ? sched_clock_cpu+0xe5/0x170 [ 4895.333299] ? find_held_lock+0x39/0x1b0 [ 4895.333299] ? sched_clock_local+0xff/0x130 [ 4895.333299] ? memset+0x1f/0x40 [ 4895.333299] ? nla_parse+0x33/0x260 [ 4895.333299] ? ns_capable_common+0x6e/0x110 [ 4895.333299] nfnetlink_rcv+0x2c0/0x310 [nfnetlink]
[ ... ]
--- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
@@ -4582,6 +4582,7 @@ static int nft_flush_set(const struct nf } set->ndeact++; +nft_set_elem_deactivate (ctx->net, set, elem);nft_trans_elem_set (trans) = set;nft_trans_elem (trans) = *elem;list_add_tail (&trans->list, &ctx->net->nft.commit_list);
Greg Kroah-Hartman
maintainerPATCH 96/168 Revert "iio: temperature: maxim_thermocouple: add MAX31856 part"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Ranostay <[email protected]>
[ Upstream commit 65099ea85e885c3ea1272eca8774b771419d8ce8 ]
This reverts commit 535fba29b3e1afef4ba201b3c69a6992583ec0bd.
Seems the submitter (er me, hang head in shame) didn't look at the datasheet enough to see that the registers are quite different.
This needs to be reverted because a) would never work b) to open it be added to a Maxim RTDs (Resistance Temperature Detectors) under development by author
--- drivers/iio/temperature/maxim_thermocouple.c | 1 - 1 file changed, 1 deletion(-)
drivers/iio/temperature/maxim_thermocouple.c +0 -1
@@ -258,7 +258,6 @@ static int maxim_thermocouple_remove(strstatic const struct spi_device_id maxim_thermocouple_id[] = { {"max6675" ,MAX6675 }, {"max31855" ,MAX31855 }, - {"max31856" ,MAX31855 }, {}, };MODULE_DEVICE_TABLE (spi, maxim_thermocouple_id);
Greg Kroah-Hartman
maintainerPATCH 97/168 iio: imu: st_lsm6dsx: take into account ts samples in wm configuration
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit a13bf65f3f2e36008ea60b49d3bda2527e09fd9c ]
Take into account hw timer samples in pattern length computation done in st_lsm6dsx_update_watermark routine for watermark configuration. Moreover use samples in pattern (sip) already computed in st_lsm6dsx_update_decimators routine
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +6 -7
@@ -187,12 +187,15 @@ static int st_lsm6dsx_set_fifo_odr(strucint st_lsm6dsx_update_watermark (struct st_lsm6dsx_sensor *sensor,u16 watermark) { -u16 fifo_watermark = ~0 , cur_watermark, sip =0 , fifo_th_mask; +u16 fifo_watermark = ~0 , cur_watermark, fifo_th_mask;struct st_lsm6dsx_hw *hw = sensor->hw;struct st_lsm6dsx_sensor *cur_sensor;int i, err, data;__le16 wdata; +if (!hw->sip) +return 0 ; +for (i =0 ; i <ST_LSM6DSX_ID_MAX ; i++) { cur_sensor =iio_priv (hw->iio_devs[i]);
@@ -203,14 +206,10 @@ int st_lsm6dsx_update_watermark(struct s : cur_sensor->watermark; fifo_watermark =min_t (u16, fifo_watermark, cur_watermark); - sip += cur_sensor->sip; } -if (!sip) -return 0 ; - - fifo_watermark =max_t (u16, fifo_watermark, sip); - fifo_watermark = (fifo_watermark / sip) * sip; + fifo_watermark =max_t (u16, fifo_watermark, hw->sip); + fifo_watermark = (fifo_watermark / hw->sip) * hw->sip; fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl; err = regmap_read(hw->regmap, hw->settings->fifo_ops.fifo_th.addr + 1,
Greg Kroah-Hartman
maintainerPATCH 98/168 RDMA/ucma: check fd type in ucma_migrate_id()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
[ Upstream commit 0d23ba6034b9cf48b8918404367506da3e4b3ee5 ]
The current code grabs the private_data of whatever file descriptor userspace has supplied and implicitly casts it to a struct ucma_file *, potentially causing a type confusion.
This is probably fine in practice because the pointer is only used for comparisons, it is never actually dereferenced; and even in the comparisons, it is unlikely that a file from another filesystem would have a ->private_data pointer that happens to also be valid in this context. But ->private_data is not always guaranteed to be a valid pointer to an object owned by the file's filesystem; for example, some filesystems just cram numbers in there.
Check the type of the supplied file descriptor to be safe, analogous to how other places in the kernel do it.
--- drivers/infiniband/core/ucma.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/core/ucma.c +6 -0
@@ -124,6 +124,8 @@ static DEFINE_MUTEX(mut);static DEFINE_IDR (ctx_idr);static DEFINE_IDR (multicast_idr); +static const struct file_operations ucma_fops; +static inline struct ucma_context *_ucma_find_context (int id,struct ucma_file *file) {
@@ -1581,6 +1583,10 @@ static ssize_t ucma_migrate_id(struct uc f =fdget (cmd.fd);if (!f.file)return -ENOENT ; +if (f.file->f_op != &ucma_fops) { + ret = -EINVAL ; + goto file_put; + }/* Validate current fd and prevent destruction of id. */ ctx =ucma_get_ctx (f.file->private_data, cmd.id);
Greg Kroah-Hartman
maintainerPATCH 99/168 riscv: Do not overwrite initrd_start and initrd_end
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit e866d3e84eb7c9588afb77604d417e8cc49fe216 ]
setup_initrd() overwrites initrd_start and initrd_end if __initramfs_size is larger than 0, which is always true even if there is no embedded initramfs. This prevents booting qemu with "-initrd" parameter. Overwriting initrd_start and initrd_end is not necessary since __initramfs_start and __initramfs_size are used directly in populate_rootfs() to load the built-in initramfs, so just drop that code.
--- arch/riscv/kernel/setup.c | 7 ------- 1 file changed, 7 deletions(-)
arch/riscv/kernel/setup.c +0 -7
@@ -64,15 +64,8 @@ atomic_t hart_lottery;#ifdef CONFIG_BLK_DEV_INITRD static void __init setup_initrd (void ) { -extern char __initramfs_start[]; -extern unsigned long __initramfs_size;unsigned long size; -if (__initramfs_size >0 ) { - initrd_start = (unsigned long )(&__initramfs_start); - initrd_end = initrd_start + __initramfs_size; - } -if (initrd_start >= initrd_end) {printk (KERN_INFO "initrd not found or empty" ); goto disable;
Greg Kroah-Hartman
maintainerPATCH 100/168 HID: sensor-hub: Restore fixup for Lenovo ThinkPad Helix 2 sensor hub report
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit ade573eb1e03d1ee5abcb3359b1259469ab6e8ed ]
Commit b0f847e16c1e ("HID: hid-sensor-hub: Force logical minimum to 1 for power and report state") not only replaced the descriptor fixup done for devices with the HID_SENSOR_HUB_ENUM_QUIRK with a generic fix, but also accidentally removed the unrelated descriptor fixup for the Lenovo ThinkPad Helix 2 sensor hub. This commit restores this fixup.
Restoring this fixup not only fixes the Lenovo ThinkPad Helix 2's sensors, but also the Lenovo ThinkPad 8's sensors.
--- drivers/hid/hid-sensor-hub.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/hid/hid-sensor-hub.c +23 -0
@@ -579,6 +579,28 @@ void sensor_hub_device_close(struct hid_ }EXPORT_SYMBOL_GPL (sensor_hub_device_close); +static __u8 *sensor_hub_report_fixup (struct hid_device *hdev,__u8 *rdesc, +unsigned int *rsize) +{ +/* +* Checks if the report descriptor of Thinkpad Helix 2 has a logical +* minimum for magnetic flux axis greater than the maximum. +*/ +if (hdev->product ==USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA && + *rsize ==2558 && rdesc[913 ] ==0x17 && rdesc[914 ] ==0x40 && + rdesc[915 ] ==0x81 && rdesc[916 ] ==0x08 && + rdesc[917 ] ==0x00 && rdesc[918 ] ==0x27 && + rdesc[921 ] ==0x07 && rdesc[922 ] ==0x00 ) { +/* Sets negative logical minimum for mag x, y and z */ + rdesc[914 ] = rdesc[935 ] = rdesc[956 ] =0xc0 ; + rdesc[915 ] = rdesc[936 ] = rdesc[957 ] =0x7e ; + rdesc[916 ] = rdesc[937 ] = rdesc[958 ] =0xf7 ; + rdesc[917 ] = rdesc[938 ] = rdesc[959 ] =0xff ; + } + +return rdesc; +} +static int sensor_hub_probe (struct hid_device *hdev,const struct hid_device_id *id) {
@@ -743,6 +765,7 @@ static struct hid_driver sensor_hub_driv .probe = sensor_hub_probe, .remove = sensor_hub_remove, .raw_event = sensor_hub_raw_event, + .report_fixup = sensor_hub_report_fixup, #ifdef CONFIG_PM .suspend = sensor_hub_suspend, .resume = sensor_hub_resume,
Greg Kroah-Hartman
maintainerPATCH 101/168 usb: host: xhci-plat: Iterate over parent nodes for finding quirks
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anurag Kumar Vulisha <[email protected]>
[ Upstream commit 222471f7640d9771a993218d825d84825adc805d ]
In xhci_plat_probe() both sysdev and pdev->dev are being used for finding quirks. There are some drivers(like dwc3 host.c) which adds quirks(like usb3-lpm-capable) into pdev and the logic present in xhci_plat_probe() checks for quirks in either sysdev or pdev for finding the quirks. Because of this logic, some of the quirks are getting missed(usb3-lpm-capable quirk added by dwc3 host.c driver is getting missed).This patch fixes this by iterating over all the available parents for finding the quirks. In this way all the quirks which are present in child or parent are correctly updated.
--- drivers/usb/host/xhci-plat.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/usb/host/xhci-plat.c +16 -11
@@ -152,7 +152,7 @@ static int xhci_plat_probe(struct platfo {const struct xhci_plat_priv *priv_match;const struct hc_driver *driver; -struct device *sysdev; +struct device *sysdev, *tmpdev;struct xhci_hcd *xhci;struct resource *res;struct usb_hcd *hcd;
@@ -272,19 +272,24 @@ static int xhci_plat_probe(struct platfo goto disable_clk; } -if (device_property_read_bool (sysdev,"usb2-lpm-disable" )) - xhci->quirks |=XHCI_HW_LPM_DISABLE ; +/* imod_interval is the interrupt moderation value in nanoseconds. */ + xhci->imod_interval =40000 ; -if (device_property_read_bool (sysdev,"usb3-lpm-capable" )) - xhci->quirks |=XHCI_LPM_SUPPORT ; +/* Iterate over all parent nodes for finding quirks */ +for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { -if (device_property_read_bool (&pdev->dev,"quirk-broken-port-ped" )) - xhci->quirks |=XHCI_BROKEN_PORT_PED ; +if (device_property_read_bool (tmpdev,"usb2-lpm-disable" )) + xhci->quirks |=XHCI_HW_LPM_DISABLE ; -/* imod_interval is the interrupt moderation value in nanoseconds. */ - xhci->imod_interval =40000 ; -device_property_read_u32 (sysdev,"imod-interval-ns" , - &xhci->imod_interval); +if (device_property_read_bool (tmpdev,"usb3-lpm-capable" )) + xhci->quirks |=XHCI_LPM_SUPPORT ; + +if (device_property_read_bool (tmpdev,"quirk-broken-port-ped" )) + xhci->quirks |=XHCI_BROKEN_PORT_PED ; + +device_property_read_u32 (tmpdev,"imod-interval-ns" , + &xhci->imod_interval); + } hcd->usb_phy =devm_usb_get_phy_by_phandle (sysdev,"usb-phy" ,0 );if (IS_ERR (hcd->usb_phy)) {
Greg Kroah-Hartman
maintainerPATCH 102/168 USB: yurex: Check for truncation in yurex_read()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
[ Upstream commit 14427b86837a4baf1c121934c6599bdb67dfa9fc ]
snprintf() always returns the full length of the string it could have printed, even if it was truncated because the buffer was too small. So in case the counter value is truncated, we will over-read from in_buffer and over-write to the caller's buffer.
I don't think it's actually possible for this to happen, but in case truncation occurs, WARN and return -EIO.
--- drivers/usb/misc/yurex.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/misc/yurex.c +3 -0
@@ -413,6 +413,9 @@ static ssize_t yurex_read(struct file *fspin_unlock_irqrestore (&dev->lock, flags);mutex_unlock (&dev->io_mutex); +if (WARN_ON_ONCE (len >=sizeof (in_buffer))) +return -EIO ; +return simple_read_from_buffer (buffer, count, ppos, in_buffer, len); }
Greg Kroah-Hartman
maintainerPATCH 103/168 nvmet-rdma: fix possible bogus dereference under heavy load
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
[ Upstream commit 8407879c4e0d7731f6e7e905893cecf61a7762c7 ]
Currently we always repost the recv buffer before we send a response capsule back to the host. Since ordering is not guaranteed for send and recv completions, it is posible that we will receive a new request from the host before we got a send completion for the response capsule.
Today, we pre-allocate 2x rsps the length of the queue, but in reality, under heavy load there is nothing that is really preventing the gap to expand until we exhaust all our rsps.
To fix this, if we don't have any pre-allocated rsps left, we dynamically allocate a rsp and make sure to free it when we are done. If under memory pressure we fail to allocate a rsp, we silently drop the command and wait for the host to retry.
--- drivers/nvme/target/rdma.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/nvme/target/rdma.c +25 -2
@@ -65,6 +65,7 @@ struct nvmet_rdma_rsp {struct nvmet_req req; +bool allocated;u8 n_rdma;u32 flags;u32 invalidate_rkey;
@@ -166,11 +167,19 @@ nvmet_rdma_get_rsp(struct nvmet_rdma_queunsigned long flags;spin_lock_irqsave (&queue->rsps_lock, flags); - rsp =list_first_entry (&queue->free_rsps, + rsp =list_first_entry_or_null (&queue->free_rsps, struct nvmet_rdma_rsp, free_list); -list_del (&rsp->free_list); +if (likely (rsp)) +list_del (&rsp->free_list);spin_unlock_irqrestore (&queue->rsps_lock, flags); +if (unlikely (!rsp)) { + rsp =kmalloc (sizeof (*rsp),GFP_KERNEL ); +if (unlikely (!rsp)) +return NULL ; + rsp->allocated = true; + } +return rsp; }
@@ -179,6 +188,11 @@ nvmet_rdma_put_rsp(struct nvmet_rdma_rsp {unsigned long flags; +if (rsp->allocated) { +kfree (rsp); +return ; + } +spin_lock_irqsave (&rsp->queue->rsps_lock, flags);list_add_tail (&rsp->free_list, &rsp->queue->free_rsps);spin_unlock_irqrestore (&rsp->queue->rsps_lock, flags);
@@ -702,6 +716,15 @@ static void nvmet_rdma_recv_done(struct cmd->queue = queue; rsp =nvmet_rdma_get_rsp (queue); +if (unlikely (!rsp)) { +/* +* we get here only under memory pressure, +* silently drop and have the host retry +* as we can't even fail it. +*/ +nvmet_rdma_post_recv (queue->dev, cmd); +return ; + } rsp->queue = queue; rsp->cmd = cmd; rsp->flags =0 ;
Greg Kroah-Hartman
maintainerPATCH 104/168 bnxt_re: Fix couple of memory leaks that could lead to IOMMU call traces
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Somnath Kotur <[email protected]>
[ Upstream commit f40f299bbe806a2e2c8b0d7cdda822fa3bdd171b ]
1. DMA-able memory allocated for Shadow QP was not being freed.
2. bnxt_qplib_alloc_qp_hdr_buf() had a bug wherein the SQ pointer was erroneously pointing to the RQ. But since the corresponding free_qp_hdr_buf() was correct, memory being free was less than what was allocated.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 ++ drivers/infiniband/hw/bnxt_re/qplib_fp.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +2 -0
@@ -844,6 +844,8 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_ "Failed to destroy Shadow QP");return rc; } +bnxt_qplib_free_qp_res (&rdev->qplib_res, + &rdev->qp1_sqp->qplib_qp);mutex_lock (&rdev->qp_lock);list_del (&rdev->qp1_sqp->list);atomic_dec (&rdev->qp_count);
drivers/infiniband/hw/bnxt_re/qplib_fp.c +1 -1
@@ -196,7 +196,7 @@ static int bnxt_qplib_alloc_qp_hdr_buf(s struct bnxt_qplib_qp *qp) {struct bnxt_qplib_q *rq = &qp->rq; -struct bnxt_qplib_q *sq = &qp->rq; +struct bnxt_qplib_q *sq = &qp->sq;int rc =0 ;if (qp->sq_hdr_buf_size && sq->hwq.max_elements) {
Greg Kroah-Hartman
maintainerPATCH 105/168 net/mlx5: Consider PCI domain in search for next dev
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Jurgens <[email protected]>
[ Upstream commit df7ddb2396cd162e64aaff9401be05e31e438961 ]
The PCI BDF is not unique. PCI domain must also be considered when searching for the next physical device during lag setup. Example below:
mlx5_core 0000:01:00.0: MLX5E: StrdRq(1) RqSz(8) StrdSz(128) RxCqeCmprss(0) mlx5_core 0000:01:00.1: MLX5E: StrdRq(1) RqSz(8) StrdSz(128) RxCqeCmprss(0) mlx5_core 0001:01:00.0: MLX5E: StrdRq(1) RqSz(8) StrdSz(128) RxCqeCmprss(0) mlx5_core 0001:01:00.1: MLX5E: StrdRq(1) RqSz(8) StrdSz(128) RxCqeCmprss(0)
--- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +4 -3
@@ -396,16 +396,17 @@ void mlx5_remove_dev_by_protocol(struct } } -static u16 mlx5_gen_pci_id (struct mlx5_core_dev *dev) +static u32 mlx5_gen_pci_id (struct mlx5_core_dev *dev) { -return (u16)((dev->pdev->bus->number <<8 ) | +return (u32)((pci_domain_nr (dev->pdev->bus) <<16 ) | + (dev->pdev->bus->number <<8 ) |PCI_SLOT (dev->pdev->devfn)); }/* Must be called with intf_mutex held */ struct mlx5_core_dev *mlx5_get_next_phys_dev (struct mlx5_core_dev *dev) { -u16 pci_id =mlx5_gen_pci_id (dev); +u32 pci_id =mlx5_gen_pci_id (dev);struct mlx5_core_dev *res =NULL ;struct mlx5_core_dev *tmp_dev;struct mlx5_priv *priv;
Greg Kroah-Hartman
maintainerPATCH 106/168 HID: i2c-hid: Dont reset device upon system resume
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
[ Upstream commit 52cf93e63ee672a92f349edc6ddad86ec8808fd8 ]
Raydium touchscreen triggers interrupt storm after system-wide suspend:
[ 179.085033] i2c_hid i2c-CUST0000:00: i2c_hid_get_input: incomplete report (58/65535)
According to Raydium, Windows driver does not reset the device after system resume.
The HID over I2C spec does specify a reset should be used at intialization, but it doesn't specify if reset is required for system suspend.
Tested this patch on other i2c-hid touchpanels I have and those touchpanels do work after S3 without doing reset. If any regression happens to other touchpanel vendors, we can use quirk for Raydium devices.
There's still one device uses I2C_HID_QUIRK_RESEND_REPORT_DESCR so keep it there.
--- drivers/hid/hid-ids.h | 4 ---- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++------ 2 files changed, 7 insertions(+), 10 deletions(-)
drivers/hid/hid-ids.h +0 -4
@@ -528,10 +528,6 @@#define I2C_VENDOR_ID_HANTICK 0x0911#define I2C_PRODUCT_ID_HANTICK_5288 0x5288 -#define I2C_VENDOR_ID_RAYD 0x2386 -#define I2C_PRODUCT_ID_RAYD_3118 0x3118 -#define I2C_PRODUCT_ID_RAYD_4B33 0x4B33 -#define USB_VENDOR_ID_HANWANG 0x0b57#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff
drivers/hid/i2c-hid/i2c-hid.c +7 -6
@@ -170,12 +170,8 @@ static const struct i2c_hid_quirks { I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, {I2C_VENDOR_ID_HANTICK ,I2C_PRODUCT_ID_HANTICK_5288 , I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, - { I2C_VENDOR_ID_RAYD, I2C_PRODUCT_ID_RAYD_3118, - I2C_HID_QUIRK_RESEND_REPORT_DESCR }, { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, I2C_HID_QUIRK_RESEND_REPORT_DESCR }, - { I2C_VENDOR_ID_RAYD, I2C_PRODUCT_ID_RAYD_4B33, - I2C_HID_QUIRK_RESEND_REPORT_DESCR }, { 0, 0 } };
@@ -1237,11 +1233,16 @@ static int i2c_hid_resume(struct devicepm_runtime_enable (dev);enable_irq (client->irq); - ret =i2c_hid_hwreset (client); + +/* Instead of resetting device, simply powers the device on. This +* solves "incomplete reports" on Raydium devices 2386:3118 and +* 2386:4B33 +*/ + ret =i2c_hid_set_power (client,I2C_HID_PWR_ON );if (ret)return ret; -/* RAYDIUM device (2386:3118) need to re-send report descr cmd +/* Some devices need to re-send report descr cmd * after resume, after this it will be back normal. * otherwise it issues too many incomplete reports. */
Greg Kroah-Hartman
maintainerPATCH 107/168 dm raid: fix reshape race on small devices
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heinz Mauelshagen <[email protected]>
[ Upstream commit 38b0bd0cda07d34ad6f145fce675ead74739c44e ]
Loading a new mapping table, the dm-raid target's constructor retrieves the volatile reshaping state from the raid superblocks.
When the new table is activated in a following resume, the actual reshape position is retrieved. The reshape driven by the previous mapping can already have finished on small and/or fast devices thus updating raid superblocks about the new raid layout.
This causes the actual array state (e.g. stripe size reshape finished) to be inconsistent with the one in the new mapping, causing hangs with left behind devices.
This race does not occur with usual raid device sizes but with small ones (e.g. those created by the lvm2 test suite).
Fix by no longer transferring stale/inconsistent raid_set state during preresume.
--- drivers/md/dm-raid.c | 48 +----------------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-)
drivers/md/dm-raid.c +1 -47
@@ -29,9 +29,6 @@*/ #define MIN_RAID456_JOURNAL_SPACE (4*2048) -/* Global list of all raid sets */ -static LIST_HEAD (raid_sets); -static bool devices_handle_discard_safely = false;/*
@@ -227,7 +224,6 @@ struct rs_layout {struct raid_set {struct dm_target *ti; -struct list_head list;uint32_t stripe_cache_entries;unsigned long ctr_flags;
@@ -273,19 +269,6 @@ static void rs_config_restore(struct rai mddev->new_chunk_sectors = l->new_chunk_sectors; } -/* Find any raid_set in active slot for @rs on global list */ -static struct raid_set *rs_find_active (struct raid_set *rs) -{ -struct raid_set *r; -struct mapped_device *md =dm_table_get_md (rs->ti->table); - -list_for_each_entry (r, &raid_sets, list) -if (r != rs &&dm_table_get_md (r->ti->table) == md) -return r; - -return NULL ; -} -/* raid10 algorithms (i.e. formats) */ #define ALGORITHM_RAID10_DEFAULT 0#define ALGORITHM_RAID10_NEAR 1
@@ -764,7 +747,6 @@ static struct raid_set *raid_set_alloc(smddev_init (&rs->md); -INIT_LIST_HEAD (&rs->list); rs->raid_disks = raid_devs; rs->delta_disks =0 ;
@@ -782,9 +764,6 @@ static struct raid_set *raid_set_alloc(sfor (i =0 ; i < raid_devs; i++)md_rdev_init (&rs->dev[i].rdev); -/* Add @rs to global list. */ -list_add (&rs->list, &raid_sets); -/* * Remaining items to be initialized by further RAID params: * rs->md.persistent
@@ -797,7 +776,7 @@ static struct raid_set *raid_set_alloc(sreturn rs; } -/* Free all @rs allocations and remove it from global list. */ +/* Free all @rs allocations */ static void raid_set_free (struct raid_set *rs) {int i;
@@ -815,8 +794,6 @@ static void raid_set_free(struct raid_sedm_put_device (rs->ti, rs->dev[i].data_dev); } -list_del (&rs->list); -kfree (rs); }
@@ -3947,29 +3924,6 @@ static int raid_preresume(struct dm_targif (test_and_set_bit (RT_FLAG_RS_PRERESUMED , &rs->runtime_flags))return 0 ; -if (!test_bit (__CTR_FLAG_REBUILD, &rs->ctr_flags)) { -struct raid_set *rs_active =rs_find_active (rs); - -if (rs_active) { -/* -* In case no rebuilds have been requested -* and an active table slot exists, copy -* current resynchonization completed and -* reshape position pointers across from -* suspended raid set in the active slot. -* -* This resumes the new mapping at current -* offsets to continue recover/reshape without -* necessarily redoing a raid set partially or -* causing data corruption in case of a reshape. -*/ -if (rs_active->md.curr_resync_completed != MaxSector) - mddev->curr_resync_completed = rs_active->md.curr_resync_completed; -if (rs_active->md.reshape_position != MaxSector) - mddev->reshape_position = rs_active->md.reshape_position; - } - } -/* * The superblocks need to be updated on disk if the * array is new or new devices got added (thus zeroed
Greg Kroah-Hartman
maintainerPATCH 108/168 drm/nouveau: fix oops in client init failure path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
[ Upstream commit a43b16dda2d7485f5c5aed075c1dc9785e339515 ]
The NV_ERROR macro requires drm->client to be initialised, which it may not be at this stage of the init process.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +7 -7
@@ -230,7 +230,7 @@ nouveau_cli_init(struct nouveau_drm *drmmutex_unlock (&drm->master.lock); }if (ret) { -NV_ERROR (drm,"Client allocation failed: %d\n" , ret); +NV_PRINTK (err, cli,"Client allocation failed: %d\n" , ret); goto done; }
@@ -240,37 +240,37 @@ nouveau_cli_init(struct nouveau_drm *drm }, sizeof(struct nv_device_v0), &cli->device);if (ret) { -NV_ERROR (drm,"Device allocation failed: %d\n" , ret); +NV_PRINTK (err, cli,"Device allocation failed: %d\n" , ret); goto done; } ret =nvif_mclass (&cli->device.object, mmus);if (ret <0 ) { -NV_ERROR (drm,"No supported MMU class\n" ); +NV_PRINTK (err, cli,"No supported MMU class\n" ); goto done; } ret =nvif_mmu_init (&cli->device.object, mmus[ret].oclass, &cli->mmu);if (ret) { -NV_ERROR (drm,"MMU allocation failed: %d\n" , ret); +NV_PRINTK (err, cli,"MMU allocation failed: %d\n" , ret); goto done; } ret =nvif_mclass (&cli->mmu.object, vmms);if (ret <0 ) { -NV_ERROR (drm,"No supported VMM class\n" ); +NV_PRINTK (err, cli,"No supported VMM class\n" ); goto done; } ret =nouveau_vmm_init (cli, vmms[ret].oclass, &cli->vmm);if (ret) { -NV_ERROR (drm,"VMM allocation failed: %d\n" , ret); +NV_PRINTK (err, cli,"VMM allocation failed: %d\n" , ret); goto done; } ret =nvif_mclass (&cli->mmu.object, mems);if (ret <0 ) { -NV_ERROR (drm,"No supported MEM class\n" ); +NV_PRINTK (err, cli,"No supported MEM class\n" ); goto done; }
Greg Kroah-Hartman
maintainerPATCH 109/168 drm/nouveau/mmu: dont attempt to dereference vmm without valid instance pointer
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
[ Upstream commit 51ed833c881b9d96557c773f6a37018d79e29a46 ]
Fixes oopses in certain failure paths.
--- drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +1 -1
@@ -1423,7 +1423,7 @@ nvkm_vmm_get(struct nvkm_vmm *vmm, u8 pavoid nvkm_vmm_part (struct nvkm_vmm *vmm,struct nvkm_memory *inst) { -if (vmm->func->part && inst) { +if (inst && vmm->func->part) {mutex_lock (&vmm->mutex); vmm->func->part (vmm, inst);mutex_unlock (&vmm->mutex);
Greg Kroah-Hartman
maintainerPATCH 110/168 drm/nouveau/TBDdevinit: dont fail when PMU/PRE_OS is missing from VBIOS
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
[ Upstream commit 0a6986c6595e9afd20ff7280dab36431c1e467f8 ]
This Falcon application doesn't appear to be present on some newer systems, so let's not fail init if we can't find it.
TBD: is there a way to determine whether it *should* be there?
--- drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c +2 -1
@@ -158,7 +158,8 @@ gm200_devinit_post(struct nvkm_devinit * }/* load and execute some other ucode image (bios therm?) */ -return pmu_load (init,0x01 , post,NULL ,NULL ); +pmu_load (init,0x01 , post,NULL ,NULL ); +return 0 ; } static const struct nvkm_devinit_func
Greg Kroah-Hartman
maintainerPATCH 111/168 drm/nouveau/disp: fix DP disable race
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
[ Upstream commit e04cfdc9b7398c60dbc70212415ea63b6c6a93ae ]
If a HPD pulse signalling the need to retrain the link occurs between the KMS driver releasing the output and the supervisor interrupt that finishes the teardown, it was possible get a NULL-ptr deref.
Avoid this by marking the link as inactive earlier.
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c | 17 ++++++++++++----- drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c | 6 +++--- drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 2 ++ drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h | 3 ++- 4 files changed, 19 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c +12 -5
@@ -412,14 +412,10 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 da }static void -nvkm_dp_release (struct nvkm_outp *outp,struct nvkm_ior *ior) +nvkm_dp_disable (struct nvkm_outp *outp,struct nvkm_ior *ior) {struct nvkm_dp *dp =nvkm_dp (outp); -/* Prevent link from being retrained if sink sends an IRQ. */ -atomic_set (&dp->lt.done,0 ); - ior->dp.nr =0 ; -/* Execute DisableLT script from DP Info Table. */ nvbios_init (&ior->disp->engine.subdev, dp->info.script[4 ], init.outp = &dp->outp.info;
@@ -428,6 +424,16 @@ nvkm_dp_release(struct nvkm_outp *outp, ); } +static void +nvkm_dp_release (struct nvkm_outp *outp) +{ +struct nvkm_dp *dp =nvkm_dp (outp); + +/* Prevent link from being retrained if sink sends an IRQ. */ +atomic_set (&dp->lt.done,0 ); + dp->outp.ior->dp.nr =0 ; +} +static int nvkm_dp_acquire (struct nvkm_outp *outp) {
@@ -576,6 +582,7 @@ nvkm_dp_func = { .fini = nvkm_dp_fini, .acquire = nvkm_dp_acquire, .release = nvkm_dp_release, + .disable = nvkm_dp_disable, }; static int
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +3 -3
@@ -501,11 +501,11 @@ nv50_disp_super_2_0(struct nv50_disp *dinv50_disp_super_ied_off (head, ior,2 );/* If we're shutting down the OR's only active head, execute -* the output path's release function. +* the output path's disable function. */ if (ior->arm.head == (1 << head->id)) { -if ((outp = ior->arm.outp) && outp->func->release) - outp->func->release (outp, ior); +if ((outp = ior->arm.outp) && outp->func->disable) + outp->func->disable (outp, ior); } }
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c +2 -0
@@ -93,6 +93,8 @@ nvkm_outp_release(struct nvkm_outp *outpif (ior) { outp->acquired &= ~user;if (!outp->acquired) { +if (outp->func->release && outp->ior) + outp->func->release (outp); outp->ior->asy.outp =NULL ; outp->ior =NULL ; }
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h +2 -1
@@ -41,7 +41,8 @@ struct nvkm_outp_func {void (*init)(struct nvkm_outp *);void (*fini)(struct nvkm_outp *);int (*acquire)(struct nvkm_outp *); -void (*release)(struct nvkm_outp *,struct nvkm_ior *); +void (*release)(struct nvkm_outp *); +void (*disable)(struct nvkm_outp *,struct nvkm_ior *); }; #define OUTP_MSG(o,l,f,a...) do { \
Greg Kroah-Hartman
maintainerPATCH 112/168 drm/nouveau/disp/gm200-: enforce identity-mapped SOR assignment for LVDS/eDP panels
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
[ Upstream commit 53b0cc46f27cfc2cadca609b503a7d92b5185a47 ]
Fixes eDP backlight issues on more recent laptops.
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | 14 ++++++++++++++ drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h | 1 + drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 15 ++++++++++++--- drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h | 1 + 4 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +14 -0
@@ -275,6 +275,7 @@ nvkm_disp_oneinit(struct nvkm_engine *enstruct nvkm_outp *outp, *outt, *pair;struct nvkm_conn *conn;struct nvkm_head *head; +struct nvkm_ior *ior;struct nvbios_connE connE;struct dcb_output dcbE;u8 hpd =0 , ver, hdr;
@@ -399,6 +400,19 @@ nvkm_disp_oneinit(struct nvkm_engine *enreturn ret; } +/* Enforce identity-mapped SOR assignment for panels, which have +* certain bits (ie. backlight controls) wired to a specific SOR. +*/ +list_for_each_entry (outp, &disp->outp, head) { +if (outp->conn->info.type ==DCB_CONNECTOR_LVDS || + outp->conn->info.type == DCB_CONNECTOR_eDP) { + ior =nvkm_ior_find (disp,SOR ,ffs (outp->info.or) -1 ); +if (!WARN_ON (!ior)) + ior->identity = true; + outp->identity = true; + } + } + i =0 ;list_for_each_entry (head, &disp->head, head) i =max (i, head->id +1 );
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +1 -0
@@ -16,6 +16,7 @@ struct nvkm_ior {char name[8 ];struct list_head head; +bool identity;struct nvkm_ior_state {struct nvkm_outp *outp;
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c +12 -3
@@ -129,17 +129,26 @@ nvkm_outp_acquire(struct nvkm_outp *outpif (proto ==UNKNOWN )return -ENOSYS ; +/* Deal with panels requiring identity-mapped SOR assignment. */ +if (outp->identity) { + ior =nvkm_ior_find (outp->disp,SOR ,ffs (outp->info.or) -1 ); +if (WARN_ON (!ior)) +return -ENOSPC ; +return nvkm_outp_acquire_ior (outp, user, ior); + } +/* First preference is to reuse the OR that is currently armed * on HW, if any, in order to prevent unnecessary switching. */ list_for_each_entry (ior, &outp->disp->ior, head) { -if (!ior->asy.outp && ior->arm.outp == outp) +if (!ior->identity && !ior->asy.outp && ior->arm.outp == outp)return nvkm_outp_acquire_ior (outp, user, ior); }/* Failing that, a completely unused OR is the next best thing. */ list_for_each_entry (ior, &outp->disp->ior, head) { -if (!ior->asy.outp && ior->type == type && !ior->arm.outp && +if (!ior->identity && + !ior->asy.outp && ior->type == type && !ior->arm.outp && (ior->func->route.set || ior->id ==__ffs (outp->info.or)))return nvkm_outp_acquire_ior (outp, user, ior); }
@@ -148,7 +157,7 @@ nvkm_outp_acquire(struct nvkm_outp *outp* but will be released during the next modeset. */ list_for_each_entry (ior, &outp->disp->ior, head) { -if (!ior->asy.outp && ior->type == type && +if (!ior->identity && !ior->asy.outp && ior->type == type && (ior->func->route.set || ior->id ==__ffs (outp->info.or)))return nvkm_outp_acquire_ior (outp, user, ior); }
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h +1 -0
@@ -17,6 +17,7 @@ struct nvkm_outp {struct list_head head;struct nvkm_conn *conn; +bool identity;/* Assembly state. */ #define NVKM_OUTP_PRIV 1
Greg Kroah-Hartman
maintainerPATCH 113/168 dm raid: fix stripe adding reshape deadlock
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heinz Mauelshagen <[email protected]>
[ Upstream commit 644e2537fdc77baeeefc829524937bca64329f82 ]
When initiating a stripe adding reshape, a deadlock between md_stop_writes() waiting for the sync thread to stop and the running sync thread waiting for inactive stripes occurs (this frequently happens on single-core but rarely on multi-core systems).
Fix this deadlock by setting MD_RECOVERY_WAIT to have the main MD resynchronization thread worker (md_do_sync()) bail out when initiating the reshape via constructor arguments.
--- drivers/md/dm-raid.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/md/dm-raid.c +3 -8
@@ -3869,14 +3869,13 @@ static int rs_start_reshape(struct raid_struct mddev *mddev = &rs->md;struct md_personality *pers = mddev->pers; +/* Don't allow the sync thread to work until the table gets reloaded. */ +set_bit (MD_RECOVERY_WAIT , &mddev->recovery); + r =rs_setup_reshape (rs);if (r)return r; -/* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */ -if (test_and_clear_bit (RT_FLAG_RS_SUSPENDED , &rs->runtime_flags)) -mddev_resume (mddev); -/* * Check any reshape constraints enforced by the personalility *
@@ -3900,10 +3899,6 @@ static int rs_start_reshape(struct raid_ } } -/* Suspend because a resume will happen in raid_resume() */ -set_bit (RT_FLAG_RS_SUSPENDED , &rs->runtime_flags); -mddev_suspend (mddev); -/* * Now reshape got set up, update superblocks to * reflect the fact so that a table reload will
Greg Kroah-Hartman
maintainerPATCH 114/168 dm raid: fix rebuild of specific devices by updating superblock
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heinz Mauelshagen <[email protected]>
[ Upstream commit c44a5ee803d2b7ed8c2e6ce24a5c4dd60778886e ]
Update superblock when particular devices are requested via rebuild (e.g. lvconvert --replace ...) to avoid spurious failure with the "New device injected into existing raid set without 'delta_disks' or 'rebuild' parameter specified" error message.
--- drivers/md/dm-raid.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/dm-raid.c +5 -0
@@ -3126,6 +3126,11 @@ static int raid_ctr(struct dm_target *tiset_bit (RT_FLAG_UPDATE_SBS , &rs->runtime_flags);rs_set_new (rs); }else if (rs_is_recovering (rs)) { +/* Rebuild particular devices */ +if (test_bit (__CTR_FLAG_REBUILD, &rs->ctr_flags)) { +set_bit (RT_FLAG_UPDATE_SBS , &rs->runtime_flags); +rs_setup_recovery (rs, MaxSector); + }/* A recovering raid set may be resized */ ;/* skip setup rs */ }else if (rs_is_reshaping (rs)) {
Greg Kroah-Hartman
maintainerPATCH 115/168 dm raid: fix RAID leg rebuild errors
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heinz Mauelshagen <[email protected]>
[ Upstream commit 36a240a706d43383bbdd377522501ddd2e5771f6 ]
On fast devices such as NVMe, a flaw in rs_get_progress() results in false target status output when userspace lvm2 requests leg rebuilds (symptom of the failure is device health chars 'aaaaaaaa' instead of expected 'aAaAAAAA' causing lvm2 to fail).
The correct sync action state definitions already exist in decipher_sync_action() so fix rs_get_progress() to use it.
Change decipher_sync_action() to return an enum rather than a string for the sync states and call it from rs_get_progress(). Introduce sync_str() to translate from enum to the string that is needed by raid_status().
--- drivers/md/dm-raid.c | 80 +++++++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 34 deletions(-)
drivers/md/dm-raid.c +46 -34
@@ -3332,32 +3332,53 @@ static int raid_map(struct dm_target *tireturn DM_MAPIO_SUBMITTED ; } -/* Return string describing the current sync action of @mddev */ -static const char *decipher_sync_action (struct mddev *mddev,unsigned long recovery) +/* Return sync state string for @state */ +enum sync_state { st_frozen, st_reshape, st_resync, st_check, st_repair, st_recover, st_idle }; +static const char *sync_str (enum sync_state state) +{ +/* Has to be in above sync_state order! */ +static const char *sync_strs[] = { +"frozen" , +"reshape" , +"resync" , +"check" , +"repair" , +"recover" , +"idle" + }; + +return __within_range (state,0 ,ARRAY_SIZE (sync_strs) -1 ) ? sync_strs[state] :"undef" ; +}; + +/* Return enum sync_state for @mddev derived from @recovery flags */ +static const enum sync_state decipher_sync_action (struct mddev *mddev,unsigned long recovery) {if (test_bit (MD_RECOVERY_FROZEN , &recovery)) -return "frozen" ; +return st_frozen; -/* The MD sync thread can be done with io but still be running */ +/* The MD sync thread can be done with io or be interrupted but still be running */ if (!test_bit (MD_RECOVERY_DONE , &recovery) && (test_bit (MD_RECOVERY_RUNNING , &recovery) || (!mddev->ro &&test_bit (MD_RECOVERY_NEEDED , &recovery)))) {if (test_bit (MD_RECOVERY_RESHAPE , &recovery)) -return "reshape" ; +return st_reshape;if (test_bit (MD_RECOVERY_SYNC , &recovery)) {if (!test_bit (MD_RECOVERY_REQUESTED , &recovery)) -return "resync" ; -else if (test_bit (MD_RECOVERY_CHECK , &recovery)) -return "check" ; -return "repair" ; +return st_resync; +if (test_bit (MD_RECOVERY_CHECK , &recovery)) +return st_check; +return st_repair; }if (test_bit (MD_RECOVERY_RECOVER , &recovery)) -return "recover" ; +return st_recover; + +if (mddev->reshape_position != MaxSector) +return st_reshape; } -return "idle" ; +return st_idle; }/*
@@ -3391,6 +3412,7 @@ static sector_t rs_get_progress(struct r sector_t resync_max_sectors) {sector_t r; +enum sync_state state;struct mddev *mddev = &rs->md;clear_bit (RT_FLAG_RS_IN_SYNC , &rs->runtime_flags);
@@ -3401,20 +3423,14 @@ static sector_t rs_get_progress(struct rset_bit (RT_FLAG_RS_IN_SYNC , &rs->runtime_flags); }else { -if (!test_bit (__CTR_FLAG_NOSYNC, &rs->ctr_flags) && - !test_bit (MD_RECOVERY_INTR , &recovery) && - (test_bit (MD_RECOVERY_NEEDED , &recovery) || -test_bit (MD_RECOVERY_RESHAPE , &recovery) || -test_bit (MD_RECOVERY_RUNNING , &recovery))) - r = mddev->curr_resync_completed; -else + state =decipher_sync_action (mddev, recovery); + +if (state == st_idle && !test_bit (MD_RECOVERY_INTR , &recovery)) r = mddev->recovery_cp; +else + r = mddev->curr_resync_completed; -if (r >= resync_max_sectors && - (!test_bit (MD_RECOVERY_REQUESTED , &recovery) || - (!test_bit (MD_RECOVERY_FROZEN , &recovery) && - !test_bit (MD_RECOVERY_NEEDED , &recovery) && - !test_bit (MD_RECOVERY_RUNNING , &recovery)))) { +if (state == st_idle && r >= resync_max_sectors) {/* * Sync complete. */
@@ -3422,24 +3438,20 @@ static sector_t rs_get_progress(struct rif (test_bit (MD_RECOVERY_RECOVER , &recovery))set_bit (RT_FLAG_RS_IN_SYNC , &rs->runtime_flags); - }else if (test_bit (MD_RECOVERY_RECOVER , &recovery)) { + }else if (state == st_recover)/* * In case we are recovering, the array is not in sync * and health chars should show the recovering legs. */ ; - - }else if (test_bit (MD_RECOVERY_SYNC , &recovery) && - !test_bit (MD_RECOVERY_REQUESTED , &recovery)) { +else if (state == st_resync)/* * If "resync" is occurring, the raid set * is or may be out of sync hence the health * characters shall be 'a'. */ set_bit (RT_FLAG_RS_RESYNCING , &rs->runtime_flags); - - }else if (test_bit (MD_RECOVERY_RESHAPE , &recovery) && - !test_bit (MD_RECOVERY_REQUESTED , &recovery)) { +else if (state == st_reshape)/* * If "reshape" is occurring, the raid set * is or may be out of sync hence the health
@@ -3447,7 +3459,7 @@ static sector_t rs_get_progress(struct r*/ set_bit (RT_FLAG_RS_RESYNCING , &rs->runtime_flags); - }else if (test_bit (MD_RECOVERY_REQUESTED , &recovery)) { + else if (state == st_check || state == st_repair)/* * If "check" or "repair" is occurring, the raid set has * undergone an initial sync and the health characters
@@ -3455,12 +3467,12 @@ static sector_t rs_get_progress(struct r*/ set_bit (RT_FLAG_RS_IN_SYNC , &rs->runtime_flags); - }else { + else {struct md_rdev *rdev;/* * We are idle and recovery is needed, prevent 'A' chars race -* caused by components still set to in-sync by constrcuctor. +* caused by components still set to in-sync by constructor. */ if (test_bit (MD_RECOVERY_NEEDED , &recovery))set_bit (RT_FLAG_RS_RESYNCING , &rs->runtime_flags);
@@ -3524,7 +3536,7 @@ static void raid_status(struct dm_target progress =rs_get_progress (rs, recovery, resync_max_sectors); resync_mismatches = (mddev->last_sync_action && !strcasecmp (mddev->last_sync_action,"check" )) ?atomic64_read (&mddev->resync_mismatches) :0 ; - sync_action =decipher_sync_action (&rs->md, recovery); + sync_action =sync_str (decipher_sync_action (&rs->md, recovery));/* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ for (i =0 ; i < rs->raid_disks; i++)
Greg Kroah-Hartman
maintainerPATCH 116/168 r8169: set TxConfig register after TX / RX is enabled, just like RxConfig
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej S. Szmigiero" <[email protected]>
[ Upstream commit f74dd480cf4e31e12971c58a1d832044db945670 ]
Commit 3559d81e76bf ("r8169: simplify rtl_hw_start_8169") changed order of two register writes:
1) Caused RxConfig to be written before TX / RX is enabled,
2) Caused TxConfig to be written before TX / RX is enabled.
At least on XIDs 10000000 ("RTL8169sb/8110sb") and
18000000 ("RTL8169sc/8110sc") such writes are ignored by the chip, leaving values in these registers intact.
Change 1) was reverted by
commit 05212ba8132b42 ("r8169: set RxConfig after tx/rx is enabled for RTL8169sb/8110sb devices"), however change 2) wasn't.
In practice, this caused TxConfig's "InterFrameGap time" and "Max DMA Burst Size per Tx DMA Burst" bits to be zero dramatically reducing TX performance (in my tests it dropped from around 500Mbps to around 50Mbps).
This patch fixes the issue by moving TxConfig register write a bit later in the code so it happens after TX / RX is already enabled.
--- drivers/net/ethernet/realtek/r8169.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +1 -1
@@ -5150,13 +5150,13 @@ static void rtl_hw_start(struct rtl8169rtl_set_rx_max_size (tp);rtl_set_rx_tx_desc_registers (tp); -rtl_set_tx_config_registers (tp);RTL_W8 (tp, Cfg9346, Cfg9346_Lock);/* Initially a 10 us delay. Turned it into a PCI commit. - FR */ RTL_R8 (tp, IntrMask);RTL_W8 (tp, ChipCmd, CmdTxEnb | CmdRxEnb);rtl_init_rxcfg (tp); +rtl_set_tx_config_registers (tp);rtl_set_rx_mode (tp->dev);/* no early-rx interrupts */
Greg Kroah-Hartman
maintainerPATCH 117/168 fs/cifs: suppress a string overflow warning
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Rothwell <[email protected]>
[ Upstream commit bcfb84a996f6fa90b5e6e2954b2accb7a4711097 ]
A powerpc build of cifs with gcc v8.2.0 produces this warning:
fs/cifs/cifssmb.c: In function ‘CIFSSMBNegotiate’:fs/cifs/cifssmb.c:605:3: warning: ‘strncpy’ writing 16 bytes into a region of size 1 overflows the destination [-Wstringop-overflow=]
strncpy(pSMB->DialectsArray+count, protocols[i].name, 16); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since we are already doing a strlen() on the source, change the strncpy to a memcpy().
--- fs/cifs/cifssmb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/cifs/cifssmb.c +8 -3
@@ -601,10 +601,15 @@ CIFSSMBNegotiate(const unsigned int xid, } count =0 ; +/* +* We know that all the name entries in the protocols array +* are short (< 16 bytes anyway) and are NUL terminated. +*/ for (i =0 ; i <CIFS_NUM_PROT ; i++) { -strncpy (pSMB->DialectsArray+count, protocols[i].name,16 ); - count +=strlen (protocols[i].name) +1 ; -/* null at end of source and target buffers anyway */ +size_t len =strlen (protocols[i].name) +1 ; + +memcpy (pSMB->DialectsArray+count, protocols[i].name, len); + count += len; }inc_rfc1001_len (pSMB, count); pSMB->ByteCount =cpu_to_le16 (count);
Greg Kroah-Hartman
maintainerPATCH 118/168 net: ena: fix surprise unplug NULL dereference kernel crash
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit 772ed869f535b4ec2b134645c951ff22de4d3f79 ]
Starting with driver version 1.5.0, in case of a surprise device unplug, there is a race caused by invoking ena_destroy_device() from two different places. As a result, the readless register might be accessed after it was destroyed.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +2 -2
@@ -3408,12 +3408,12 @@ static void ena_remove(struct pci_dev *p netdev->rx_cpu_rmap = NULL; }#endif /* CONFIG_RFS_ACCEL */ - -unregister_netdev (netdev);del_timer_sync (&adapter->timer_service);cancel_work_sync (&adapter->reset_task); +unregister_netdev (netdev); +/* Reset the device only if the device is running. */ if (test_bit (ENA_FLAG_DEVICE_RUNNING , &adapter->flags))ena_com_dev_reset (ena_dev, adapter->reset_reason);
Greg Kroah-Hartman
maintainerPATCH 119/168 net: ena: fix driver when PAGE_SIZE == 64kB
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit ef5b0771d247379c90c8bf1332ff32f7f74bff7f ]
The buffer length field in the ena rx descriptor is 16 bit, and the current driver passes a full page in each ena rx descriptor. When PAGE_SIZE equals 64kB or more, the buffer length field becomes zero.
To solve this issue, limit the ena Rx descriptor to use 16kB even when allocating 64kB kernel pages. This change would not impact ena device functionality, as 16kB is still larger than maximum MTU.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 10 +++++----- drivers/net/ethernet/amazon/ena/ena_netdev.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +5 -5
@@ -461,7 +461,7 @@ static inline int ena_alloc_rx_page(strureturn -ENOMEM ; } - dma =dma_map_page (rx_ring->dev, page,0 ,PAGE_SIZE , + dma =dma_map_page (rx_ring->dev, page,0 ,ENA_PAGE_SIZE ,DMA_FROM_DEVICE );if (unlikely (dma_mapping_error (rx_ring->dev, dma))) {u64_stats_update_begin (&rx_ring->syncp);
@@ -478,7 +478,7 @@ static inline int ena_alloc_rx_page(stru rx_info->page_offset =0 ; ena_buf = &rx_info->ena_buf; ena_buf->paddr = dma; - ena_buf->len =PAGE_SIZE ; + ena_buf->len =ENA_PAGE_SIZE ;return 0 ; }
@@ -495,7 +495,7 @@ static void ena_free_rx_page(struct ena_return ; } -dma_unmap_page (rx_ring->dev, ena_buf->paddr,PAGE_SIZE , +dma_unmap_page (rx_ring->dev, ena_buf->paddr,ENA_PAGE_SIZE ,DMA_FROM_DEVICE );__free_page (page);
@@ -916,10 +916,10 @@ static struct sk_buff *ena_rx_skb(struct do { dma_unmap_page(rx_ring->dev, dma_unmap_addr(&rx_info->ena_buf, paddr), - PAGE_SIZE, DMA_FROM_DEVICE); + ENA_PAGE_SIZE, DMA_FROM_DEVICE); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page, - rx_info->page_offset, len, PAGE_SIZE); + rx_info->page_offset, len, ENA_PAGE_SIZE); netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, "rx skb updated. len %d. data_len %d\n",
drivers/net/ethernet/amazon/ena/ena_netdev.h +11 -0
@@ -355,4 +355,15 @@ void ena_dump_stats_to_buf(struct ena_adint ena_get_sset_count (struct net_device *netdev,int sset); +/* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the +* driver passas 0. +* Since the max packet size the ENA handles is ~9kB limit the buffer length to +* 16kB. +*/ +#if PAGE_SIZE >SZ_16K +#define ENA_PAGE_SIZE SZ_16K +#else +#define ENA_PAGE_SIZE PAGE_SIZE +#endif +#endif /* !(ENA_H) */
Greg Kroah-Hartman
maintainerPATCH 120/168 net: ena: fix device destruction to gracefully free resources
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit cfa324a514233b28a6934de619183eee941f02d7 ]
When ena_destroy_device() is called from ena_suspend(), the device is still reachable from the driver. Therefore, the driver can send a command to the device to free all resources.
However, in all other cases of calling ena_destroy_device(), the device is potentially in an error state and unreachable from the driver. In these cases the driver must not send commands to the device.
The current implementation does not request resource freeing from the device even when possible. We add the graceful parameter to ena_destroy_device() to enable resource freeing when possible, and use it in ena_suspend().
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +7 -6
@@ -76,7 +76,7 @@ MODULE_DEVICE_TABLE(pci, ena_pci_tbl);static int ena_rss_init_default (struct ena_adapter *adapter);static void check_for_admin_com_state (struct ena_adapter *adapter); -static void ena_destroy_device (struct ena_adapter *adapter); +static void ena_destroy_device (struct ena_adapter *adapter,bool graceful);static int ena_restore_device (struct ena_adapter *adapter);static void ena_tx_timeout (struct net_device *dev)
@@ -1900,7 +1900,7 @@ static int ena_close(struct net_device * "Destroy failure, restarting device\n");ena_dump_stats_to_dmesg (adapter);/* rtnl lock already obtained in dev_ioctl() layer */ -ena_destroy_device (adapter); +ena_destroy_device (adapter, false);ena_restore_device (adapter); }
@@ -2549,7 +2549,7 @@ err_disable_msix:return rc; } -static void ena_destroy_device (struct ena_adapter *adapter) +static void ena_destroy_device (struct ena_adapter *adapter,bool graceful) {struct net_device *netdev = adapter->netdev;struct ena_com_dev *ena_dev = adapter->ena_dev;
@@ -2562,7 +2562,8 @@ static void ena_destroy_device(struct en dev_up =test_bit (ENA_FLAG_DEV_UP , &adapter->flags); adapter->dev_up_before_reset = dev_up; -ena_com_set_admin_running_state (ena_dev, false); +if (!graceful) +ena_com_set_admin_running_state (ena_dev, false);if (test_bit (ENA_FLAG_DEV_UP , &adapter->flags))ena_down (adapter);
@@ -2664,7 +2665,7 @@ static void ena_fw_reset_device(struct wreturn ; }rtnl_lock (); -ena_destroy_device (adapter); +ena_destroy_device (adapter, false);ena_restore_device (adapter);rtnl_unlock (); }
@@ -3466,7 +3467,7 @@ static int ena_suspend(struct pci_dev *p "ignoring device reset request as the device is being suspended\n");clear_bit (ENA_FLAG_TRIGGER_RESET , &adapter->flags); } -ena_destroy_device (adapter); +ena_destroy_device (adapter, true);rtnl_unlock ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 121/168 net: ena: fix potential double ena_destroy_device()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit fe870c77efdf8682252545cbd3d29800d8379efc ]
ena_destroy_device() can potentially be called twice. To avoid this, check that the device is running and only then proceed destroying it.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/amazon/ena/ena_netdev.c +5 -0
@@ -2555,6 +2555,9 @@ static void ena_destroy_device(struct enstruct ena_com_dev *ena_dev = adapter->ena_dev;bool dev_up; +if (!test_bit (ENA_FLAG_DEVICE_RUNNING , &adapter->flags)) +return ; +netif_carrier_off (netdev);del_timer_sync (&adapter->timer_service);
@@ -2591,6 +2594,7 @@ static void ena_destroy_device(struct en adapter->reset_reason =ENA_REGS_RESET_NORMAL ;clear_bit (ENA_FLAG_TRIGGER_RESET , &adapter->flags); +clear_bit (ENA_FLAG_DEVICE_RUNNING , &adapter->flags); }static int ena_restore_device (struct ena_adapter *adapter)
@@ -2635,6 +2639,7 @@ static int ena_restore_device(struct ena } } +set_bit (ENA_FLAG_DEVICE_RUNNING , &adapter->flags);mod_timer (&adapter->timer_service,round_jiffies (jiffies +HZ ));dev_err (&pdev->dev,"Device reset completed successfully\n" );
Greg Kroah-Hartman
maintainerPATCH 122/168 net: ena: fix missing lock during device destruction
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit 944b28aa2982b4590d4d4dfc777cf85135dca2c0 ]
acquire the rtnl_lock during device destruction to avoid using partially destroyed device.
ena_remove() shares almost the same logic as ena_destroy_device(), so use ena_destroy_device() and avoid duplications.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +7 -13
@@ -3420,24 +3420,18 @@ static void ena_remove(struct pci_dev *punregister_netdev (netdev); -/* Reset the device only if the device is running. */ +/* If the device is running then we want to make sure the device will be +* reset to make sure no more events will be issued by the device. +*/ if (test_bit (ENA_FLAG_DEVICE_RUNNING , &adapter->flags)) -ena_com_dev_reset (ena_dev, adapter->reset_reason); +set_bit (ENA_FLAG_TRIGGER_RESET , &adapter->flags); -ena_free_mgmnt_irq (adapter); - -ena_disable_msix (adapter); +rtnl_lock (); +ena_destroy_device (adapter, true); +rtnl_unlock ();free_netdev (netdev); -ena_com_mmio_reg_read_request_destroy (ena_dev); - -ena_com_abort_admin_commands (ena_dev); - -ena_com_wait_for_abort_completion (ena_dev); - -ena_com_admin_destroy (ena_dev); -ena_com_rss_destroy (ena_dev);ena_com_delete_debug_area (ena_dev);
Greg Kroah-Hartman
maintainerPATCH 123/168 net: ena: fix missing calls to READ_ONCE
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Netanel Belgazal <[email protected]>
[ Upstream commit 28abf4e9c9201eda5c4d29ea609d07e877b464b8 ]
Add READ_ONCE calls where necessary (for example when iterating over a memory field that gets updated by the hardware).
--- drivers/net/ethernet/amazon/ena/ena_com.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/amazon/ena/ena_com.c +4 -4
@@ -459,7 +459,7 @@ static void ena_com_handle_admin_complet cqe = &admin_queue->cq.entries[head_masked];/* Go over all the completions */ -while ((cqe->acq_common_descriptor.flags & +while ((READ_ONCE (cqe->acq_common_descriptor.flags) &ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK ) == phase) {/* Do not read the rest of the completion entry before the * phase bit was validated
@@ -637,7 +637,7 @@ static u32 ena_com_reg_bar_read32(structmmiowb ();for (i =0 ; i < timeout; i++) { -if (read_resp->req_id == mmio_read->seq_num) +if (READ_ONCE (read_resp->req_id) == mmio_read->seq_num)break ;udelay (1 );
@@ -1796,8 +1796,8 @@ void ena_com_aenq_intr_handler(struct en aenq_common = &aenq_e->aenq_common_desc;/* Go over all the events */ -while ((aenq_common->flags &ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK ) == - phase) { +while ((READ_ONCE (aenq_common->flags) & +ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK ) == phase) { pr_debug("AENQ! Group[%x] Syndrom[%x] timestamp: [%llus]\n", aenq_common->group, aenq_common->syndrom, (u64)aenq_common->timestamp_low +
Greg Kroah-Hartman
maintainerPATCH 124/168 perf/x86/intel: Add support/quirk for the MISPREDICT bit on Knights Landing CPUs
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacek Tomaka <[email protected]>
[ Upstream commit 16160c1946b702dcfa95ef63389a56deb2f1c7cb ]
Problem: perf did not show branch predicted/mispredicted bit in brstack.
Output of perf -F brstack for profile collected
Before:
0x4fdbcd/0x4fdc03/-/-/-/0
0x45f4c1/0x4fdba0/-/-/-/0
0x45f544/0x45f4bb/-/-/-/0
0x45f555/0x45f53c/-/-/-/0
0x7f66901cc24b/0x45f555/-/-/-/0
0x7f66901cc22e/0x7f66901cc23d/-/-/-/0
0x7f66901cc1ff/0x7f66901cc20f/-/-/-/0
0x7f66901cc1e8/0x7f66901cc1fc/-/-/-/0
After:
0x4fdbcd/0x4fdc03/P/-/-/0
0x45f4c1/0x4fdba0/P/-/-/0
0x45f544/0x45f4bb/P/-/-/0
0x45f555/0x45f53c/P/-/-/0
0x7f66901cc24b/0x45f555/P/-/-/0
0x7f66901cc22e/0x7f66901cc23d/P/-/-/0
0x7f66901cc1ff/0x7f66901cc20f/P/-/-/0
0x7f66901cc1e8/0x7f66901cc1fc/P/-/-/0
Cause:
As mentioned in Software Development Manual vol 3, 17.4.8.1, IA32_PERF_CAPABILITIES[5:0] indicates the format of the address that is stored in the LBR stack. Knights Landing reports 1 (LBR_FORMAT_LIP) as its format. Despite that, registers containing FROM address of the branch, do have MISPREDICT bit but because of the format indicated in IA32_PERF_CAPABILITIES[5:0], LBR did not read MISPREDICT bit.
Solution:
Teach LBR about above Knights Landing quirk and make it read MISPREDICT bit.
--- arch/x86/events/intel/lbr.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/events/intel/lbr.c +4 -0
@@ -1250,4 +1250,8 @@ void intel_pmu_lbr_init_knl(void) x86_pmu.lbr_sel_mask =LBR_SEL_MASK ; x86_pmu.lbr_sel_map = snb_lbr_sel_map; + +/* Knights Landing does have MISPREDICT bit */ +if (x86_pmu.intel_cap.lbr_format ==LBR_FORMAT_LIP ) + x86_pmu.intel_cap.lbr_format =LBR_FORMAT_EIP_FLAGS ; }
Greg Kroah-Hartman
maintainerPATCH 125/168 sched/topology: Set correct NUMA topology type
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srikar Dronamraju <[email protected]>
[ Upstream commit e5e96fafd9028b1478b165db78c52d981c14f471 ]
With the following commit:
051f3ca02e46 ("sched/topology: Introduce NUMA identity node sched domain")
the scheduler introduced a new NUMA level. However this leads to the NUMA topology on 2 node systems to not be marked as NUMA_DIRECT anymore.
After this commit, it gets reported as NUMA_BACKPLANE, because sched_domains_numa_level is now 2 on 2 node systems.
Fix this by allowing setting systems that have up to 2 NUMA levels as NUMA_DIRECT.
While here remove code that assumes that level can be 0.
--- kernel/sched/topology.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/sched/topology.c +1 -4
@@ -1295,7 +1295,7 @@ static void init_numa_topology_type(void n = sched_max_numa_distance; -if (sched_domains_numa_levels <=1 ) { +if (sched_domains_numa_levels <=2 ) { sched_numa_topology_type =NUMA_DIRECT ;return ; }
@@ -1380,9 +1380,6 @@ void sched_init_numa(void)break ; } -if (!level) -return ; -/* * 'level' contains the number of unique distances *
Greg Kroah-Hartman
maintainerPATCH 126/168 dm thin metadata: try to avoid ever aborting transactions
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Thornber <[email protected]>
[ Upstream commit 3ab91828166895600efd9cdc3a0eb32001f7204a ]
Committing a transaction can consume some metadata of it's own, we now reserve a small amount of metadata to cover this. Free metadata reported by the kernel will not include this reserve.
If any of the reserve has been used after a commit we enter a new internal state PM_OUT_OF_METADATA_SPACE. This is reported as PM_READ_ONLY, so no userland changes are needed. If the metadata device is resized the pool will move back to PM_WRITE.
These changes mean we never need to abort and rollback a transaction due to running out of metadata space. This is particularly important because there have been a handful of reports of data corruption against DM thin-provisioning that can all be attributed to the thin-pool having ran out of metadata space.
--- drivers/md/dm-thin-metadata.c | 36 ++++++++++++++++++++ drivers/md/dm-thin.c | 73 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 100 insertions(+), 9 deletions(-)
drivers/md/dm-thin-metadata.c +35 -1
@@ -189,6 +189,12 @@ struct dm_pool_metadata {sector_t data_block_size;/* +* We reserve a section of the metadata for commit overhead. +* All reported space does *not* include this. +*/ +dm_block_t metadata_reserve; + +/* * Set if a transaction has to be aborted but the attempt to roll back * to the previous (good) transaction failed. The only pool metadata * operation possible in this state is the closing of the device.
@@ -816,6 +822,22 @@ static int __commit_transaction(struct dreturn dm_tm_commit (pmd->tm, sblock); } +static void __set_metadata_reserve (struct dm_pool_metadata *pmd) +{ +int r; +dm_block_t total; +dm_block_t max_blocks =4096 ;/* 16M */ + + r =dm_sm_get_nr_blocks (pmd->metadata_sm, &total); +if (r) { +DMERR ("could not get size of metadata device" ); + pmd->metadata_reserve = max_blocks; + }else { +sector_div (total,10 ); + pmd->metadata_reserve =min (max_blocks, total); + } +} +struct dm_pool_metadata *dm_pool_metadata_open (struct block_device *bdev,sector_t data_block_size,bool format_device)
@@ -849,6 +871,8 @@ struct dm_pool_metadata *dm_pool_metadatreturn ERR_PTR (r); } +__set_metadata_reserve (pmd); +return pmd; }
@@ -1820,6 +1844,13 @@ int dm_pool_get_free_metadata_block_coundown_read (&pmd->root_lock);if (!pmd->fail_io) r =dm_sm_get_nr_free (pmd->metadata_sm, result); + +if (!r) { +if (*result < pmd->metadata_reserve) + *result =0 ; +else + *result -= pmd->metadata_reserve; + }up_read (&pmd->root_lock);return r;
@@ -1932,8 +1963,11 @@ int dm_pool_resize_metadata_dev(struct dint r = -EINVAL ;down_write (&pmd->root_lock); -if (!pmd->fail_io) +if (!pmd->fail_io) { r =__resize_space_map (pmd->metadata_sm, new_count); +if (!r) +__set_metadata_reserve (pmd); + }up_write (&pmd->root_lock);return r;
drivers/md/dm-thin.c +65 -8
141 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 127/168 netfilter: conntrack: timeout interface depend on CONFIG_NF_CONNTRACK_TIMEOUT
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit a874752a10da113f513980e28f562d946d3f829d ]
Now that cttimeout support for nft_ct is in place, these should depend on CONFIG_NF_CONNTRACK_TIMEOUT otherwise we can crash when dumping the policy if this option is not enabled.
[ 71.600121] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [...] [ 71.600141] CPU: 3 PID: 7612 Comm: nft Not tainted 4.18.0+ #246 [...] [ 71.600188] Call Trace: [ 71.600201] ? nft_ct_timeout_obj_dump+0xc6/0xf0 [nft_ct]
--- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 8 ++++---- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 8 ++++---- net/netfilter/nf_conntrack_proto_dccp.c | 12 ++++++------ net/netfilter/nf_conntrack_proto_generic.c | 8 ++++---- net/netfilter/nf_conntrack_proto_gre.c | 8 ++++---- net/netfilter/nf_conntrack_proto_sctp.c | 14 +++++++------- net/netfilter/nf_conntrack_proto_tcp.c | 12 ++++++------ net/netfilter/nf_conntrack_proto_udp.c | 20 ++++++++++---------- 8 files changed, 45 insertions(+), 45 deletions(-)
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +4 -4
@@ -269,7 +269,7 @@ static unsigned int icmp_nlattr_tuple_si }#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -307,7 +307,7 @@ static const struct nla_policy icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = { [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL static struct ctl_table icmp_sysctl_table[] = {
@@ -369,7 +369,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_to_tuple = icmp_nlattr_to_tuple, .nla_policy = icmp_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = icmp_timeout_nlattr_to_obj, .obj_to_nlattr = icmp_timeout_obj_to_nlattr,
@@ -377,7 +377,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int), .nla_policy = icmp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = icmp_init_net, .get_net_proto = icmp_get_net_proto, };
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +4 -4
@@ -270,7 +270,7 @@ static unsigned int icmpv6_nlattr_tuple_ }#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -308,7 +308,7 @@ static const struct nla_policy icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = { [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL static struct ctl_table icmpv6_sysctl_table[] = {
@@ -368,7 +368,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_to_tuple = icmpv6_nlattr_to_tuple, .nla_policy = icmpv6_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj, .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr,
@@ -376,7 +376,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int), .nla_policy = icmpv6_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = icmpv6_init_net, .get_net_proto = icmpv6_get_net_proto, };
net/netfilter/nf_conntrack_proto_dccp.c +6 -6
@@ -699,7 +699,7 @@ static int nlattr_to_dccp(struct nlattr }#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -750,7 +750,7 @@ dccp_timeout_nla_policy[CTA_TIMEOUT_DCCP [CTA_TIMEOUT_DCCP_CLOSING] = { .type = NLA_U32 }, [CTA_TIMEOUT_DCCP_TIMEWAIT] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL /* template, data assigned later */
@@ -883,7 +883,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = dccp_timeout_nlattr_to_obj, .obj_to_nlattr = dccp_timeout_obj_to_nlattr,
@@ -891,7 +891,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, .nla_policy = dccp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = dccp_init_net, .get_net_proto = dccp_get_net_proto, };
@@ -919,7 +919,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = dccp_timeout_nlattr_to_obj, .obj_to_nlattr = dccp_timeout_obj_to_nlattr,
@@ -927,7 +927,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, .nla_policy = dccp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = dccp_init_net, .get_net_proto = dccp_get_net_proto, };
net/netfilter/nf_conntrack_proto_generic.c +4 -4
@@ -79,7 +79,7 @@ static bool generic_new(struct nf_conn *return ret; } -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -119,7 +119,7 @@ static const struct nla_policy generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = { [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL static struct ctl_table generic_sysctl_table[] = {
@@ -172,7 +172,7 @@ const struct nf_conntrack_l4proto nf_con .packet = generic_packet, .get_timeouts = generic_get_timeouts, .new = generic_new, -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = generic_timeout_nlattr_to_obj, .obj_to_nlattr = generic_timeout_obj_to_nlattr,
@@ -180,7 +180,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int), .nla_policy = generic_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = generic_init_net, .get_net_proto = generic_get_net_proto, };
net/netfilter/nf_conntrack_proto_gre.c +4 -4
@@ -289,7 +289,7 @@ static void gre_destroy(struct nf_conn *nf_ct_gre_keymap_destroy (master); } -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -336,7 +336,7 @@ gre_timeout_nla_policy[CTA_TIMEOUT_GRE_M [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 }, [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ static int gre_init_net (struct net *net,u_int16_t proto) {
@@ -371,7 +371,7 @@ static const struct nf_conntrack_l4proto .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = gre_timeout_nlattr_to_obj, .obj_to_nlattr = gre_timeout_obj_to_nlattr,
@@ -379,7 +379,7 @@ static const struct nf_conntrack_l4proto .obj_size = sizeof(unsigned int) * GRE_CT_MAX, .nla_policy = gre_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .net_id = &proto_gre_net_id, .init_net = gre_init_net, };
net/netfilter/nf_conntrack_proto_sctp.c +7 -7
@@ -615,7 +615,7 @@ static int nlattr_to_sctp(struct nlattr }#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -668,7 +668,7 @@ sctp_timeout_nla_policy[CTA_TIMEOUT_SCTP [CTA_TIMEOUT_SCTP_HEARTBEAT_SENT] = { .type = NLA_U32 }, [CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL
@@ -800,7 +800,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = sctp_timeout_nlattr_to_obj, .obj_to_nlattr = sctp_timeout_obj_to_nlattr,
@@ -808,7 +808,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, .nla_policy = sctp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = sctp_init_net, .get_net_proto = sctp_get_net_proto, };
@@ -836,7 +836,8 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy, -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#endif +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = sctp_timeout_nlattr_to_obj, .obj_to_nlattr = sctp_timeout_obj_to_nlattr,
@@ -844,8 +845,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, .nla_policy = sctp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ -#endif +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = sctp_init_net, .get_net_proto = sctp_get_net_proto, };
net/netfilter/nf_conntrack_proto_tcp.c +6 -6
@@ -1305,7 +1305,7 @@ static unsigned int tcp_nlattr_tuple_siz }#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -1415,7 +1415,7 @@ static const struct nla_policy tcp_timeo [CTA_TIMEOUT_TCP_RETRANS] = { .type = NLA_U32 }, [CTA_TIMEOUT_TCP_UNACK] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL static struct ctl_table tcp_sysctl_table[] = {
@@ -1578,7 +1578,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_size = TCP_NLATTR_SIZE, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = tcp_timeout_nlattr_to_obj, .obj_to_nlattr = tcp_timeout_obj_to_nlattr,
@@ -1587,7 +1587,7 @@ const struct nf_conntrack_l4proto nf_con TCP_CONNTRACK_TIMEOUT_MAX, .nla_policy = tcp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = tcp_init_net, .get_net_proto = tcp_get_net_proto, };
@@ -1616,7 +1616,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = tcp_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = tcp_timeout_nlattr_to_obj, .obj_to_nlattr = tcp_timeout_obj_to_nlattr,
@@ -1625,7 +1625,7 @@ const struct nf_conntrack_l4proto nf_con TCP_CONNTRACK_TIMEOUT_MAX, .nla_policy = tcp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = tcp_init_net, .get_net_proto = tcp_get_net_proto, };
net/netfilter/nf_conntrack_proto_udp.c +10 -10
@@ -192,7 +192,7 @@ static int udp_error(struct net *net, streturn NF_ACCEPT ; } -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -239,7 +239,7 @@ udp_timeout_nla_policy[CTA_TIMEOUT_UDP_M [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 }, [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 }, }; -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_SYSCTL static struct ctl_table udp_sysctl_table[] = {
@@ -313,7 +313,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = udp_timeout_nlattr_to_obj, .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -321,7 +321,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, .nla_policy = udp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = udp_init_net, .get_net_proto = udp_get_net_proto, };
@@ -345,7 +345,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = udp_timeout_nlattr_to_obj, .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -353,7 +353,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, .nla_policy = udp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = udp_init_net, .get_net_proto = udp_get_net_proto, };
@@ -377,7 +377,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = udp_timeout_nlattr_to_obj, .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -385,7 +385,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, .nla_policy = udp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = udp_init_net, .get_net_proto = udp_get_net_proto, };
@@ -409,7 +409,7 @@ const struct nf_conntrack_l4proto nf_con .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy,#endif -#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT .ctnl_timeout = { .nlattr_to_obj = udp_timeout_nlattr_to_obj, .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -417,7 +417,7 @@ const struct nf_conntrack_l4proto nf_con .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, .nla_policy = udp_timeout_nla_policy, }, -#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ .init_net = udp_init_net, .get_net_proto = udp_get_net_proto, };
Greg Kroah-Hartman
maintainerPATCH 128/168 netfilter: nfnetlink_queue: Solve the NFQUEUE/conntrack clash for NF_REPEAT
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal 'vorner' Vaner <[email protected]>
[ Upstream commit ad18d7bf68a3da860ebb62a59c449804a6d237b4 ]
NF_REPEAT places the packet at the beginning of the iptables chain instead of accepting or rejecting it right away. The packet however will reach the end of the chain and continue to the end of iptables eventually, so it needs the same handling as NF_ACCEPT and NF_DROP.
--- net/netfilter/nfnetlink_queue.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nfnetlink_queue.c +1 -0
@@ -233,6 +233,7 @@ static void nfqnl_reinject(struct nf_queint err;if (verdict ==NF_ACCEPT || + verdict ==NF_REPEAT || verdict ==NF_STOP ) {rcu_read_lock (); ct_hook =rcu_dereference (nf_ct_hook);
Greg Kroah-Hartman
maintainerPATCH 129/168 netfilter: xt_hashlimit: use s->file instead of s->private
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 1286df269f498165061e0cf8092ca212545dbb5a ]
After switching to the new procfs API, it is supposed to retrieve the private pointer from PDE_DATA(file_inode(s->file)), s->private is no longer referred.
--- net/netfilter/xt_hashlimit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
net/netfilter/xt_hashlimit.c +9 -9
@@ -1057,7 +1057,7 @@ static struct xt_match hashlimit_mt_reg[static void *dl_seq_start (struct seq_file *s,loff_t *pos) __acquires(htable->lock) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket;spin_lock_bh (&htable->lock);
@@ -1074,7 +1074,7 @@ static void *dl_seq_start(struct seq_filstatic void *dl_seq_next (struct seq_file *s,void *v,loff_t *pos) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket = v; *pos = ++(*bucket);
@@ -1088,7 +1088,7 @@ static void *dl_seq_next(struct seq_filestatic void dl_seq_stop (struct seq_file *s,void *v) __releases(htable->lock) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket = v;if (!IS_ERR (bucket))
@@ -1130,7 +1130,7 @@ static void dl_seq_print(struct dsthash_static int dl_seq_real_show_v2 (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1145,7 +1145,7 @@ static int dl_seq_real_show_v2(struct dsstatic int dl_seq_real_show_v1 (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1160,7 +1160,7 @@ static int dl_seq_real_show_v1(struct dsstatic int dl_seq_real_show (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1174,7 +1174,7 @@ static int dl_seq_real_show(struct dsthastatic int dl_seq_show_v2 (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket = (unsigned int *)v;struct dsthash_ent *ent;
@@ -1188,7 +1188,7 @@ static int dl_seq_show_v2(struct seq_filstatic int dl_seq_show_v1 (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket = v;struct dsthash_ent *ent;
@@ -1202,7 +1202,7 @@ static int dl_seq_show_v1(struct seq_filstatic int dl_seq_show (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->private)); +struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file));unsigned int *bucket = v;struct dsthash_ent *ent;
Greg Kroah-Hartman
maintainerPATCH 130/168 arch/hexagon: fix kernel/dma.c build warning
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 200f351e27f014fcbf69b544b0b4b72aeaf45fd3 ]
Fix build warning in arch/hexagon/kernel/dma.c by casting a void * to unsigned long to match the function parameter type.
../arch/hexagon/kernel/dma.c: In function 'arch_dma_alloc':../arch/hexagon/kernel/dma.c:51:5: warning: passing argument 2 of 'gen_pool_add' makes integer from pointer without a cast [enabled by default] ../include/linux/genalloc.h:112:19: note: expected 'long unsigned int' but argument is of type 'void *'
Patch-mainline: linux-kernel @ 07/20/2018, 20:17
--- arch/hexagon/kernel/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/hexagon/kernel/dma.c +1 -1
@@ -60,7 +60,7 @@ static void *hexagon_dma_alloc_coherent(panic ("Can't create %s() memory pool!" , __func__); else gen_pool_add(coherent_pool, -pfn_to_virt (max_low_pfn ), + (unsigned long )pfn_to_virt (max_low_pfn ), hexagon_coherent_pool_size, -1); }
Greg Kroah-Hartman
maintainerPATCH 131/168 hexagon: modify ffs() and fls() to return int
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 5c41aaad409c097cf1ef74f2c649fed994744ef5 ]
Building drivers/mtd/nand/raw/nandsim.c on arch/hexagon/ produces a printk format build warning. This is due to hexagon's ffs() being coded as returning long instead of int.
Fix the printk format warning by changing all of hexagon's ffs() and fls() functions to return int instead of long. The variables that they return are already int instead of long. This return type matches the return type in <asm-generic/bitops/>.
../drivers/mtd/nand/raw/nandsim.c: In function 'init_nandsim':../drivers/mtd/nand/raw/nandsim.c:760:2: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'long int' [-Wformat]
There are no ffs() or fls() allmodconfig build errors after making this change.
Patch-mainline: linux-kernel @ 07/22/2018, 16:03
--- arch/hexagon/include/asm/bitops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/hexagon/include/asm/bitops.h +2 -2
@@ -211,7 +211,7 @@ static inline long ffz(int x)* This is defined the same way as ffs. * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. */ -static inline long fls (int x) +static inline int fls (int x) {int r;
@@ -232,7 +232,7 @@ static inline long fls(int x)* the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). */ -static inline long ffs (int x) +static inline int ffs (int x) {int r;
Greg Kroah-Hartman
maintainerPATCH 132/168 drm/amdgpu: Fix SDMA hang in prt mode v2
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Zhou <[email protected]>
[ Upstream commit 68ebc13ea40656fddd3803735d621921a2d74a5e ]
Fix SDMA hang in prt mode, clear XNACK_WATERMARK in reg SDMA0_UTCL1_WATERMK to avoid the issue
Affected ASICs: VEGA10 VEGA12 RV1 RV2
v2: add reg clear for SDMA1
--- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +5 -2
@@ -67,6 +67,7 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_IB_CNTL,0x800f0100 ,0x00000100 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_RB_WPTR_POLL_CNTL,0x0000fff0 ,0x00403000 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003c0 ), +SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_WATERMK,0xfc000000 ,0x00000000 ),SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_CHICKEN_BITS,0xfe931f07 ,0x02831f07 ),SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_CLK_CTRL,0xffffffff ,0x3f000100 ), SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100),
@@ -78,7 +79,8 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_RLC0_RB_WPTR_POLL_CNTL,0x0000fff0 ,0x00403000 ),SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_RLC1_IB_CNTL,0x800f0100 ,0x00000100 ),SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_RLC1_RB_WPTR_POLL_CNTL,0x0000fff0 ,0x00403000 ), -SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_UTCL1_PAGE,0x000003ff ,0x000003c0 ) +SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_UTCL1_PAGE,0x000003ff ,0x000003c0 ), +SOC15_REG_GOLDEN_VALUE (SDMA1 ,0 , mmSDMA1_UTCL1_WATERMK,0xfc000000 ,0x00000000 ) }; static const struct soc15_reg_golden golden_settings_sdma_vg10[] = {
@@ -106,7 +108,8 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC0_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_IB_CNTL,0x800f0111 ,0x00000100 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ), -SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003c0 ) +SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003c0 ), +SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_WATERMK,0xfc000000 ,0x00000000 ) }; static const struct soc15_reg_golden golden_settings_sdma_4_2[] =
Greg Kroah-Hartman
maintainerPATCH 133/168 arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
[ Upstream commit 13aceef06adfaf93d52e01e28a8bc8a0ad471d83 ]
All other uses of "asm goto" go through asm_volatile_goto, which avoids a miscompile when using GCC < 4.8.2. Replace our open-coded "asm goto" statements with the asm_volatile_goto macro to avoid issues with older toolchains.
--- arch/arm64/include/asm/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/jump_label.h +2 -2
@@ -28,7 +28,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { - asm goto("1: nop\n\t" +asm_volatile_goto ("1: nop\n\t" ".pushsection __jump_table, \"aw\"\n\t" ".align 3\n\t" ".quad 1b, %l[l_yes], %c0\n\t"
@@ -42,7 +42,7 @@ l_yes: static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) { - asm goto("1: b %l[l_yes]\n\t" +asm_volatile_goto ("1: b %l[l_yes]\n\t" ".pushsection __jump_table, \"aw\"\n\t" ".align 3\n\t" ".quad 1b, %l[l_yes], %c0\n\t"
Greg Kroah-Hartman
maintainerPATCH 134/168 drm/amdgpu: fix error handling in amdgpu_cs_user_fence_chunk
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Christian K�nig" <[email protected]>
[ Upstream commit 0165de983272d1fae0809ed9db47c46a412279bc ]
Slowly leaking memory one page at a time :)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +15 -8
@@ -38,6 +38,7 @@ static int amdgpu_cs_user_fence_chunk(st {struct drm_gem_object *gobj;unsigned long size; +int r; gobj =drm_gem_object_lookup (p->filp, data->handle);if (gobj ==NULL )
@@ -49,20 +50,26 @@ static int amdgpu_cs_user_fence_chunk(st p->uf_entry.tv.shared = true; p->uf_entry.user_pages =NULL ; - size =amdgpu_bo_size (p->uf_entry.robj); -if (size !=PAGE_SIZE || (data->offset +8 ) > size) -return -EINVAL ; - - *offset = data->offset; -drm_gem_object_put_unlocked (gobj); + size =amdgpu_bo_size (p->uf_entry.robj); +if (size !=PAGE_SIZE || (data->offset +8 ) > size) { + r = -EINVAL ; + goto error_unref; + } +if (amdgpu_ttm_tt_get_usermm (p->uf_entry.robj->tbo.ttm)) { -amdgpu_bo_unref (&p->uf_entry.robj); -return -EINVAL ; + r = -EINVAL ; + goto error_unref; } + *offset = data->offset; +return 0 ; + +error_unref: +amdgpu_bo_unref (&p->uf_entry.robj); +return r; }static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,void *data)
Greg Kroah-Hartman
maintainerPATCH 135/168 r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
[ Upstream commit 6ad569019999300afd8e614d296fdc356550b77f ]
After system suspend, sometimes the r8169 doesn't work when ethernet cable gets pluggued.
This issue happens because rtl_reset_work() doesn't get called from rtl8169_runtime_resume(), after system suspend.
In rtl_task(), RTL_FLAG_TASK_* only gets cleared if this condition is met:
if (!netif_running(dev) ||
!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
...If RTL_FLAG_TASK_ENABLED was cleared during system suspend while RTL_FLAG_TASK_RESET_PENDING was set, the next rtl_schedule_task() won't schedule task as the flag is still there.
So in addition to clearing RTL_FLAG_TASK_ENABLED, also clears other flags.
--- drivers/net/ethernet/realtek/r8169.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/realtek/r8169.c +6 -3
@@ -730,7 +730,7 @@ struct rtl8169_tc_offsets { };enum rtl_flag { -RTL_FLAG_TASK_ENABLED , +RTL_FLAG_TASK_ENABLED =0 ,RTL_FLAG_TASK_SLOW_PENDING ,RTL_FLAG_TASK_RESET_PENDING ,RTL_FLAG_TASK_PHY_PENDING ,
@@ -7125,7 +7125,8 @@ static int rtl8169_close(struct net_devirtl8169_update_counters (tp);rtl_lock_work (tp); -clear_bit (RTL_FLAG_TASK_ENABLED , tp->wk.flags); +/* Clear all task flags */ +bitmap_zero (tp->wk.flags,RTL_FLAG_MAX );rtl8169_down (dev);rtl_unlock_work (tp);
@@ -7301,7 +7302,9 @@ static void rtl8169_net_suspend(struct nrtl_lock_work (tp);napi_disable (&tp->napi); -clear_bit (RTL_FLAG_TASK_ENABLED , tp->wk.flags); +/* Clear all task flags */ +bitmap_zero (tp->wk.flags,RTL_FLAG_MAX ); +rtl_unlock_work (tp);rtl_pll_power_down (tp);
Greg Kroah-Hartman
maintainerPATCH 136/168 s390/qeth: use vzalloc for QUERY OAT buffer
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjia Zhang <[email protected]>
[ Upstream commit aec45e857c5538664edb76a60dd452e3265f37d1 ]
qeth_query_oat_command() currently allocates the kernel buffer for the SIOC_QETH_QUERY_OAT ioctl with kzalloc. So on systems with fragmented memory, large allocations may fail (eg. the qethqoat tool by default uses 132KB).
Solve this issue by using vzalloc, backing the allocation with non-contiguous memory.
--- drivers/s390/net/qeth_core_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_core_main.c +3 -2
@@ -25,6 +25,7 @@#include <linux/netdevice.h> #include <linux/netdev_features.h> #include <linux/skbuff.h> +#include <linux/vmalloc.h> #include <net/iucv/af_iucv.h> #include <net/dsfield.h>
@@ -4738,7 +4739,7 @@ static int qeth_query_oat_command(struct priv.buffer_len = oat_data.buffer_len; priv.response_len =0 ; - priv.buffer =kzalloc (oat_data.buffer_len,GFP_KERNEL ); + priv.buffer =vzalloc (oat_data.buffer_len);if (!priv.buffer) { rc = -ENOMEM ; goto out;
@@ -4779,7 +4780,7 @@ static int qeth_query_oat_command(struct rc = -EFAULT ; out_free: -kfree (priv.buffer); +vfree (priv.buffer); out:return rc; }
Greg Kroah-Hartman
maintainerPATCH 137/168 s390/qeth: dont dump past end of unknown HW header
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Wiedmann <[email protected]>
[ Upstream commit 0ac1487c4b2de383b91ecad1be561b8f7a2c15f4 ]
For inbound data with an unsupported HW header format, only dump the actual HW header. We have no idea how much payload follows it, and what it contains. Worst case, we dump past the end of the Inbound Buffer and access whatever is located next in memory.
--- drivers/s390/net/qeth_l2_main.c | 2 +- drivers/s390/net/qeth_l3_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_l2_main.c +1 -1
@@ -425,7 +425,7 @@ static int qeth_l2_process_inbound_buffedefault :dev_kfree_skb_any (skb);QETH_CARD_TEXT (card,3 ,"inbunkno" ); -QETH_DBF_HEX (CTRL ,3 , hdr,QETH_DBF_CTRL_LEN ); +QETH_DBF_HEX (CTRL ,3 , hdr,sizeof (*hdr));continue ; } work_done++;
drivers/s390/net/qeth_l3_main.c +1 -1
@@ -1390,7 +1390,7 @@ static int qeth_l3_process_inbound_buffedefault :dev_kfree_skb_any (skb);QETH_CARD_TEXT (card,3 ,"inbunkno" ); -QETH_DBF_HEX (CTRL ,3 , hdr,QETH_DBF_CTRL_LEN ); +QETH_DBF_HEX (CTRL ,3 , hdr,sizeof (*hdr));continue ; } work_done++;
Greg Kroah-Hartman
maintainerPATCH 138/168 cifs: read overflow in is_valid_oplock_break()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 097f5863b1a0c9901f180bbd56ae7d630655faaa ]
We need to verify that the "data_offset" is within bounds.
--- fs/cifs/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/cifs/misc.c +8 -0
@@ -404,9 +404,17 @@ is_valid_oplock_break(char *buffer, stru (struct smb_com_transaction_change_notify_rsp *)buf;struct file_notify_information *pnotify;__u32 data_offset =0 ; +size_t len = srv->total_read -sizeof (pSMBr->hdr.smb_buf_length); +if (get_bcc (buf) >sizeof (struct file_notify_information )) { data_offset =le32_to_cpu (pSMBr->DataOffset); +if (data_offset > + len -sizeof (struct file_notify_information )) { +cifs_dbg (FYI ,"invalid data_offset %u\n" , + data_offset); +return true; + } pnotify = (struct file_notify_information *) ((char *)&pSMBr->hdr.Protocol + data_offset); cifs_dbg(FYI, "dnotify on %s Action: 0x%x\n",
Greg Kroah-Hartman
maintainerPATCH 139/168 asm-generic: io: Fix ioport_map() for !CONFIG_GENERIC_IOMAP && CONFIG_INDIRECT_PIO
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Murray <[email protected]>
[ Upstream commit 500dd232449e7c07500e713dc6970aa713f8e4f1 ]
The !CONFIG_GENERIC_IOMAP version of ioport_map uses MMIO_UPPER_LIMIT to prevent users from making I/O accesses outside the expected I/O range - however it erroneously treats MMIO_UPPER_LIMIT as a mask which is contradictory to its other users.
The introduction of CONFIG_INDIRECT_PIO, which subtracts an arbitrary amount from IO_SPACE_LIMIT to form MMIO_UPPER_LIMIT, results in ioport_map mangling the given port rather than capping it.
We address this by aligning more closely with the CONFIG_GENERIC_IOMAP implementation of ioport_map by using the comparison operator and returning NULL where the port exceeds MMIO_UPPER_LIMIT. Though note that we preserve the existing behavior of masking with IO_SPACE_LIMIT such that we don't break existing buggy drivers that somehow rely on this masking.
--- include/asm-generic/io.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/asm-generic/io.h +2 -1
@@ -1026,7 +1026,8 @@ static inline void __iomem *ioremap_wt(p#define ioport_map ioport_mapstatic inline void __iomem *ioport_map (unsigned long port,unsigned int nr) { -return PCI_IOBASE + (port &MMIO_UPPER_LIMIT ); + port &=IO_SPACE_LIMIT ; +return (port >MMIO_UPPER_LIMIT ) ?NULL :PCI_IOBASE + port; }#endif
Greg Kroah-Hartman
maintainerPATCH 140/168 xen/manage: dont complain about an empty value in control/sysrq node
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Kuznetsov <[email protected]>
[ Upstream commit 87dffe86d406bee8782cac2db035acb9a28620a7 ]
When guest receives a sysrq request from the host it acknowledges it by writing '\0' to control/sysrq xenstore node. This, however, make xenstore watch fire again but xenbus_scanf() fails to parse empty value with "%c" format string:
sysrq: SysRq : Emergency Sync
Emergency Sync complete
xen:manage: Error -34 reading sysrq code in control/sysrq
Ignore -ERANGE the same way we already ignore -ENOENT, empty value in control/sysrq is totally legal.
--- drivers/xen/manage.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/xen/manage.c +4 -2
@@ -280,9 +280,11 @@ static void sysrq_handler(struct xenbus_/* * The Xenstore watch fires directly after registering it and * after a suspend/resume cycle. So ENOENT is no error but -* might happen in those cases. +* might happen in those cases. ERANGE is observed when we get +* an empty value (''), this happens when we acknowledge the +* request by writing '\0' below. */ -if (err != -ENOENT ) +if (err != -ENOENT && err != -ERANGE )pr_err ("Error %d reading sysrq code in control/sysrq\n" , err);xenbus_transaction_end (xbt,1 );
Greg Kroah-Hartman
maintainerPATCH 141/168 xen: avoid crash in disable_hotplug_cpu
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olaf Hering <[email protected]>
[ Upstream commit 3366cdb6d350d95466ee430ac50f3c8415ca8f46 ]
The command 'xl vcpu-set 0 0', issued in dom0, will crash dom0:
BUG: unable to handle kernel NULL pointer dereference at 00000000000002d8 PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 7 PID: 65 Comm: xenwatch Not tainted 4.19.0-rc2-1.ga9462db-default #1 openSUSE Tumbleweed (unreleased) Hardware name: Intel Corporation S5520UR/S5520UR, BIOS S5500.86B.01.00.0050.050620101605 05/06/2010 RIP: e030:device_offline+0x9/0xb0 Code: 77 24 00 e9 ce fe ff ff 48 8b 13 e9 68 ff ff ff 48 8b 13 e9 29 ff ff ff 48 8b 13 e9 ea fe ff ff 90 66 66 66 66 90 41 54 55 53 <f6> 87 d8 02 00 00 01 0f 85 88 00 00 00 48 c7 c2 20 09 60 81 31 f6 RSP: e02b:ffffc90040f27e80 EFLAGS: 00010203 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff8801f3800000 RSI: ffffc90040f27e70 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffff820e47b3 R09: 0000000000000000 R10: 0000000000007ff0 R11: 0000000000000000 R12: ffffffff822e6d30 R13: dead000000000200 R14: dead000000000100 R15: ffffffff8158b4e0 FS: 00007ffa595158c0(0000) GS:ffff8801f39c0000(0000) knlGS:0000000000000000 CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000002d8 CR3: 00000001d9602000 CR4: 0000000000002660 Call Trace: handle_vcpu_hotplug_event+0xb5/0xc0 xenwatch_thread+0x80/0x140 ? wait_woken+0x80/0x80 kthread+0x112/0x130 ? kthread_create_worker_on_cpu+0x40/0x40 ret_from_fork+0x3a/0x50
This happens because handle_vcpu_hotplug_event is called twice. In the first iteration cpu_present is still true, in the second iteration cpu_present is false which causes get_cpu_device to return NULL. In case of cpu#0, cpu_online is apparently always true.
Fix this crash by checking if the cpu can be hotplugged, which is false for a cpu that was just removed.
Also check if the cpu was actually offlined by device_remove, otherwise leave the cpu_present state as it is.
Rearrange to code to do all work with device_hotplug_lock held.
--- drivers/xen/cpu_hotplug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/xen/cpu_hotplug.c +8 -7
@@ -19,15 +19,16 @@ static void enable_hotplug_cpu(int cpu)static void disable_hotplug_cpu (int cpu) { -if (cpu_online (cpu)) { -lock_device_hotplug (); +if (!cpu_is_hotpluggable (cpu)) +return ; +lock_device_hotplug (); +if (cpu_online (cpu))device_offline (get_cpu_device (cpu)); -unlock_device_hotplug (); - } -if (cpu_present (cpu)) +if (!cpu_online (cpu) &&cpu_present (cpu)) {xen_arch_unregister_cpu (cpu); - -set_cpu_present (cpu, false); +set_cpu_present (cpu, false); + } +unlock_device_hotplug (); }static int vcpu_online (unsigned int cpu)
Greg Kroah-Hartman
maintainerPATCH 142/168 xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Abraham <[email protected]>
[ Upstream commit 4dca864b59dd150a221730775e2f21f49779c135 ]
This patch removes duplicate macro useage in events_base.c.
It also fixes gcc warning:
variable ‘col’ set but not used [-Wunused-but-set-variable]
--- drivers/xen/events/events_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +1 -1
@@ -138,7 +138,7 @@ static int set_evtchn_to_irq(unsigned evclear_evtchn_to_irq_row (row); } - evtchn_to_irq[EVTCHN_ROW (evtchn)][EVTCHN_COL (evtchn)] = irq; + evtchn_to_irq[row][col] = irq;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 143/168 x86/APM: Fix build warning when PROC_FS is not enabled
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 002b87d2aace62b4f3841c3aa43309d2380092be ]
Fix build warning in apm_32.c when CONFIG_PROC_FS is not enabled:
../arch/x86/kernel/apm_32.c:1643:12: warning: 'proc_apm_show' defined but not used [-Wunused-function]
static int proc_apm_show(struct seq_file *m, void *v)
--- arch/x86/kernel/apm_32.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/apm_32.c +2 -0
@@ -1640,6 +1640,7 @@ static int do_open(struct inode *inode,return 0 ; } +#ifdef CONFIG_PROC_FS static int proc_apm_show (struct seq_file *m,void *v) {unsigned short bx;
@@ -1719,6 +1720,7 @@ static int proc_apm_show(struct seq_file units); return 0; } +#endif static int apm (void *unused) {
Greg Kroah-Hartman
maintainerPATCH 144/168 new primitive: discard_new_inode()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit c2b6d621c4ffe9936adf7a55c8b1c769672c306f upstream.
We don't want open-by-handle picking half-set-up in-core
struct inode from e.g. mkdir() having failed halfway through. In other words, we don't want such inodes returned by iget_locked() on their way to extinction. However, we can't just have them unhashed - otherwise open-by-handle immediately *after* that would've ended up creating a new in-core inode over the on-disk one that is in process of being freed right under us.
Solution: new flag (I_CREATING) set by insert_inode_locked() and
removed by unlock_new_inode() and a new primitive (discard_new_inode()) to be used by such halfway-through-setup failure exits instead of unlock_new_inode() / iput() combinations. That primitive unlocks new inode, but leaves I_CREATING in place.
iget_locked() treats finding an I_CREATING inode as failure
(-ESTALE, once we sort out the error propagation).
insert_inode_locked() treats the same as instant -EBUSY. ilookup() treats those as icache miss.
[Fix by Dan Carpenter <[email protected]> folded in]
--- fs/dcache.c | 2 +- fs/inode.c | 45 +++++++++++++++++++++++++++++++++++++++++---- include/linux/fs.h | 6 +++++- 3 files changed, 47 insertions(+), 6 deletions(-)
fs/dcache.c +1 -1
@@ -1890,7 +1890,7 @@ void d_instantiate_new(struct dentry *enspin_lock (&inode->i_lock);__d_instantiate (entry, inode);WARN_ON (!(inode->i_state &I_NEW )); - inode->i_state &= ~I_NEW ; + inode->i_state &= ~I_NEW & ~I_CREATING ;smp_mb ();wake_up_bit (&inode->i_state, __I_NEW);spin_unlock (&inode->i_lock);
fs/inode.c +41 -4
116 lines not on this page · raw message
include/linux/fs.h +5 -1
@@ -2014,6 +2014,8 @@ static inline void init_sync_kiocb(struc* I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper * and work dirs among overlayfs mounts. * +* I_CREATING New object's inode in the middle of setting up. +* * Q: What is the difference between I_WILL_FREE and I_FREEING? */ #define I_DIRTY_SYNC (1 << 0)
@@ -2034,7 +2036,8 @@ static inline void init_sync_kiocb(struc#define __I_DIRTY_TIME_EXPIRED 12#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED)#define I_WB_SWITCH (1 << 13) -#define I_OVL_INUSE (1 << 14) +#define I_OVL_INUSE (1 << 14) +#define I_CREATING (1 << 15)#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
@@ -2918,6 +2921,7 @@ extern void lockdep_annotate_inode_mutexstatic inline void lockdep_annotate_inode_mutex_key (struct inode *inode) { };#endif extern void unlock_new_inode (struct inode *); +extern void discard_new_inode (struct inode *);extern unsigned int get_next_ino (void );extern void evict_inodes (struct super_block *sb);
Greg Kroah-Hartman
maintainerPATCH 145/168 vfs: dont evict uninitialized inode
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit e950564b97fd0f541b02eb207685d0746f5ecf29 upstream.
iput() ends up calling ->evict() on new inode, which is not yet initialized by owning fs. So use destroy_inode() instead.
Add to sb->s_inodes list only if inode is not in I_CREATING state (meaning that it wasn't allocated with new_inode(), which already does the insertion).
--- fs/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/inode.c +6 -2
@@ -1050,6 +1050,7 @@ struct inode *inode_insert5(struct inode {struct hlist_head *head = inode_hashtable +hash (inode->i_sb, hashval);struct inode *old; +bool creating = inode->i_state &I_CREATING ; again:spin_lock (&inode_hash_lock);
@@ -1083,6 +1084,8 @@ again: inode->i_state |=I_NEW ;hlist_add_head (&inode->i_hash, head);spin_unlock (&inode->i_lock); +if (!creating) +inode_sb_list_add (inode); unlock:spin_unlock (&inode_hash_lock);
@@ -1117,12 +1120,13 @@ struct inode *iget5_locked(struct super_struct inode *inode =ilookup5 (sb, hashval, test, data);if (!inode) { -struct inode *new =new_inode (sb); +struct inode *new =alloc_inode (sb);if (new) { + new->i_state =0 ; inode =inode_insert5 (new, hashval, test, set, data);if (unlikely (inode != new)) -iput (new); +destroy_inode (new); } }return inode;
Greg Kroah-Hartman
maintainerPATCH 146/168 ovl: set I_CREATING on inode being created
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 6faf05c2b2b4fe70d9068067437649401531de0a upstream.
...otherwise there will be list corruption due to inode_sb_list_add() being called for inode already on the sb list.
To: Amir Goldstein <[email protected]>
--- fs/overlayfs/dir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/overlayfs/dir.c +4 -0
@@ -601,6 +601,10 @@ static int ovl_create_object(struct dentif (!inode) goto out_drop_write; +spin_lock (&inode->i_lock); + inode->i_state |=I_CREATING ; +spin_unlock (&inode->i_lock); +inode_init_owner (inode, dentry->d_parent->d_inode, mode); attr.mode = inode->i_mode;
Greg Kroah-Hartman
maintainerPATCH 147/168 ovl: fix access beyond unterminated strings
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 601350ff58d5415a001769532f6b8333820e5786 upstream.
KASAN detected slab-out-of-bounds access in printk from overlayfs, because string format used %*s instead of %.*s.
Quoted 4 lines
BUG: KASAN: slab-out-of-bounds in string+0x298/0x2d0 lib/vsprintf.c:604 Read of size 1 at addr ffff8801c36c66ba by task syz-executor2/27811 CPU: 0 PID: 27811 Comm: syz-executor2 Not tainted 4.19.0-rc5+ #36
...
Quoted 2 lines
printk+0xa7/0xcf kernel/printk/printk.c:1996 ovl_lookup_index.cold.15+0xe8/0x1f8 fs/overlayfs/namei.c:689
--- fs/overlayfs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/namei.c +1 -1
@@ -705,7 +705,7 @@ struct dentry *ovl_lookup_index(struct o index =NULL ; goto out; } -pr_warn_ratelimited ("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n" +pr_warn_ratelimited ("overlayfs: failed inode index lookup (ino=%lu, key=%.*s, err=%i);\n" "overlayfs: mount with '-o index=off' to disable inodes index.\n" ,d_inode (origin)->i_ino, name.len, name.name, err);
Greg Kroah-Hartman
maintainerPATCH 148/168 ovl: fix memory leak on unlink of indexed file
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 63e132528032ce937126aba591a7b37ec593a6bb upstream.
The memory leak was detected by kmemleak when running xfstests overlay/051,053
--- fs/overlayfs/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/overlayfs/util.c +2 -1
@@ -531,7 +531,7 @@ static void ovl_cleanup_index(struct denstruct dentry *upperdentry =ovl_dentry_upper (dentry);struct dentry *index =NULL ;struct inode *inode; -struct qstr name; +struct qstr name = { };int err; err =ovl_get_index_name (lowerdentry, &name);
@@ -574,6 +574,7 @@ static void ovl_cleanup_index(struct den goto fail; out: +kfree (name.name);dput (index);return ;
Greg Kroah-Hartman
maintainerPATCH 149/168 ovl: fix format of setxattr debug
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 1a8f8d2a443ef9ad9a3065ba8c8119df714240fa upstream.
Format has a typo: it was meant to be "%.*s", not "%*s". But at some point callers grew nonprintable values as well, so use "%*pE" instead with a maximized length.
--- fs/overlayfs/overlayfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/overlayfs.h +2 -2
@@ -147,8 +147,8 @@ static inline int ovl_do_setxattr(struct const void *value, size_t size, int flags) { int err = vfs_setxattr(dentry, name, value, size, flags); -pr_debug ("setxattr(%pd2, \"%s\", \"%*s\", 0x%x) = %i\n" , - dentry, name, (int ) size, (char *) value, flags, err); +pr_debug ("setxattr(%pd2, \"%s\", \"%*pE\", %zu, 0x%x) = %i\n" , + dentry, name,min ((int )size,48 ), value, size, flags, err);return err; }
Greg Kroah-Hartman
maintainerPATCH 150/168 sysfs: Do not return POSIX ACL xattrs via listxattr
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
commit ffc4c92227db5699493e43eb140b4cb5904c30ff upstream.
Commit 786534b92f3c introduced a regression that caused listxattr to return the POSIX ACL attribute names even though sysfs doesn't support POSIX ACLs. This happens because simple_xattr_list checks for NULL i_acl / i_default_acl, but inode_init_always initializes those fields to ACL_NOT_CACHED ((void *)-1). For example:
$ getfattr -m- -d /sys
/sys: system.posix_acl_access: Operation not supported
/sys: system.posix_acl_default: Operation not supported
Fix this in simple_xattr_list by checking if the filesystem supports POSIX ACLs.--- fs/xattr.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
fs/xattr.c +13 -11
@@ -949,17 +949,19 @@ ssize_t simple_xattr_list(struct inode *int err =0 ;#ifdef CONFIG_FS_POSIX_ACL -if (inode->i_acl) { - err =xattr_list_one (&buffer, &remaining_size, -XATTR_NAME_POSIX_ACL_ACCESS ); -if (err) -return err; - } -if (inode->i_default_acl) { - err =xattr_list_one (&buffer, &remaining_size, -XATTR_NAME_POSIX_ACL_DEFAULT ); -if (err) -return err; +if (IS_POSIXACL (inode)) { +if (inode->i_acl) { + err =xattr_list_one (&buffer, &remaining_size, +XATTR_NAME_POSIX_ACL_ACCESS ); +if (err) +return err; + } +if (inode->i_default_acl) { + err =xattr_list_one (&buffer, &remaining_size, +XATTR_NAME_POSIX_ACL_DEFAULT ); +if (err) +return err; + } }#endif
Greg Kroah-Hartman
maintainerPATCH 151/168 b43: fix DMA error related regression with proprietary firmware
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
commit 2823c8716c687d6c7e261a3a02b3cab43809fe9c upstream.
In commit 66cffd6daab7 ("b43: fix transmit failure when VT is switched"), a condition is noted where the network controller needs to be reset. Note that this situation happens when running the open-source firmware
(http://netweb.ing.unibs.it/~openfwwf/), plus a number of other special conditions.
for a different card model, it is reported that this change breaks operation running the proprietary firmware
(https://marc.info/?l=linux-wireless&m=153504546924558&w=2). Rather than reverting the previous patch, the code is tweaked to avoid the reset unless the open-source firmware is being used.
--- drivers/net/wireless/broadcom/b43/dma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/b43/dma.c +4 -2
@@ -1518,13 +1518,15 @@ void b43_dma_handle_txstatus(struct b43_ } }else {/* More than a single header/data pair were missed. -* Report this error, and reset the controller to +* Report this error. If running with open-source +* firmware, then reset the controller to * revive operation. */ b43dbg (dev->wl,"Out of order TX status report on DMA ring %d. Expected %d, but got %d\n" , ring->index, firstused, slot); -b43_controller_restart (dev,"Out of order TX" ); +if (dev->fw.opensource) +b43_controller_restart (dev,"Out of order TX" );return ; } }
Greg Kroah-Hartman
maintainerPATCH 152/168 firmware: Fix security issue with request_firmware_into_buf()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rishabh Bhatnagar <[email protected]>
commit 422b3db2a5036add39a82425b1dd9fb6c96481e8 upstream.
When calling request_firmware_into_buf() with the FW_OPT_NOCACHE flag it is expected that firmware is loaded into buffer from memory. But inside alloc_lookup_fw_priv every new firmware that is loaded is added to the firmware cache (fwc) list head. So if any driver requests a firmware that is already loaded the code iterates over the above mentioned list and it can end up giving a pointer to other device driver's firmware buffer.
Also the existing copy may either be modified by drivers, remote processors or even freed. This causes a potential security issue with batched requests when using request_firmware_into_buf.
Fix alloc_lookup_fw_priv to not add to the fwc head list if FW_OPT_NOCACHE is set, and also don't do the lookup in the list.
--- drivers/base/firmware_loader/main.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/base/firmware_loader/main.c +18 -12
@@ -209,21 +209,24 @@ static struct fw_priv *__lookup_fw_priv(static int alloc_lookup_fw_priv (const char *fw_name,struct firmware_cache *fwc,struct fw_priv **fw_priv,void *dbuf, -size_t size) +size_t size,enum fw_opt opt_flags) {struct fw_priv *tmp;spin_lock (&fwc->lock); - tmp =__lookup_fw_priv (fw_name); -if (tmp) { -kref_get (&tmp->ref); -spin_unlock (&fwc->lock); - *fw_priv = tmp; -pr_debug ("batched request - sharing the same struct fw_priv and lookup for multiple requests\n" ); -return 1 ; +if (!(opt_flags &FW_OPT_NOCACHE )) { + tmp =__lookup_fw_priv (fw_name); +if (tmp) { +kref_get (&tmp->ref); +spin_unlock (&fwc->lock); + *fw_priv = tmp; +pr_debug ("batched request - sharing the same struct fw_priv and lookup for multiple requests\n" ); +return 1 ; + } } + tmp =__allocate_fw_priv (fw_name, fwc, dbuf, size); -if (tmp) +if (tmp && !(opt_flags &FW_OPT_NOCACHE ))list_add (&tmp->list, &fwc->head);spin_unlock (&fwc->lock);
@@ -493,7 +496,8 @@ int assign_fw(struct firmware *fw, struc*/ static int _request_firmware_prepare (struct firmware **firmware_p,const char *name, -struct device *device,void *dbuf,size_t size) +struct device *device,void *dbuf,size_t size, +enum fw_opt opt_flags) {struct firmware *firmware;struct fw_priv *fw_priv;
@@ -511,7 +515,8 @@ _request_firmware_prepare(struct firmwarreturn 0 ;/* assigned */ } - ret =alloc_lookup_fw_priv (name, &fw_cache, &fw_priv, dbuf, size); + ret =alloc_lookup_fw_priv (name, &fw_cache, &fw_priv, dbuf, size, + opt_flags);/* * bind with 'priv' now to avoid warning in failure path
@@ -571,7 +576,8 @@ _request_firmware(const struct firmware goto out; } - ret =_request_firmware_prepare (&fw, name, device, buf, size); + ret =_request_firmware_prepare (&fw, name, device, buf, size, + opt_flags);if (ret <=0 )/* error or already assigned */ goto out;
Greg Kroah-Hartman
maintainerPATCH 153/168 firmware: Always initialize the fw_priv list object
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit 7012040576c6ae25a47035659ee48673612c2c27 upstream.
When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.
Make sure to initialize the list object regardless of this flag.
--- drivers/base/firmware_loader/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/base/firmware_loader/main.c +5 -2
@@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const ch } tmp =__allocate_fw_priv (fw_name, fwc, dbuf, size); -if (tmp && !(opt_flags &FW_OPT_NOCACHE )) -list_add (&tmp->list, &fwc->head); +if (tmp) { +INIT_LIST_HEAD (&tmp->list); +if (!(opt_flags &FW_OPT_NOCACHE )) +list_add (&tmp->list, &fwc->head); + }spin_unlock (&fwc->lock); *fw_priv = tmp;
Greg Kroah-Hartman
maintainerPATCH 154/168 cpufreq: qcom-kryo: Fix section annotations
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit d51aea13dd6753186a2bea7619029c460bdf0c4c upstream.
There is currently a warning when building the Kryo cpufreq driver into the kernel image:
WARNING: vmlinux.o(.text+0x8aa424): Section mismatch in reference from the function qcom_cpufreq_kryo_probe() to the function .init.text:qcom_cpufreq_kryo_get_msm_id()
The function qcom_cpufreq_kryo_probe() references
the function __init qcom_cpufreq_kryo_get_msm_id().
This is often because qcom_cpufreq_kryo_probe lacks a __init annotation or the annotation of qcom_cpufreq_kryo_get_msm_id is wrong.
Remove the '__init' annotation from qcom_cpufreq_kryo_get_msm_id so that there is no more mismatch warning.
Additionally, Nick noticed that the remove function was marked as '__init' when it should really be marked as '__exit'.
--- drivers/cpufreq/qcom-cpufreq-kryo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/qcom-cpufreq-kryo.c +2 -2
@@ -44,7 +44,7 @@ enum _msm8996_version {struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; -static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) +static enum _msm8996_version qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;u32 *msm_id;
@@ -221,7 +221,7 @@ static int __init qcom_cpufreq_kryo_init }module_init (qcom_cpufreq_kryo_init); -static void __init qcom_cpufreq_kryo_exit (void ) +static void __exit qcom_cpufreq_kryo_exit(void) {platform_device_unregister (kryo_cpufreq_pdev);platform_driver_unregister (&qcom_cpufreq_kryo_driver);