4.9.233-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainercover 4.9.233-rc1 review
This is the start of the stable review cycle for the 4.9.233 release. There are 212 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 Sat, 22 Aug 2020 09:15:09 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.233-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.9.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.9.233-rc1
Denis Efremov <[email protected]>
drm/radeon: fix fb_div check in ni_init_smc_spll_table()
Oscar Salvador <[email protected]>
mm: Avoid calling build_all_zonelists_init under hotplug context
Hugh Dickins <[email protected]>
khugepaged: retract_page_tables() remember to test exit
Geert Uytterhoeven <[email protected]>
sh: landisk: Add missing initialization of sh_io_port_base
Dinghao Liu <[email protected]>
ALSA: echoaudio: Fix potential Oops in snd_echo_resume()
Andy Shevchenko <[email protected]>
mfd: dln2: Run event handler loop under spinlock
Colin Ian King <[email protected]>
fs/ufs: avoid potential u32 multiplication overflow
Jeffrey Mitchell <[email protected]>
nfs: Fix getxattr kernel panic and memory overflow
Wang Hai <[email protected]>
net: qcom/emac: add missed clk_disable_unprepare in error path of emac_clks_phase1_init
Dan Carpenter <[email protected]>
drm/vmwgfx: Fix two list_for_each loop exit tests
Colin Ian King <[email protected]>
Input: sentelic - fix error return when fsp_reg_write fails
Rayagonda Kokatanur <[email protected]>
pwm: bcm-iproc: handle clk_get_rate() return
Xu Wang <[email protected]>
clk: clk-atlas6: fix return value check in atlas6_clk_init()
Wolfram Sang <[email protected]>
i2c: rcar: slave: only send STOP event when we have been addressed
Liu Yi L <[email protected]>
iommu/vt-d: Enforce PASID devTLB field mask
Colin Ian King <[email protected]>
iommu/omap: Check for failure of a call to omap_iommu_dump_ctx
Steve Longerbeam <[email protected]>
gpu: ipu-v3: image-convert: Combine rotate/no-rotate irq handlers
Johan Hovold <[email protected]>
USB: serial: ftdi_sio: fix break and sysrq handling
Johan Hovold <[email protected]>
USB: serial: ftdi_sio: clean up receive processing
Johan Hovold <[email protected]>
USB: serial: ftdi_sio: make process-packet buffer unsigned
Charles Keepax <[email protected]>
mfd: arizona: Ensure 32k clock is put on driver unbind and error
Anton Blanchard <[email protected]>
pseries: Fix 64 bit logical memory block panic
Ahmad Fatoum <[email protected]>
watchdog: f71808e_wdt: clear watchdog timeout occurred flag
Ahmad Fatoum <[email protected]>
watchdog: f71808e_wdt: remove use of wrong watchdog_info option
Ahmad Fatoum <[email protected]>
watchdog: f71808e_wdt: indicate WDIOF_CARDRESET support in watchdog_info.options
Muchun Song <[email protected]>
kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler
Chengming Zhou <[email protected]>
ftrace: Setup correct FTRACE_FL_REGS flags for module
Junxiao Bi <[email protected]>
ocfs2: change slot number type s16 to u16
Mikulas Patocka <[email protected]>
ext2: fix missing percpu_counter_inc
Huacai Chen <[email protected]>
MIPS: CPU#0 is not hotpluggable
Johannes Berg <[email protected]>
mac80211: fix misplaced while instead of if
Coly Li <[email protected]>
bcache: allocate meta data pages as compound pages
ChangSyun Peng <[email protected]>
md/raid5: Fix Force reconstruct-write io stuck in degraded raid5
Kees Cook <[email protected]>
net/compat: Add missing sock updates for SCM_RIGHTS
Jonathan McDowell <[email protected]>
net: stmmac: dwmac1000: provide multicast filter fallback
Jonathan McDowell <[email protected]>
net: ethernet: stmmac: Disable hardware multicast filter
Michael Ellerman <[email protected]>
powerpc: Fix circular dependency between percpu.h and mmu.h
Max Filippov <[email protected]>
xtensa: fix xtensa_pmu_setup prototype
Alexandru Ardelean <[email protected]>
iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw()
Filipe Manana <[email protected]>
btrfs: fix memory leaks after failure to lookup checksums during inode logging
Josef Bacik <[email protected]>
btrfs: only search for left_info if there is no right_info in try_merge_free_space
Qu Wenruo <[email protected]>
btrfs: don't allocate anonymous block device for user invisible roots
Rafael J. Wysocki <[email protected]>
PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context()
Steve French <[email protected]>
smb3: warn on confusing error scenario with sec=krb5
Roger Pau Monne <[email protected]>
xen/balloon: make the balloon wait interruptible
Roger Pau Monne <[email protected]>
xen/balloon: fix accounting in alloc_xenballooned_pages error path
Nathan Huckleberry <[email protected]>
ARM: 8992/1: Fix unwind_frame for clang-built kernels
Sven Schnelle <[email protected]>
parisc: mask out enable and reserved bits from sba imask
Zheng Bin <[email protected]>
9p: Fix memory leak in v9fs_mount
Hector Martin <[email protected]>
ALSA: usb-audio: work around streaming quirk for MacroSilicon MS2109
Eric Biggers <[email protected]>
fs/minix: reject too-large maximum file size
Eric Biggers <[email protected]>
fs/minix: don't allow getting deleted inodes
Eric Biggers <[email protected]>
fs/minix: check return value of sb_getblk()
John Allen <[email protected]>
crypto: ccp - Fix use of merged scatterlists
Tom Rix <[email protected]>
crypto: qat - fix double free in qat_uclo_create_batch_init_list
Hector Martin <[email protected]>
ALSA: usb-audio: add quirk for Pioneer DDJ-RB
Hector Martin <[email protected]>
ALSA: usb-audio: fix overeager device match for MacroSilicon MS2109
Mirko Dietrich <[email protected]>
ALSA: usb-audio: Creative USB X-Fi Pro SB1095 volume knob support
Brant Merryman <[email protected]>
USB: serial: cp210x: enable usb generic throttle/unthrottle
Brant Merryman <[email protected]>
USB: serial: cp210x: re-enable auto-RTS on open
Miaohe Lin <[email protected]>
net: Set fput_needed iff FDPUT_FPUT is set
Qingyu Li <[email protected]>
net/nfc/rawsock.c: add CAP_NET_RAW check.
Xie He <[email protected]>
drivers/net/wan/lapbether: Added needed_headroom and a skb->len check
Drew Fustini <[email protected]>
pinctrl-single: fix pcs_parse_pinconf() return value
Wang Hai <[email protected]>
dlm: Fix kobject memleak
Florinel Iordache <[email protected]>
fsl/fman: fix eth hash table allocation
Florinel Iordache <[email protected]>
fsl/fman: check dereferencing null pointer
Florinel Iordache <[email protected]>
fsl/fman: fix unreachable code
Florinel Iordache <[email protected]>
fsl/fman: fix dereference null return value
Florinel Iordache <[email protected]>
fsl/fman: use 32-bit unsigned integer
Christophe JAILLET <[email protected]>
net: spider_net: Fix the size used in a 'dma_free_coherent()' call
Wang Hai <[email protected]>
wl1251: fix always return 0 error
Julian Wiedmann <[email protected]>
s390/qeth: don't process empty bridge port events
Sandipan Das <[email protected]>
selftests/powerpc: Fix online CPU selection
Harish <[email protected]>
selftests/powerpc: Fix CPU affinity for child process
Tom Rix <[email protected]>
power: supply: check if calc_soc succeeded in pm860x_init_battery
Dan Carpenter <[email protected]>
Smack: prevent underflow in smk_set_cipso()
Dan Carpenter <[email protected]>
Smack: fix another vsscanf out of bounds
Finn Thain <[email protected]>
scsi: mesh: Fix panic after host or bus reset
Marek Szyprowski <[email protected]>
usb: dwc2: Fix error path in gadget registration
Johan Hovold <[email protected]>
USB: serial: iuu_phoenix: fix led-activity helpers
Marco Felsch <[email protected]>
drm/imx: tve: fix regulator_disable error path
Xiongfeng Wang <[email protected]>
PCI/ASPM: Add missing newline in sysfs 'policy'
Colin Ian King <[email protected]>
staging: rtl8192u: fix a dubious looking mask before a shift
Milton Miller <[email protected]>
powerpc/vdso: Fix vdso cpu truncation
Dan Carpenter <[email protected]>
mwifiex: Prevent memory corruption handling keys
John Garry <[email protected]>
scsi: scsi_debug: Add check for sdebug_max_queue during module init
Laurent Pinchart <[email protected]>
drm: panel: simple: Fix bpc for LG LB070WV8 panel
Kai-Heng Feng <[email protected]>
leds: core: Flush scheduled work for system suspend
Bjorn Helgaas <[email protected]>
PCI: Fix pci_cfg_wait queue locking problem
Darrick J. Wong <[email protected]>
xfs: fix reflink quota reservation accounting error
Chuhong Yuan <[email protected]>
media: exynos4-is: Add missed check for pinctrl_lookup_state()
Dan Carpenter <[email protected]>
media: firewire: Using uninitialized values in node_probe()
Christophe JAILLET <[email protected]>
scsi: eesox: Fix different dev_id between request_irq() and free_irq()
Christophe JAILLET <[email protected]>
scsi: powertec: Fix different dev_id between request_irq() and free_irq()
Colin Ian King <[email protected]>
drm/radeon: fix array out-of-bounds read and write issues
Wang Hai <[email protected]>
cxl: Fix kobject memleak
Emil Velikov <[email protected]>
drm/mipi: use dcs write for mipi_dsi_dcs_set_tear_scanline
Christophe JAILLET <[email protected]>
scsi: cumana_2: Fix different dev_id between request_irq() and free_irq()
Chuhong Yuan <[email protected]>
media: omap3isp: Add missed v4l2_ctrl_handler_free() for preview_init_entities()
Arnd Bergmann <[email protected]>
leds: lm355x: avoid enum conversion warning
Tomasz Duszynski <[email protected]>
iio: improve IIO_CONCENTRATION channel type description
Christophe JAILLET <[email protected]>
video: pxafb: Fix the function used to balance a 'dma_alloc_coherent()' call
Dejin Zheng <[email protected]>
console: newport_con: fix an issue about leak related system resources
Dejin Zheng <[email protected]>
video: fbdev: sm712fb: fix an issue about iounmap for a wrong address
Qiushi Wu <[email protected]>
agp/intel: Fix a memory leak on module initialisation failure
Erik Kaneda <[email protected]>
ACPICA: Do not increment operation_region reference counts for field units
Coly Li <[email protected]>
bcache: fix super block seq numbers comparision in register_cache_set()
Jim Cromie <[email protected]>
dyndbg: fix a BUG_ON in ddebug_describe_flags
Sasi Kumar <[email protected]>
bdc: Fix bug causing crash after multiple disconnects
Evgeny Novikov <[email protected]>
usb: gadget: net2280: fix memory leak on probe error handling paths
Bolarinwa Olayemi Saheed <[email protected]>
iwlegacy: Check the return value of pcie_capability_read_*()
Prasanna Kerekoppa <[email protected]>
brcmfmac: To fix Bss Info flag definition Bug
Paul E. McKenney <[email protected]>
mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls
Michael Tretter <[email protected]>
drm/debugfs: fix plain echo to connector "force" attribute
Aditya Pakki <[email protected]>
drm/nouveau: fix multiple instances of reference count leaks
Zhao Heming <[email protected]>
md-cluster: fix wild pointer of unlock_all_bitmaps()
Evgeny Novikov <[email protected]>
video: fbdev: neofb: fix memory leak in neo_scan_monitor()
Aditya Pakki <[email protected]>
drm/radeon: Fix reference count leaks caused by pm_runtime_get_sync
Paul E. McKenney <[email protected]>
fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls
Lihong Kou <[email protected]>
Bluetooth: add a mutex lock to avoid UAF in do_enale_set
Tomi Valkeinen <[email protected]>
drm/tilcdc: fix leak & null ref in panel_connector_get_modes
Yu Kuai <[email protected]>
ARM: socfpga: PM: add missing put_device() call in socfpga_setup_ocram_self_refresh()
yu kuai <[email protected]>
ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
Lu Wei <[email protected]>
platform/x86: intel-vbtn: Fix return value check in check_acpi_dev()
Lu Wei <[email protected]>
platform/x86: intel-hid: Fix return value check in check_acpi_dev()
Finn Thain <[email protected]>
m68k: mac: Fix IOP status/control register writes
Finn Thain <[email protected]>
m68k: mac: Don't send IOP message until channel is idle
Alim Akhtar <[email protected]>
arm64: dts: exynos: Fix silent hang after boot on Espresso
Stephan Gerhold <[email protected]>
arm64: dts: qcom: msm8916: Replace invalid bias-pull-none property
Qiushi Wu <[email protected]>
EDAC: Fix reference count leaks
Yang Yingliang <[email protected]>
cgroup: add missing skcd->no_refcnt check in cgroup_sk_clone()
Uwe Kleine-König <[email protected]>
gpio: fix oops resulting from calling of_get_named_gpio(NULL, ...)
Nick Desaulniers <[email protected]>
tracepoint: Mark __tracepoint_string's __used
Eric Biggers <[email protected]>
Smack: fix use-after-free in smk_write_relabel_self()
Rustam Kovhaev <[email protected]>
usb: hso: check for return value in hso_serial_common_create()
Hangbin Liu <[email protected]>
Revert "vxlan: fix tos value before xmit"
Johan Hovold <[email protected]>
net: lan78xx: replace bogus endpoint lookup
Ido Schimmel <[email protected]>
vxlan: Ensure FDB dump is performed under RCU
Cong Wang <[email protected]>
ipv6: fix memory leaks on IPV6_ADDRFORM path
Ido Schimmel <[email protected]>
ipv4: Silence suspicious RCU usage warning
Jann Horn <[email protected]>
binder: Prevent context manager from incrementing ref 0
Frank van der Linden <[email protected]>
xattr: break delegations in {set,remove}xattr
Philippe Duplessis-Guindon <[email protected]>
tools lib traceevent: Fix memory leak in process_dynamic_array_len
Xin Xiong <[email protected]>
atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent
Francesco Ruggeri <[email protected]>
igb: reinit_locked() should be called with rtnl_lock
Julian Squires <[email protected]>
cfg80211: check vendor command doit pointer before use
Ben Skeggs <[email protected]>
drm/nouveau/fbcon: fix module unload when fbcon init has failed for some reason
Christoph Hellwig <[email protected]>
net/9p: validate fds in p9_fd_open
Johan Hovold <[email protected]>
leds: 88pm860x: fix use-after-free on unbind
Johan Hovold <[email protected]>
leds: lm3533: fix use-after-free on unbind
Johan Hovold <[email protected]>
leds: da903x: fix use-after-free on unbind
Johan Hovold <[email protected]>
leds: wm831x-status: fix use-after-free on unbind
Greg Kroah-Hartman <[email protected]>
mtd: properly check all write ioctls for permissions
Yunhai Zhang <[email protected]>
vgacon: Fix for missing check in scrollback handling
Adam Ford <[email protected]>
omapfb: dss: Fix max fclk divider for omap36xx
Peilin Ye <[email protected]>
Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()
Peilin Ye <[email protected]>
Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt()
Peilin Ye <[email protected]>
Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
Takashi Iwai <[email protected]>
ALSA: seq: oss: Serialize ioctls
Roi Dayan <[email protected]>
net/mlx5e: Don't support phys switch id if not in switchdev mode
Erik Ekman <[email protected]>
USB: serial: qcserial: add EM7305 QDL product ID
Jiang Ying <[email protected]>
ext4: fix direct I/O read error
Linus Torvalds <[email protected]>
random32: move the pseudo-random 32-bit definitions to prandom.h
Linus Torvalds <[email protected]>
random32: remove net_rand_state from the latent entropy gcc plugin
Willy Tarreau <[email protected]>
random: fix circular include dependency on arm64 after addition of percpu.h
Grygorii Strashko <[email protected]>
ARM: percpu.h: fix build error
Willy Tarreau <[email protected]>
random32: update the net random state on interrupt and activity
Thomas Gleixner <[email protected]>
x86/i8259: Use printk_deferred() to prevent deadlock
Wanpeng Li <[email protected]>
KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled
Andrea Righi <[email protected]>
xen-netfront: fix potential deadlock in xennet_remove()
Raviteja Narayanam <[email protected]>
Revert "i2c: cadence: Fix the hold bit setting"
Yoshihiro Shimoda <[email protected]>
net: ethernet: ravb: exit if re-initialization fails in tx timeout
Liam Beguin <[email protected]>
parisc: add support for cmpxchg on u8 pointers
Navid Emamdoost <[email protected]>
nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame
Laurence Oberman <[email protected]>
qed: Disable "MFW indication via attention" SPAM every 5 minutes
Geert Uytterhoeven <[email protected]>
usb: hso: Fix debug compile warning on sparc32
Robin Murphy <[email protected]>
arm64: csum: Fix handling of bad packets
Remi Pommarel <[email protected]>
mac80211: mesh: Free pending skb when destroying a mpath
Remi Pommarel <[email protected]>
mac80211: mesh: Free ie data when leaving mesh
Thomas Falcon <[email protected]>
ibmvnic: Fix IRQ mapping disposal in error path
Ido Schimmel <[email protected]>
mlxsw: core: Free EMAD transactions using kfree_rcu()
Ido Schimmel <[email protected]>
mlxsw: core: Increase scope of RCU read-side critical section
Jakub Kicinski <[email protected]>
mlx4: disable device on shutdown
Johan Hovold <[email protected]>
net: lan78xx: fix transfer-buffer memory leak
Johan Hovold <[email protected]>
net: lan78xx: add missing endpoint sanity check
Michael Karcher <[email protected]>
sh: Fix validation of system call number
YueHaibing <[email protected]>
net/x25: Fix null-ptr-deref in x25_disconnect
Xiyu Yang <[email protected]>
net/x25: Fix x25_neigh refcnt leak when x25 disconnect
Rolf Eike Beer <[email protected]>
install several missing uapi headers
Nicolas Dichtel <[email protected]>
uapi: includes linux/types.h before exporting files
Rik van Riel <[email protected]>
xfs: fix missed wakeup on l_flush_wait
Peilin Ye <[email protected]>
rds: Prevent kernel-infoleak in rds_notify_queue_get()
Tetsuo Handa <[email protected]>
fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins.
Joerg Roedel <[email protected]>
x86, vmlinux.lds: Page-align end of ..page_aligned sections
Sami Tolvanen <[email protected]>
x86/build/lto: Fix truncated .bss with -fdata-sections
Wang Hai <[email protected]>
9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work
Dominique Martinet <[email protected]>
9p/trans_fd: abort p9_read_work if req status changed
Sheng Yong <[email protected]>
f2fs: check if file namelen exceeds max value
Jaegeuk Kim <[email protected]>
f2fs: check memory boundary by insane namelen
Steve Cohen <[email protected]>
drm: hold gem reference until object is no longer accessed
Peilin Ye <[email protected]>
drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()
Will Deacon <[email protected]>
ARM: 8986/1: hw_breakpoint: Don't invoke overflow handler on uaccess watchpoints
Robert Hancock <[email protected]>
PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge
Navid Emamdoost <[email protected]>
ath9k: release allocated buffer if timed out
Navid Emamdoost <[email protected]>
ath9k_htc: release allocated buffer if timed out
Navid Emamdoost <[email protected]>
media: rc: prevent memory leak in cx23888_ir_probe
Navid Emamdoost <[email protected]>
crypto: ccp - Release all allocated memory if sha type is invalid
Wei Yongjun <[email protected]>
net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe()
Eric Sandeen <[email protected]>
xfs: don't call xfs_da_shrink_inode with NULL bp
Dave Chinner <[email protected]>
xfs: validate cached inodes are free when allocated
Dave Chinner <[email protected]>
xfs: catch inode allocation state mismatch corruption
-------------
Diffstat:
Documentation/ABI/testing/sysfs-bus-iio | 3 +- Makefile | 4 +- arch/arm/include/asm/percpu.h | 2 + arch/arm/kernel/hw_breakpoint.c | 27 ++++- arch/arm/kernel/stacktrace.c | 24 +++++ arch/arm/mach-at91/pm.c | 11 +- arch/arm/mach-socfpga/pm.c | 8 +- arch/arm64/boot/dts/exynos/exynos7-espresso.dts | 1 + arch/arm64/boot/dts/qcom/msm8916-pins.dtsi | 10 +- arch/arm64/include/asm/checksum.h | 5 +- arch/m68k/mac/iop.c | 21 ++-- arch/mips/include/uapi/asm/Kbuild | 3 + arch/mips/kernel/topology.c | 2 +- arch/parisc/include/asm/cmpxchg.h | 2 + arch/parisc/lib/bitops.c | 12 +++ arch/powerpc/include/asm/percpu.h | 4 +- arch/powerpc/include/uapi/asm/Kbuild | 1 + arch/powerpc/kernel/vdso.c | 2 +- arch/powerpc/platforms/pseries/hotplug-memory.c | 2 +- arch/sh/boards/mach-landisk/setup.c | 3 + arch/sh/kernel/entry-common.S | 6 +- arch/x86/kernel/i8259.c | 2 +- arch/x86/kernel/vmlinux.lds.S | 3 +- arch/x86/kvm/lapic.c | 2 +- arch/xtensa/kernel/perf_event.c | 2 +- drivers/acpi/acpica/exprep.c | 4 - drivers/acpi/acpica/utdelete.c | 6 +- drivers/android/binder.c | 9 ++ drivers/atm/atmtcp.c | 10 +- drivers/char/agp/intel-gtt.c | 4 +- drivers/char/random.c | 1 + drivers/clk/sirf/clk-atlas6.c | 2 +- drivers/crypto/ccp/ccp-dev.h | 1 + drivers/crypto/ccp/ccp-ops.c | 40 +++++--- drivers/crypto/qat/qat_common/qat_uclo.c | 9 +- drivers/edac/edac_device_sysfs.c | 1 + drivers/edac/edac_pci_sysfs.c | 2 +- drivers/gpio/gpiolib-of.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +- drivers/gpu/drm/drm_debugfs.c | 8 +- drivers/gpu/drm/drm_gem.c | 10 +- drivers/gpu/drm/drm_mipi_dsi.c | 6 +- drivers/gpu/drm/imx/imx-tve.c | 20 ++-- drivers/gpu/drm/nouveau/nouveau_drm.c | 8 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 1 + drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +- drivers/gpu/drm/panel/panel-simple.c | 2 +- drivers/gpu/drm/radeon/ci_dpm.c | 2 +- drivers/gpu/drm/radeon/ni_dpm.c | 2 +- drivers/gpu/drm/radeon/radeon_display.c | 4 +- drivers/gpu/drm/radeon/radeon_drv.c | 4 +- drivers/gpu/drm/radeon/radeon_kms.c | 4 +- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 8 +- drivers/gpu/ipu-v3/ipu-image-convert.c | 58 ++++------- drivers/i2c/busses/i2c-cadence.c | 9 +- drivers/i2c/busses/i2c-rcar.c | 7 +- drivers/iio/dac/ad5592r-base.c | 4 +- drivers/input/mouse/sentelic.c | 2 +- drivers/iommu/omap-iommu-debug.c | 3 + drivers/leds/led-class.c | 1 + drivers/leds/leds-88pm860x.c | 14 ++- drivers/leds/leds-da903x.c | 14 ++- drivers/leds/leds-lm3533.c | 12 ++- drivers/leds/leds-lm355x.c | 7 +- drivers/leds/leds-wm831x-status.c | 14 ++- drivers/md/bcache/bset.c | 2 +- drivers/md/bcache/btree.c | 2 +- drivers/md/bcache/journal.c | 4 +- drivers/md/bcache/super.c | 11 +- drivers/md/md-cluster.c | 1 + drivers/md/raid5.c | 3 +- drivers/media/firewire/firedtv-fw.c | 2 + drivers/media/pci/cx23885/cx23888-ir.c | 5 +- drivers/media/platform/exynos4-is/media-dev.c | 3 + drivers/media/platform/omap3isp/isppreview.c | 4 +- drivers/mfd/arizona-core.c | 18 ++++ drivers/mfd/dln2.c | 4 + drivers/misc/cxl/sysfs.c | 2 +- drivers/mtd/mtdchar.c | 56 ++++++++-- drivers/net/ethernet/freescale/fman/fman.c | 3 +- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 4 +- drivers/net/ethernet/freescale/fman/fman_mac.h | 2 +- drivers/net/ethernet/freescale/fman/fman_memac.c | 3 +- drivers/net/ethernet/freescale/fman/fman_port.c | 9 +- drivers/net/ethernet/freescale/fman/fman_tgec.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.c | 2 +- drivers/net/ethernet/intel/igb/igb_main.c | 9 ++ drivers/net/ethernet/mellanox/mlx4/main.c | 2 + drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/core.c | 8 +- drivers/net/ethernet/qlogic/qed/qed_int.c | 3 +- drivers/net/ethernet/qualcomm/emac/emac.c | 17 +++- drivers/net/ethernet/renesas/ravb_main.c | 26 ++++- .../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | 1 + .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 3 + drivers/net/ethernet/toshiba/spider_net.c | 4 +- drivers/net/phy/mdio-bcm-unimac.c | 2 + drivers/net/usb/hso.c | 10 +- drivers/net/usb/lan78xx.c | 113 ++++++--------------- drivers/net/vxlan.c | 10 +- drivers/net/wan/lapbether.c | 10 +- drivers/net/wireless/ath/ath9k/htc_hst.c | 3 + drivers/net/wireless/ath/ath9k/wmi.c | 1 + .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- drivers/net/wireless/intel/iwlegacy/common.c | 4 +- drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 22 ++-- drivers/net/wireless/ti/wl1251/event.c | 2 +- drivers/net/xen-netfront.c | 64 ++++++++---- drivers/nfc/s3fwrn5/core.c | 1 + drivers/parisc/sba_iommu.c | 2 +- drivers/pci/access.c | 8 +- drivers/pci/hotplug/acpiphp_glue.c | 14 ++- drivers/pci/pcie/aspm.c | 1 + drivers/pci/quirks.c | 13 +++ drivers/pinctrl/pinctrl-single.c | 11 +- drivers/platform/x86/intel-hid.c | 2 +- drivers/platform/x86/intel-vbtn.c | 2 +- drivers/power/supply/88pm860x_battery.c | 6 +- drivers/pwm/pwm-bcm-iproc.c | 9 +- drivers/s390/net/qeth_l2_main.c | 4 + drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/mesh.c | 8 +- drivers/scsi/scsi_debug.c | 6 ++ drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/usb/dwc2/platform.c | 4 +- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 + drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 +-- drivers/usb/gadget/udc/net2280.c | 4 +- drivers/usb/serial/cp210x.c | 19 ++++ drivers/usb/serial/ftdi_sio.c | 57 ++++++----- drivers/usb/serial/iuu_phoenix.c | 14 +-- drivers/usb/serial/qcserial.c | 1 + drivers/video/console/bitblit.c | 4 +- drivers/video/console/fbcon_ccw.c | 4 +- drivers/video/console/fbcon_cw.c | 4 +- drivers/video/console/fbcon_ud.c | 4 +- drivers/video/console/newport_con.c | 12 ++- drivers/video/console/vgacon.c | 4 + drivers/video/fbdev/neofb.c | 1 + drivers/video/fbdev/omap2/omapfb/dss/dss.c | 2 +- drivers/video/fbdev/pxafb.c | 4 +- drivers/video/fbdev/sm712fb.c | 2 + drivers/watchdog/f71808e_wdt.c | 13 ++- drivers/xen/balloon.c | 12 ++- fs/9p/v9fs.c | 5 +- fs/btrfs/disk-io.c | 13 ++- fs/btrfs/extent_io.c | 2 + fs/btrfs/free-space-cache.c | 4 +- fs/btrfs/tree-log.c | 8 +- fs/cifs/smb2pdu.c | 2 + fs/dlm/lockspace.c | 6 +- fs/ext2/ialloc.c | 3 +- fs/ext4/inode.c | 5 + fs/f2fs/dir.c | 12 ++- fs/minix/inode.c | 36 ++++++- fs/minix/itree_common.c | 8 +- fs/nfs/nfs4proc.c | 2 - fs/nfs/nfs4xdr.c | 6 +- fs/ocfs2/ocfs2.h | 4 +- fs/ocfs2/suballoc.c | 4 +- fs/ocfs2/super.c | 4 +- fs/ufs/super.c | 2 +- fs/xattr.c | 84 +++++++++++++-- fs/xfs/libxfs/xfs_attr_leaf.c | 5 +- fs/xfs/xfs_icache.c | 58 +++++++++-- fs/xfs/xfs_log.c | 9 +- fs/xfs/xfs_reflink.c | 21 ++-- include/asm-generic/vmlinux.lds.h | 5 +- include/linux/intel-iommu.h | 4 +- include/linux/mmzone.h | 3 +- include/linux/prandom.h | 78 ++++++++++++++ include/linux/random.h | 63 +----------- include/linux/tracepoint.h | 2 +- include/linux/xattr.h | 2 + include/net/addrconf.h | 1 + include/net/sock.h | 4 + include/uapi/drm/Kbuild | 3 + include/uapi/linux/Kbuild | 20 ++++ include/uapi/linux/bcache.h | 2 +- include/uapi/linux/btrfs_tree.h | 2 + include/uapi/linux/cifs/Kbuild | 1 + include/uapi/linux/cryptouser.h | 2 + include/uapi/linux/genwqe/Kbuild | 1 + include/uapi/linux/pr.h | 2 + include/uapi/linux/qrtr.h | 1 + init/main.c | 2 +- kernel/cgroup.c | 2 + kernel/kprobes.c | 7 ++ kernel/time/timer.c | 8 ++ kernel/trace/ftrace.c | 11 +- lib/dynamic_debug.c | 23 ++--- lib/random32.c | 2 +- mm/khugepaged.c | 22 ++-- mm/memory_hotplug.c | 10 +- mm/mmap.c | 1 + mm/page_alloc.c | 7 +- net/9p/trans_fd.c | 56 +++++++--- net/bluetooth/6lowpan.c | 5 + net/bluetooth/hci_event.c | 11 +- net/compat.c | 1 + net/core/sock.c | 21 ++++ net/ipv4/fib_trie.c | 2 +- net/ipv6/anycast.c | 17 +++- net/ipv6/ipv6_sockglue.c | 1 + net/mac80211/cfg.c | 1 + net/mac80211/mesh_pathtbl.c | 1 + net/mac80211/sta_info.c | 2 +- net/nfc/rawsock.c | 7 +- net/rds/recv.c | 3 +- net/socket.c | 2 +- net/wireless/nl80211.c | 6 +- net/x25/x25_subr.c | 6 ++ security/smack/smackfs.c | 19 +++- sound/core/seq/oss/seq_oss.c | 8 +- sound/pci/echoaudio/echoaudio.c | 2 - sound/usb/card.h | 1 + sound/usb/mixer_quirks.c | 1 + sound/usb/pcm.c | 6 ++ sound/usb/quirks-table.h | 64 +++++++++++- sound/usb/quirks.c | 3 + sound/usb/stream.c | 1 + tools/lib/traceevent/event-parse.c | 1 + .../selftests/powerpc/benchmarks/context_switch.c | 21 +++- tools/testing/selftests/powerpc/utils.c | 37 ++++--- 227 files changed, 1495 insertions(+), 635 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/212 xfs: catch inode allocation state mismatch corruption
From: Dave Chinner <[email protected]>
[ Upstream commit ee457001ed6c6f31ddad69c24c1da8f377d8472d ]
We recently came across a V4 filesystem causing memory corruption due to a newly allocated inode being setup twice and being added to the superblock inode list twice. From code inspection, the only way this could happen is if a newly allocated inode was not marked as free on disk (i.e. di_mode wasn't zero).
Running the metadump on an upstream debug kernel fails during inode allocation like so:
XFS: Assertion failed: ip->i_d.di_nblocks == 0, file: fs/xfs/xfs_inod= e.c, line: 838
------------[ cut here ]------------ kernel BUG at fs/xfs/xfs_message.c:114! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 11 PID: 3496 Comm: mkdir Not tainted 4.16.0-rc5-dgc #442 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/0= 1/2014 RIP: 0010:assfail+0x28/0x30 RSP: 0018:ffffc9000236fc80 EFLAGS: 00010202 RAX: 00000000ffffffea RBX: 0000000000004000 RCX: 0000000000000000 RDX: 00000000ffffffc0 RSI: 000000000000000a RDI: ffffffff8227211b RBP: ffffc9000236fce8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000bec R11: f000000000000000 R12: ffffc9000236fd30 R13: ffff8805c76bab80 R14: ffff8805c77ac800 R15: ffff88083fb12e10 FS: 00007fac8cbff040(0000) GS:ffff88083fd00000(0000) knlGS:0000000000000= 000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fffa6783ff8 CR3: 00000005c6e2b003 CR4: 00000000000606e0 Call Trace: xfs_ialloc+0x383/0x570 xfs_dir_ialloc+0x6a/0x2a0 xfs_create+0x412/0x670 xfs_generic_create+0x1f7/0x2c0 ? capable_wrt_inode_uidgid+0x3f/0x50 vfs_mkdir+0xfb/0x1b0 SyS_mkdir+0xcf/0xf0 do_syscall_64+0x73/0x1a0 entry_SYSCALL_64_after_hwframe+0x42/0xb7
Extracting the inode number we crashed on from an event trace and looking at it with xfs_db:
xfs_db> inode 184452204xfs_db> p
core.magic = 0x494e
core.mode = 0100644
core.version = 2
core.format = 2 (extents)
core.nlinkv2 = 1
core.onlink = 0
.....
Confirms that it is not a free inode on disk. xfs_repair also trips over this inode:
.....
zero length extent (off = 0, fsbno = 0) in ino 184452204 correcting nextents for inode 184452204
bad attribute fork in inode 184452204, would clear attr fork bad nblocks 1 for inode 184452204, would reset to 0 bad anextents 1 for inode 184452204, would reset to 0 imap claims in-use inode 184452204 is free, would correct imap would have cleared inode 184452204
.....
disconnected inode 184452204, would move to lost+found
And so we have a situation where the directory structure and the inobt thinks the inode is free, but the inode on disk thinks it is still in use. Where this corruption came from is not possible to diagnose, but we can detect it and prevent the kernel from oopsing on lookup. The reproducer now results in:
$ sudo mkdir /mnt/scratch/{0,1,2,3,4,5}{0,1,2,3,4,5}
mkdir: cannot create directory =E2=80=98/mnt/scratch/00=E2=80=99: File ex=
ists
mkdir: cannot create directory =E2=80=98/mnt/scratch/01=E2=80=99: File ex=
ists
mkdir: cannot create directory =E2=80=98/mnt/scratch/03=E2=80=99: Structu=
re needs cleaning
mkdir: cannot create directory =E2=80=98/mnt/scratch/04=E2=80=99: Input/o=
utput error
mkdir: cannot create directory =E2=80=98/mnt/scratch/05=E2=80=99: Input/o=
utput error
....And this corruption shutdown:
[ 54.843517] XFS (loop0): Corruption detected! Free inode 0xafe846c not= marked free on disk [ 54.845885] XFS (loop0): Internal error xfs_trans_cancel at line 1023 = of file fs/xfs/xfs_trans.c. Caller xfs_create+0x425/0x670 [ 54.848994] CPU: 10 PID: 3541 Comm: mkdir Not tainted 4.16.0-rc5-dgc #= 443 [ 54.850753] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIO= S 1.10.2-1 04/01/2014 [ 54.852859] Call Trace: [ 54.853531] dump_stack+0x85/0xc5 [ 54.854385] xfs_trans_cancel+0x197/0x1c0 [ 54.855421] xfs_create+0x425/0x670 [ 54.856314] xfs_generic_create+0x1f7/0x2c0 [ 54.857390] ? capable_wrt_inode_uidgid+0x3f/0x50 [ 54.858586] vfs_mkdir+0xfb/0x1b0 [ 54.859458] SyS_mkdir+0xcf/0xf0 [ 54.860254] do_syscall_64+0x73/0x1a0 [ 54.861193] entry_SYSCALL_64_after_hwframe+0x42/0xb7 [ 54.862492] RIP: 0033:0x7fb73bddf547 [ 54.863358] RSP: 002b:00007ffdaa553338 EFLAGS: 00000246 ORIG_RAX: 0000= 000000000053 [ 54.865133] RAX: ffffffffffffffda RBX: 00007ffdaa55449a RCX: 00007fb73= bddf547 [ 54.866766] RDX: 0000000000000001 RSI: 00000000000001ff RDI: 00007ffda= a55449a [ 54.868432] RBP: 00007ffdaa55449a R08: 00000000000001ff R09: 00005623a= 8670dd0 [ 54.870110] R10: 00007fb73be72d5b R11: 0000000000000246 R12: 000000000= 00001ff [ 54.871752] R13: 00007ffdaa5534b0 R14: 0000000000000000 R15: 00007ffda= a553500 [ 54.873429] XFS (loop0): xfs_do_force_shutdown(0x8) called from line 1= 024 of file fs/xfs/xfs_trans.c. Return address = ffffffff814cd050 [ 54.882790] XFS (loop0): Corruption of in-memory data detected. Shutt= ing down filesystem [ 54.884597] XFS (loop0): Please umount the filesystem and rectify the =
problem(s)
Note that this crash is only possible on v4 filesystemsi or v5 filesystems mounted with the ikeep mount option. For all other V5 filesystems, this problem cannot occur because we don't read inodes we are allocating from disk - we simply overwrite them with the new inode information.
--- fs/xfs/xfs_icache.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
fs/xfs/xfs_icache.c +22 -1
@@ -471,7 +471,28 @@ xfs_iget_cache_miss(trace_xfs_iget_miss (ip); -if ((VFS_I (ip)->i_mode ==0 ) && !(flags &XFS_IGET_CREATE )) { + +/* +* If we are allocating a new inode, then check what was returned is +* actually a free, empty inode. If we are not allocating an inode, +* the check we didn't find a free inode. +*/ +if (flags &XFS_IGET_CREATE ) { +if (VFS_I (ip)->i_mode !=0 ) { +xfs_warn (mp, +"Corruption detected! Free inode 0x%llx not marked free on disk" , + ino); + error = -EFSCORRUPTED ; + goto out_destroy; + } +if (ip->i_d.di_nblocks !=0 ) { +xfs_warn (mp, +"Corruption detected! Free inode 0x%llx has blocks allocated!" , + ino); + error = -EFSCORRUPTED ; + goto out_destroy; + } + }else if (VFS_I (ip)->i_mode ==0 ) { error = -ENOENT ; goto out_destroy; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 2/212 xfs: validate cached inodes are free when allocated
In reply to Greg Kroah-HartmanFrom: Dave Chinner <[email protected]>
[ Upstream commit afca6c5b2595fc44383919fba740c194b0b76aff ]
A recent fuzzed filesystem image cached random dcache corruption when the reproducer was run. This often showed up as panics in lookup_slow() on a null inode->i_ops pointer when doing pathwalks.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 .... Call Trace: lookup_slow+0x44/0x60 walk_component+0x3dd/0x9f0 link_path_walk+0x4a7/0x830 path_lookupat+0xc1/0x470 filename_lookup+0x129/0x270 user_path_at_empty+0x36/0x40 path_listxattr+0x98/0x110 SyS_listxattr+0x13/0x20 do_syscall_64+0xf5/0x280 entry_SYSCALL_64_after_hwframe+0x42/0xb7
but had many different failure modes including deadlocks trying to lock the inode that was just allocated or KASAN reports of use-after-free violations.
The cause of the problem was a corrupt INOBT on a v4 fs where the root inode was marked as free in the inobt record. Hence when we allocated an inode, it chose the root inode to allocate, found it in the cache and re-initialised it.
We recently fixed a similar inode allocation issue caused by inobt record corruption problem in xfs_iget_cache_miss() in commit ee457001ed6c ("xfs: catch inode allocation state mismatch corruption"). This change adds similar checks to the cache-hit path to catch it, and turns the reproducer into a corruption shutdown situation.
--- fs/xfs/xfs_icache.c | 73 +++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 25 deletions(-)
fs/xfs/xfs_icache.c +48 -25
@@ -307,6 +307,46 @@ xfs_reinit_inode(return error; } +/* +* If we are allocating a new inode, then check what was returned is +* actually a free, empty inode. If we are not allocating an inode, +* then check we didn't find a free inode. +* +* Returns: +* 0 if the inode free state matches the lookup context +* -ENOENT if the inode is free and we are not allocating +* -EFSCORRUPTED if there is any state mismatch at all +*/ +static int +xfs_iget_check_free_state ( +struct xfs_inode *ip, +int flags) +{ +if (flags &XFS_IGET_CREATE ) { +/* should be a free inode */ +if (VFS_I (ip)->i_mode !=0 ) { +xfs_warn (ip->i_mount, +"Corruption detected! Free inode 0x%llx not marked free! (mode 0x%x)" , + ip->i_ino,VFS_I (ip)->i_mode); +return -EFSCORRUPTED ; + } + +if (ip->i_d.di_nblocks !=0 ) { +xfs_warn (ip->i_mount, +"Corruption detected! Free inode 0x%llx has blocks allocated!" , + ip->i_ino); +return -EFSCORRUPTED ; + } +return 0 ; + } + +/* should be an allocated inode */ +if (VFS_I (ip)->i_mode ==0 ) +return -ENOENT ; + +return 0 ; +} +/* * Check the validity of the inode we just found it the cache */
@@ -356,12 +396,12 @@ xfs_iget_cache_hit( }/* -* If lookup is racing with unlink return an error immediately. +* Check the inode free state is valid. This also detects lookup +* racing with unlinks. */ -if (VFS_I (ip)->i_mode ==0 && !(flags &XFS_IGET_CREATE )) { - error = -ENOENT ; + error =xfs_iget_check_free_state (ip, flags); +if (error) goto out_error; - }/* * If IRECLAIMABLE is set, we've torn down the VFS inode already.
@@ -473,29 +513,12 @@ xfs_iget_cache_miss(/* -* If we are allocating a new inode, then check what was returned is -* actually a free, empty inode. If we are not allocating an inode, -* the check we didn't find a free inode. +* Check the inode free state is valid. This also detects lookup +* racing with unlinks. */ -if (flags &XFS_IGET_CREATE ) { -if (VFS_I (ip)->i_mode !=0 ) { -xfs_warn (mp, -"Corruption detected! Free inode 0x%llx not marked free on disk" , - ino); - error = -EFSCORRUPTED ; - goto out_destroy; - } -if (ip->i_d.di_nblocks !=0 ) { -xfs_warn (mp, -"Corruption detected! Free inode 0x%llx has blocks allocated!" , - ino); - error = -EFSCORRUPTED ; - goto out_destroy; - } - }else if (VFS_I (ip)->i_mode ==0 ) { - error = -ENOENT ; + error =xfs_iget_check_free_state (ip, flags); +if (error) goto out_destroy; - }/* * Preload the radix tree so we can insert safely under the
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 3/212 xfs: dont call xfs_da_shrink_inode with NULL bp
In reply to Greg Kroah-HartmanFrom: Eric Sandeen <[email protected]>
[ Upstream commit bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a ]
xfs_attr3_leaf_create may have errored out before instantiating a buffer, for example if the blkno is out of range. In that case there is no work to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops if we try.
This also seems to fix a flaw where the original error from xfs_attr3_leaf_create gets overwritten in the cleanup case, and it removes a pointless assignment to bp which isn't used after this.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969
--- fs/xfs/libxfs/xfs_attr_leaf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +2 -3
@@ -785,9 +785,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)ASSERT (blkno ==0 ); error =xfs_attr3_leaf_create (args, blkno, &bp);if (error) { - error =xfs_da_shrink_inode (args,0 , bp); - bp =NULL ; -if (error) +/* xfs_attr3_leaf_create may not have instantiated a block */ +if (bp && (xfs_da_shrink_inode (args,0 , bp) !=0 )) goto out;xfs_idata_realloc (dp, size,XFS_ATTR_FORK );/* try to put */ memcpy (ifp->if_u1.if_data, tmpbuffer, size);/* it back */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 4/212 net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 297a6961ffb8ff4dc66c9fbf53b924bd1dda05d5 ]
platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code.
This is detected by Coccinelle semantic patch.
@@
expression pdev, res, n, t, e, e1, e2;
@@
res = platform_get_resource(pdev, t, n);
+ if (!res)
+ return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);
--- drivers/net/phy/mdio-bcm-unimac.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/phy/mdio-bcm-unimac.c +2 -0
@@ -177,6 +177,8 @@ static int unimac_mdio_probe(struct platform_device *pdev)return -ENOMEM ; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -EINVAL ;/* Just ioremap, as this MDIO block is usually integrated into an * Ethernet MAC controller register range
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 5/212 crypto: ccp - Release all allocated memory if sha type is invalid
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 128c66429247add5128c03dc1e144ca56f05a4e2 ]
Release all allocated memory if sha type is invalid:
In ccp_run_sha_cmd, if the type of sha is invalid, the allocated hmac_buf should be released.
v2: fix the goto.
--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
@@ -1216,8 +1216,9 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) digest_size);break ;default : +kfree (hmac_buf); ret = -EINVAL ; - goto e_ctx; + goto e_data; }memset (&hmac_cmd,0 ,sizeof (hmac_cmd));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 6/212 media: rc: prevent memory leak in cx23888_ir_probe
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit a7b2df76b42bdd026e3106cf2ba97db41345a177 ]
In cx23888_ir_probe if kfifo_alloc fails the allocated memory for state should be released.
--- drivers/media/pci/cx23885/cx23888-ir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23888-ir.c +4 -1
@@ -1179,8 +1179,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev)return -ENOMEM ;spin_lock_init (&state->rx_kfifo_lock); -if (kfifo_alloc (&state->rx_kfifo,CX23888_IR_RX_KFIFO_SIZE ,GFP_KERNEL )) +if (kfifo_alloc (&state->rx_kfifo,CX23888_IR_RX_KFIFO_SIZE , +GFP_KERNEL )) { +kfree (state);return -ENOMEM ; + } state->dev = dev; sd = &state->sd;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 7/212 ath9k_htc: release allocated buffer if timed out
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 853acf7caf10b828102d92d05b5c101666a6142b ]
In htc_config_pipe_credits, htc_setup_complete, and htc_connect_service if time out happens, the allocated buffer needs to be released. Otherwise there will be memory leak.
--- drivers/net/wireless/ath/ath9k/htc_hst.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/htc_hst.c +3 -0
@@ -175,6 +175,7 @@ static int htc_config_pipe_credits(struct htc_target *target) time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC credit config timeout\n" ); +kfree_skb (skb);return -ETIMEDOUT ; }
@@ -211,6 +212,7 @@ static int htc_setup_complete(struct htc_target *target) time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC start timeout\n" ); +kfree_skb (skb);return -ETIMEDOUT ; }
@@ -284,6 +286,7 @@ int htc_connect_service(struct htc_target *target,if (!time_left) {dev_err (target->dev,"Service connection timeout for: %d\n" , service_connreq->service_id); +kfree_skb (skb);return -ETIMEDOUT ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 8/212 ath9k: release allocated buffer if timed out
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 728c1e2a05e4b5fc52fab3421dce772a806612a2 ]
In ath9k_wmi_cmd, the allocated network buffer needs to be released if timeout happens. Otherwise memory will be leaked.
--- drivers/net/wireless/ath/ath9k/wmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath9k/wmi.c +1 -0
@@ -340,6 +340,7 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,ath_dbg (common,WMI ,"Timeout waiting for WMI command: %s\n" ,wmi_cmd_to_name (cmd_id));mutex_unlock (&wmi->op_mutex); +kfree_skb (skb);return -ETIMEDOUT ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 9/212 PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
commit b361663c5a40c8bc758b7f7f2239f7a192180e7c upstream.
Recently ASPM handling was changed to allow ASPM on PCIe-to-PCI/PCI-X bridges. Unfortunately the ASMedia ASM1083/1085 PCIe to PCI bridge device doesn't seem to function properly with ASPM enabled. On an Asus PRIME H270-PRO motherboard, it causes errors like these:
pcieport 0000:00:1c.0: AER: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Transmitter ID)
pcieport 0000:00:1c.0: AER: device [8086:a292] error status/mask=00003000/00002000
pcieport 0000:00:1c.0: AER: [12] Timeout
pcieport 0000:00:1c.0: AER: Corrected error received: 0000:00:1c.0
pcieport 0000:00:1c.0: AER: can't find device of ID00e0
In addition to flooding the kernel log, this also causes the machine to wake up immediately after suspend is initiated.
The device advertises ASPM L0s and L1 support in the Link Capabilities register, but the ASMedia web page for ASM1083 [1] claims "No PCIe ASPM support".
Windows 10 (build 2004) enables L0s, but it also logs correctable PCIe errors.
Add a quirk to disable ASPM for this device.
[1] https://www.asmedia.com.tw/eng/e_show_products.php?cate_index=169&item=114
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208667
--- drivers/pci/quirks.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
@@ -2046,6 +2046,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INDECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x10f4 , quirk_disable_aspm_l0s);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x1508 , quirk_disable_aspm_l0s); +static void quirk_disable_aspm_l0s_l1 (struct pci_dev *dev) +{ +pci_info (dev,"Disabling ASPM L0s/L1\n" ); +pci_disable_link_state (dev,PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 ); +} + +/* +* ASM1083/1085 PCIe-PCI bridge devices cause AER timeout errors on the +* upstream PCIe root port when ASPM is enabled. At least L0s mode is affected; +* disable both L0s and L1 for now to be safe. +*/ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ASMEDIA ,0x1080 , quirk_disable_aspm_l0s_l1); +/* * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain * Link bit cleared after starting the link retrain process to allow this
Greg Kroah-Hartman
maintainerPATCH 10/212 ARM: 8986/1: hw_breakpoint: Dont invoke overflow handler on uaccess watchpoints
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit eec13b42d41b0f3339dcf0c4da43734427c68620 upstream.
Unprivileged memory accesses generated by the so-called "translated" instructions (e.g. LDRT) in kernel mode can cause user watchpoints to fire unexpectedly. In such cases, the hw_breakpoint logic will invoke the user overflow handler which will typically raise a SIGTRAP back to the current task. This is futile when returning back to the kernel because (a) the signal won't have been delivered and (b) userspace can't handle the thing anyway.
Avoid invoking the user overflow handler for watchpoints triggered by kernel uaccess routines, and instead single-step over the faulting instruction as we would if no overflow handler had been installed.
--- arch/arm/kernel/hw_breakpoint.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
arch/arm/kernel/hw_breakpoint.c +22 -5
@@ -688,6 +688,12 @@ static void disable_single_step(struct parch_install_hw_breakpoint (bp); } +static int watchpoint_fault_on_uaccess (struct pt_regs *regs, +struct arch_hw_breakpoint *info) +{ +return !user_mode (regs) && info->ctrl.privilege ==ARM_BREAKPOINT_USER ; +} +static void watchpoint_handler (unsigned long addr,unsigned int fsr,struct pt_regs *regs) {
@@ -747,16 +753,27 @@ static void watchpoint_handler(unsigned }pr_debug ("watchpoint fired: address = 0x%x\n" , info->trigger); + +/* +* If we triggered a user watchpoint from a uaccess routine, +* then handle the stepping ourselves since userspace really +* can't help us with this. +*/ +if (watchpoint_fault_on_uaccess (regs, info)) + goto step; +perf_bp_event (wp, regs);/* -* If no overflow handler is present, insert a temporary -* mismatch breakpoint so we can single-step over the -* watchpoint trigger. +* Defer stepping to the overflow handler if one is installed. +* Otherwise, insert a temporary mismatch breakpoint so that +* we can single-step over the watchpoint trigger. */ -if (is_default_overflow_handler (wp)) -enable_single_step (wp,instruction_pointer (regs)); +if (!is_default_overflow_handler (wp)) + goto unlock; +step: +enable_single_step (wp,instruction_pointer (regs)); unlock:rcu_read_unlock (); }
Greg Kroah-Hartman
maintainerPATCH 11/212 drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 543e8669ed9bfb30545fd52bc0e047ca4df7fb31 upstream.
Compiler leaves a 4-byte hole near the end of dev_info, causing amdgpu_info_ioctl() to copy uninitialized kernel stack memory to userspace when size is greater than 356.
In 2015 we tried to fix this issue by doing = {}; on dev_info, which unfortunately does not initialize that 4-byte hole. Fix it by using memset() instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
@@ -452,8 +452,9 @@ static int amdgpu_info_ioctl(struct drm_return n ? -EFAULT :0 ; }case AMDGPU_INFO_DEV_INFO : { -struct drm_amdgpu_info_device dev_info = {}; +struct drm_amdgpu_info_device dev_info; +memset (&dev_info,0 ,sizeof (dev_info)); dev_info.device_id = dev->pdev->device; dev_info.chip_rev = adev->rev_id; dev_info.external_rev = adev->external_rev_id;
Greg Kroah-Hartman
maintainerPATCH 12/212 drm: hold gem reference until object is no longer accessed
In reply to Greg Kroah-HartmanFrom: Steve Cohen <[email protected]>
commit 8490d6a7e0a0a6fab5c2d82d57a3937306660864 upstream.
A use-after-free in drm_gem_open_ioctl can happen if the GEM object handle is closed between the idr lookup and retrieving the size from said object since a local reference is not being held at that point. Hold the local reference while the object can still be accessed to fix this and plug the potential security hole.
--- drivers/gpu/drm/drm_gem.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_gem.c +4 -6
@@ -694,9 +694,6 @@ err:* @file_priv: drm file-private structure * * Open an object using the global name, returning a handle and the size. -* -* This handle (of course) holds a reference to the object, so the object -* will not go away until the handle is deleted. */ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
@@ -721,14 +718,15 @@ drm_gem_open_ioctl(struct drm_device *de/* drm_gem_handle_create_tail unlocks dev->object_name_lock. */ ret =drm_gem_handle_create_tail (file_priv, obj, &handle); -drm_gem_object_unreference_unlocked (obj);if (ret) -return ret; + goto err; args->handle = handle; args->size = obj->size; -return 0 ; +err: +drm_gem_object_unreference_unlocked (obj); +return ret; }/**
Greg Kroah-Hartman
maintainerPATCH 13/212 f2fs: check memory boundary by insane namelen
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 4e240d1bab1ead280ddf5eb05058dba6bbd57d10 ]
If namelen is corrupted to have very long value, fill_dentries can copy wrong memory area.
--- fs/f2fs/dir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +10 -1
@@ -843,6 +843,16 @@ bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, de_name.name = d->filename[bit_pos]; de_name.len =le16_to_cpu (de->name_len); +/* check memory boundary before moving forward */ + bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); +if (unlikely (bit_pos > d->max)) { +f2fs_msg (F2FS_I_SB (d->inode)->sb,KERN_WARNING , +"%s: corrupted namelen=%d, run fsck to fix." , + __func__,le16_to_cpu (de->name_len)); +set_sbi_flag (F2FS_I_SB (d->inode)->sb->s_fs_info,SBI_NEED_FSCK ); +return -EINVAL ; + } +if (f2fs_encrypted_inode (d->inode)) {int save_len = fstr->len;int err;
@@ -861,7 +871,6 @@ bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, le32_to_cpu(de->ino), d_type))return true; - bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); ctx->pos = start_pos + bit_pos; }return false;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 14/212 f2fs: check if file namelen exceeds max value
In reply to Greg Kroah-HartmanFrom: Sheng Yong <[email protected]>
[ Upstream commit 720db068634c91553a8e1d9a0fcd8c7050e06d2b ]
Dentry bitmap is not enough to detect incorrect dentries. So this patch also checks the namelen value of a dentry.
--- fs/f2fs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +2 -1
@@ -845,7 +845,8 @@ bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,/* check memory boundary before moving forward */ bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); -if (unlikely (bit_pos > d->max)) { +if (unlikely (bit_pos > d->max || +le16_to_cpu (de->name_len) >F2FS_NAME_LEN )) {f2fs_msg (F2FS_I_SB (d->inode)->sb,KERN_WARNING ,"%s: corrupted namelen=%d, run fsck to fix." , __func__,le16_to_cpu (de->name_len));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 15/212 9p/trans_fd: abort p9_read_work if req status changed
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
[ Upstream commit e4ca13f7d075e551dc158df6af18fb412a1dba0a ]
p9_read_work would try to handle an errored req even if it got put to error state by another thread between the lookup (that worked) and the time it had been fully read.
The request itself is safe to use because we hold a ref to it from the lookup (for m->rreq, so it was safe to read into the request data buffer until this point), but the req_list has been deleted at the same time status changed, and client_cb already has been called as well, so we should not do either.
--- net/9p/trans_fd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/9p/trans_fd.c +11 -6
@@ -295,7 +295,6 @@ static void p9_read_work(struct work_struct *work) {int n, err;struct p9_conn *m; -int status =REQ_STATUS_ERROR ; m = container_of(work, struct p9_conn, rq);
@@ -375,11 +374,17 @@ static void p9_read_work(struct work_struct *work)if ((m->req) && (m->rc.offset == m->rc.capacity)) {p9_debug (P9_DEBUG_TRANS ,"got new packet\n" );spin_lock (&m->client->lock); -if (m->req->status !=REQ_STATUS_ERROR ) - status =REQ_STATUS_RCVD ; -list_del (&m->req->req_list); -/* update req->status while holding client->lock */ -p9_client_cb (m->client, m->req, status); +if (m->req->status ==REQ_STATUS_SENT ) { +list_del (&m->req->req_list); +p9_client_cb (m->client, m->req,REQ_STATUS_RCVD ); + }else { +spin_unlock (&m->client->lock); +p9_debug (P9_DEBUG_ERROR , +"Request tag %d errored out while we were reading the reply\n" , + m->rc.tag); + err = -EIO ; + goto error; + }spin_unlock (&m->client->lock); m->rc.sdata =NULL ; m->rc.offset =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 16/212 9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 74d6a5d5662975aed7f25952f62efbb6f6dadd29 ]
p9_read_work and p9_fd_cancelled may be called concurrently. In some cases, req->req_list may be deleted by both p9_read_work and p9_fd_cancelled.
We can fix it by ignoring replies associated with a cancelled request and ignoring cancelled request if message has been received before lock.
--- net/9p/trans_fd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/9p/trans_fd.c +14 -1
@@ -377,6 +377,10 @@ static void p9_read_work(struct work_struct *work)if (m->req->status ==REQ_STATUS_SENT ) {list_del (&m->req->req_list);p9_client_cb (m->client, m->req,REQ_STATUS_RCVD ); + }else if (m->req->status ==REQ_STATUS_FLSHD ) { +/* Ignore replies associated with a cancelled request. */ +p9_debug (P9_DEBUG_TRANS , +"Ignore replies associated with a cancelled request\n" ); }else {spin_unlock (&m->client->lock); p9_debug(P9_DEBUG_ERROR,
@@ -717,11 +721,20 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req) {p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); +spin_lock (&client->lock); +/* Ignore cancelled request if message has been received +* before lock. +*/ +if (req->status ==REQ_STATUS_RCVD ) { +spin_unlock (&client->lock); +return 0 ; + } +/* we haven't received a response for oldreq, * remove it from the list. */ -spin_lock (&client->lock);list_del (&req->req_list); + req->status =REQ_STATUS_FLSHD ;spin_unlock (&client->lock);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 17/212 x86/build/lto: Fix truncated .bss with -fdata-sections
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit 6a03469a1edc94da52b65478f1e00837add869a3 ]
With CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y, we compile the kernel with -fdata-sections, which also splits the .bss section.
The new section, with a new .bss.* name, which pattern gets missed by the main x86 linker script which only expects the '.bss' name. This results in the discarding of the second part and a too small, truncated .bss section and an unhappy, non-working kernel.
Use the common BSS_MAIN macro in the linker script to properly capture and merge all the generated BSS sections.
--- arch/x86/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/vmlinux.lds.S +1 -1
@@ -329,7 +329,7 @@ SECTIONS .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __bss_start = .; *(.bss..page_aligned) - *(.bss) + *(BSS_MAIN) . = ALIGN(PAGE_SIZE); __bss_stop = .; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 18/212 x86, vmlinux.lds: Page-align end of ..page_aligned sections
In reply to Greg Kroah-HartmanFrom: Joerg Roedel <[email protected]>
[ Upstream commit de2b41be8fcccb2f5b6c480d35df590476344201 ]
On x86-32 the idt_table with 256 entries needs only 2048 bytes. It is page-aligned, but the end of the .bss..page_aligned section is not guaranteed to be page-aligned.
As a result, objects from other .bss sections may end up on the same 4k page as the idt_table, and will accidentially get mapped read-only during boot, causing unexpected page-faults when the kernel writes to them.
This could be worked around by making the objects in the page aligned sections page sized, but that's wrong.
Explicit sections which store only page aligned objects have an implicit guarantee that the object is alone in the page in which it is placed. That works for all objects except the last one. That's inconsistent.
Enforcing page sized objects for these sections would wreckage memory sanitizers, because the object becomes artificially larger than it should be and out of bound access becomes legit.
Align the end of the .bss..page_aligned and .data..page_aligned section on page-size so all objects places in these sections are guaranteed to have their own page.
[ tglx: Amended changelog ]
--- arch/x86/kernel/vmlinux.lds.S | 1 + include/asm-generic/vmlinux.lds.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/vmlinux.lds.S +1 -0
@@ -329,6 +329,7 @@ SECTIONS .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __bss_start = .; *(.bss..page_aligned) + . = ALIGN(PAGE_SIZE); *(BSS_MAIN) . = ALIGN(PAGE_SIZE); __bss_stop = .;
include/asm-generic/vmlinux.lds.h +4 -1
@@ -250,7 +250,8 @@#define PAGE_ALIGNED_DATA (page_align) \ . = ALIGN(page_align); \ - *(.data..page_aligned) + *(.data..page_aligned) \ + . = ALIGN(page_align);#define READ_MOSTLY_DATA (align) \ . = ALIGN(align); \
@@ -625,7 +626,9 @@ . = ALIGN(bss_align); \ .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \BSS_FIRST_SECTIONS \ + . = ALIGN(PAGE_SIZE); \ *(.bss..page_aligned) \ + . = ALIGN(PAGE_SIZE); \ *(.dynbss) \ *(BSS_MAIN ) \ *(COMMON ) \
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 19/212 fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins.
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 033724d6864245a11f8e04c066002e6ad22b3fd0 ]
syzbot is reporting general protection fault in bitfill_aligned() [1] caused by integer underflow in bit_clear_margins(). The cause of this problem is when and how do_vc_resize() updates vc->vc_{cols,rows}.
If vc_do_resize() fails (e.g. kzalloc() fails) when var.xres or var.yres is going to shrink, vc->vc_{cols,rows} will not be updated. This allows bit_clear_margins() to see info->var.xres < (vc->vc_cols * cw) or info->var.yres < (vc->vc_rows * ch). Unexpectedly large rw or bh will try to overrun the __iomem region and causes general protection fault.
Also, vc_resize(vc, 0, 0) does not set vc->vc_{cols,rows} = 0 due to
new_cols = (cols ? cols : vc->vc_cols); new_rows = (lines ? lines : vc->vc_rows);
exception. Since cols and lines are calculated as
cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); cols /= vc->vc_font.width; rows /= vc->vc_font.height; vc_resize(vc, cols, rows);
in fbcon_modechanged(), var.xres < vc->vc_font.width makes cols = 0 and var.yres < vc->vc_font.height makes rows = 0. This means that
const int fd = open("/dev/fb0", O_ACCMODE);
struct fb_var_screeninfo var = { };
ioctl(fd, FBIOGET_VSCREENINFO, &var);
var.xres = var.yres = 1;
ioctl(fd, FBIOPUT_VSCREENINFO, &var);easily reproduces integer underflow bug explained above.
Of course, callers of vc_resize() are not handling vc_do_resize() failure is bad. But we can't avoid vc_resize(vc, 0, 0) which returns 0. Therefore, as a band-aid workaround, this patch checks integer underflow in "struct fbcon_ops"->clear_margins call, assuming that vc->vc_cols * vc->vc_font.width and vc->vc_rows * vc->vc_font.heigh do not cause integer overflow.
[1] https://syzkaller.appspot.com/bug?id=a565882df74fa76f10d3a6fec4be31098dbb37c6
--- drivers/video/console/bitblit.c | 4 ++-- drivers/video/console/fbcon_ccw.c | 4 ++-- drivers/video/console/fbcon_cw.c | 4 ++-- drivers/video/console/fbcon_ud.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/video/console/bitblit.c +2 -2
@@ -216,7 +216,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, region.color =0 ; region.rop =ROP_COPY ; -if (rw && !bottom_only) { +if ((int ) rw >0 && !bottom_only) { region.dx = info->var.xoffset + rs; region.dy =0 ; region.width = rw;
@@ -224,7 +224,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, info->fbops->fb_fillrect (info, ®ion); } -if (bh) { +if ((int ) bh >0 ) { region.dx = info->var.xoffset; region.dy = info->var.yoffset + bs; region.width = rs;
drivers/video/console/fbcon_ccw.c +2 -2
@@ -201,7 +201,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, region.color =0 ; region.rop =ROP_COPY ; -if (rw && !bottom_only) { +if ((int ) rw >0 && !bottom_only) { region.dx =0 ; region.dy = info->var.yoffset; region.height = rw;
@@ -209,7 +209,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, info->fbops->fb_fillrect (info, ®ion); } -if (bh) { +if ((int ) bh >0 ) { region.dx = info->var.xoffset + bs; region.dy =0 ; region.height = info->var.yres_virtual;
drivers/video/console/fbcon_cw.c +2 -2
@@ -184,7 +184,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, region.color =0 ; region.rop =ROP_COPY ; -if (rw && !bottom_only) { +if ((int ) rw >0 && !bottom_only) { region.dx =0 ; region.dy = info->var.yoffset + rs; region.height = rw;
@@ -192,7 +192,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, info->fbops->fb_fillrect (info, ®ion); } -if (bh) { +if ((int ) bh >0 ) { region.dx = info->var.xoffset; region.dy = info->var.yoffset; region.height = info->var.yres;
drivers/video/console/fbcon_ud.c +2 -2
@@ -231,7 +231,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, region.color =0 ; region.rop =ROP_COPY ; -if (rw && !bottom_only) { +if ((int ) rw >0 && !bottom_only) { region.dy =0 ; region.dx = info->var.xoffset; region.width = rw;
@@ -239,7 +239,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, info->fbops->fb_fillrect (info, ®ion); } -if (bh) { +if ((int ) bh >0 ) { region.dy = info->var.yoffset; region.dx = info->var.xoffset; region.height = bh;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 20/212 rds: Prevent kernel-infoleak in rds_notify_queue_get()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit bbc8a99e952226c585ac17477a85ef1194501762 upstream.
rds_notify_queue_get() is potentially copying uninitialized kernel stack memory to userspace since the compiler may leave a 4-byte hole at the end of cmsg.
In 2016 we tried to fix this issue by doing = { 0 }; on cmsg, which unfortunately does not always initialize that 4-byte hole. Fix it by using memset() instead.
--- net/rds/recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/recv.c +2 -1
@@ -405,12 +405,13 @@ static int rds_still_queued(struct rds_sint rds_notify_queue_get (struct rds_sock *rs,struct msghdr *msghdr) {struct rds_notifier *notifier; -struct rds_rdma_notify cmsg = {0 };/* fill holes with zero */ +struct rds_rdma_notify cmsg;unsigned int count =0 , max_messages = ~0U ;unsigned long flags;LIST_HEAD (copy);int err =0 ; +memset (&cmsg,0 ,sizeof (cmsg));/* fill holes with zero */ /* put_cmsg copies to user space and thus may sleep. We can't do this * with rs_lock held, so first grab as many notifications as we can stuff
Greg Kroah-Hartman
maintainerPATCH 21/212 xfs: fix missed wakeup on l_flush_wait
In reply to Greg Kroah-HartmanFrom: Rik van Riel <[email protected]>
commit cdea5459ce263fbc963657a7736762ae897a8ae6 upstream.
The code in xlog_wait uses the spinlock to make adding the task to the wait queue, and setting the task state to UNINTERRUPTIBLE atomic with respect to the waker.
Doing the wakeup after releasing the spinlock opens up the following race condition:
Task 1 task 2
add task to wait queue
wake up task
set task state to UNINTERRUPTIBLE
This issue was found through code inspection as a result of kworkers being observed stuck in UNINTERRUPTIBLE state with an empty wait queue. It is rare and largely unreproducable.
Simply moving the spin_unlock to after the wake_up_all results in the waker not being able to see a task on the waitqueue before it has set its state to UNINTERRUPTIBLE.
This bug dates back to the conversion of this code to generic waitqueue infrastructure from a counting semaphore back in 2008 which didn't place the wakeups consistently w.r.t. to the relevant spin locks.
[dchinner: Also fix a similar issue in the shutdown path on xc_commit_wait. Update commit log with more details of the issue.]
--- fs/xfs/xfs_log.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_log.c +4 -5
@@ -2634,7 +2634,6 @@ xlog_state_do_callback(int funcdidcallbacks;/* flag: function did callbacks */ int repeats;/* for issuing console warnings if * looping too many times */ -int wake =0 ;spin_lock (&log->l_icloglock); first_iclog = iclog = log->l_iclog;
@@ -2836,11 +2835,9 @@ xlog_state_do_callback(#endif if (log->l_iclog->ic_state & (XLOG_STATE_ACTIVE |XLOG_STATE_IOERROR )) - wake =1 ; -spin_unlock (&log->l_icloglock); - -if (wake)wake_up_all (&log->l_flush_wait); + +spin_unlock (&log->l_icloglock); }
@@ -4002,7 +3999,9 @@ xfs_log_force_umount(* item committed callback functions will do this again under lock to * avoid races. */ +spin_lock (&log->l_cilp->xc_push_lock);wake_up_all (&log->l_cilp->xc_commit_wait); +spin_unlock (&log->l_cilp->xc_push_lock);xlog_state_do_callback (log,XFS_LI_ABORTED ,NULL );#ifdef XFSERRORDEBUG
Greg Kroah-Hartman
maintainerPATCH 22/212 uapi: includes linux/types.h before exporting files
In reply to Greg Kroah-HartmanFrom: Nicolas Dichtel <[email protected]>
commit 9078b4eea119c13d633d45af0397c821a517b522 upstream.
Some files will be exported after a following patch. 0-day tests report the following warning/error:./usr/include/linux/bcache.h:8: include of <linux/types.h> is preferred over <asm/types.h> ./usr/include/linux/bcache.h:11: found __[us]{8,16,32,64} type without #include <linux/types.h> ./usr/include/linux/qrtr.h:8: found __[us]{8,16,32,64} type without #include <linux/types.h> ./usr/include/linux/cryptouser.h:39: found __[us]{8,16,32,64} type without #include <linux/types.h> ./usr/include/linux/pr.h:14: found __[us]{8,16,32,64} type without #include <linux/types.h> ./usr/include/linux/btrfs_tree.h:337: found __[us]{8,16,32,64} type without #include <linux/types.h> ./usr/include/rdma/bnxt_re-abi.h:45: found __[us]{8,16,32,64} type without #include <linux/types.h>
reb: left out include/uapi/rdma/bnxt_re-abi.h as it's not in this kernel version
--- include/uapi/linux/bcache.h | 2 +- include/uapi/linux/btrfs_tree.h | 2 ++ include/uapi/linux/cryptouser.h | 2 ++ include/uapi/linux/pr.h | 2 ++ include/uapi/linux/qrtr.h | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)
include/uapi/linux/bcache.h +1 -1
@@ -5,7 +5,7 @@* Bcache on disk data structures */ -#include <asm/types.h> +#include <linux/types.h> #define BITMASK (name, type, field, offset, size) \ static inline __u64 name(const type *k) \
include/uapi/linux/btrfs_tree.h +2 -0
@@ -1,6 +1,8 @@#ifndef _BTRFS_CTREE_H_#define _BTRFS_CTREE_H_ +#include <linux/types.h> +/* * This header contains the structure definitions and constants used * by file system objects that can be retrieved using
include/uapi/linux/cryptouser.h +2 -0
@@ -18,6 +18,8 @@* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <linux/types.h> +/* Netlink configuration messages. */ enum {CRYPTO_MSG_BASE =0x10 ,
include/uapi/linux/pr.h +2 -0
@@ -1,6 +1,8 @@#ifndef _UAPI_PR_H#define _UAPI_PR_H +#include <linux/types.h> +enum pr_type {PR_WRITE_EXCLUSIVE =1 , PR_EXCLUSIVE_ACCESS = 2,
include/uapi/linux/qrtr.h +1 -0
@@ -2,6 +2,7 @@#define _LINUX_QRTR_H#include <linux/socket.h> +#include <linux/types.h> struct sockaddr_qrtr {__kernel_sa_family_t sq_family;
Greg Kroah-Hartman
maintainerPATCH 23/212 install several missing uapi headers
In reply to Greg Kroah-HartmanFrom: Rolf Eike Beer <[email protected]>
Commit fcc8487d477a3452a1d0ccbdd4c5e0e1e3cb8bed ("uapi: export all headers under uapi directories") changed the default to install all headers not marked to be conditional. This takes the list of headers listed in the commit message and manually adds an export for those that are already present in this kernel version.
Found during an attempt to build mtd-utils 2.1.2 as it wants hash_info.h, which exists since 3.13 but has not been installed until the above mentioned commit, which ended up in 4.12.
--- arch/mips/include/uapi/asm/Kbuild | 3 +++ arch/powerpc/include/uapi/asm/Kbuild | 1 + include/uapi/drm/Kbuild | 3 +++ include/uapi/linux/Kbuild | 20 ++++++++++++++++++++ include/uapi/linux/cifs/Kbuild | 1 + include/uapi/linux/genwqe/Kbuild | 1 + 6 files changed, 29 insertions(+) create mode 100644 include/uapi/linux/cifs/Kbuild create mode 100644 include/uapi/linux/genwqe/Kbuild
arch/mips/include/uapi/asm/Kbuild +3 -0
@@ -39,3 +39,6 @@ header-y += termbits.h header-y += termios.h header-y += types.h header-y += unistd.h +header-y += hwcap.h +header-y += reg.h +header-y += ucontext.h
arch/powerpc/include/uapi/asm/Kbuild +1 -0
@@ -45,3 +45,4 @@ header-y += tm.h header-y += types.h header-y += ucontext.h header-y += unistd.h +header-y += perf_regs.h
include/uapi/drm/Kbuild +3 -0
@@ -20,3 +20,6 @@ header-y += vmwgfx_drm.h header-y += msm_drm.h header-y += vc4_drm.h header-y += virtgpu_drm.h +header-y += armada_drm.h +header-y += etnaviv_drm.h +header-y += vgem_drm.h
include/uapi/linux/Kbuild +20 -0
@@ -475,3 +475,23 @@ header-y += xilinx-v4l2-controls.h header-y += zorro.h header-y += zorro_ids.h header-y += userfaultfd.h +header-y += auto_dev-ioctl.h +header-y += bcache.h +header-y += btrfs_tree.h +header-y += coresight-stm.h +header-y += cryptouser.h +header-y += hash_info.h +header-y += kcm.h +header-y += kcov.h +header-y += kfd_ioctl.h +header-y += lightnvm.h +header-y += module.h +header-y += nilfs2_api.h +header-y += nilfs2_ondisk.h +header-y += nsfs.h +header-y += pr.h +header-y += qrtr.h +header-y += stm.h +header-y += wil6210_uapi.h +header-y += cifs/ +header-y += genwqe/
include/uapi/linux/cifs/Kbuild new file +1 -0
@@ -0,0 +1 @@ +header-y += cifs_mount.h
include/uapi/linux/genwqe/Kbuild new file +1 -0
@@ -0,0 +1 @@ +header-y += genwqe_card.h
Greg Kroah-Hartman
maintainerPATCH 24/212 net/x25: Fix x25_neigh refcnt leak when x25 disconnect
In reply to Greg Kroah-HartmanFrom: Xiyu Yang <[email protected]>
commit 4becb7ee5b3d2829ed7b9261a245a77d5b7de902 upstream.
x25_connect() invokes x25_get_neigh(), which returns a reference of the specified x25_neigh object to "x25->neighbour" with increased refcnt.
When x25 connect success and returns, the reference still be hold by "x25->neighbour", so the refcount should be decreased in x25_disconnect() to keep refcount balanced.
The reference counting issue happens in x25_disconnect(), which forgets to decrease the refcnt increased by x25_get_neigh() in x25_connect(), causing a refcnt leak.
Fix this issue by calling x25_neigh_put() before x25_disconnect() returns.
--- net/x25/x25_subr.c | 4 ++++ 1 file changed, 4 insertions(+)
net/x25/x25_subr.c +4 -0
@@ -368,6 +368,10 @@ void x25_disconnect(struct sock *sk, int sk->sk_state_change (sk);sock_set_flag (sk,SOCK_DEAD ); } +read_lock_bh (&x25_list_lock); +x25_neigh_put (x25->neighbour); + x25->neighbour =NULL ; +read_unlock_bh (&x25_list_lock); }/*
Greg Kroah-Hartman
maintainerPATCH 25/212 net/x25: Fix null-ptr-deref in x25_disconnect
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit 8999dc89497ab1c80d0718828e838c7cd5f6bffe upstream.
We should check null before do x25_neigh_put in x25_disconnect, otherwise may cause null-ptr-deref like this:
#include <sys/socket.h>
#include <linux/x25.h>
int main() {
int sck_x25;
sck_x25 = socket(AF_X25, SOCK_SEQPACKET, 0);
close(sck_x25);
return 0;}
BUG: kernel NULL pointer dereference, address: 00000000000000d8 CPU: 0 PID: 4817 Comm: t2 Not tainted 5.7.0-rc3+ #159 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3- RIP: 0010:x25_disconnect+0x91/0xe0 Call Trace: x25_release+0x18a/0x1b0 __sock_release+0x3d/0xc0 sock_close+0x13/0x20 __fput+0x107/0x270 ____fput+0x9/0x10 task_work_run+0x6d/0xb0 exit_to_usermode_loop+0x102/0x110 do_syscall_64+0x23c/0x260 entry_SYSCALL_64_after_hwframe+0x49/0xb3
--- net/x25/x25_subr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/x25/x25_subr.c +6 -4
@@ -368,10 +368,12 @@ void x25_disconnect(struct sock *sk, int sk->sk_state_change (sk);sock_set_flag (sk,SOCK_DEAD ); } -read_lock_bh (&x25_list_lock); -x25_neigh_put (x25->neighbour); - x25->neighbour =NULL ; -read_unlock_bh (&x25_list_lock); +if (x25->neighbour) { +read_lock_bh (&x25_list_lock); +x25_neigh_put (x25->neighbour); + x25->neighbour =NULL ; +read_unlock_bh (&x25_list_lock); + } }/*
Greg Kroah-Hartman
maintainerPATCH 26/212 sh: Fix validation of system call number
In reply to Greg Kroah-HartmanFrom: Michael Karcher <[email protected]>
[ Upstream commit 04a8a3d0a73f51c7c2da84f494db7ec1df230e69 ]
The slow path for traced system call entries accessed a wrong memory location to get the number of the maximum allowed system call number. Renumber the numbered "local" label for the correct location to avoid collisions with actual local labels.
--- arch/sh/kernel/entry-common.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/sh/kernel/entry-common.S +3 -3
@@ -203,7 +203,7 @@ syscall_trace_entry: mov.l @(OFF_R7,r15), r7 ! arg3 mov.l @(OFF_R3,r15), r3 ! syscall_nr ! - mov.l 2f, r10 ! Number of syscalls + mov.l 6f, r10 ! Number of syscalls cmp/hs r10, r3 bf syscall_call mov #-ENOSYS, r0
@@ -357,7 +357,7 @@ ENTRY(system_call) tst r9, r8 bf syscall_trace_entry ! - mov.l 2f, r8 ! Number of syscalls + mov.l 6f, r8 ! Number of syscalls cmp/hs r8, r3 bt syscall_badsys !
@@ -396,7 +396,7 @@ syscall_exit: #if !defined(CONFIG_CPU_SH2) 1: .long TRA #endif -2: .long NR_syscalls +6: .long NR_syscalls 3: .long sys_call_table 7: .long do_syscall_trace_enter 8: .long do_syscall_trace_leave
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 27/212 net: lan78xx: add missing endpoint sanity check
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 8d8e95fd6d69d774013f51e5f2ee10c6e6d1fc14 ]
Add the missing endpoint sanity check to prevent a NULL-pointer dereference should a malicious device lack the expected endpoints.
Note that the driver has a broken endpoint-lookup helper, lan78xx_get_endpoints(), which can end up accepting interfaces in an altsetting without endpoints as long as *some* altsetting has a bulk-in and a bulk-out endpoint.
--- drivers/net/usb/lan78xx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/usb/lan78xx.c +5 -0
@@ -3392,6 +3392,11 @@ static int lan78xx_probe(struct usb_interface *intf, netdev->mtu = dev->hard_mtu - netdev->hard_header_len;netif_set_gso_max_size (netdev,MAX_SINGLE_PACKET_SIZE -MAX_HEADER ); +if (intf->cur_altsetting->desc.bNumEndpoints <3 ) { + ret = -ENODEV ; + goto out3; + } + dev->ep_blkin = (intf->cur_altsetting)->endpoint +0 ; dev->ep_blkout = (intf->cur_altsetting)->endpoint +1 ; dev->ep_intr = (intf->cur_altsetting)->endpoint +2 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 28/212 net: lan78xx: fix transfer-buffer memory leak
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 63634aa679ba8b5e306ad0727120309ae6ba8a8e ]
The interrupt URB transfer-buffer was never freed on disconnect or after probe errors.
--- drivers/net/usb/lan78xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/lan78xx.c +1 -0
@@ -3421,6 +3421,7 @@ static int lan78xx_probe(struct usb_interface *intf,usb_fill_int_urb (dev->urb_intr, dev->udev, dev->pipe_intr, buf, maxp, intr_complete, dev, period); + dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 29/212 mlx4: disable device on shutdown
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 3cab8c65525920f00d8f4997b3e9bb73aecb3a8e ]
It appears that not disabling a PCI device on .shutdown may lead to a Hardware Error with particular (perhaps buggy) BIOS versions:
mlx4_en: eth0: Close port called
mlx4_en 0000:04:00.0: removed PHC
reboot: Restarting system
{1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{1}[Hardware Error]: event severity: fatal
{1}[Hardware Error]: Error 0, type: fatal
{1}[Hardware Error]: section_type: PCIe error
{1}[Hardware Error]: port_type: 4, root port
{1}[Hardware Error]: version: 1.16
{1}[Hardware Error]: command: 0x4010, status: 0x0143
{1}[Hardware Error]: device_id: 0000:00:02.2
{1}[Hardware Error]: slot: 0
{1}[Hardware Error]: secondary_bus: 0x04
{1}[Hardware Error]: vendor_id: 0x8086, device_id: 0x2f06
{1}[Hardware Error]: class_code: 000604
{1}[Hardware Error]: bridge: secondary_status: 0x2000, control: 0x0003
{1}[Hardware Error]: aer_uncor_status: 0x00100000, aer_uncor_mask: 0x00000000
{1}[Hardware Error]: aer_uncor_severity: 0x00062030
{1}[Hardware Error]: TLP Header: 40000018 040000ff 791f4080 00000000
[hw error repeats]
Kernel panic - not syncing: Fatal hardware error!
CPU: 0 PID: 2189 Comm: reboot Kdump: loaded Not tainted 5.6.x-blabla #1
Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 05/05/2017Fix the mlx4 driver.
This is a very similar problem to what had been fixed in:
commit 0d98ba8d70b0 ("scsi: hpsa: disable device during shutdown") to address https://bugzilla.kernel.org/show_bug.cgi?id=199779.
--- drivers/net/ethernet/mellanox/mlx4/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx4/main.c +2 -0
@@ -4176,12 +4176,14 @@ end:static void mlx4_shutdown (struct pci_dev *pdev) {struct mlx4_dev_persistent *persist =pci_get_drvdata (pdev); +struct mlx4_dev *dev = persist->dev;mlx4_info (persist->dev,"mlx4_shutdown was called\n" );mutex_lock (&persist->interface_state_mutex);if (persist->interface_state &MLX4_INTERFACE_STATE_UP )mlx4_unload_one (pdev);mutex_unlock (&persist->interface_state_mutex); +mlx4_pci_disable_device (dev); }static const struct pci_error_handlers mlx4_err_handler = {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 30/212 mlxsw: core: Increase scope of RCU read-side critical section
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 7d8e8f3433dc8d1dc87c1aabe73a154978fb4c4d ]
The lifetime of the Rx listener item ('rxl_item') is managed using RCU, but is dereferenced outside of RCU read-side critical section, which can lead to a use-after-free.
Fix this by increasing the scope of the RCU read-side critical section.
--- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +4 -2
@@ -1584,9 +1584,10 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,break ; } } -rcu_read_unlock (); -if (!found) +if (!found) { +rcu_read_unlock (); goto drop; + } pcpu_stats =this_cpu_ptr (mlxsw_core->pcpu_stats);u64_stats_update_begin (&pcpu_stats->syncp);
@@ -1597,6 +1598,7 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,u64_stats_update_end (&pcpu_stats->syncp); rxl->func (skb, local_port, rxl_item->priv); +rcu_read_unlock ();return ; drop:
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 31/212 mlxsw: core: Free EMAD transactions using kfree_rcu()
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 3c8ce24b037648a5a15b85888b259a74b05ff97d ]
The lifetime of EMAD transactions (i.e., 'struct mlxsw_reg_trans') is managed using RCU. They are freed using kfree_rcu() once the transaction ends.
However, in case the transaction failed it is freed immediately after being removed from the active transactions list. This is problematic because it is still possible for a different CPU to dereference the transaction from an RCU read-side critical section while traversing the active transaction list in mlxsw_emad_rx_listener_func(). In which case, a use-after-free is triggered [1].
Fix this by freeing the transaction after a grace period by calling kfree_rcu().
[1]
BUG: KASAN: use-after-free in mlxsw_emad_rx_listener_func+0x969/0xac0 drivers/net/ethernet/mellanox/mlxsw/core.c:671
Read of size 8 at addr ffff88800b7964e8 by task syz-executor.2/2881
CPU: 0 PID: 2881 Comm: syz-executor.2 Not tainted 5.8.0-rc4+ #44
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xf6/0x16e lib/dump_stack.c:118
print_address_description.constprop.0+0x1c/0x250 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
mlxsw_emad_rx_listener_func+0x969/0xac0 drivers/net/ethernet/mellanox/mlxsw/core.c:671
mlxsw_core_skb_receive+0x571/0x700 drivers/net/ethernet/mellanox/mlxsw/core.c:2061
mlxsw_pci_cqe_rdq_handle drivers/net/ethernet/mellanox/mlxsw/pci.c:595 [inline]
mlxsw_pci_cq_tasklet+0x12a6/0x2520 drivers/net/ethernet/mellanox/mlxsw/pci.c:651
tasklet_action_common.isra.0+0x13f/0x3e0 kernel/softirq.c:550
__do_softirq+0x223/0x964 kernel/softirq.c:292
asm_call_on_stack+0x12/0x20 arch/x86/entry/entry_64.S:711
</IRQ>
__run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline]
run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline]
do_softirq_own_stack+0x109/0x140 arch/x86/kernel/irq_64.c:77
invoke_softirq kernel/softirq.c:387 [inline]
__irq_exit_rcu kernel/softirq.c:417 [inline]
irq_exit_rcu+0x16f/0x1a0 kernel/softirq.c:429
sysvec_apic_timer_interrupt+0x4e/0xd0 arch/x86/kernel/apic/apic.c:1091
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:587
RIP: 0010:arch_local_irq_restore arch/x86/include/asm/irqflags.h:85 [inline]
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x3b/0x40 kernel/locking/spinlock.c:191
Code: e8 2a c3 f4 fc 48 89 ef e8 12 96 f5 fc f6 c7 02 75 11 53 9d e8 d6 db 11 fd 65 ff 0d 1f 21 b3 56 5b 5d c3 e8 a7 d7 11 fd 53 9d <eb> ed 0f 1f 00 55 48 89 fd 65 ff 05 05 21 b3 56 ff 74 24 08 48 8d
RSP: 0018:ffff8880446ffd80 EFLAGS: 00000286
RAX: 0000000000000006 RBX: 0000000000000286 RCX: 0000000000000006
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffa94ecea9
RBP: ffff888012934408 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: fffffbfff57be301 R12: 1ffff110088dffc1
R13: ffff888037b817c0 R14: ffff88802442415a R15: ffff888024424000
__do_sys_perf_event_open+0x1b5d/0x2bd0 kernel/events/core.c:11874
do_syscall_64+0x56/0xa0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x473dbd
Code: Bad RIP value.
RSP: 002b:00007f21e5e9cc28 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 000000000057bf00 RCX: 0000000000473dbd
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000040
RBP: 000000000057bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 000000000057bf0c
R13: 00007ffd0493503f R14: 00000000004d0f46 R15: 00007f21e5e9cd80
Allocated by task 871:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc mm/kasan/common.c:494 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:467
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
mlxsw_core_reg_access_emad+0x70/0x1410 drivers/net/ethernet/mellanox/mlxsw/core.c:1812
mlxsw_core_reg_access+0xeb/0x540 drivers/net/ethernet/mellanox/mlxsw/core.c:1991
mlxsw_sp_port_get_hw_xstats+0x335/0x7e0 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1130
update_stats_cache+0xf4/0x140 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1173
process_one_work+0xa3e/0x17a0 kernel/workqueue.c:2269
worker_thread+0x9e/0x1050 kernel/workqueue.c:2415
kthread+0x355/0x470 kernel/kthread.c:291
ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293
Freed by task 871:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0x12c/0x170 mm/kasan/common.c:455
slab_free_hook mm/slub.c:1474 [inline]
slab_free_freelist_hook mm/slub.c:1507 [inline]
slab_free mm/slub.c:3072 [inline]
kfree+0xe6/0x320 mm/slub.c:4052
mlxsw_core_reg_access_emad+0xd45/0x1410 drivers/net/ethernet/mellanox/mlxsw/core.c:1819
mlxsw_core_reg_access+0xeb/0x540 drivers/net/ethernet/mellanox/mlxsw/core.c:1991
mlxsw_sp_port_get_hw_xstats+0x335/0x7e0 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1130
update_stats_cache+0xf4/0x140 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1173
process_one_work+0xa3e/0x17a0 kernel/workqueue.c:2269
worker_thread+0x9e/0x1050 kernel/workqueue.c:2415
kthread+0x355/0x470 kernel/kthread.c:291
ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293
The buggy address belongs to the object at ffff88800b796400
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 232 bytes inside of
512-byte region [ffff88800b796400, ffff88800b796600)
The buggy address belongs to the page:
page:ffffea00002de500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea00002de500 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x100000000010200(slab|head)
raw: 0100000000010200 dead000000000100 dead000000000122 ffff88806c402500
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88800b796380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800b796400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88800b796480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88800b796500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800b796580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -1
@@ -1370,7 +1370,7 @@ static int mlxsw_core_reg_access_emad(struct mlxsw_core *mlxsw_core, err =mlxsw_emad_reg_access (mlxsw_core, reg, payload, type, trans, bulk_list, cb, cb_priv, tid);if (err) { -kfree (trans); +kfree_rcu (trans, rcu);return err; }return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 32/212 ibmvnic: Fix IRQ mapping disposal in error path
In reply to Greg Kroah-HartmanFrom: Thomas Falcon <[email protected]>
[ Upstream commit 27a2145d6f826d1fad9de06ac541b1016ced3427 ]
RX queue IRQ mappings are disposed in both the TX IRQ and RX IRQ error paths. Fix this and dispose of TX IRQ mappings correctly in case of an error.
--- drivers/net/ethernet/ibm/ibmvnic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +1 -1
@@ -1515,7 +1515,7 @@ req_rx_irq_failed: req_tx_irq_failed:for (j =0 ; j < i; j++) {free_irq (adapter->tx_scrq[j]->irq, adapter->tx_scrq[j]); -irq_dispose_mapping (adapter->rx_scrq[j]->irq); +irq_dispose_mapping (adapter->tx_scrq[j]->irq); }release_sub_crqs_no_irqs (adapter);return rc;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 33/212 mac80211: mesh: Free ie data when leaving mesh
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
[ Upstream commit 6a01afcf8468d3ca2bd8bbb27503f60dcf643b20 ]
At ieee80211_join_mesh() some ie data could have been allocated (see copy_mesh_setup()) and need to be cleaned up when leaving the mesh.
This fixes the following kmemleak report:
unreferenced object 0xffff0000116bc600 (size 128):
comm "wpa_supplicant", pid 608, jiffies 4294898983 (age 293.484s) hex dump (first 32 bytes):
30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 0...............
00 0f ac 08 00 00 00 00 c4 65 40 00 00 00 00 00 .........e@.....
backtrace:
[<00000000bebe439d>] __kmalloc_track_caller+0x1c0/0x330
[<00000000a349dbe1>] kmemdup+0x28/0x50
[<0000000075d69baa>] ieee80211_join_mesh+0x6c/0x3b8 [mac80211]
[<00000000683bb98b>] __cfg80211_join_mesh+0x1e8/0x4f0 [cfg80211]
[<0000000072cb507f>] nl80211_join_mesh+0x520/0x6b8 [cfg80211]
[<0000000077e9bcf9>] genl_family_rcv_msg+0x374/0x680
[<00000000b1bd936d>] genl_rcv_msg+0x78/0x108
[<0000000022c53788>] netlink_rcv_skb+0xb0/0x1c0
[<0000000011af8ec9>] genl_rcv+0x34/0x48
[<0000000069e41f53>] netlink_unicast+0x268/0x2e8
[<00000000a7517316>] netlink_sendmsg+0x320/0x4c0
[<0000000069cba205>] ____sys_sendmsg+0x354/0x3a0
[<00000000e06bab0f>] ___sys_sendmsg+0xd8/0x120
[<0000000037340728>] __sys_sendmsg+0xa4/0xf8
[<000000004fed9776>] __arm64_sys_sendmsg+0x44/0x58
[<000000001c1e5647>] el0_svc_handler+0xd0/0x1a0--- net/mac80211/cfg.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/cfg.c +1 -0
@@ -1964,6 +1964,7 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)ieee80211_stop_mesh (sdata);mutex_lock (&sdata->local->mtx);ieee80211_vif_release_channel (sdata); +kfree (sdata->u.mesh.ie);mutex_unlock (&sdata->local->mtx);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 34/212 mac80211: mesh: Free pending skb when destroying a mpath
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
[ Upstream commit 5e43540c2af0a0c0a18e39579b1ad49541f87506 ]
A mpath object can hold reference on a list of skb that are waiting for mpath resolution to be sent. When destroying a mpath this skb list should be cleaned up in order to not leak memory.
Fixing that kind of leak:
unreferenced object 0xffff0000181c9300 (size 1088):
comm "openvpn", pid 1782, jiffies 4295071698 (age 80.416s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 f9 80 36 00 00 00 00 00 ..........6.....
02 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
backtrace:
[<000000004bc6a443>] kmem_cache_alloc+0x1a4/0x2f0
[<000000002caaef13>] sk_prot_alloc.isra.39+0x34/0x178
[<00000000ceeaa916>] sk_alloc+0x34/0x228
[<00000000ca1f1d04>] inet_create+0x198/0x518
[<0000000035626b1c>] __sock_create+0x134/0x328
[<00000000a12b3a87>] __sys_socket+0xb0/0x158
[<00000000ff859f23>] __arm64_sys_socket+0x40/0x58
[<00000000263486ec>] el0_svc_handler+0xd0/0x1a0
[<0000000005b5157d>] el0_svc+0x8/0xc
unreferenced object 0xffff000012973a40 (size 216):
comm "openvpn", pid 1782, jiffies 4295082137 (age 38.660s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 c0 06 16 00 00 ff ff 00 93 1c 18 00 00 ff ff ................
backtrace:
[<000000004bc6a443>] kmem_cache_alloc+0x1a4/0x2f0
[<0000000023c8c8f9>] __alloc_skb+0xc0/0x2b8
[<000000007ad950bb>] alloc_skb_with_frags+0x60/0x320
[<00000000ef90023a>] sock_alloc_send_pskb+0x388/0x3c0
[<00000000104fb1a3>] sock_alloc_send_skb+0x1c/0x28
[<000000006919d2dd>] __ip_append_data+0xba4/0x11f0
[<0000000083477587>] ip_make_skb+0x14c/0x1a8
[<0000000024f3d592>] udp_sendmsg+0xaf0/0xcf0
[<000000005aabe255>] inet_sendmsg+0x5c/0x80
[<000000008651ea08>] __sys_sendto+0x15c/0x218
[<000000003505c99b>] __arm64_sys_sendto+0x74/0x90
[<00000000263486ec>] el0_svc_handler+0xd0/0x1a0
[<0000000005b5157d>] el0_svc+0x8/0xc--- net/mac80211/mesh_pathtbl.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/mesh_pathtbl.c +1 -0
@@ -555,6 +555,7 @@ static void mesh_path_free_rcu(struct mesh_table *tbl,del_timer_sync (&mpath->timer);atomic_dec (&sdata->u.mesh.mpaths);atomic_dec (&tbl->entries); +mesh_path_flush_pending (mpath);kfree_rcu (mpath, rcu); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 35/212 arm64: csum: Fix handling of bad packets
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 05fb3dbda187bbd9cc1cd0e97e5d6595af570ac6 ]
Although iph is expected to point to at least 20 bytes of valid memory, ihl may be bogus, for example on reception of a corrupt packet. If it happens to be less than 5, we really don't want to run away and dereference 16GB worth of memory until it wraps back to exactly zero...
--- arch/arm64/include/asm/checksum.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/checksum.h +3 -2
@@ -30,16 +30,17 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) {__uint128_t tmp;u64 sum; +int n = ihl;/* we want it signed */ tmp = *(const __uint128_t *)iph; iph +=16 ; - ihl -=4 ; + n -=4 ; tmp += ((tmp >>64 ) | (tmp <<64 )); sum = tmp >>64 ;do { sum += *(const u32 *)iph; iph +=4 ; - }while (--ihl); + }while (--n >0 ); sum += ((sum >>32 ) | (sum <<32 ));return csum_fold (sum >>32 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 36/212 usb: hso: Fix debug compile warning on sparc32
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit e0484010ec05191a8edf980413fc92f28050c1cc ]
On sparc32, tcflag_t is "unsigned long", unlike on all other architectures, where it is "unsigned int":
drivers/net/usb/hso.c: In function ‘hso_serial_set_termios’:
include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘unsigned int’, but argument 4 has type ‘tcflag_t {aka long unsigned int}’ [-Wformat=] drivers/net/usb/hso.c:1393:3: note: in expansion of macro ‘hso_dbg’
hso_dbg(0x16, "Termios called with: cflags new[%d] - old[%d]\n",
^~~~~~~
include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘unsigned int’, but argument 5 has type ‘tcflag_t {aka long unsigned int}’ [-Wformat=] drivers/net/usb/hso.c:1393:3: note: in expansion of macro ‘hso_dbg’
hso_dbg(0x16, "Termios called with: cflags new[%d] - old[%d]\n",
^~~~~~~
As "unsigned long" is 32-bit on sparc32, fix this by casting all tcflag_t parameters to "unsigned int".
While at it, use "%u" to format unsigned numbers.
--- drivers/net/usb/hso.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/usb/hso.c +3 -2
@@ -1404,8 +1404,9 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)unsigned long flags;if (old) -hso_dbg (0x16 ,"Termios called with: cflags new[%d] - old[%d]\n" , - tty->termios.c_cflag, old->c_cflag); +hso_dbg (0x16 ,"Termios called with: cflags new[%u] - old[%u]\n" , + (unsigned int )tty->termios.c_cflag, + (unsigned int )old->c_cflag);/* the actual setup */ spin_lock_irqsave (&serial->serial_lock, flags);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 37/212 qed: Disable "MFW indication via attention" SPAM every 5 minutes
In reply to Greg Kroah-HartmanFrom: Laurence Oberman <[email protected]>
[ Upstream commit 1d61e21852d3161f234b9656797669fe185c251b ]
This is likely firmware causing this but its starting to annoy customers. Change the message level to verbose to prevent the spam.
Note that this seems to only show up with ISCSI enabled on the HBA via the qedi driver.
--- drivers/net/ethernet/qlogic/qed/qed_int.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_int.c +2 -1
@@ -2158,7 +2158,8 @@ static int qed_int_attentions(struct qed_hwfn *p_hwfn) index, attn_bits, attn_acks, asserted_bits, deasserted_bits, p_sb_attn_sw->known_attn); }else if (asserted_bits ==0x100 ) { -DP_INFO (p_hwfn,"MFW indication via attention\n" ); +DP_VERBOSE (p_hwfn,NETIF_MSG_INTR , +"MFW indication via attention\n" ); }else {DP_VERBOSE (p_hwfn,NETIF_MSG_INTR ,"MFW indication [deassertion]\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 38/212 nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 1e8fd3a97f2d83a7197876ceb4f37b4c2b00a0f3 ]
The implementation of s3fwrn5_recv_frame() is supposed to consume skb on all execution paths. Release skb before returning -ENODEV.
--- drivers/nfc/s3fwrn5/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nfc/s3fwrn5/core.c +1 -0
@@ -209,6 +209,7 @@ int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,case S3FWRN5_MODE_FW :return s3fwrn5_fw_recv_frame (ndev, skb);default : +kfree_skb (skb);return -ENODEV ; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 39/212 parisc: add support for cmpxchg on u8 pointers
In reply to Greg Kroah-HartmanFrom: Liam Beguin <[email protected]>
[ Upstream commit b344d6a83d01c52fddbefa6b3b4764da5b1022a0 ]
The kernel test bot reported[1] that using set_mask_bits on a u8 causes the following issue on parisc:
hppa-linux-ld: drivers/phy/ti/phy-tusb1210.o: in function `tusb1210_probe': >> (.text+0x2f4): undefined reference to `__cmpxchg_called_with_bad_pointer' >> hppa-linux-ld: (.text+0x324): undefined reference to `__cmpxchg_called_with_bad_pointer' hppa-linux-ld: (.text+0x354): undefined reference to `__cmpxchg_called_with_bad_pointer'
Add support for cmpxchg on u8 pointers.
[1] https://lore.kernel.org/patchwork/patch/1272617/#1468946
--- arch/parisc/include/asm/cmpxchg.h | 2 ++ arch/parisc/lib/bitops.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)
arch/parisc/include/asm/cmpxchg.h +2 -0
@@ -59,6 +59,7 @@ extern void __cmpxchg_called_with_bad_pointer(void);extern unsigned long __cmpxchg_u32 (volatile unsigned int *m,unsigned int old,unsigned int new_);extern u64 __cmpxchg_u64 (volatile u64 *ptr,u64 old,u64 new_); +extern u8 __cmpxchg_u8 (volatile u8 *ptr,u8 old,u8 new_);/* don't worry...optimizer will get rid of most of this */ static inline unsigned long
@@ -70,6 +71,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)#endif case 4 :return __cmpxchg_u32 ((unsigned int *)ptr, (unsigned int )old, (unsigned int )new_); +case 1 :return __cmpxchg_u8 ((u8 *)ptr, (u8 )old, (u8 )new_); }__cmpxchg_called_with_bad_pointer ();return old;
arch/parisc/lib/bitops.c +12 -0
@@ -78,3 +78,15 @@ unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsign_atomic_spin_unlock_irqrestore (ptr, flags);return (unsigned long )prev; } + +u8 __cmpxchg_u8 (volatile u8 *ptr,u8 old,u8 new) +{ +unsigned long flags; +u8 prev; + +_atomic_spin_lock_irqsave (ptr, flags); +if ((prev = *ptr) == old) + *ptr = new; +_atomic_spin_unlock_irqrestore (ptr, flags); +return prev; +}
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 40/212 net: ethernet: ravb: exit if re-initialization fails in tx timeout
In reply to Greg Kroah-HartmanFrom: Yoshihiro Shimoda <[email protected]>
[ Upstream commit 015c5d5e6aa3523c758a70eb87b291cece2dbbb4 ]
According to the report of [1], this driver is possible to cause the following error in ravb_tx_timeout_work().
ravb e6800000.ethernet ethernet: failed to switch device to config mode
This error means that the hardware could not change the state from "Operation" to "Configuration" while some tx and/or rx queue are operating. After that, ravb_config() in ravb_dmac_init() will fail, and then any descriptors will be not allocaled anymore so that NULL pointer dereference happens after that on ravb_start_xmit().
To fix the issue, the ravb_tx_timeout_work() should check the return values of ravb_stop_dma() and ravb_dmac_init(). If ravb_stop_dma() fails, ravb_tx_timeout_work() re-enables TX and RX and just exits. If ravb_dmac_init() fails, just exits.
[1]
https://lore.kernel.org/linux-renesas-soc/[email protected]/
--- drivers/net/ethernet/renesas/ravb_main.c | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +24 -2
@@ -1444,6 +1444,7 @@ static void ravb_tx_timeout_work(struct work_struct *work) struct ravb_private *priv = container_of(work, struct ravb_private, work);struct net_device *ndev = priv->ndev; +int error;netif_tx_stop_all_queues (ndev);
@@ -1452,15 +1453,36 @@ static void ravb_tx_timeout_work(struct work_struct *work)ravb_ptp_stop (ndev);/* Wait for DMA stopping */ -ravb_stop_dma (ndev); +if (ravb_stop_dma (ndev)) { +/* If ravb_stop_dma() fails, the hardware is still operating +* for TX and/or RX. So, this should not call the following +* functions because ravb_dmac_init() is possible to fail too. +* Also, this should not retry ravb_stop_dma() again and again +* here because it's possible to wait forever. So, this just +* re-enables the TX and RX and skip the following +* re-initialization procedure. +*/ +ravb_rcv_snd_enable (ndev); + goto out; + }ravb_ring_free (ndev,RAVB_BE );ravb_ring_free (ndev,RAVB_NC );/* Device init */ -ravb_dmac_init (ndev); + error =ravb_dmac_init (ndev); +if (error) { +/* If ravb_dmac_init() fails, descriptors are freed. So, this +* should return here to avoid re-enabling the TX and RX in +* ravb_emac_init(). +*/ +netdev_err (ndev,"%s: ravb_dmac_init() failed, error %d\n" , + __func__, error); +return ; + }ravb_emac_init (ndev); +out:/* Initialise PTP Clock driver */ if (priv->chip_id ==RCAR_GEN2 )ravb_ptp_init (ndev, priv->pdev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 41/212 Revert "i2c: cadence: Fix the hold bit setting"
In reply to Greg Kroah-HartmanFrom: Raviteja Narayanam <[email protected]>
[ Upstream commit 0db9254d6b896b587759e2c844c277fb1a6da5b9 ]
This reverts commit d358def706880defa4c9e87381c5bf086a97d5f9.
There are two issues with "i2c: cadence: Fix the hold bit setting" commit.
1. In case of combined message request from user space, when the HOLD bit is cleared in cdns_i2c_mrecv function, a STOP condition is sent on the bus even before the last message is started. This is because when the HOLD bit is cleared, the FIFOS are empty and there is no pending transfer. The STOP condition should occur only after the last message is completed.
2. The code added by the commit is redundant. Driver is handling the setting/clearing of HOLD bit in right way before the commit.
The setting of HOLD bit based on 'bus_hold_flag' is taken care in cdns_i2c_master_xfer function even before cdns_i2c_msend/cdns_i2c_recv functions.
The clearing of HOLD bit is taken care at the end of cdns_i2c_msend and cdns_i2c_recv functions based on bus_hold_flag and byte count. Since clearing of HOLD bit is done after the slave address is written to the register (writing to address register triggers the message transfer), it is ensured that STOP condition occurs at the right time after completion of the pending transfer (last message).
--- drivers/i2c/busses/i2c-cadence.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-cadence.c +2 -7
@@ -382,10 +382,8 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if ((id->recv_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) +if (id->recv_count >CDNS_I2C_FIFO_DEPTH ) ctrl_reg |=CDNS_I2C_CR_HOLD ; -else - ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ;cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );
@@ -442,11 +440,8 @@ static void cdns_i2c_msend(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if ((id->send_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) +if (id->send_count >CDNS_I2C_FIFO_DEPTH ) ctrl_reg |=CDNS_I2C_CR_HOLD ; -else - ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ; -cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );/* Clear the interrupts in interrupt status register. */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 42/212 xen-netfront: fix potential deadlock in xennet_remove()
In reply to Greg Kroah-HartmanFrom: Andrea Righi <[email protected]>
[ Upstream commit c2c633106453611be07821f53dff9e93a9d1c3f0 ]
There's a potential race in xennet_remove(); this is what the driver is doing upon unregistering a network device:
1. state = read bus state
2. if state is not "Closed":
3. request to set state to "Closing" 4. wait for state to be set to "Closing" 5. request to set state to "Closed" 6. wait for state to be set to "Closed"
If the state changes to "Closed" immediately after step 1 we are stuck forever in step 4, because the state will never go back from "Closed" to "Closing".
Make sure to check also for state == "Closed" in step 4 to prevent the deadlock.
Also add a 5 sec timeout any time we wait for the bus state to change, to avoid getting stuck forever in wait_event().
--- drivers/net/xen-netfront.c | 64 +++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 22 deletions(-)
drivers/net/xen-netfront.c +42 -22
@@ -62,6 +62,8 @@ module_param_named(max_queues, xennet_max_queues, uint, 0644);MODULE_PARM_DESC (max_queues,"Maximum number of queues per virtual interface" ); +#define XENNET_TIMEOUT (5 * HZ) +static const struct ethtool_ops xennet_ethtool_ops;struct netfront_cb {
@@ -1355,12 +1357,15 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)netif_carrier_off (netdev); -xenbus_switch_state (dev, XenbusStateInitialising); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) != - XenbusStateClosed && -xenbus_read_driver_state (dev->otherend) != - XenbusStateUnknown); +do { +xenbus_switch_state (dev, XenbusStateInitialising); + err =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) != + XenbusStateClosed && +xenbus_read_driver_state (dev->otherend) != + XenbusStateUnknown,XENNET_TIMEOUT ); + }while (!err); +return netdev; exit:
@@ -2172,28 +2177,43 @@ static const struct attribute_group xennet_dev_group = { };#endif /* CONFIG_SYSFS */ -static int xennet_remove (struct xenbus_device *dev) +static void xennet_bus_close (struct xenbus_device *dev) { -struct netfront_info *info =dev_get_drvdata (&dev->dev); - -dev_dbg (&dev->dev,"%s\n" , dev->nodename); +int ret; -if (xenbus_read_driver_state (dev->otherend) != XenbusStateClosed) { +if (xenbus_read_driver_state (dev->otherend) == XenbusStateClosed) +return ; +do {xenbus_switch_state (dev, XenbusStateClosing); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) == - XenbusStateClosing || -xenbus_read_driver_state (dev->otherend) == - XenbusStateUnknown); + ret =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosing || +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosed || +xenbus_read_driver_state (dev->otherend) == + XenbusStateUnknown, +XENNET_TIMEOUT ); + }while (!ret); + +if (xenbus_read_driver_state (dev->otherend) == XenbusStateClosed) +return ; +do {xenbus_switch_state (dev, XenbusStateClosed); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) == - XenbusStateClosed || -xenbus_read_driver_state (dev->otherend) == - XenbusStateUnknown); - } + ret =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosed || +xenbus_read_driver_state (dev->otherend) == + XenbusStateUnknown, +XENNET_TIMEOUT ); + }while (!ret); +} + +static int xennet_remove (struct xenbus_device *dev) +{ +struct netfront_info *info =dev_get_drvdata (&dev->dev); +xennet_bus_close (dev);xennet_disconnect_backend (info);if (info->netdev->reg_state ==NETREG_REGISTERED )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 43/212 KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled
In reply to Greg Kroah-HartmanFrom: Wanpeng Li <[email protected]>
commit d2286ba7d574ba3103a421a2f9ec17cb5b0d87a1 upstream.
Prevent setting the tscdeadline timer if the lapic is hw disabled.
Message-Id: <[email protected]>
--- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
@@ -1756,7 +1756,7 @@ void kvm_set_lapic_tscdeadline_msr(struc {struct kvm_lapic *apic = vcpu->arch.apic; -if (!lapic_in_kernel (vcpu) ||apic_lvtt_oneshot (apic) || +if (!kvm_apic_present (vcpu) ||apic_lvtt_oneshot (apic) ||apic_lvtt_period (apic))return ;
Greg Kroah-Hartman
maintainerPATCH 44/212 x86/i8259: Use printk_deferred() to prevent deadlock
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit bdd65589593edd79b6a12ce86b3b7a7c6dae5208 upstream.
0day reported a possible circular locking dependency:
Chain exists of: &irq_desc_lock_class --> console_owner --> &port_lock_key Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&port_lock_key);
lock(console_owner);
lock(&port_lock_key); lock(&irq_desc_lock_class);
The reason for this is a printk() in the i8259 interrupt chip driver which is invoked with the irq descriptor lock held, which reverses the lock operations vs. printk() from arbitrary contexts.
Switch the printk() to printk_deferred() to avoid that.
--- arch/x86/kernel/i8259.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/i8259.c +1 -1
@@ -205,7 +205,7 @@ spurious_8259A_irq:* lets ACK and report it. [once per IRQ] */ if (!(spurious_irq_mask & irqmask)) { -printk (KERN_DEBUG +printk_deferred (KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n" , irq); spurious_irq_mask |= irqmask; }
Greg Kroah-Hartman
maintainerPATCH 45/212 random32: update the net random state on interrupt and activity
In reply to Greg Kroah-HartmanFrom: Willy Tarreau <[email protected]>
commit f227e3ec3b5cad859ad15666874405e8c1bbc1d4 upstream.
This modifies the first 32 bits out of the 128 bits of a random CPU's net_rand_state on interrupt or CPU activity to complicate remote observations that could lead to guessing the network RNG's internal state.
Note that depending on some network devices' interrupt rate moderation or binding, this re-seeding might happen on every packet or even almost never.
In addition, with NOHZ some CPUs might not even get timer interrupts, leaving their local state rarely updated, while they are running networked processes making use of the random state. For this reason, we also perform this update in update_process_times() in order to at least update the state when there is user or system activity, since it's the only case we care about.
--- drivers/char/random.c | 1 + include/linux/random.h | 3 +++ kernel/time/timer.c | 8 ++++++++ lib/random32.c | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-)
drivers/char/random.c +1 -0
@@ -1211,6 +1211,7 @@ void add_interrupt_randomness(int irq, ifast_mix (fast_pool);add_interrupt_bench (cycles); +this_cpu_add (net_rand_state.s1, fast_pool->pool[cycles &3 ]);if (unlikely (crng_init ==0 )) { if ((fast_pool->count >= 64) &&
include/linux/random.h +3 -0
@@ -8,6 +8,7 @@#include <linux/list.h> #include <linux/once.h> +#include <linux/percpu.h> #include <uapi/linux/random.h>
@@ -55,6 +56,8 @@ struct rnd_state {__u32 s1, s2, s3, s4; }; +DECLARE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +u32 prandom_u32_state (struct rnd_state *state);void prandom_bytes_state (struct rnd_state *state,void *buf,size_t nbytes);void prandom_seed_full_state (struct rnd_state __percpu *pcpu_state);
kernel/time/timer.c +8 -0
@@ -42,6 +42,7 @@#include <linux/sched/sysctl.h> #include <linux/slab.h> #include <linux/compat.h> +#include <linux/random.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -1635,6 +1636,13 @@ void update_process_times(int user_tick)#endif scheduler_tick ();run_posix_cpu_timers (p); + +/* The current CPU might make use of net randoms without receiving IRQs +* to renew them often enough. Let's update the net_rand_state from a +* non-constant value that's not affine to the number of calls to make +* sure it's updated when there's some activity (we don't care in idle). +*/ +this_cpu_add (net_rand_state.s1,rol32 (jiffies,24 ) + user_tick); }/**
lib/random32.c +1 -1
@@ -47,7 +47,7 @@ static inline void prandom_state_selftes }#endif -static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;/** * prandom_u32_state - seeded pseudo-random number generator.
Greg Kroah-Hartman
maintainerPATCH 46/212 ARM: percpu.h: fix build error
In reply to Greg Kroah-HartmanFrom: Grygorii Strashko <[email protected]>
commit aa54ea903abb02303bf55855fb51e3fcee135d70 upstream.
Fix build error for the case:
defined(CONFIG_SMP) && !defined(CONFIG_CPU_V6)
config: keystone_defconfig
CC arch/arm/kernel/signal.o
In file included from ../include/linux/random.h:14,
from ../arch/arm/kernel/signal.c:8:
../arch/arm/include/asm/percpu.h: In function ‘__my_cpu_offset’:
../arch/arm/include/asm/percpu.h:29:34: error: ‘current_stack_pointer’ undeclared (first use in this function); did you mean ‘user_stack_pointer’?
: "Q" (*(const unsigned long *)current_stack_pointer));
^~~~~~~~~~~~~~~~~~~~~
user_stack_pointer--- arch/arm/include/asm/percpu.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/percpu.h +2 -0
@@ -16,6 +16,8 @@#ifndef _ASM_ARM_PERCPU_H_#define _ASM_ARM_PERCPU_H_ +#include <asm/thread_info.h> +/* * Same as asm-generic/percpu.h, except that we store the per cpu offset * in the TPIDRPRW. TPIDRPRW only exists on V6K and V7
Greg Kroah-Hartman
maintainerPATCH 47/212 random: fix circular include dependency on arm64 after addition of percpu.h
In reply to Greg Kroah-HartmanFrom: Willy Tarreau <[email protected]>
commit 1c9df907da83812e4f33b59d3d142c864d9da57f upstream.
Daniel Díaz and Kees Cook independently reported that commit f227e3ec3b5c ("random32: update the net random state on interrupt and activity") broke arm64 due to a circular dependency on include files since the addition of percpu.h in random.h.
The correct fix would definitely be to move all the prandom32 stuff out of random.h but for backporting, a smaller solution is preferred.
This one replaces linux/percpu.h with asm/percpu.h, and this fixes the problem on x86_64, arm64, arm, and mips. Note that moving percpu.h around didn't change anything and that removing it entirely broke differently. When backporting, such options might still be considered if this patch fails to help.
[ It turns out that an alternate fix seems to be to just remove the
troublesome <asm/pointer_auth.h> remove from the arm64 <asm/smp.h> that causes the circular dependency.
But we might as well do the whole belt-and-suspenders thing, and minimize inclusion in <linux/random.h> too. Either will fix the
problem, and both are good changes. - Linus ]
--- include/linux/random.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/random.h +1 -1
@@ -8,7 +8,7 @@#include <linux/list.h> #include <linux/once.h> -#include <linux/percpu.h> +#include <asm/percpu.h> #include <uapi/linux/random.h>
Greg Kroah-Hartman
maintainerPATCH 48/212 random32: remove net_rand_state from the latent entropy gcc plugin
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 83bdc7275e6206f560d247be856bceba3e1ed8f2 upstream.
It turns out that the plugin right now ends up being really unhappy about the change from 'static' to 'extern' storage that happened in commit f227e3ec3b5c ("random32: update the net random state on interrupt and activity").
This is probably a trivial fix for the latent_entropy plugin, but for now, just remove net_rand_state from the list of things the plugin worries about.
--- include/linux/random.h | 2 +- lib/random32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/random.h +1 -1
@@ -56,7 +56,7 @@ struct rnd_state {__u32 s1, s2, s3, s4; }; -DECLARE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DECLARE_PER_CPU(struct rnd_state, net_rand_state);u32 prandom_u32_state (struct rnd_state *state);void prandom_bytes_state (struct rnd_state *state,void *buf,size_t nbytes);
lib/random32.c +1 -1
@@ -47,7 +47,7 @@ static inline void prandom_state_selftes }#endif -DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DEFINE_PER_CPU(struct rnd_state, net_rand_state);/** * prandom_u32_state - seeded pseudo-random number generator.
Greg Kroah-Hartman
maintainerPATCH 49/212 random32: move the pseudo-random 32-bit definitions to prandom.h
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit c0842fbc1b18c7a044e6ff3e8fa78bfa822c7d1a upstream.
The addition of percpu.h to the list of includes in random.h revealed some circular dependencies on arm64 and possibly other platforms. This include was added solely for the pseudo-random definitions, which have nothing to do with the rest of the definitions in this file but are still there for legacy reasons.
This patch moves the pseudo-random parts to linux/prandom.h and the percpu.h include with it, which is now guarded by _LINUX_PRANDOM_H and protected against recursive inclusion.
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.
But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.
So the "nice cleanup" part may or may never happen.
--- include/linux/prandom.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/random.h | 66 ++-------------------------------------- 2 files changed, 82 insertions(+), 62 deletions(-)
include/linux/prandom.h new file +78 -0
@@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* include/linux/prandom.h +* +* Include file for the fast pseudo-random 32-bit +* generation. +*/ +#ifndef _LINUX_PRANDOM_H +#define _LINUX_PRANDOM_H + +#include <linux/types.h> +#include <linux/percpu.h> + +u32 prandom_u32 (void ); +void prandom_bytes (void *buf,size_t nbytes); +void prandom_seed (u32 seed); +void prandom_reseed_late (void ); + +struct rnd_state { +__u32 s1, s2, s3, s4; +}; + +DECLARE_PER_CPU(struct rnd_state, net_rand_state); + +u32 prandom_u32_state (struct rnd_state *state); +void prandom_bytes_state (struct rnd_state *state,void *buf,size_t nbytes); +void prandom_seed_full_state (struct rnd_state __percpu *pcpu_state); + +#define prandom_init_once (pcpu_state) \ + DO_ONCE(prandom_seed_full_state, (pcpu_state)) + +/** +* prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro) +* @ep_ro: right open interval endpoint +* +* Returns a pseudo-random number that is in interval [0, ep_ro). Note +* that the result depends on PRNG being well distributed in [0, ~0U] +* u32 space. Here we use maximally equidistributed combined Tausworthe +* generator, that is, prandom_u32(). This is useful when requesting a +* random index of an array containing ep_ro elements, for example. +* +* Returns: pseudo-random number in interval [0, ep_ro) +*/ +static inline u32 prandom_u32_max (u32 ep_ro) +{ +return (u32)(((u64 )prandom_u32 () * ep_ro) >>32 ); +} + +/* +* Handle minimum values for seeds +*/ +static inline u32 __seed (u32 x,u32 m) +{ +return (x < m) ? x + m : x; +} + +/** +* prandom_seed_state - set seed for prandom_u32_state(). +* @state: pointer to state structure to receive the seed. +* @seed: arbitrary 64-bit value to use as a seed. +*/ +static inline void prandom_seed_state (struct rnd_state *state,u64 seed) +{ +u32 i = (seed >>32 ) ^ (seed <<10 ) ^ seed; + + state->s1 =__seed (i,2U ); + state->s2 =__seed (i,8U ); + state->s3 =__seed (i,16U ); + state->s4 =__seed (i,128U ); +} + +/* Pseudo random number generator from numerical recipes. */ +static inline u32 next_pseudo_random32 (u32 seed) +{ +return seed *1664525 +1013904223 ; +} + +#endif
include/linux/random.h +4 -62
84 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 50/212 ext4: fix direct I/O read error
In reply to Greg Kroah-HartmanFrom: Jiang Ying <[email protected]>
This patch is used to fix ext4 direct I/O read error when the read size is not aligned with block size.
Then, I will use a test to explain the error.
(1) Make a file that is not aligned with block size:
$dd if=/dev/zero of=./test.jar bs=1000 count=3
(2) I wrote a source file named "direct_io_read_file.c" as following:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#define BUF_SIZE 1024
int main()
{
int fd;
int ret;
unsigned char *buf;
ret = posix_memalign((void **)&buf, 512, BUF_SIZE);
if (ret) {
perror("posix_memalign failed");
exit(1);
}
fd = open("./test.jar", O_RDONLY | O_DIRECT, 0755);
if (fd < 0){
perror("open ./test.jar failed");
exit(1);
}
do {
ret = read(fd, buf, BUF_SIZE);
printf("ret=%d\n",ret);
if (ret < 0) {
perror("write test.jar failed");
}
} while (ret > 0);
free(buf);
close(fd);
}(3) Compile the source file:
$gcc direct_io_read_file.c -D_GNU_SOURCE
(4) Run the test program:
$./a.out The result is as following: ret=1024 ret=1024 ret=952 ret=-1 write test.jar failed: Invalid argument.
I have tested this program on XFS filesystem, XFS does not have this problem, because XFS use iomap_dio_rw() to do direct I/O read. And the comparing between read offset and file size is done in iomap_dio_rw(), the code is as following:
if (pos < size) {
retval = filemap_write_and_wait_range(mapping, pos,
pos + iov_length(iov, nr_segs) - 1);
if (!retval) {
retval = mapping->a_ops->direct_IO(READ, iocb,
iov, pos, nr_segs);
}
...
}...only when "pos < size", direct I/O can be done, or 0 will be return.
I have tested the fix patch on Ext4, it is up to the mustard of EINVAL in man2(read) as following:
#include <unistd.h> ssize_t read(int fd, void *buf, size_t count); EINVAL fd is attached to an object which is unsuitable for reading; or the file was opened with the O_DIRECT flag, and either the address specified in buf, the value specified in count, or the current file offset is not suitably aligned.
So I think this patch can be applied to fix ext4 direct I/O error.
However Ext4 introduces direct I/O read using iomap infrastructure on kernel 5.5, the patch is commit <b1b4705d54ab>
("ext4: introduce direct I/O read using iomap infrastructure"), then Ext4 will be the same as XFS, they all use iomap_dio_rw() to do direct I/O read. So this problem does not exist on kernel 5.5 for Ext4.
Quoted 1 line
From above description, we can see this problem exists on all the kernel
versions between kernel 3.14 and kernel 5.4. It will cause the Applications to fail to read. For example, when the search service downloads a new full index file, the search engine is loading the previous index file and is processing the search request, it can not use buffer io that may squeeze the previous index file in use from pagecache, so the serch service must use direct I/O read.
Please apply this patch on these kernel versions, or please use the method on kernel 5.5 to fix this problem.
--- fs/ext4/inode.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ext4/inode.c +5 -0
@@ -3575,6 +3575,11 @@ static ssize_t ext4_direct_IO_read(strucstruct address_space *mapping = iocb->ki_filp->f_mapping;struct inode *inode = mapping->host;ssize_t ret; +loff_t offset = iocb->ki_pos; +loff_t size =i_size_read (inode); + +if (offset >= size) +return 0 ;/* * Shared inode_lock is enough for us - it protects against concurrent
Greg Kroah-Hartman
maintainerPATCH 51/212 USB: serial: qcserial: add EM7305 QDL product ID
In reply to Greg Kroah-HartmanFrom: Erik Ekman <[email protected]>
commit d2a4309c1ab6df424b2239fe2920d6f26f808d17 upstream.
When running qmi-firmware-update on the Sierra Wireless EM7305 in a Toshiba laptop, it changed product ID to 0x9062 when entering QDL mode:
usb 2-4: new high-speed USB device number 78 using xhci_hcd
usb 2-4: New USB device found, idVendor=1199, idProduct=9062, bcdDevice= 0.00 usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 2-4: Product: EM7305
usb 2-4: Manufacturer: Sierra Wireless, Incorporated
The upgrade could complete after running
# echo 1199 9062 > /sys/bus/usb-serial/drivers/qcserial/new_id
qcserial 2-4:1.0: Qualcomm USB modem converter detected usb 2-4: Qualcomm USB modem converter now attached to ttyUSB0
--- drivers/usb/serial/qcserial.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/qcserial.c +1 -0
@@ -159,6 +159,7 @@ static const struct usb_device_id id_tab {DEVICE_SWI(0x1199, 0x9056)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9060)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9061)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9062)}, /* Sierra Wireless EM7305 QDL */ {DEVICE_SWI(0x1199, 0x9063)}, /* Sierra Wireless EM7305 */ {DEVICE_SWI(0x1199, 0x9070)}, /* Sierra Wireless MC74xx */ {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */
Greg Kroah-Hartman
maintainerPATCH 52/212 net/mlx5e: Dont support phys switch id if not in switchdev mode
In reply to Greg Kroah-HartmanFrom: Roi Dayan <[email protected]>
Support for phys switch id ndo added for representors and if we do not have representors there is no need to support it. Since each port return different switch id supporting this block support for creating bond over PFs and attaching to bridge in legacy mode.
This bug doesn't exist upstream as the code got refactored and the netdev api is totally different.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
@@ -139,7 +139,7 @@ int mlx5e_attr_get(struct net_device *destruct mlx5_eswitch_rep *rep = priv->ppriv;struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -if (esw->mode ==SRIOV_NONE ) +if (esw->mode !=SRIOV_OFFLOADS )return -EOPNOTSUPP ;switch (attr->id) {
Greg Kroah-Hartman
maintainerPATCH 53/212 ALSA: seq: oss: Serialize ioctls
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 80982c7e834e5d4e325b6ce33757012ecafdf0bb upstream.
Some ioctls via OSS sequencer API may race and lead to UAF when the port create and delete are performed concurrently, as spotted by a couple of syzkaller cases. This patch is an attempt to address it by serializing the ioctls with the existing register_mutex.
Basically OSS sequencer API is an obsoleted interface and was designed without much consideration of the concurrency. There are very few applications with it, and the concurrent performance isn't asked, hence this "big hammer" approach should be good enough.
--- sound/core/seq/oss/seq_oss.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/core/seq/oss/seq_oss.c +7 -1
@@ -181,10 +181,16 @@ static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct seq_oss_devinfo *dp; +long rc; + dp = file->private_data;if (snd_BUG_ON (!dp))return -ENXIO ; -return snd_seq_oss_ioctl (dp, cmd, arg); + +mutex_lock (®ister_mutex); + rc =snd_seq_oss_ioctl (dp, cmd, arg); +mutex_unlock (®ister_mutex); +return rc; }#ifdef CONFIG_COMPAT
Greg Kroah-Hartman
maintainerPATCH 54/212 Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 51c19bf3d5cfaa66571e4b88ba2a6f6295311101 upstream.
Check upon num_rsp is insufficient. A malformed event packet with a large num_rsp number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it.
This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2
--- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_event.c +1 -1
@@ -3826,7 +3826,7 @@ static void hci_extended_inquiry_result_BT_DBG ("%s num_rsp %d" , hdev->name, num_rsp); -if (!num_rsp) +if (!num_rsp || skb->len < num_rsp *sizeof (*info) +1 )return ;if (hci_dev_test_flag (hdev,HCI_PERIODIC_INQ ))
Greg Kroah-Hartman
maintainerPATCH 55/212 Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 75bbd2ea50ba1c5d9da878a17e92eac02fe0fd3a upstream.
Check num_rsp before using it as for-loop counter.
--- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_event.c +1 -1
@@ -2094,7 +2094,7 @@ static void hci_inquiry_result_evt(strucBT_DBG ("%s num_rsp %d" , hdev->name, num_rsp); -if (!num_rsp) +if (!num_rsp || skb->len < num_rsp *sizeof (*info) +1 )return ;if (hci_dev_test_flag (hdev,HCI_PERIODIC_INQ ))
Greg Kroah-Hartman
maintainerPATCH 56/212 Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 629b49c848ee71244203934347bd7730b0ddee8d upstream.
Check num_rsp before using it as for-loop counter. Add unlock label.
--- net/bluetooth/hci_event.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/hci_event.c +7 -0
@@ -3623,6 +3623,9 @@ static void hci_inquiry_result_with_rssistruct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data +1 ); +if (skb->len < num_rsp *sizeof (*info) +1 ) + goto unlock; +for (; num_rsp; num_rsp--, info++) {u32 flags;
@@ -3644,6 +3647,9 @@ static void hci_inquiry_result_with_rssi }else {struct inquiry_info_with_rssi *info = (void *) (skb->data +1 ); +if (skb->len < num_rsp *sizeof (*info) +1 ) + goto unlock; +for (; num_rsp; num_rsp--, info++) {u32 flags;
@@ -3664,6 +3670,7 @@ static void hci_inquiry_result_with_rssi } } +unlock:hci_dev_unlock (hdev); }
Greg Kroah-Hartman
maintainerPATCH 57/212 omapfb: dss: Fix max fclk divider for omap36xx
In reply to Greg Kroah-HartmanFrom: Adam Ford <[email protected]>
commit 254503a2b186caa668a188dbbd7ab0d25149c0a5 upstream.
The drm/omap driver was fixed to correct an issue where using a divider of 32 breaks the DSS despite the TRM stating 32 is a valid number. Through experimentation, it appears that 31 works, and it is consistent with the value used by the drm/omap driver.
This patch fixes the divider for fbdev driver instead of the drm.
--- drivers/video/fbdev/omap2/omapfb/dss/dss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/dss/dss.c +1 -1
@@ -843,7 +843,7 @@ static const struct dss_features omap34x };static const struct dss_features omap3630_dss_feats = { - .fck_div_max =32 , + .fck_div_max =31 , .dss_fck_multiplier =1 , .parent_clk_name ="dpll4_ck" , .dpi_select_source = &dss_dpi_select_source_omap2_omap3,
Greg Kroah-Hartman
maintainerPATCH 58/212 vgacon: Fix for missing check in scrollback handling
In reply to Greg Kroah-HartmanFrom: Yunhai Zhang <[email protected]>
commit ebfdfeeae8c01fcb2b3b74ffaf03876e20835d2d upstream.
vgacon_scrollback_update() always leaves enbough room in the scrollback buffer for the next call, but if the console size changed that room might not actually be enough, and so we need to re-check.
The check should be in the loop since vgacon_scrollback_cur->tail is updated in the loop and count may be more than 1 when triggered by CSI M, as Jiri's PoC:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
int main(int argc, char** argv)
{
int fd = open("/dev/tty1", O_RDWR);
unsigned short size[3] = {25, 200, 0};
ioctl(fd, 0x5609, size); // VT_RESIZE
write(fd, "\e[1;1H", 6);
for (int i = 0; i < 30; i++)
write(fd, "\e[10M", 5);
}It leads to various crashes as vgacon_scrollback_update writes out of the buffer:
BUG: unable to handle page fault for address: ffffc900001752a0 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page RIP: 0010:mutex_unlock+0x13/0x30 ... Call Trace: n_tty_write+0x1a0/0x4d0 tty_write+0x1a0/0x2e0
Or to KASAN reports:
BUG: KASAN: slab-out-of-bounds in vgacon_scroll+0x57a/0x8ed
This fixes CVE-2020-14331.
--- drivers/video/console/vgacon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/video/console/vgacon.c +4 -0
@@ -219,6 +219,10 @@ static void vgacon_scrollback_update(str p = (void *) (c->vc_origin + t * c->vc_size_row);while (count--) { +if ((vgacon_scrollback_tail + c->vc_size_row) > + vgacon_scrollback_size) + vgacon_scrollback_tail =0 ; +scr_memcpyw (vgacon_scrollback + vgacon_scrollback_tail, p, c->vc_size_row); vgacon_scrollback_cnt++;
Greg Kroah-Hartman
maintainerPATCH 59/212 mtd: properly check all write ioctls for permissions
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit f7e6b19bc76471ba03725fe58e0c218a3d6266c3 upstream.
When doing a "write" ioctl call, properly check that we have permissions to do so before copying anything from userspace or anything else so we can "fail fast". This includes also covering the MEMWRITE ioctl which previously missed checking for this.
--- drivers/mtd/mtdchar.c | 56 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-)
drivers/mtd/mtdchar.c +47 -9
@@ -372,9 +372,6 @@ static int mtdchar_writeoob(struct fileuint32_t retlen;int ret =0 ; -if (!(file->f_mode &FMODE_WRITE )) -return -EPERM ; -if (length >4096 )return -EINVAL ;
@@ -681,6 +678,48 @@ static int mtdchar_ioctl(struct file *fireturn -EFAULT ; } +/* +* Check the file mode to require "dangerous" commands to have write +* permissions. +*/ +switch (cmd) { +/* "safe" commands */ +case MEMGETREGIONCOUNT : +case MEMGETREGIONINFO : +case MEMGETINFO : +case MEMREADOOB : +case MEMREADOOB64 : +case MEMLOCK : +case MEMUNLOCK : +case MEMISLOCKED : +case MEMGETOOBSEL : +case MEMGETBADBLOCK : +case MEMSETBADBLOCK : +case OTPSELECT : +case OTPGETREGIONCOUNT : +case OTPGETREGIONINFO : +case OTPLOCK : +case ECCGETLAYOUT : +case ECCGETSTATS : +case MTDFILEMODE : +case BLKPG : +case BLKRRPART : +break ; + +/* "dangerous" commands */ +case MEMERASE : +case MEMERASE64 : +case MEMWRITEOOB : +case MEMWRITEOOB64 : +case MEMWRITE : +if (!(file->f_mode &FMODE_WRITE )) +return -EPERM ; +break ; + +default : +return -ENOTTY ; + } +switch (cmd) {case MEMGETREGIONCOUNT :if (copy_to_user (argp, &(mtd->numeraseregions),sizeof (int )))
@@ -728,9 +767,6 @@ static int mtdchar_ioctl(struct file *fi {struct erase_info *erase; -if (!(file->f_mode &FMODE_WRITE )) -return -EPERM ; - erase=kzalloc (sizeof (struct erase_info ),GFP_KERNEL );if (!erase) ret = -ENOMEM ;
@@ -1051,9 +1087,6 @@ static int mtdchar_ioctl(struct file *fi ret =0 ;break ; } - -default : - ret = -ENOTTY ; }return ret;
@@ -1097,6 +1130,11 @@ static long mtdchar_compat_ioctl(structstruct mtd_oob_buf32 buf;struct mtd_oob_buf32 __user *buf_user = argp; +if (!(file->f_mode &FMODE_WRITE )) { + ret = -EPERM ; +break ; + } +if (copy_from_user (&buf, argp,sizeof (buf))) ret = -EFAULT ;else
Greg Kroah-Hartman
maintainerPATCH 60/212 leds: wm831x-status: fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 47a459ecc800a17109d0c496a4e21e478806ee40 upstream.
Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered.
--- drivers/leds/leds-wm831x-status.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/leds/leds-wm831x-status.c +13 -1
@@ -283,12 +283,23 @@ static int wm831x_status_probe(struct pl drvdata->cdev.blink_set = wm831x_status_blink_set; drvdata->cdev.groups = wm831x_status_groups; - ret =devm_led_classdev_register (wm831x->dev, &drvdata->cdev); + ret =led_classdev_register (wm831x->dev, &drvdata->cdev);if (ret <0 ) {dev_err (&pdev->dev,"Failed to register LED: %d\n" , ret);return ret; } +platform_set_drvdata (pdev, drvdata); + +return 0 ; +} + +static int wm831x_status_remove (struct platform_device *pdev) +{ +struct wm831x_status *drvdata =platform_get_drvdata (pdev); + +led_classdev_unregister (&drvdata->cdev); +return 0 ; }
@@ -297,6 +308,7 @@ static struct platform_driver wm831x_sta .name = "wm831x-status", }, .probe = wm831x_status_probe, + .remove = wm831x_status_remove, };module_platform_driver (wm831x_status_driver);
Greg Kroah-Hartman
maintainerPATCH 61/212 leds: da903x: fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 6f4aa35744f69ed9b0bf5a736c9ca9b44bc1dcea upstream.
Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered.
--- drivers/leds/leds-da903x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/leds/leds-da903x.c +13 -1
@@ -113,12 +113,23 @@ static int da903x_led_probe(struct platf led->flags = pdata->flags; led->master = pdev->dev.parent; - ret =devm_led_classdev_register (led->master, &led->cdev); + ret =led_classdev_register (led->master, &led->cdev);if (ret) {dev_err (&pdev->dev,"failed to register LED %d\n" , id);return ret; } +platform_set_drvdata (pdev, led); + +return 0 ; +} + +static int da903x_led_remove (struct platform_device *pdev) +{ +struct da903x_led *led =platform_get_drvdata (pdev); + +led_classdev_unregister (&led->cdev); +return 0 ; }
@@ -127,6 +138,7 @@ static struct platform_driver da903x_led .name = "da903x-led", }, .probe = da903x_led_probe, + .remove = da903x_led_remove, };module_platform_driver (da903x_led_driver);
Greg Kroah-Hartman
maintainerPATCH 62/212 leds: lm3533: fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit d584221e683bbd173738603b83a315f27d27d043 upstream.
Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered.
--- drivers/leds/leds-lm3533.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/leds/leds-lm3533.c +9 -3
@@ -698,7 +698,7 @@ static int lm3533_led_probe(struct platfplatform_set_drvdata (pdev, led); - ret =devm_led_classdev_register (pdev->dev.parent, &led->cdev); + ret =led_classdev_register (pdev->dev.parent, &led->cdev);if (ret) {dev_err (&pdev->dev,"failed to register LED %d\n" , pdev->id);return ret;
@@ -708,13 +708,18 @@ static int lm3533_led_probe(struct platf ret =lm3533_led_setup (led, pdata);if (ret) -return ret; + goto err_deregister; ret =lm3533_ctrlbank_enable (&led->cb);if (ret) -return ret; + goto err_deregister;return 0 ; + +err_deregister: +led_classdev_unregister (&led->cdev); + +return ret; }static int lm3533_led_remove (struct platform_device *pdev)
@@ -724,6 +729,7 @@ static int lm3533_led_remove(struct platdev_dbg (&pdev->dev,"%s\n" , __func__);lm3533_ctrlbank_disable (&led->cb); +led_classdev_unregister (&led->cdev);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 63/212 leds: 88pm860x: fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit eca21c2d8655387823d695b26e6fe78cf3975c05 upstream.
Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered.
--- drivers/leds/leds-88pm860x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/leds/leds-88pm860x.c +13 -1
@@ -207,21 +207,33 @@ static int pm860x_led_probe(struct platf data->cdev.brightness_set_blocking = pm860x_led_set;mutex_init (&data->lock); - ret =devm_led_classdev_register (chip->dev, &data->cdev); + ret =led_classdev_register (chip->dev, &data->cdev);if (ret <0 ) {dev_err (&pdev->dev,"Failed to register LED: %d\n" , ret);return ret; }pm860x_led_set (&data->cdev,0 ); + +platform_set_drvdata (pdev, data); +return 0 ; } +static int pm860x_led_remove (struct platform_device *pdev) +{ +struct pm860x_led *data =platform_get_drvdata (pdev); + +led_classdev_unregister (&data->cdev); + +return 0 ; +}static struct platform_driver pm860x_led_driver = { .driver = { .name ="88pm860x-led" , }, .probe = pm860x_led_probe, + .remove = pm860x_led_remove, };module_platform_driver (pm860x_led_driver);
Greg Kroah-Hartman
maintainerPATCH 64/212 net/9p: validate fds in p9_fd_open
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit a39c46067c845a8a2d7144836e9468b7f072343e ]
p9_fd_open just fgets file descriptors passed in from userspace, but doesn't verify that they are valid for read or writing. This gets cought down in the VFS when actually attempting a read or write, but a new warning added in linux-next upsets syzcaller.
Fix this by just verifying the fds early on.
--- net/9p/trans_fd.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
net/9p/trans_fd.c +16 -8
@@ -815,20 +815,28 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd)return -ENOMEM ; ts->rd =fget (rfd); +if (!ts->rd) + goto out_free_ts; +if (!(ts->rd->f_mode &FMODE_READ )) + goto out_put_rd; ts->wr =fget (wfd); -if (!ts->rd || !ts->wr) { -if (ts->rd) -fput (ts->rd); -if (ts->wr) -fput (ts->wr); -kfree (ts); -return -EIO ; - } +if (!ts->wr) + goto out_put_rd; +if (!(ts->wr->f_mode &FMODE_WRITE )) + goto out_put_wr; client->trans = ts; client->status = Connected;return 0 ; + +out_put_wr: +fput (ts->wr); +out_put_rd: +fput (ts->rd); +out_free_ts: +kfree (ts); +return -EIO ; }static int p9_socket_open (struct p9_client *client,struct socket *csocket)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 65/212 drm/nouveau/fbcon: fix module unload when fbcon init has failed for some reason
In reply to Greg Kroah-HartmanFrom: Ben Skeggs <[email protected]>
[ Upstream commit 498595abf5bd51f0ae074cec565d888778ea558f ]
Stale pointer was tripping up the unload path.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -0
@@ -584,6 +584,7 @@ fini:drm_fb_helper_fini (&fbcon->helper); free:kfree (fbcon); + drm->fbcon =NULL ;return ret; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 66/212 cfg80211: check vendor command doit pointer before use
In reply to Greg Kroah-HartmanFrom: Julian Squires <[email protected]>
[ Upstream commit 4052d3d2e8f47a15053320bbcbe365d15610437d ]
In the case where a vendor command does not implement doit, and has no flags set, doit would not be validated and a NULL pointer dereference would occur, for example when invoking the vendor command via iw.
I encountered this while developing new vendor commands. Perhaps in practice it is advisable to always implement doit along with dumpit, but it seems reasonable to me to always check doit anyway, not just when NEED_WDEV.
--- net/wireless/nl80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/wireless/nl80211.c +3 -3
@@ -11317,13 +11317,13 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info)if (!wdev->netdev && !wdev->p2p_started)return -ENETDOWN ; } - -if (!vcmd->doit) -return -EOPNOTSUPP ; }else { wdev =NULL ; } +if (!vcmd->doit) +return -EOPNOTSUPP ; +if (info->attrs[NL80211_ATTR_VENDOR_DATA ]) { data =nla_data (info->attrs[NL80211_ATTR_VENDOR_DATA ]); len =nla_len (info->attrs[NL80211_ATTR_VENDOR_DATA ]);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 67/212 igb: reinit_locked() should be called with rtnl_lock
In reply to Greg Kroah-HartmanFrom: Francesco Ruggeri <[email protected]>
[ Upstream commit 024a8168b749db7a4aa40a5fbdfa04bf7e77c1c0 ]
We observed two panics involving races with igb_reset_task. The first panic is caused by this race condition:
kworker reboot -f igb_reset_task igb_reinit_locked igb_down napi_synchronize __igb_shutdown igb_clear_interrupt_scheme igb_free_q_vectors igb_free_q_vector adapter->q_vector[v_idx] = NULL; napi_disable Panics trying to access adapter->q_vector[v_idx].napi_state
The second panic (a divide error) is caused by this race:
kworker reboot -f tx packet
igb_reset_task
__igb_shutdown rtnl_lock() ... igb_clear_interrupt_scheme igb_free_q_vectors adapter->num_tx_queues = 0 ... rtnl_unlock()
rtnl_lock()igb_reinit_lockedigb_downigb_upnetif_tx_start_all_queues
dev_hard_start_xmit igb_xmit_frame igb_tx_queue_mapping Panics on r_idx % adapter->num_tx_queues
This commit applies to igb_reset_task the same changes that were applied to ixgbe in commit 2f90b8657ec9 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver"), commit 8f4c5c9fb87a ("ixgbe: reinit_locked() should be called with rtnl_lock") and commit 88adce4ea8f9 ("ixgbe: fix possible race in reset subtask").
--- drivers/net/ethernet/intel/igb/igb_main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/intel/igb/igb_main.c +9 -0
@@ -5381,9 +5381,18 @@ static void igb_reset_task(struct work_struct *work)struct igb_adapter *adapter; adapter = container_of(work, struct igb_adapter, reset_task); +rtnl_lock (); +/* If we're already down or resetting, just bail */ +if (test_bit (__IGB_DOWN, &adapter->state) || +test_bit (__IGB_RESETTING, &adapter->state)) { +rtnl_unlock (); +return ; + } +igb_dump (adapter);netdev_err (adapter->netdev,"Reset adapter\n" );igb_reinit_locked (adapter); +rtnl_unlock (); }/**
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 68/212 atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit 51875dad43b44241b46a569493f1e4bfa0386d86 ]
atmtcp_remove_persistent() invokes atm_dev_lookup(), which returns a reference of atm_dev with increased refcount or NULL if fails.
The refcount leaks issues occur in two error handling paths. If dev_data->persist is zero or PRIV(dev)->vcc isn't NULL, the function returns 0 without decreasing the refcount kept by a local variable, resulting in refcount leaks.
Fix the issue by adding atm_dev_put() before returning 0 both when dev_data->persist is zero or PRIV(dev)->vcc isn't NULL.
--- drivers/atm/atmtcp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/atm/atmtcp.c +8 -2
@@ -432,9 +432,15 @@ static int atmtcp_remove_persistent(int itf)return -EMEDIUMTYPE ; } dev_data =PRIV (dev); -if (!dev_data->persist)return 0 ; +if (!dev_data->persist) { +atm_dev_put (dev); +return 0 ; + } dev_data->persist =0 ; -if (PRIV (dev)->vcc)return 0 ; +if (PRIV (dev)->vcc) { +atm_dev_put (dev); +return 0 ; + }kfree (dev_data);atm_dev_put (dev);atm_dev_deregister (dev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 69/212 tools lib traceevent: Fix memory leak in process_dynamic_array_len
In reply to Greg Kroah-HartmanFrom: Philippe Duplessis-Guindon <[email protected]>
[ Upstream commit e24c6447ccb7b1a01f9bf0aec94939e6450c0b4d ]
I compiled with AddressSanitizer and I had these memory leaks while I was using the tep_parse_format function:
Direct leak of 28 byte(s) in 4 object(s) allocated from:
#0 0x7fb07db49ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
#1 0x7fb07a724228 in extend_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:985
#2 0x7fb07a724c21 in __read_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1140
#3 0x7fb07a724f78 in read_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1206
#4 0x7fb07a725191 in __read_expect_type /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1291
#5 0x7fb07a7251df in read_expect_type /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1299
#6 0x7fb07a72e6c8 in process_dynamic_array_len /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:2849
#7 0x7fb07a7304b8 in process_function /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3161
#8 0x7fb07a730900 in process_arg_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3207
#9 0x7fb07a727c0b in process_arg /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1786
#10 0x7fb07a731080 in event_read_print_args /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3285
#11 0x7fb07a731722 in event_read_print /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3369
#12 0x7fb07a740054 in __tep_parse_format /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6335
#13 0x7fb07a74047a in __parse_event /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6389
#14 0x7fb07a740536 in tep_parse_format /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6431
#15 0x7fb07a785acf in parse_event ../../../src/fs-src/fs.c:251
#16 0x7fb07a785ccd in parse_systems ../../../src/fs-src/fs.c:284
#17 0x7fb07a786fb3 in read_metadata ../../../src/fs-src/fs.c:593
#18 0x7fb07a78760e in ftrace_fs_source_init ../../../src/fs-src/fs.c:727
#19 0x7fb07d90c19c in add_component_with_init_method_data ../../../../src/lib/graph/graph.c:1048
#20 0x7fb07d90c87b in add_source_component_with_initialize_method_data ../../../../src/lib/graph/graph.c:1127
#21 0x7fb07d90c92a in bt_graph_add_source_component ../../../../src/lib/graph/graph.c:1152
#22 0x55db11aa632e in cmd_run_ctx_create_components_from_config_components ../../../src/cli/babeltrace2.c:2252
#23 0x55db11aa6fda in cmd_run_ctx_create_components ../../../src/cli/babeltrace2.c:2347
#24 0x55db11aa780c in cmd_run ../../../src/cli/babeltrace2.c:2461
#25 0x55db11aa8a7d in main ../../../src/cli/babeltrace2.c:2673
#26 0x7fb07d5460b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)The token variable in the process_dynamic_array_len function is allocated in the read_expect_type function, but is not freed before calling the read_token function.
Free the token variable before calling read_token in order to plug the leak.
--- tools/lib/traceevent/event-parse.c | 1 + 1 file changed, 1 insertion(+)
tools/lib/traceevent/event-parse.c +1 -0
@@ -2764,6 +2764,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg,if (read_expected (EVENT_DELIM ,")" ) <0 ) goto out_err; +free_token (token); type =read_token (&token); *tok = token;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 70/212 xattr: break delegations in {set,remove}xattr
In reply to Greg Kroah-HartmanFrom: Frank van der Linden <[email protected]>
commit 08b5d5014a27e717826999ad20e394a8811aae92 upstream.
set/removexattr on an exported filesystem should break NFS delegations. This is true in general, but also for the upcoming support for RFC 8726 (NFSv4 extended attribute support). Make sure that they do.
Additionally, they need to grow a _locked variant, since callers might call this with i_rwsem held (like the NFS server code).
--- fs/xattr.c | 84 +++++++++++++++++++++++++++++++++++++++++++++----- include/linux/xattr.h | 2 + 2 files changed, 79 insertions(+), 7 deletions(-)
fs/xattr.c +77 -7
@@ -203,10 +203,22 @@ int __vfs_setxattr_noperm(struct dentryreturn error; } - +/** +* __vfs_setxattr_locked: set an extended attribute while holding the inode +* lock +* +* @dentry - object to perform setxattr on +* @name - xattr name to set +* @value - value to set @name to +* @size - size of @value +* @flags - flags to pass into filesystem operations +* @delegated_inode - on return, will contain an inode pointer that +* a delegation was broken on, NULL if none. +*/ int -vfs_setxattr (struct dentry *dentry,const char *name,const void *value, -size_t size,int flags) +__vfs_setxattr_locked (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags, +struct inode **delegated_inode) {struct inode *inode = dentry->d_inode;int error;
@@ -215,15 +227,40 @@ vfs_setxattr(struct dentry *dentry, consif (error)return error; -inode_lock (inode); error =security_inode_setxattr (dentry, name, value, size, flags);if (error) goto out; + error =try_break_deleg (inode, delegated_inode); +if (error) + goto out; + error =__vfs_setxattr_noperm (dentry, name, value, size, flags); out: +return error; +} +EXPORT_SYMBOL_GPL (__vfs_setxattr_locked); + +int +vfs_setxattr (struct dentry *dentry,const char *name,const void *value, +size_t size,int flags) +{ +struct inode *inode = dentry->d_inode; +struct inode *delegated_inode =NULL ; +int error; + +retry_deleg: +inode_lock (inode); + error =__vfs_setxattr_locked (dentry, name, value, size, flags, + &delegated_inode);inode_unlock (inode); + +if (delegated_inode) { + error =break_deleg_wait (&delegated_inode); +if (!error) + goto retry_deleg; + }return error; }EXPORT_SYMBOL_GPL (vfs_setxattr);
@@ -379,8 +416,18 @@ __vfs_removexattr(struct dentry *dentry, }EXPORT_SYMBOL (__vfs_removexattr); +/** +* __vfs_removexattr_locked: set an extended attribute while holding the inode +* lock +* +* @dentry - object to perform setxattr on +* @name - name of xattr to remove +* @delegated_inode - on return, will contain an inode pointer that +* a delegation was broken on, NULL if none. +*/ int -vfs_removexattr (struct dentry *dentry,const char *name) +__vfs_removexattr_locked (struct dentry *dentry,const char *name, +struct inode **delegated_inode) {struct inode *inode = dentry->d_inode;int error;
@@ -389,11 +436,14 @@ vfs_removexattr(struct dentry *dentry, cif (error)return error; -inode_lock (inode); error =security_inode_removexattr (dentry, name);if (error) goto out; + error =try_break_deleg (inode, delegated_inode); +if (error) + goto out; + error =__vfs_removexattr (dentry, name);if (!error) {
@@ -402,12 +452,32 @@ vfs_removexattr(struct dentry *dentry, c } out: +return error; +} +EXPORT_SYMBOL_GPL (__vfs_removexattr_locked); + +int +vfs_removexattr (struct dentry *dentry,const char *name) +{ +struct inode *inode = dentry->d_inode; +struct inode *delegated_inode =NULL ; +int error; + +retry_deleg: +inode_lock (inode); + error =__vfs_removexattr_locked (dentry, name, &delegated_inode);inode_unlock (inode); + +if (delegated_inode) { + error =break_deleg_wait (&delegated_inode); +if (!error) + goto retry_deleg; + } +return error; }EXPORT_SYMBOL_GPL (vfs_removexattr); -/* * Extended attribute SET operations */
include/linux/xattr.h +2 -0
@@ -51,8 +51,10 @@ ssize_t vfs_getxattr(struct dentry *, cossize_t vfs_listxattr (struct dentry *d,char *list,size_t size);int __vfs_setxattr (struct dentry *,struct inode *,const char *,const void *,size_t ,int );int __vfs_setxattr_noperm (struct dentry *,const char *,const void *,size_t ,int ); +int __vfs_setxattr_locked (struct dentry *,const char *,const void *,size_t ,int ,struct inode **);int vfs_setxattr (struct dentry *,const char *,const void *,size_t ,int );int __vfs_removexattr (struct dentry *,const char *); +int __vfs_removexattr_locked (struct dentry *,const char *,struct inode **);int vfs_removexattr (struct dentry *,const char *);ssize_t generic_listxattr (struct dentry *dentry,char *buffer,size_t buffer_size);
Greg Kroah-Hartman
maintainerPATCH 71/212 binder: Prevent context manager from incrementing ref 0
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit 4b836a1426cb0f1ef2a6e211d7e553221594f8fc upstream.
Binder is designed such that a binder_proc never has references to itself. If this rule is violated, memory corruption can occur when a process sends a transaction to itself; see e.g.
<https://syzkaller.appspot.com/bug?extid=09e05aba06723a94d43d>.
There is a remaining edgecase through which such a transaction-to-self can still occur from the context of a task with BINDER_SET_CONTEXT_MGR access:
- task A opens /dev/binder twice, creating binder_proc instances P1 and P2
- P1 becomes context manager
- P2 calls ACQUIRE on the magic handle 0, allocating index 0 in its handle table
- P1 dies (by closing the /dev/binder fd and waiting a bit)
- P2 becomes context manager
- P2 calls ACQUIRE on the magic handle 0, allocating index 1 in its handle table
[this triggers a warning: "binder: 1974:1974 tried to acquire reference to desc 0, got 1 instead"]
- task B opens /dev/binder once, creating binder_proc instance P3
- P3 calls P2 (via magic handle 0) with (void*)1 as argument (two-way transaction)
- P2 receives the handle and uses it to call P3 (two-way transaction)
- P3 calls P2 (via magic handle 0) (two-way transaction)
- P2 calls P2 (via handle 1) (two-way transaction)
And then, if P2 does *NOT* accept the incoming transaction work, but instead closes the binder fd, we get a crash.
Solve it by preventing the context manager from using ACQUIRE on ref 0. There shouldn't be any legitimate reason for the context manager to do that.
Additionally, print a warning if someone manages to find another way to trigger a transaction-to-self bug in the future.
[manual backport: remove fine-grained locking and error reporting that
don't exist in <=4.9]
--- drivers/android/binder.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/android/binder.c +9 -0
@@ -1427,6 +1427,10 @@ static void binder_transaction(struct bi return_error =BR_DEAD_REPLY ; goto err_dead_binder; } +if (WARN_ON (proc == target_proc)) { + return_error =BR_FAILED_REPLY ; + goto err_invalid_target_handle; + }if (security_binder_transaction (proc->tsk, target_proc->tsk) <0 ) { return_error =BR_FAILED_REPLY ;
@@ -1830,6 +1834,11 @@ static int binder_thread_write(struct bi ptr +=sizeof (uint32_t );if (target ==0 && binder_context_mgr_node && (cmd ==BC_INCREFS || cmd ==BC_ACQUIRE )) { +if (binder_context_mgr_node->proc == proc) { +binder_user_error ("%d:%d context manager tried to acquire desc 0\n" , + proc->pid, thread->pid); +return -EINVAL ; + } ref =binder_get_ref_for_node (proc, binder_context_mgr_node);if (ref->desc != target) {
Greg Kroah-Hartman
maintainerPATCH 72/212 ipv4: Silence suspicious RCU usage warning
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 83f3522860f702748143e022f1a546547314c715 ]
fib_trie_unmerge() is called with RTNL held, but not from an RCU read-side critical section. This leads to the following warning [1] when the FIB alias list in a leaf is traversed with hlist_for_each_entry_rcu().
Since the function is always called with RTNL held and since modification of the list is protected by RTNL, simply use hlist_for_each_entry() and silence the warning.
[1]
WARNING: suspicious RCU usage 5.8.0-rc4-custom-01520-gc1f937f3f83b #30 Not tainted
-----------------------------net/ipv4/fib_trie.c:1867 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by ip/164:
#0: ffffffff85a27850 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x49a/0xbd0
stack backtrace: CPU: 0 PID: 164 Comm: ip Not tainted 5.8.0-rc4-custom-01520-gc1f937f3f83b #30 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014 Call Trace: dump_stack+0x100/0x184 lockdep_rcu_suspicious+0x153/0x15d fib_trie_unmerge+0x608/0xdb0 fib_unmerge+0x44/0x360 fib4_rule_configure+0xc8/0xad0 fib_nl_newrule+0x37a/0x1dd0 rtnetlink_rcv_msg+0x4f7/0xbd0 netlink_rcv_skb+0x17a/0x480 rtnetlink_rcv+0x22/0x30 netlink_unicast+0x5ae/0x890 netlink_sendmsg+0x98a/0xf40 ____sys_sendmsg+0x879/0xa00 ___sys_sendmsg+0x122/0x190 __sys_sendmsg+0x103/0x1d0 __x64_sys_sendmsg+0x7d/0xb0 do_syscall_64+0x54/0xa0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fc80a234e97 Code: Bad RIP value. RSP: 002b:00007ffef8b66798 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc80a234e97 RDX: 0000000000000000 RSI: 00007ffef8b66800 RDI: 0000000000000003 RBP: 000000005f141b1c R08: 0000000000000001 R09: 0000000000000000 R10: 00007fc80a2a8ac0 R11: 0000000000000246 R12: 0000000000000001 R13: 0000000000000000 R14: 00007ffef8b67008 R15: 0000556fccb10020
--- net/ipv4/fib_trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fib_trie.c +1 -1
@@ -1719,7 +1719,7 @@ struct fib_table *fib_trie_unmerge(strucwhile ((l =leaf_walk_rcu (&tp, key)) !=NULL ) {struct key_vector *local_l =NULL , *local_tp; -hlist_for_each_entry_rcu (fa, &l->leaf, fa_list) { +hlist_for_each_entry (fa, &l->leaf, fa_list) {struct fib_alias *new_fa;if (local_tb->tb_id != fa->tb_id)
Greg Kroah-Hartman
maintainerPATCH 73/212 ipv6: fix memory leaks on IPV6_ADDRFORM path
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 8c0de6e96c9794cb523a516c465991a70245da1c ]
IPV6_ADDRFORM causes resource leaks when converting an IPv6 socket to IPv4, particularly struct ipv6_ac_socklist. Similar to struct ipv6_mc_socklist, we should just close it on this path.
This bug can be easily reproduced with the following C program:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main()
{
int s, value;
struct sockaddr_in6 addr;
struct ipv6_mreq m6; s = socket(AF_INET6, SOCK_DGRAM, 0);
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(5000);
inet_pton(AF_INET6, "::ffff:192.168.122.194", &addr.sin6_addr);
connect(s, (struct sockaddr *)&addr, sizeof(addr));
inet_pton(AF_INET6, "fe80::AAAA", &m6.ipv6mr_multiaddr);
m6.ipv6mr_interface = 5;
setsockopt(s, SOL_IPV6, IPV6_JOIN_ANYCAST, &m6, sizeof(m6));
value = AF_INET;
setsockopt(s, SOL_IPV6, IPV6_ADDRFORM, &value, sizeof(value));
close(s);
return 0;}
--- include/net/addrconf.h | 1 + net/ipv6/anycast.c | 17 ++++++++++++----- net/ipv6/ipv6_sockglue.c | 1 + 3 files changed, 14 insertions(+), 5 deletions(-)
include/net/addrconf.h +1 -0
@@ -253,6 +253,7 @@ int ipv6_sock_ac_join(struct sock *sk, i const struct in6_addr *addr);int ipv6_sock_ac_drop (struct sock *sk,int ifindex,const struct in6_addr *addr); +void __ipv6_sock_ac_close (struct sock *sk);void ipv6_sock_ac_close (struct sock *sk);int __ipv6_dev_ac_inc (struct inet6_dev *idev,const struct in6_addr *addr);
net/ipv6/anycast.c +12 -5
@@ -170,7 +170,7 @@ int ipv6_sock_ac_drop(struct sock *sk, ireturn 0 ; } -void ipv6_sock_ac_close (struct sock *sk) +void __ipv6_sock_ac_close (struct sock *sk) {struct ipv6_pinfo *np =inet6_sk (sk);struct net_device *dev =NULL ;
@@ -178,10 +178,7 @@ void ipv6_sock_ac_close(struct sock *sk)struct net *net =sock_net (sk);int prev_index; -if (!np->ipv6_ac_list) -return ; - -rtnl_lock (); +ASSERT_RTNL (); pac = np->ipv6_ac_list; np->ipv6_ac_list =NULL ;
@@ -198,6 +195,16 @@ void ipv6_sock_ac_close(struct sock *sk)sock_kfree_s (sk, pac,sizeof (*pac)); pac = next; } +} + +void ipv6_sock_ac_close (struct sock *sk) +{ +struct ipv6_pinfo *np =inet6_sk (sk); + +if (!np->ipv6_ac_list) +return ; +rtnl_lock (); +__ipv6_sock_ac_close (sk);rtnl_unlock (); }
net/ipv6/ipv6_sockglue.c +1 -0
@@ -206,6 +206,7 @@ static int do_ipv6_setsockopt(struct socfl6_free_socklist (sk);__ipv6_sock_mc_close (sk); +__ipv6_sock_ac_close (sk);/* * Sock is moving from IPv6 to IPv4 (sk_prot), so
Greg Kroah-Hartman
maintainerPATCH 74/212 vxlan: Ensure FDB dump is performed under RCU
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit b5141915b5aec3b29a63db869229e3741ebce258 ]
The commit cited below removed the RCU read-side critical section from rtnl_fdb_dump() which means that the ndo_fdb_dump() callback is invoked without RCU protection.
This results in the following warning [1] in the VXLAN driver, which relied on the callback being invoked from an RCU read-side critical section.
Fix this by calling rcu_read_lock() in the VXLAN driver, as already done in the bridge driver.
[1]
WARNING: suspicious RCU usage 5.8.0-rc4-custom-01521-g481007553ce6 #29 Not tainted
-----------------------------drivers/net/vxlan.c:1379 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by bridge/166:
#0: ffffffff85a27850 (rtnl_mutex){+.+.}-{3:3}, at: netlink_dump+0xea/0x1090
stack backtrace: CPU: 1 PID: 166 Comm: bridge Not tainted 5.8.0-rc4-custom-01521-g481007553ce6 #29 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014 Call Trace: dump_stack+0x100/0x184 lockdep_rcu_suspicious+0x153/0x15d vxlan_fdb_dump+0x51e/0x6d0 rtnl_fdb_dump+0x4dc/0xad0 netlink_dump+0x540/0x1090 __netlink_dump_start+0x695/0x950 rtnetlink_rcv_msg+0x802/0xbd0 netlink_rcv_skb+0x17a/0x480 rtnetlink_rcv+0x22/0x30 netlink_unicast+0x5ae/0x890 netlink_sendmsg+0x98a/0xf40 __sys_sendto+0x279/0x3b0 __x64_sys_sendto+0xe6/0x1a0 do_syscall_64+0x54/0xa0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fe14fa2ade0 Code: Bad RIP value. RSP: 002b:00007fff75bb5b88 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00005614b1ba0020 RCX: 00007fe14fa2ade0 RDX: 000000000000011c RSI: 00007fff75bb5b90 RDI: 0000000000000003 RBP: 00007fff75bb5b90 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00005614b1b89160 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
--- drivers/net/vxlan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/vxlan.c +5 -1
@@ -889,6 +889,7 @@ static int vxlan_fdb_dump(struct sk_bufffor (h =0 ; h <FDB_HASH_SIZE ; ++h) {struct vxlan_fdb *f; +rcu_read_lock ();hlist_for_each_entry_rcu (f, &vxlan->fdb_head[h], hlist) {struct vxlan_rdst *rd;
@@ -901,12 +902,15 @@ static int vxlan_fdb_dump(struct sk_buff cb->nlh->nlmsg_seq,RTM_NEWNEIGH , NLM_F_MULTI, rd); -if (err <0 ) +if (err <0 ) { +rcu_read_unlock (); goto out; + } skip: *idx +=1 ; } } +rcu_read_unlock (); } out:return err;
Greg Kroah-Hartman
maintainerPATCH 75/212 net: lan78xx: replace bogus endpoint lookup
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit ea060b352654a8de1e070140d25fe1b7e4d50310 ]
Drop the bogus endpoint-lookup helper which could end up accepting interfaces based on endpoints belonging to unrelated altsettings.
Note that the returned bulk pipes and interrupt endpoint descriptor were never actually used. Instead the bulk-endpoint numbers are hardcoded to 1 and 2 (matching the specification), while the interrupt- endpoint descriptor was assumed to be the third descriptor created by USB core.
Try to bring some order to this by dropping the bogus lookup helper and adding the missing endpoint sanity checks while keeping the interrupt- descriptor assumption for now.
--- drivers/net/usb/lan78xx.c | 117 +++++++++++----------------------------------- 1 file changed, 30 insertions(+), 87 deletions(-)
drivers/net/usb/lan78xx.c +30 -87
@@ -315,10 +315,6 @@ struct lan78xx_net {struct tasklet_struct bh;struct delayed_work wq; -struct usb_host_endpoint *ep_blkin; -struct usb_host_endpoint *ep_blkout; -struct usb_host_endpoint *ep_intr; -int msg_enable;struct urb *urb_intr;
@@ -2554,78 +2550,12 @@ lan78xx_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } -static int -lan78xx_get_endpoints (struct lan78xx_net *dev,struct usb_interface *intf) -{ -int tmp; -struct usb_host_interface *alt =NULL ; -struct usb_host_endpoint *in =NULL , *out =NULL ; -struct usb_host_endpoint *status =NULL ; - -for (tmp =0 ; tmp < intf->num_altsetting; tmp++) { -unsigned ep; - - in =NULL ; - out =NULL ; - status =NULL ; - alt = intf->altsetting + tmp; - -for (ep =0 ; ep < alt->desc.bNumEndpoints; ep++) { -struct usb_host_endpoint *e; -int intr =0 ; - - e = alt->endpoint + ep; -switch (e->desc.bmAttributes) { -case USB_ENDPOINT_XFER_INT : -if (!usb_endpoint_dir_in (&e->desc)) -continue ; - intr =1 ; -/* FALLTHROUGH */ -case USB_ENDPOINT_XFER_BULK : -break ; -default : -continue ; - } -if (usb_endpoint_dir_in (&e->desc)) { -if (!intr && !in) - in = e; -else if (intr && !status) - status = e; - }else { -if (!out) - out = e; - } - } -if (in && out) -break ; - } -if (!alt || !in || !out) -return -EINVAL ; - - dev->pipe_in =usb_rcvbulkpipe (dev->udev, - in->desc.bEndpointAddress & -USB_ENDPOINT_NUMBER_MASK ); - dev->pipe_out =usb_sndbulkpipe (dev->udev, - out->desc.bEndpointAddress & -USB_ENDPOINT_NUMBER_MASK ); - dev->ep_intr = status; - -return 0 ; -} -static int lan78xx_bind (struct lan78xx_net *dev,struct usb_interface *intf) {struct lan78xx_priv *pdata =NULL ;int ret;int i; - ret =lan78xx_get_endpoints (dev, intf); -if (ret) { -netdev_warn (dev->net,"lan78xx_get_endpoints failed: %d\n" , - ret); -return ret; - } - dev->data[0 ] = (unsigned long )kzalloc (sizeof (*pdata),GFP_KERNEL ); pdata = (struct lan78xx_priv *)(dev->data[0 ]);
@@ -3333,6 +3263,7 @@ static void lan78xx_stat_monitor(unsignestatic int lan78xx_probe (struct usb_interface *intf,const struct usb_device_id *id) { +struct usb_host_endpoint *ep_blkin, *ep_blkout, *ep_intr;struct lan78xx_net *dev;struct net_device *netdev;struct usb_device *udev;
@@ -3383,32 +3314,44 @@ static int lan78xx_probe(struct usb_intemutex_init (&dev->stats.access_lock); - ret =lan78xx_bind (dev, intf); -if (ret <0 ) - goto out2; -strcpy (netdev->name,"eth%d" ); - -if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) - netdev->mtu = dev->hard_mtu - netdev->hard_header_len; -netif_set_gso_max_size (netdev,MAX_SINGLE_PACKET_SIZE -MAX_HEADER ); -if (intf->cur_altsetting->desc.bNumEndpoints <3 ) { ret = -ENODEV ; - goto out3; + goto out2; } - dev->ep_blkin = (intf->cur_altsetting)->endpoint +0 ; - dev->ep_blkout = (intf->cur_altsetting)->endpoint +1 ; - dev->ep_intr = (intf->cur_altsetting)->endpoint +2 ; - dev->pipe_in =usb_rcvbulkpipe (udev,BULK_IN_PIPE ); + ep_blkin =usb_pipe_endpoint (udev, dev->pipe_in); +if (!ep_blkin || !usb_endpoint_is_bulk_in (&ep_blkin->desc)) { + ret = -ENODEV ; + goto out2; + } + dev->pipe_out =usb_sndbulkpipe (udev,BULK_OUT_PIPE ); + ep_blkout =usb_pipe_endpoint (udev, dev->pipe_out); +if (!ep_blkout || !usb_endpoint_is_bulk_out (&ep_blkout->desc)) { + ret = -ENODEV ; + goto out2; + } + + ep_intr = &intf->cur_altsetting->endpoint[2 ]; +if (!usb_endpoint_is_int_in (&ep_intr->desc)) { + ret = -ENODEV ; + goto out2; + } dev->pipe_intr =usb_rcvintpipe (dev->udev, - dev->ep_intr->desc.bEndpointAddress & -USB_ENDPOINT_NUMBER_MASK ); - period = dev->ep_intr->desc.bInterval; +usb_endpoint_num (&ep_intr->desc)); + + ret =lan78xx_bind (dev, intf); +if (ret <0 ) + goto out2; +strcpy (netdev->name,"eth%d" ); + +if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) + netdev->mtu = dev->hard_mtu - netdev->hard_header_len; +netif_set_gso_max_size (netdev,MAX_SINGLE_PACKET_SIZE -MAX_HEADER ); + period = ep_intr->desc.bInterval; maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); buf =kmalloc (maxp,GFP_KERNEL );if (buf) {
Greg Kroah-Hartman
maintainerPATCH 76/212 Revert "vxlan: fix tos value before xmit"
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit a0dced17ad9dc08b1b25e0065b54c97a318e6e8b ]
This reverts commit 71130f29979c7c7956b040673e6b9d5643003176.
In commit 71130f29979c ("vxlan: fix tos value before xmit") we want to make sure the tos value are filtered by RT_TOS() based on RFC1349.
0 1 2 3 4 5 6 7
+-----+-----+-----+-----+-----+-----+-----+-----+
| PRECEDENCE | TOS | MBZ |
+-----+-----+-----+-----+-----+-----+-----+-----+
But RFC1349 has been obsoleted by RFC2474. The new DSCP field defined like
0 1 2 3 4 5 6 7
+-----+-----+-----+-----+-----+-----+-----+-----+
| DS FIELD, DSCP | ECN FIELD |
+-----+-----+-----+-----+-----+-----+-----+-----+
So with
IPTOS_TOS_MASK 0x1ERT_TOS(tos) ((tos)&IPTOS_TOS_MASK)
the first 3 bits DSCP info will get lost.
To take all the DSCP info in xmit, we should revert the patch and just push all tos bits to ip_tunnel_ecn_encap(), which will handling ECN field later.
--- drivers/net/vxlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/vxlan.c +2 -2
@@ -2110,7 +2110,7 @@ static void vxlan_xmit_one(struct sk_bufelse if (info->key.tun_flags &TUNNEL_DONT_FRAGMENT ) df =htons (IP_DF ); - tos =ip_tunnel_ecn_encap (RT_TOS (tos), old_iph, skb); + tos =ip_tunnel_ecn_encap (tos, old_iph, skb); ttl = ttl ? :ip4_dst_hoplimit (&rt->dst); err =vxlan_build_skb (skb, &rt->dst,sizeof (struct iphdr ), vni, md, flags, udp_sum);
@@ -2169,7 +2169,7 @@ static void vxlan_xmit_one(struct sk_bufif (!info) udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM6_TX ); - tos =ip_tunnel_ecn_encap (RT_TOS (tos), old_iph, skb); + tos =ip_tunnel_ecn_encap (tos, old_iph, skb); ttl = ttl ? :ip6_dst_hoplimit (ndst);skb_scrub_packet (skb, xnet); err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr),
Greg Kroah-Hartman
maintainerPATCH 77/212 usb: hso: check for return value in hso_serial_common_create()
In reply to Greg Kroah-HartmanFrom: Rustam Kovhaev <[email protected]>
[ Upstream commit e911e99a0770f760377c263bc7bac1b1593c6147 ]
in case of an error tty_register_device_attr() returns ERR_PTR(), add IS_ERR() check
--- drivers/net/usb/hso.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/hso.c +4 -1
@@ -2274,12 +2274,14 @@ static int hso_serial_common_create(stru minor =get_free_serial_index ();if (minor <0 ) - goto exit; + goto exit2;/* register our minor number */ serial->parent->dev =tty_port_register_device_attr (&serial->port, tty_drv, minor, &serial->parent->interface->dev, serial->parent, hso_serial_dev_groups); +if (IS_ERR (serial->parent->dev)) + goto exit2; dev = serial->parent->dev;/* fill in specific data for later use */
@@ -2325,6 +2327,7 @@ static int hso_serial_common_create(strureturn 0 ; exit:hso_serial_tty_unregister (serial); +exit2:hso_serial_common_free (serial);return -1 ; }
Greg Kroah-Hartman
maintainerPATCH 78/212 Smack: fix use-after-free in smk_write_relabel_self()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit beb4ee6770a89646659e6a2178538d2b13e2654e upstream.
smk_write_relabel_self() frees memory from the task's credentials with no locking, which can easily cause a use-after-free because multiple tasks can share the same credentials structure.
Fix this by using prepare_creds() and commit_creds() to correctly modify the task's credentials.
Reproducer for "BUG: KASAN: use-after-free in smk_write_relabel_self":
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
static void *thrproc(void *arg)
{
int fd = open("/sys/fs/smackfs/relabel-self", O_WRONLY);
for (;;) write(fd, "foo", 3);
}
int main()
{
pthread_t t;
pthread_create(&t, NULL, thrproc, NULL);
thrproc(NULL);
}--- security/smack/smackfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
security/smack/smackfs.c +11 -2
@@ -2741,7 +2741,6 @@ static int smk_open_relabel_self(structstatic ssize_t smk_write_relabel_self (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct task_smack *tsp =current_security ();char *data;int rc;LIST_HEAD (list_tmp);
@@ -2766,11 +2765,21 @@ static ssize_t smk_write_relabel_self(stkfree (data);if (!rc || (rc == -EINVAL &&list_empty (&list_tmp))) { +struct cred *new; +struct task_smack *tsp; + + new =prepare_creds (); +if (!new) { + rc = -ENOMEM ; + goto out; + } + tsp = new->security;smk_destroy_label_list (&tsp->smk_relabel);list_splice (&list_tmp, &tsp->smk_relabel); +commit_creds (new);return count; } - +out:smk_destroy_label_list (&list_tmp);return rc; }
Greg Kroah-Hartman
maintainerPATCH 79/212 tracepoint: Mark __tracepoint_strings __used
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
commit f3751ad0116fb6881f2c3c957d66a9327f69cefb upstream.
__tracepoint_string's have their string data stored in .rodata, and an address to that data stored in the "__tracepoint_str" section. Functions that refer to those strings refer to the symbol of the address. Compiler optimization can replace those address references with references directly to the string data. If the address doesn't appear to have other uses, then it appears dead to the compiler and is removed. This can break the /tracing/printk_formats sysfs node which iterates the addresses stored in the "__tracepoint_str" section.
Like other strings stored in custom sections in this header, mark these __used to inform the compiler that there are other non-obvious users of the address, so they should still be emitted.
--- include/linux/tracepoint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/tracepoint.h +1 -1
@@ -314,7 +314,7 @@ extern void syscall_unregfunc(void); static const char *___tp_str __tracepoint_string = str; \ ___tp_str; \ }) -#define __tracepoint_string __attribute__((section("__tracepoint_str"))) +#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))#else /* * tracepoint_string() is used to save the string address for userspace
Greg Kroah-Hartman
maintainerPATCH 80/212 gpio: fix oops resulting from calling of_get_named_gpio(NULL, ...)
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
This happens for the spi-imx driver when running a dt-enabled kernel on a non-dt machine on Linux 4.0. Among the still supported stable versions only 4.4 and 4.9 are affected. (However the spi-imx driver doesn't call of_get_named_gpio() since v4.8-rc1 (commit b36581df7e78 ("spi: imx:
Using existing properties for chipselects")) any more, but the problem might still affect other users of of_get_named_gpio().)
In 4.14-rc1 this problem is gone with
commit 7eb6ce2f2723 ("gpio: Convert to using %pOF instead of full_name"). This commit however doesn't seem sensible to backport as it depends on ce4fecf1fe15 ("vsprintf: Add %p extension "%pOF" for device tree") which doesn't trivially apply to v4.4.
[ 1.649453] Unable to handle kernel NULL pointer dereference at virtual address 0000000c [ 1.659270] pgd = c0004000 [ 1.662036] [0000000c] *pgd=00000000 [ 1.665919] Internal error: Oops - BUG: 5 [#1] PREEMPT ARM [ 1.671438] Modules linked in: [ 1.674552] CPU: 0 PID: 1 Comm: swapper Not tainted 4.0.0 #1 [ 1.680235] Hardware name: Eckelmann ECU01 [ 1.684361] task: c7840000 ti: c7842000 task.ti: c7842000 [ 1.689821] PC is at of_get_named_gpiod_flags+0xac/0xe0 [ 1.695104] LR is at of_find_property+0x38/0x7c [ 1.699674] pc : [<c025db2c>] lr : [<c03c5f54>] psr: a0000013 [ 1.699674] sp : c7843cc8 ip : c7843c38 fp : c7843d3c [ 1.711183] r10: c7884dc0 r9 : c7a8de10 r8 : 00000000 [ 1.716434] r7 : 00000000 r6 : 00000000 r5 : c065ef50 r4 : fffffffe [ 1.722986] r3 : 00000000 r2 : 00000000 r1 : c065ef50 r0 : fffffffe [ 1.729541] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 1.736879] Control: 0005317f Table: 80004000 DAC: 00000017 [ 1.742652] Process swapper (pid: 1, stack limit = 0xc7842190) [ 1.748510] Stack: (0xc7843cc8 to 0xc7844000) [ 1.752906] 3cc0: c7843cd4 c003ccec 00000000 00000000 00000000 00000000 [ 1.761125] 3ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 1.769345] 3d00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fffffdfb [ 1.777566] 3d20: 00000000 c78b4e10 c7a8dc00 000001ff c7843d4c c7843d40 c025db70 c025da90 [ 1.785788] 3d40: c7843dcc c7843d50 c02f8938 c025db70 c7843d74 c7843d60 c79bc3c0 c79bc320 [ 1.794007] 3d60: c78bb140 c065476c c7a8de10 00000000 c78b4e10 c78b4e00 00000004 00000001 [ 1.802227] 3d80: c06d25d4 00000000 c7843dbc c7843d98 c0115a68 c0112538 00000001 c78b4e10 [ 1.810448] 3da0: c78b4e18 ffffffed c78b4e10 fffffdfb c070bc80 00000000 c06d25d4 00000000 [ 1.818669] 3dc0: c7843dec c7843dd0 c02a0670 c02f8828 c78b4e10 c073fcb0 00000000 c070bc80 [ 1.826890] 3de0: c7843e14 c7843df0 c029f064 c02a0630 00000000 c78b4e10 c070bc80 c78b4e44 [ 1.835110] 3e00: 00000000 c06c8cac c7843e34 c7843e18 c029f204 c029ef70 c029f170 00000000 [ 1.843332] 3e20: c070bc80 c029f170 c7843e5c c7843e38 c029d6f4 c029f180 c785c1cc c7873c30 [ 1.851553] 3e40: c0235728 c070bc80 c7ab9720 c0701e20 c7843e6c c7843e60 c029eb74 c029d6a4 [ 1.859774] 3e60: c7843e94 c7843e70 c029e7f4 c029eb64 c065f390 c7843e80 c070bc80 c06f0718 [ 1.867998] 3e80: c7ab8d60 c06b1528 c7843eac c7843e98 c029f810 c029e728 c06f0718 c06f0718 [ 1.876220] 3ea0: c7843ebc c7843eb0 c02a04dc c029f7ac c7843ecc c7843ec0 c06c8cc4 c02a049c [ 1.884443] 3ec0: c7843f4c c7843ed0 c00089dc c06c8cbc c0109ec0 c0109d18 c780ac00 00000001 [ 1.892665] 3ee0: c7843f00 c7843ef0 c06b1544 c0238a24 c7ffca48 c054c854 c7843f4c c7843f08 [ 1.900886] 3f00: c002e7f4 c06b1538 c003d0e0 00000006 00000006 c06af1a4 00000000 c066ccb4 [ 1.909107] 3f20: c7843f4c c06ea994 00000006 c071ff20 c06b1528 c06d25e0 c06d25d4 0000008f [ 1.917327] 3f40: c7843f94 c7843f50 c06b1e6c c0008964 00000006 00000006 c06b1528 dfe48a08 [ 1.925547] 3f60: 33f73660 3fd760c5 0b5d4bfd 00000000 c0527ef0 00000000 00000000 00000000 [ 1.933768] 3f80: 00000000 00000000 c7843fac c7843f98 c0527f00 c06b1d00 c7842000 00000000 [ 1.941988] 3fa0: 00000000 c7843fb0 c0009798 c0527f00 00000000 00000000 00000000 00000000 [ 1.950206] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 1.958424] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 b3cf731f fe6afeef [ 1.966617] Backtrace: [ 1.969150] [<c025da80>] (of_get_named_gpiod_flags) from [<c025db70>] (of_get_named_gpio_flags+0x10/0x24) [ 1.978744] r7:000001ff r6:c7a8dc00 r5:c78b4e10 r4:00000000 [ 1.984548] [<c025db60>] (of_get_named_gpio_flags) from [<c02f8938>] (spi_imx_probe+0x120/0x67c) [ 1.993390] [<c02f8818>] (spi_imx_probe) from [<c02a0670>] (platform_drv_probe+0x50/0xac) [ 2.001589] r10:00000000 r9:c06d25d4 r8:00000000 r7:c070bc80 r6:fffffdfb r5:c78b4e10 [ 2.009549] r4:ffffffed [ 2.012144] [<c02a0620>] (platform_drv_probe) from [<c029f064>] (driver_probe_device+0x104/0x210) [ 2.021040] r7:c070bc80 r6:00000000 r5:c073fcb0 r4:c78b4e10 [ 2.026822] [<c029ef60>] (driver_probe_device) from [<c029f204>] (__driver_attach+0x94/0x98) [ 2.035282] r8:c06c8cac r7:00000000 r6:c78b4e44 r5:c070bc80 r4:c78b4e10 r3:00000000 [ 2.043191] [<c029f170>] (__driver_attach) from [<c029d6f4>] (bus_for_each_dev+0x60/0x90) [ 2.051394] r6:c029f170 r5:c070bc80 r4:00000000 r3:c029f170 [ 2.057185] [<c029d694>] (bus_for_each_dev) from [<c029eb74>] (driver_attach+0x20/0x28) [ 2.065212] r6:c0701e20 r5:c7ab9720 r4:c070bc80 [ 2.069931] [<c029eb54>] (driver_attach) from [<c029e7f4>] (bus_add_driver+0xdc/0x1dc) [ 2.077894] [<c029e718>] (bus_add_driver) from [<c029f810>] (driver_register+0x74/0xec) [ 2.085919] r7:c06b1528 r6:c7ab8d60 r5:c06f0718 r4:c070bc80 [ 2.091705] [<c029f79c>] (driver_register) from [<c02a04dc>] (__platform_driver_register+0x50/0x64) [ 2.100774] r5:c06f0718 r4:c06f0718 [ 2.104437] [<c02a048c>] (__platform_driver_register) from [<c06c8cc4>] (spi_imx_driver_init+0x18/0x20) [ 2.113884] [<c06c8cac>] (spi_imx_driver_init) from [<c00089dc>] (do_one_initcall+0x88/0x1b0) [ 2.122459] [<c0008954>] (do_one_initcall) from [<c06b1e6c>] (kernel_init_freeable+0x17c/0x248) [ 2.131182] r10:0000008f r9:c06d25d4 r8:c06d25e0 r7:c06b1528 r6:c071ff20 r5:00000006 [ 2.139141] r4:c06ea994 [ 2.141751] [<c06b1cf0>] (kernel_init_freeable) from [<c0527f00>] (kernel_init+0x10/0xec) [ 2.149955] r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0527ef0 [ 2.157909] r4:00000000 [ 2.160508] [<c0527ef0>] (kernel_init) from [<c0009798>] (ret_from_fork+0x14/0x3c) [ 2.168099] r4:00000000 r3:c7842000 [ 2.171755] Code: eb0b2dc2 e51b0020 e24bd01c e89da8f0 (e597300c)
--- drivers/gpio/gpiolib-of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-of.c +1 -1
@@ -80,7 +80,7 @@ struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, &gpiospec);if (ret) {pr_debug ("%s: can't parse '%s' property of node '%s[%d]'\n" , - __func__, propname, np->full_name, index); + __func__, propname, np ? np->full_name :NULL , index);return ERR_PTR (ret); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 81/212 cgroup: add missing skcd->no_refcnt check in cgroup_sk_clone()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
Add skcd->no_refcnt check which is missed when backporting ad0f75e5f57c ("cgroup: fix cgroup_sk_alloc() for sk_clone_lock()").
This patch is needed in stable-4.9, stable-4.14 and stable-4.19.
--- kernel/cgroup.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/cgroup.c +2 -0
@@ -6355,6 +6355,8 @@ void cgroup_sk_clone(struct sock_cgroup_data *skcd) {/* Socket clone path */ if (skcd->val) { +if (skcd->no_refcnt) +return ;/* * We might be cloning a socket which is left in an empty * cgroup and the cgroup might have already been rmdir'd.
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 82/212 EDAC: Fix reference count leaks
In reply to Greg Kroah-HartmanFrom: Qiushi Wu <[email protected]>
[ Upstream commit 17ed808ad243192fb923e4e653c1338d3ba06207 ]
When kobject_init_and_add() returns an error, it should be handled because kobject_init_and_add() takes a reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object.
Therefore, replace calling kfree() and call kobject_put() and add a missing kobject_put() in the edac_device_register_sysfs_main_kobj() error path.
[ bp: Massage and merge into a single patch. ]
--- drivers/edac/edac_device_sysfs.c | 1 + drivers/edac/edac_pci_sysfs.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/edac/edac_device_sysfs.c +1 -0
@@ -275,6 +275,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)/* Error exit stack */ err_kobj_reg: +kobject_put (&edac_dev->kobj);module_put (edac_dev->owner); err_out:
drivers/edac/edac_pci_sysfs.c +1 -1
@@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void)/* Error unwind statck */ kobject_init_and_add_fail: -kfree (edac_pci_top_main_kobj); +kobject_put (edac_pci_top_main_kobj); kzalloc_fail:module_put (THIS_MODULE );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 83/212 arm64: dts: qcom: msm8916: Replace invalid bias-pull-none property
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 1b6a1a162defe649c5599d661b58ac64bb6f31b6 ]
msm8916-pins.dtsi specifies "bias-pull-none" for most of the audio pin configurations. This was likely copied from the qcom kernel fork where the same property was used for these audio pins.
However, "bias-pull-none" actually does not exist at all - not in mainline and not in downstream. I can only guess that the original intention was to configure "no pull", i.e. bias-disable.
Change it to that instead.
--- arch/arm64/boot/dts/qcom/msm8916-pins.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/qcom/msm8916-pins.dtsi +5 -5
@@ -542,7 +542,7 @@ pinconf { pins = "gpio63", "gpio64", "gpio65", "gpio66", "gpio67", "gpio68"; drive-strength = <8>; - bias-pull-none; + bias-disable; }; }; cdc_pdm_lines_sus: pdm_lines_off {
@@ -571,7 +571,7 @@ pinconf { pins = "gpio113", "gpio114", "gpio115", "gpio116"; drive-strength = <8>; - bias-pull-none; + bias-disable; }; };
@@ -599,7 +599,7 @@ pinmux { pinconf { pins = "gpio110"; drive-strength = <8>; - bias-pull-none; + bias-disable; }; };
@@ -625,7 +625,7 @@ pinmux { pinconf { pins = "gpio116"; drive-strength = <8>; - bias-pull-none; + bias-disable; }; }; ext_mclk_tlmm_lines_sus: mclk_lines_off {
@@ -653,7 +653,7 @@ pinconf { pins = "gpio112", "gpio117", "gpio118", "gpio119"; drive-strength = <8>; - bias-pull-none; + bias-disable; }; }; ext_sec_tlmm_lines_sus: tlmm_lines_off {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 84/212 arm64: dts: exynos: Fix silent hang after boot on Espresso
In reply to Greg Kroah-HartmanFrom: Alim Akhtar <[email protected]>
[ Upstream commit b072714bfc0e42c984b8fd6e069f3ca17de8137a ]
Once regulators are disabled after kernel boot, on Espresso board silent hang observed because of LDO7 being disabled. LDO7 actually provide power to CPU cores and non-cpu blocks circuitries. Keep this regulator always-on to fix this hang.
--- arch/arm64/boot/dts/exynos/exynos7-espresso.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/exynos/exynos7-espresso.dts +1 -0
@@ -131,6 +131,7 @@ ldo7_reg: LDO7 { regulator-min-microvolt = <700000>; regulator-max-microvolt = <1150000>; regulator-enable-ramp-delay = <125>; + regulator-always-on; }; ldo8_reg: LDO8 {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 85/212 m68k: mac: Dont send IOP message until channel is idle
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit aeb445bf2194d83e12e85bf5c65baaf1f093bd8f ]
In the following sequence of calls, iop_do_send() gets called when the "send" channel is not in the IOP_MSG_IDLE state:
iop_ism_irq() iop_handle_send() (msg->handler)() iop_send_message() iop_do_send()
Avoid this by testing the channel state before calling iop_do_send().
When sending, and iop_send_queue is empty, call iop_do_send() because the channel is idle. If iop_send_queue is not empty, iop_do_send() will get called later by iop_handle_send().
--- arch/m68k/mac/iop.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/m68k/mac/iop.c +3 -6
@@ -416,7 +416,8 @@ static void iop_handle_send(uint iop_num, uint chan)iop_free_msg (msg2); iop_send_queue[iop_num][chan] = msg; -if (msg)iop_do_send (msg); +if (msg &&iop_readb (iop,IOP_ADDR_SEND_STATE + chan) ==IOP_MSG_IDLE ) +iop_do_send (msg); }/*
@@ -497,16 +498,12 @@ int iop_send_message(uint iop_num, uint chan, void *privdata,if (!(q = iop_send_queue[iop_num][chan])) { iop_send_queue[iop_num][chan] = msg; +iop_do_send (msg); }else {while (q->next) q = q->next; q->next = msg; } -if (iop_readb (iop_base[iop_num], -IOP_ADDR_SEND_STATE + chan) ==IOP_MSG_IDLE ) { -iop_do_send (msg); - } -return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 86/212 m68k: mac: Fix IOP status/control register writes
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit 931fc82a6aaf4e2e4a5490addaa6a090d78c24a7 ]
When writing values to the IOP status/control register make sure those values do not have any extraneous bits that will clear interrupt flags.
To place the SCC IOP into bypass mode would be desirable but this is not achieved by writing IOP_DMAINACTIVE | IOP_RUN | IOP_AUTOINC | IOP_BYPASS to the control register. Drop this ineffective register write.
Remove the flawed and unused iop_bypass() function. Make use of the unused iop_stop() function.
--- arch/m68k/mac/iop.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
arch/m68k/mac/iop.c +3 -9
@@ -173,7 +173,7 @@ static __inline__ void iop_writeb(volatile struct mac_iop *iop, __u16 addr, __u8static __inline__void iop_stop (volatile struct mac_iop *iop) { - iop->status_ctrl &= ~IOP_RUN ; + iop->status_ctrl =IOP_AUTOINC ; }static __inline__void iop_start (volatile struct mac_iop *iop)
@@ -181,14 +181,9 @@ static __inline__ void iop_start(volatile struct mac_iop *iop) iop->status_ctrl =IOP_RUN |IOP_AUTOINC ; } -static __inline__void iop_bypass (volatile struct mac_iop *iop) -{ - iop->status_ctrl |=IOP_BYPASS ; -} -static __inline__void iop_interrupt (volatile struct mac_iop *iop) { - iop->status_ctrl |=IOP_IRQ ; + iop->status_ctrl =IOP_IRQ |IOP_RUN |IOP_AUTOINC ; }static int iop_alive (volatile struct mac_iop *iop)
@@ -239,7 +234,6 @@ void __init iop_preinit(void) }else { iop_base[IOP_NUM_SCC ] = (struct mac_iop *)SCC_IOP_BASE_QUADRA ; } - iop_base[IOP_NUM_SCC ]->status_ctrl =0x87 ; iop_scc_present =1 ; }else { iop_base[IOP_NUM_SCC ] =NULL ;
@@ -251,7 +245,7 @@ void __init iop_preinit(void) }else { iop_base[IOP_NUM_ISM ] = (struct mac_iop *)ISM_IOP_BASE_QUADRA ; } - iop_base[IOP_NUM_ISM ]->status_ctrl =0 ; +iop_stop (iop_base[IOP_NUM_ISM ]); iop_ism_present =1 ; }else { iop_base[IOP_NUM_ISM ] =NULL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 87/212 platform/x86: intel-hid: Fix return value check in check_acpi_dev()
In reply to Greg Kroah-HartmanFrom: Lu Wei <[email protected]>
[ Upstream commit 71fbe886ce6dd0be17f20aded9c63fe58edd2806 ]
In the function check_acpi_dev(), if it fails to create platform device, the return value is ERR_PTR() or NULL. Thus it must use IS_ERR_OR_NULL() to check return value.
--- drivers/platform/x86/intel-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel-hid.c +1 -1
@@ -264,7 +264,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)return AE_OK ;if (acpi_match_device_ids (dev, ids) ==0 ) -if (acpi_create_platform_device (dev,NULL )) +if (!IS_ERR_OR_NULL (acpi_create_platform_device (dev,NULL )))dev_info (&dev->dev,"intel-hid: created platform device\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 88/212 platform/x86: intel-vbtn: Fix return value check in check_acpi_dev()
In reply to Greg Kroah-HartmanFrom: Lu Wei <[email protected]>
[ Upstream commit 64dd4a5a7d214a07e3d9f40227ec30ac8ba8796e ]
In the function check_acpi_dev(), if it fails to create platform device, the return value is ERR_PTR() or NULL. Thus it must use IS_ERR_OR_NULL() to check return value.
--- drivers/platform/x86/intel-vbtn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel-vbtn.c +1 -1
@@ -168,7 +168,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)return AE_OK ;if (acpi_match_device_ids (dev, ids) ==0 ) -if (acpi_create_platform_device (dev,NULL )) +if (!IS_ERR_OR_NULL (acpi_create_platform_device (dev,NULL )))dev_info (&dev->dev,"intel-vbtn: created platform device\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 89/212 ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
In reply to Greg Kroah-HartmanFrom: yu kuai <[email protected]>
[ Upstream commit f87a4f022c44e5b87e842a9f3e644fba87e8385f ]
if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have a corresponding put_device(). Thus add a jump target to fix the exception handling for this function implementation.
--- arch/arm/mach-at91/pm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/arm/mach-at91/pm.c +8 -3
@@ -411,13 +411,13 @@ static void __init at91_pm_sram_init(void) sram_pool =gen_pool_get (&pdev->dev,NULL );if (!sram_pool) {pr_warn ("%s: sram pool unavailable!\n" , __func__); -return ; + goto out_put_device; } sram_base =gen_pool_alloc (sram_pool, at91_pm_suspend_in_sram_sz);if (!sram_base) {pr_warn ("%s: unable to alloc sram!\n" , __func__); -return ; + goto out_put_device; } sram_pbase =gen_pool_virt_to_phys (sram_pool, sram_base);
@@ -425,12 +425,17 @@ static void __init at91_pm_sram_init(void) at91_pm_suspend_in_sram_sz, false);if (!at91_suspend_sram_fn) {pr_warn ("SRAM: Could not map\n" ); -return ; + goto out_put_device; }/* Copy the pm suspend handler to SRAM */ at91_suspend_sram_fn =fncpy (at91_suspend_sram_fn, &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); +return ; + +out_put_device: +put_device (&pdev->dev); +return ; }static const struct of_device_id atmel_pmc_ids[]__initconst = {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 90/212 ARM: socfpga: PM: add missing put_device() call in socfpga_setup_ocram_self_refresh()
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 3ad7b4e8f89d6bcc9887ca701cf2745a6aedb1a0 ]
if of_find_device_by_node() succeed, socfpga_setup_ocram_self_refresh doesn't have a corresponding put_device(). Thus add a jump target to fix the exception handling for this function implementation.
--- arch/arm/mach-socfpga/pm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/pm.c +5 -3
@@ -60,14 +60,14 @@ static int socfpga_setup_ocram_self_refresh(void)if (!ocram_pool) {pr_warn ("%s: ocram pool unavailable!\n" , __func__); ret = -ENODEV ; - goto put_node; + goto put_device; } ocram_base =gen_pool_alloc (ocram_pool, socfpga_sdram_self_refresh_sz);if (!ocram_base) {pr_warn ("%s: unable to alloc ocram!\n" , __func__); ret = -ENOMEM ; - goto put_node; + goto put_device; } ocram_pbase =gen_pool_virt_to_phys (ocram_pool, ocram_base);
@@ -78,7 +78,7 @@ static int socfpga_setup_ocram_self_refresh(void)if (!suspend_ocram_base) {pr_warn ("%s: __arm_ioremap_exec failed!\n" , __func__); ret = -ENOMEM ; - goto put_node; + goto put_device; }/* Copy the code that puts DDR in self refresh to ocram */
@@ -92,6 +92,8 @@ static int socfpga_setup_ocram_self_refresh(void)if (!socfpga_sdram_self_refresh_in_ocram) ret = -EFAULT ; +put_device: +put_device (&pdev->dev); put_node:of_node_put (np);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 91/212 drm/tilcdc: fix leak & null ref in panel_connector_get_modes
In reply to Greg Kroah-HartmanFrom: Tomi Valkeinen <[email protected]>
[ Upstream commit 3f9c1c872cc97875ddc8d63bc9fe6ee13652b933 ]
If videomode_from_timings() returns true, the mode allocated with drm_mode_create will be leaked.
Also, the return value of drm_mode_create() is never checked, and thus could cause NULL deref.
Fix these two issues.
--- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/tilcdc/tilcdc_panel.c +5 -1
@@ -159,12 +159,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)int i;for (i =0 ; i < timings->num_timings; i++) { -struct drm_display_mode *mode =drm_mode_create (dev); +struct drm_display_mode *mode;struct videomode vm;if (videomode_from_timings (timings, &vm, i))break ; + mode =drm_mode_create (dev); +if (!mode) +break ; +drm_display_mode_from_videomode (&vm, mode); mode->type =DRM_MODE_TYPE_DRIVER ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 92/212 Bluetooth: add a mutex lock to avoid UAF in do_enale_set
In reply to Greg Kroah-HartmanFrom: Lihong Kou <[email protected]>
[ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ]
In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug.
BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990
net/bluetooth/l2cap_core.c:730
Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868
CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine,
BIOS Google 01/01/2011
Workqueue: events do_enable_set
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fb/0x318 lib/dump_stack.c:118
print_address_description+0x74/0x5c0 mm/kasan/report.c:374
__kasan_report+0x149/0x1c0 mm/kasan/report.c:506
kasan_report+0x26/0x50 mm/kasan/common.c:641
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730
do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074
process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264
worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410
kthread+0x332/0x350 kernel/kthread.c:255
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
Allocated by task 2870:
save_stack mm/kasan/common.c:72 [inline]
set_track mm/kasan/common.c:80 [inline]
__kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446
chan_create net/bluetooth/6lowpan.c:640 [inline]
bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline]
do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078
process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264
worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410
kthread+0x332/0x350 kernel/kthread.c:255
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
Freed by task 2870:
save_stack mm/kasan/common.c:72 [inline]
set_track mm/kasan/common.c:80 [inline]
kasan_set_free_info mm/kasan/common.c:337 [inline]
__kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476
kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
__cache_free mm/slab.c:3426 [inline]
kfree+0x10d/0x220 mm/slab.c:3757
l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline]
kref_put include/linux/kref.h:65 [inline]
l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498
do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075
process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264
worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410
kthread+0x332/0x350 kernel/kthread.c:255
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
The buggy address belongs to the object at ffff888096950000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 0 bytes inside of
2048-byte region [ffff888096950000, ffff888096950800)
The buggy address belongs to the page:
page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00
raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/6lowpan.c +5 -0
@@ -57,6 +57,7 @@ static bool enable_6lowpan;/* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX (set_lock);struct lowpan_peer {struct list_head list;
@@ -1187,12 +1188,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; +mutex_lock (&set_lock);if (listen_chan) {l2cap_chan_close (listen_chan,0 );l2cap_chan_put (listen_chan); } listen_chan =bt_6lowpan_listen (); +mutex_unlock (&set_lock);kfree (set_enable); }
@@ -1244,11 +1247,13 @@ static ssize_t lowpan_control_write(struct file *fp,if (ret == -EINVAL )return ret; +mutex_lock (&set_lock);if (listen_chan) {l2cap_chan_close (listen_chan,0 );l2cap_chan_put (listen_chan); listen_chan =NULL ; } +mutex_unlock (&set_lock);if (conn) {struct lowpan_peer *peer;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 93/212 fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 9f47eb5461aaeb6cb8696f9d11503ae90e4d5cb0 ]
Very large I/Os can cause the following RCU CPU stall warning:
RIP: 0010:rb_prev+0x8/0x50 Code: 49 89 c0 49 89 d1 48 89 c2 48 89 f8 e9 e5 fd ff ff 4c 89 48 10 c3 4c =
89 06 c3 4c 89 40 10 c3 0f 1f 00 48 8b 0f 48 39 cf 74 38 <48> 8b 47 10 48 85 c0 74 22 48 8b 50 08 48 85 d2 74 0c 48 89 d0 48
RSP: 0018:ffffc9002212bab0 EFLAGS: 00000287 ORIG_RAX: ffffffffffffff13
RAX: ffff888821f93630 RBX: ffff888821f93630 RCX: ffff888821f937e0
RDX: 0000000000000000 RSI: 0000000000102000 RDI: ffff888821f93630
RBP: 0000000000103000 R08: 000000000006c000 R09: 0000000000000238
R10: 0000000000102fff R11: ffffc9002212bac8 R12: 0000000000000001
R13: ffffffffffffffff R14: 0000000000102000 R15: ffff888821f937e0
__lookup_extent_mapping+0xa0/0x110 try_release_extent_mapping+0xdc/0x220 btrfs_releasepage+0x45/0x70 shrink_page_list+0xa39/0xb30 shrink_inactive_list+0x18f/0x3b0 shrink_lruvec+0x38e/0x6b0 shrink_node+0x14d/0x690 do_try_to_free_pages+0xc6/0x3e0 try_to_free_mem_cgroup_pages+0xe6/0x1e0 reclaim_high.constprop.73+0x87/0xc0 mem_cgroup_handle_over_high+0x66/0x150 exit_to_usermode_loop+0x82/0xd0 do_syscall_64+0xd4/0x100 entry_SYSCALL_64_after_hwframe+0x44/0xa9
On a PREEMPT=n kernel, the try_release_extent_mapping() function's "while" loop might run for a very long time on a large I/O. This commit therefore adds a cond_resched() to this loop, providing RCU any needed quiescent states.
--- fs/btrfs/extent_io.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/extent_io.c +2 -0
@@ -4340,6 +4340,8 @@ int try_release_extent_mapping(struct extent_map_tree *map,/* once for us */ free_extent_map (em); + +cond_resched ();/* Allow large-extent preemption. */ } }return try_release_extent_state (map, tree, page, mask);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 94/212 drm/radeon: Fix reference count leaks caused by pm_runtime_get_sync
In reply to Greg Kroah-HartmanFrom: Aditya Pakki <[email protected]>
[ Upstream commit 9fb10671011143d15b6b40d6d5fa9c52c57e9d63 ]
On calling pm_runtime_get_sync() the reference count of the device is incremented. In case of failure, decrement the reference count before returning the error.
--- drivers/gpu/drm/radeon/radeon_display.c | 4 +++- drivers/gpu/drm/radeon/radeon_drv.c | 4 +++- drivers/gpu/drm/radeon/radeon_kms.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_display.c +3 -1
@@ -639,8 +639,10 @@ radeon_crtc_set_config(struct drm_mode_set *set) dev = set->crtc->dev; ret =pm_runtime_get_sync (dev->dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put_autosuspend (dev->dev);return ret; + } ret =drm_crtc_helper_set_config (set);
drivers/gpu/drm/radeon/radeon_drv.c +3 -1
@@ -496,8 +496,10 @@ long radeon_drm_ioctl(struct file *filp,long ret; dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put_autosuspend (dev->dev);return ret; + } ret =drm_ioctl (filp, cmd, arg);
drivers/gpu/drm/radeon/radeon_kms.c +3 -1
@@ -634,8 +634,10 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) file_priv->driver_priv =NULL ; r =pm_runtime_get_sync (dev->dev); -if (r <0 ) +if (r <0 ) { +pm_runtime_put_autosuspend (dev->dev);return r; + }/* new gpu have virtual address space support */ if (rdev->family >=CHIP_CAYMAN ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 95/212 video: fbdev: neofb: fix memory leak in neo_scan_monitor()
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit edcb3895a751c762a18d25c8d9846ce9759ed7e1 ]
neofb_probe() calls neo_scan_monitor() that can successfully allocate a memory for info->monspecs.modedb and proceed to case 0x03. There it does not free the memory and returns -1. neofb_probe() goes to label err_scan_monitor, thus, it does not free this memory through calling fb_destroy_modedb() as well. We can not go to label err_init_hw since neo_scan_monitor() can fail during memory allocation. So, the patch frees the memory directly for case 0x03.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/video/fbdev/neofb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/neofb.c +1 -0
@@ -1820,6 +1820,7 @@ static int neo_scan_monitor(struct fb_info *info)#else printk (KERN_ERR "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n" ); +kfree (info->monspecs.modedb);return -1 ;#endif default :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 96/212 md-cluster: fix wild pointer of unlock_all_bitmaps()
In reply to Greg Kroah-HartmanFrom: Zhao Heming <[email protected]>
[ Upstream commit 60f80d6f2d07a6d8aee485a1d1252327eeee0c81 ]
reproduction steps:
``` node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb node2 # mdadm -A /dev/md0 /dev/sda /dev/sdb node1 # mdadm -G /dev/md0 -b none mdadm: failed to remove clustered bitmap. node1 # mdadm -S --scan ^C <==== mdadm hung & kernel crash ```
kernel stack:
``` [ 335.230657] general protection fault: 0000 [#1] SMP NOPTI [...] [ 335.230848] Call Trace: [ 335.230873] ? unlock_all_bitmaps+0x5/0x70 [md_cluster] [ 335.230886] unlock_all_bitmaps+0x3d/0x70 [md_cluster] [ 335.230899] leave+0x10f/0x190 [md_cluster] [ 335.230932] ? md_super_wait+0x93/0xa0 [md_mod] [ 335.230947] ? leave+0x5/0x190 [md_cluster] [ 335.230973] md_cluster_stop+0x1a/0x30 [md_mod] [ 335.230999] md_bitmap_free+0x142/0x150 [md_mod] [ 335.231013] ? _cond_resched+0x15/0x40 [ 335.231025] ? mutex_lock+0xe/0x30 [ 335.231056] __md_stop+0x1c/0xa0 [md_mod] [ 335.231083] do_md_stop+0x160/0x580 [md_mod] [ 335.231119] ? 0xffffffffc05fb078 [ 335.231148] md_ioctl+0xa04/0x1930 [md_mod] [ 335.231165] ? filename_lookup+0xf2/0x190 [ 335.231179] blkdev_ioctl+0x93c/0xa10 [ 335.231205] ? _cond_resched+0x15/0x40 [ 335.231214] ? __check_object_size+0xd4/0x1a0 [ 335.231224] block_ioctl+0x39/0x40 [ 335.231243] do_vfs_ioctl+0xa0/0x680 [ 335.231253] ksys_ioctl+0x70/0x80 [ 335.231261] __x64_sys_ioctl+0x16/0x20 [ 335.231271] do_syscall_64+0x65/0x1f0 [ 335.231278] entry_SYSCALL_64_after_hwframe+0x44/0xa9 ```
--- drivers/md/md-cluster.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/md-cluster.c +1 -0
@@ -1234,6 +1234,7 @@ static void unlock_all_bitmaps(struct mddev *mddev) } }kfree (cinfo->other_bitmap_lockres); + cinfo->other_bitmap_lockres =NULL ; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 97/212 drm/nouveau: fix multiple instances of reference count leaks
In reply to Greg Kroah-HartmanFrom: Aditya Pakki <[email protected]>
[ Upstream commit 659fb5f154c3434c90a34586f3b7aa1c39cf6062 ]
On calling pm_runtime_get_sync() the reference count of the device is incremented. In case of failure, decrement the
ref count before returning the error.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 8 ++++++-- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +6 -2
@@ -823,8 +823,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)/* need to bring up power immediately if opening device */ ret =pm_runtime_get_sync (dev->dev); -if (ret <0 && ret != -EACCES ) +if (ret <0 && ret != -EACCES ) { +pm_runtime_put_autosuspend (dev->dev);return ret; + }get_task_comm (tmpname, current);snprintf (name,sizeof (name),"%s[%d]" , tmpname,pid_nr (fpriv->pid));
@@ -912,8 +914,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)long ret; ret =pm_runtime_get_sync (dev->dev); -if (ret <0 && ret != -EACCES ) +if (ret <0 && ret != -EACCES ) { +pm_runtime_put_autosuspend (dev->dev);return ret; + }switch (_IOC_NR (cmd) -DRM_COMMAND_BASE ) {case DRM_NOUVEAU_NVIF :
drivers/gpu/drm/nouveau/nouveau_gem.c +3 -1
@@ -42,8 +42,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem)int ret; ret =pm_runtime_get_sync (dev); -if (WARN_ON (ret <0 && ret != -EACCES )) +if (WARN_ON (ret <0 && ret != -EACCES )) { +pm_runtime_put_autosuspend (dev);return ; + }if (gem->import_attach)drm_prime_gem_destroy (gem, nvbo->bo.sg);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 98/212 drm/debugfs: fix plain echo to connector "force" attribute
In reply to Greg Kroah-HartmanFrom: Michael Tretter <[email protected]>
[ Upstream commit c704b17071c4dc571dca3af4e4151dac51de081a ]
Using plain echo to set the "force" connector attribute fails with -EINVAL, because echo appends a newline to the output.
Replace strcmp with sysfs_streq to also accept strings that end with a newline.
v2: use sysfs_streq instead of stripping trailing whitespace
--- drivers/gpu/drm/drm_debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_debugfs.c +4 -4
@@ -287,13 +287,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf, buf[len] ='\0' ; -if (!strcmp (buf,"on" )) +if (sysfs_streq (buf,"on" )) connector->force =DRM_FORCE_ON ; -else if (!strcmp (buf,"digital" )) +else if (sysfs_streq (buf,"digital" )) connector->force =DRM_FORCE_ON_DIGITAL ; -else if (!strcmp (buf,"off" )) +else if (sysfs_streq (buf,"off" )) connector->force =DRM_FORCE_OFF ; -else if (!strcmp (buf,"unspecified" )) +else if (sysfs_streq (buf,"unspecified" )) connector->force =DRM_FORCE_UNSPECIFIED ;else return -EINVAL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 99/212 mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 0a3b3c253a1eb2c7fe7f34086d46660c909abeb3 ]
A large process running on a heavily loaded system can encounter the following RCU CPU stall warning:
rcu: INFO: rcu_sched self-detected stall on CPU rcu: 3-....: (20998 ticks this GP) idle=4ea/1/0x4000000000000002 softirq=556558/556558 fqs=5190 (t=21013 jiffies g=1005461 q=132576) NMI backtrace for cpu 3 CPU: 3 PID: 501900 Comm: aio-free-ring-w Kdump: loaded Not tainted 5.2.9-108_fbk12_rc3_3858_gb83b75af7909 #1 Hardware name: Wiwynn HoneyBadger/PantherPlus, BIOS HBM6.71 02/03/2016 Call Trace: <IRQ> dump_stack+0x46/0x60 nmi_cpu_backtrace.cold.3+0x13/0x50 ? lapic_can_unplug_cpu.cold.27+0x34/0x34 nmi_trigger_cpumask_backtrace+0xba/0xca rcu_dump_cpu_stacks+0x99/0xc7 rcu_sched_clock_irq.cold.87+0x1aa/0x397 ? tick_sched_do_timer+0x60/0x60 update_process_times+0x28/0x60 tick_sched_timer+0x37/0x70 __hrtimer_run_queues+0xfe/0x270 hrtimer_interrupt+0xf4/0x210 smp_apic_timer_interrupt+0x5e/0x120 apic_timer_interrupt+0xf/0x20 </IRQ> RIP: 0010:kmem_cache_free+0x223/0x300 Code: 88 00 00 00 0f 85 ca 00 00 00 41 8b 55 18 31 f6 f7 da 41 f6 45 0a 02 40 0f 94 c6 83 c6 05 9c 41 5e fa e8 a0 a7 01 00 41 56 9d <49> 8b 47 08 a8 03 0f 85 87 00 00 00 65 48 ff 08 e9 3d fe ff ff 65 RSP: 0018:ffffc9000e8e3da8 EFLAGS: 00000206 ORIG_RAX: ffffffffffffff13 RAX: 0000000000020000 RBX: ffff88861b9de960 RCX: 0000000000000030 RDX: fffffffffffe41e8 RSI: 000060777fe3a100 RDI: 000000000001be18 RBP: ffffea00186e7780 R08: ffffffffffffffff R09: ffffffffffffffff R10: ffff88861b9dea28 R11: ffff88887ffde000 R12: ffffffff81230a1f R13: ffff888854684dc0 R14: 0000000000000206 R15: ffff8888547dbc00 ? remove_vma+0x4f/0x60 remove_vma+0x4f/0x60 exit_mmap+0xd6/0x160 mmput+0x4a/0x110 do_exit+0x278/0xae0 ? syscall_trace_enter+0x1d3/0x2b0 ? handle_mm_fault+0xaa/0x1c0 do_group_exit+0x3a/0xa0 __x64_sys_exit_group+0x14/0x20 do_syscall_64+0x42/0x100 entry_SYSCALL_64_after_hwframe+0x44/0xa9
And on a PREEMPT=n kernel, the "while (vma)" loop in exit_mmap() can run for a very long time given a large process. This commit therefore adds a cond_resched() to this loop, providing RCU any needed quiescent states.
--- mm/mmap.c | 1 + 1 file changed, 1 insertion(+)
mm/mmap.c +1 -0
@@ -3018,6 +3018,7 @@ void exit_mmap(struct mm_struct *mm)if (vma->vm_flags &VM_ACCOUNT ) nr_accounted +=vma_pages (vma); vma =remove_vma (vma); +cond_resched (); }vm_unacct_memory (nr_accounted); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 100/212 brcmfmac: To fix Bss Info flag definition Bug
In reply to Greg Kroah-HartmanFrom: Prasanna Kerekoppa <[email protected]>
[ Upstream commit fa3266541b13f390eb35bdbc38ff4a03368be004 ]
Bss info flag definition need to be fixed from 0x2 to 0x4 This flag is for rssi info received on channel.
All Firmware branches defined as 0x4 and this is bug in brcmfmac.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +1 -1
@@ -30,7 +30,7 @@#define BRCMF_ARP_OL_PEER_AUTO_REPLY 0x00000008#define BRCMF_BSS_INFO_VERSION 109/* curr ver of brcmf_bss_info_le struct */ -#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0002 +#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0004#define BRCMF_STA_WME 0x00000002/* WMM association */ #define BRCMF_STA_AUTHE 0x00000008/* Authenticated */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 101/212 iwlegacy: Check the return value of pcie_capability_read_*()
In reply to Greg Kroah-HartmanFrom: Bolarinwa Olayemi Saheed <[email protected]>
[ Upstream commit 9018fd7f2a73e9b290f48a56b421558fa31e8b75 ]
On failure pcie_capability_read_dword() sets it's last parameter, val to 0. However, with Patch 14/14, it is possible that val is set to ~0 on failure. This would introduce a bug because (x & x) == (~0 & x).
This bug can be avoided without changing the function's behaviour if the return value of pcie_capability_read_dword is checked to confirm success.
Check the return value of pcie_capability_read_dword() to ensure success.
--- drivers/net/wireless/intel/iwlegacy/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlegacy/common.c +2 -2
@@ -4302,8 +4302,8 @@ il_apm_init(struct il_priv *il)* power savings, even without L1. */ if (il->cfg->set_l0s) { -pcie_capability_read_word (il->pci_dev,PCI_EXP_LNKCTL , &lctl); -if (lctl &PCI_EXP_LNKCTL_ASPM_L1 ) { + ret =pcie_capability_read_word (il->pci_dev,PCI_EXP_LNKCTL , &lctl); +if (!ret && (lctl &PCI_EXP_LNKCTL_ASPM_L1 )) {/* L1-ASPM enabled; disable(!) L0S */ il_set_bit (il,CSR_GIO_REG ,CSR_GIO_REG_VAL_L0S_ENABLED );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 102/212 usb: gadget: net2280: fix memory leak on probe error handling paths
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 2468c877da428ebfd701142c4cdfefcfb7d4c00e ]
Driver does not release memory for device on error handling paths in net2280_probe() when gadget_release() is not registered yet.
The patch fixes the bug like in other similar drivers.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/usb/gadget/udc/net2280.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/net2280.c +3 -1
@@ -3785,8 +3785,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; done: -if (dev) +if (dev) {net2280_remove (pdev); +kfree (dev); + }return retval; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 103/212 bdc: Fix bug causing crash after multiple disconnects
In reply to Greg Kroah-HartmanFrom: Sasi Kumar <[email protected]>
[ Upstream commit a95bdfd22076497288868c028619bc5995f5cc7f ]
Multiple connects/disconnects can cause a crash on the second disconnect. The driver had a problem where it would try to send endpoint commands after it was disconnected which is not allowed by the hardware. The fix is to only allow the endpoint commands when the endpoint is connected. This will also fix issues that showed up when using configfs to create gadgets.
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 ++++ drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +4 -0
@@ -286,6 +286,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)* in that case reinit is passed as 1 */ if (reinit) { +int i;/* Enable interrupts */ temp =bdc_readl (bdc->regs,BDC_BDCSC ); temp |=BDC_GIE ;
@@ -295,6 +296,9 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)/* Initialize SRR to 0 */ memset (bdc->srr.sr_bds,0 ,NUM_SR_ENTRIES *sizeof (struct bdc_bd )); +/* clear ep flags to avoid post disconnect stops/deconfigs */ +for (i =1 ; i < bdc->num_eps; ++i) + bdc->bdc_ep_array[i]->flags =0 ; }else {/* One time initiaization only */ /* Enable status report function pointers */
drivers/usb/gadget/udc/bdc/bdc_ep.c +10 -6
@@ -621,7 +621,6 @@ int bdc_ep_enable(struct bdc_ep *ep) }bdc_dbg_bd_list (bdc, ep);/* only for ep0: config ep is called for ep0 from connect event */ - ep->flags |=BDC_EP_ENABLED ;if (ep->ep_num ==1 )return ret;
@@ -765,10 +764,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) __func__, ep->name, start_bdi, end_bdi);dev_dbg (bdc->dev,"ep_dequeue ep=%p ep->desc=%p\n" , ep, (void *)ep->usb_ep.desc); -/* Stop the ep to see where the HW is ? */ - ret =bdc_stop_ep (bdc, ep->ep_num); -/* if there is an issue with stopping ep, then no need to go further */ -if (ret) +/* if still connected, stop the ep to see where the HW is ? */ +if (!(bdc_readl (bdc->regs,BDC_USPC ) &BDC_PST_MASK )) { + ret =bdc_stop_ep (bdc, ep->ep_num); +/* if there is an issue, then no need to go further */ +if (ret) +return 0 ; + }else return 0 ;/*
@@ -1917,7 +1919,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep) __func__, ep->name, ep->flags);if (!(ep->flags &BDC_EP_ENABLED )) { -dev_warn (bdc->dev,"%s is already disabled\n" , ep->name); +if (bdc->gadget.speed !=USB_SPEED_UNKNOWN ) +dev_warn (bdc->dev,"%s is already disabled\n" , + ep->name);return 0 ; }spin_lock_irqsave (&bdc->lock, flags);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 104/212 dyndbg: fix a BUG_ON in ddebug_describe_flags
In reply to Greg Kroah-HartmanFrom: Jim Cromie <[email protected]>
[ Upstream commit f678ce8cc3cb2ad29df75d8824c74f36398ba871 ]
ddebug_describe_flags() currently fills a caller provided string buffer, after testing its size (also passed) in a BUG_ON. Fix this by replacing them with a known-big-enough string buffer wrapped in a struct, and passing that instead.
Also simplify ddebug_describe_flags() flags parameter from a struct to a member in that struct, and hoist the member deref up to the caller. This makes the function reusable (soon) where flags are unpacked.
--- lib/dynamic_debug.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
lib/dynamic_debug.c +11 -12
@@ -85,22 +85,22 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_NONE, '_' }, }; +struct flagsbuf {char buf[ARRAY_SIZE (opt_array)+1 ]; }; +/* format a string into buf[] which describes the _ddebug's flags */ -static char *ddebug_describe_flags (struct _ddebug *dp,char *buf, -size_t maxlen) +static char *ddebug_describe_flags (unsigned int flags,struct flagsbuf *fb) { -char *p = buf; +char *p = fb->buf;int i; -BUG_ON (maxlen <6 );for (i =0 ; i <ARRAY_SIZE (opt_array); ++i) -if (dp->flags & opt_array[i].flag) +if (flags & opt_array[i].flag) *p++ = opt_array[i].opt_char; -if (p == buf) +if (p == fb->buf) *p++ ='_' ; *p ='\0' ; -return buf; +return fb->buf; }#define vpr_info (fmt, ...) \
@@ -142,7 +142,7 @@ static int ddebug_change(const struct ddebug_query *query,struct ddebug_table *dt;unsigned int newflags;unsigned int nfound =0 ; -char flagbuf[10 ]; +struct flagsbuf fbuf;/* search for matching ddebugs */ mutex_lock (&ddebug_lock);
@@ -199,8 +199,7 @@ static int ddebug_change(const struct ddebug_query *query,vpr_info ("changed %s:%d [%s]%s =%s\n" ,trim_prefix (dp->filename), dp->lineno, dt->mod_name, dp->function, -ddebug_describe_flags (dp, flagbuf, -sizeof (flagbuf))); +ddebug_describe_flags (dp->flags, &fbuf)); } }mutex_unlock (&ddebug_lock);
@@ -779,7 +778,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) {struct ddebug_iter *iter = m->private;struct _ddebug *dp = p; -char flagsbuf[10 ]; +struct flagsbuf flags;vpr_info ("called m=%p p=%p\n" , m, p);
@@ -792,7 +791,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)seq_printf (m,"%s:%u [%s]%s =%s \"" ,trim_prefix (dp->filename), dp->lineno, iter->table->mod_name, dp->function, -ddebug_describe_flags (dp, flagsbuf,sizeof (flagsbuf))); +ddebug_describe_flags (dp->flags, &flags));seq_escape (m, dp->format,"\t\r\n\"" );seq_puts (m,"\"\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 105/212 bcache: fix super block seq numbers comparision in register_cache_set()
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
[ Upstream commit 117f636ea695270fe492d0c0c9dfadc7a662af47 ]
In register_cache_set(), c is pointer to struct cache_set, and ca is pointer to struct cache, if ca->sb.seq > c->sb.seq, it means this registering cache has up to date version and other members, the in- memory version and other members should be updated to the newer value.
But current implementation makes a cache set only has a single cache device, so the above assumption works well except for a special case. The execption is when a cache device new created and both ca->sb.seq and c->sb.seq are 0, because the super block is never flushed out yet. In the location for the following if() check,
2156 if (ca->sb.seq > c->sb.seq) {
2157 c->sb.version = ca->sb.version;
2158 memcpy(c->sb.set_uuid, ca->sb.set_uuid, 16);
2159 c->sb.flags = ca->sb.flags;
2160 c->sb.seq = ca->sb.seq;
2161 pr_debug("set version = %llu\n", c->sb.version);2162 }c->sb.version is not initialized yet and valued 0. When ca->sb.seq is 0, the if() check will fail (because both values are 0), and the cache set version, set_uuid, flags and seq won't be updated.
The above problem is hiden for current code, because the bucket size is compatible among different super block version. And the next time when running cache set again, ca->sb.seq will be larger than 0 and cache set super block version will be updated properly.
But if the large bucket feature is enabled, sb->bucket_size is the low 16bits of the bucket size. For a power of 2 value, when the actual bucket size exceeds 16bit width, sb->bucket_size will always be 0. Then read_super_common() will fail because the if() check to is_power_of_2(sb->bucket_size) is false. This is how the long time hidden bug is triggered.
This patch modifies the if() check to the following way,
2156 if (ca->sb.seq > c->sb.seq || c->sb.seq == 0) {
Then cache set's version, set_uuid, flags and seq will always be updated corectly including for a new created cache device.
--- drivers/md/bcache/super.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +8 -1
@@ -1778,7 +1778,14 @@ static const char *register_cache_set(struct cache *ca) sysfs_create_link(&c->kobj, &ca->kobj, buf)) goto err; -if (ca->sb.seq > c->sb.seq) { +/* +* A special case is both ca->sb.seq and c->sb.seq are 0, +* such condition happens on a new created cache device whose +* super block is never flushed yet. In this case c->sb.version +* and other members should be updated too, otherwise we will +* have a mistaken super block version in cache set. +*/ +if (ca->sb.seq > c->sb.seq || c->sb.seq ==0 ) { c->sb.version = ca->sb.version;memcpy (c->sb.set_uuid, ca->sb.set_uuid,16 ); c->sb.flags = ca->sb.flags;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 106/212 ACPICA: Do not increment operation_region reference counts for field units
In reply to Greg Kroah-HartmanFrom: Erik Kaneda <[email protected]>
[ Upstream commit 6a54ebae6d047c988a31f5ac5a64ab5cf83797a2 ]
ACPICA commit e17b28cfcc31918d0db9547b6b274b09c413eb70
Object reference counts are used as a part of ACPICA's garbage collection mechanism. This mechanism keeps track of references to heap-allocated structures such as the ACPI operand objects.
Recent server firmware has revealed that this reference count can overflow on large servers that declare many field units under the same operation_region. This occurs because each field unit declaration will add a reference count to the source operation_region.
This change solves the reference count overflow for operation_regions objects by preventing fieldunits from incrementing their operation_region's reference count. Each operation_region's reference count will not be changed by named objects declared under the Field operator. During namespace deletion, the operation_region namespace node will be deleted and each fieldunit will be deleted without touching the deleted operation_region object.
--- drivers/acpi/acpica/exprep.c | 4 ---- drivers/acpi/acpica/utdelete.c | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-)
drivers/acpi/acpica/exprep.c +0 -4
@@ -507,10 +507,6 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) (u8 )access_byte_width; } } -/* An additional reference for the container */ - -acpi_ut_add_reference (obj_desc->field.region_obj); - ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", obj_desc->field.start_field_bit_offset,
drivers/acpi/acpica/utdelete.c +1 -5
@@ -591,11 +591,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) next_object = object->buffer_field.buffer_obj;break ; -case ACPI_TYPE_LOCAL_REGION_FIELD : - - next_object = object->field.region_obj; -break ; -case ACPI_TYPE_LOCAL_BANK_FIELD : next_object = object->bank_field.bank_obj;
@@ -636,6 +631,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) }break ; +case ACPI_TYPE_LOCAL_REGION_FIELD :case ACPI_TYPE_REGION :default :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 107/212 agp/intel: Fix a memory leak on module initialisation failure
In reply to Greg Kroah-HartmanFrom: Qiushi Wu <[email protected]>
[ Upstream commit b975abbd382fe442713a4c233549abb90e57c22b ]
In intel_gtt_setup_scratch_page(), pointer "page" is not released if pci_dma_mapping_error() return an error, leading to a memory leak on module initialisation failure. Simply fix this issue by freeing "page" before return.
--- drivers/char/agp/intel-gtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/agp/intel-gtt.c +3 -1
@@ -303,8 +303,10 @@ static int intel_gtt_setup_scratch_page(void)if (intel_private.needs_dmar) { dma_addr =pci_map_page (intel_private.pcidev, page,0 ,PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (intel_private.pcidev, dma_addr)) +if (pci_dma_mapping_error (intel_private.pcidev, dma_addr)) { +__free_page (page);return -EINVAL ; + } intel_private.scratch_page_dma = dma_addr; }else
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 108/212 video: fbdev: sm712fb: fix an issue about iounmap for a wrong address
In reply to Greg Kroah-HartmanFrom: Dejin Zheng <[email protected]>
[ Upstream commit 98bd4f72988646c35569e1e838c0ab80d06c77f6 ]
the sfb->fb->screen_base is not save the value get by iounmap() when the chip id is 0x720. so iounmap() for address sfb->fb->screen_base is not right.
--- drivers/video/fbdev/sm712fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/sm712fb.c +2 -0
@@ -1428,6 +1428,8 @@ static int smtc_map_smem(struct smtcfb_info *sfb,static void smtc_unmap_smem (struct smtcfb_info *sfb) {if (sfb && sfb->fb->screen_base) { +if (sfb->chip_id ==0x720 ) + sfb->fb->screen_base -=0x00200000 ;iounmap (sfb->fb->screen_base); sfb->fb->screen_base =NULL ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 109/212 console: newport_con: fix an issue about leak related system resources
In reply to Greg Kroah-HartmanFrom: Dejin Zheng <[email protected]>
[ Upstream commit fd4b8243877250c05bb24af7fea5567110c9720b ]
A call of the function do_take_over_console() can fail here. The corresponding system resources were not released then. Thus add a call of iounmap() and release_mem_region() together with the check of a failure predicate. and also add release_mem_region() on device removal.
--- drivers/video/console/newport_con.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/video/console/newport_con.c +10 -2
@@ -31,6 +31,8 @@#include <linux/linux_logo.h> #include <linux/font.h> +#define NEWPORT_LEN 0x10000 +#define FONT_DATA ((unsigned char *)font_vga_8x16.data)/* borrowed from fbcon.c */
@@ -42,6 +44,7 @@static unsigned char *font_data[MAX_NR_CONSOLES ];static struct newport_regs *npregs; +static unsigned long newport_addr;static int logo_active;static int topscan;
@@ -701,7 +704,6 @@ const struct consw newport_con = {static int newport_probe (struct gio_device *dev,const struct gio_device_id *id) { -unsigned long newport_addr;int err;if (!dev->resource.start)
@@ -711,7 +713,7 @@ static int newport_probe(struct gio_device *dev,return -EBUSY ;/* we only support one Newport as console */ newport_addr = dev->resource.start +0xF0000 ; -if (!request_mem_region (newport_addr,0x10000 ,"Newport" )) +if (!request_mem_region (newport_addr,NEWPORT_LEN ,"Newport" ))return -ENODEV ; npregs = (struct newport_regs *)/* ioremap cannot fail */
@@ -719,6 +721,11 @@ static int newport_probe(struct gio_device *dev,console_lock (); err =do_take_over_console (&newport_con,0 ,MAX_NR_CONSOLES -1 ,1 );console_unlock (); + +if (err) { +iounmap ((void *)npregs); +release_mem_region (newport_addr,NEWPORT_LEN ); + }return err; }
@@ -726,6 +733,7 @@ static void newport_remove(struct gio_device *dev) {give_up_console (&newport_con);iounmap ((void *)npregs); +release_mem_region (newport_addr,NEWPORT_LEN ); }static struct gio_device_id newport_ids[] = {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 110/212 video: pxafb: Fix the function used to balance a dma_alloc_coherent() call
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 499a2c41b954518c372873202d5e7714e22010c4 ]
'dma_alloc_coherent()' must be balanced by a call to 'dma_free_coherent()' not 'dma_free_wc()'.
The correct dma_free_ function is already used in the error handling path of the probe function.
--- drivers/video/fbdev/pxafb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/pxafb.c +2 -2
@@ -2447,8 +2447,8 @@ static int pxafb_remove(struct platform_device *dev)free_pages_exact (fbi->video_mem, fbi->video_mem_size); -dma_free_wc (&dev->dev, fbi->dma_buff_size, fbi->dma_buff, - fbi->dma_buff_phys); +dma_free_coherent (&dev->dev, fbi->dma_buff_size, fbi->dma_buff, + fbi->dma_buff_phys);iounmap (fbi->mmio_base);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 111/212 iio: improve IIO_CONCENTRATION channel type description
In reply to Greg Kroah-HartmanFrom: Tomasz Duszynski <[email protected]>
[ Upstream commit df16c33a4028159d1ba8a7061c9fa950b58d1a61 ]
IIO_CONCENTRATION together with INFO_RAW specifier is used for reporting raw concentrations of pollutants. Raw value should be meaningless before being properly scaled. Because of that description shouldn't mention raw value unit whatsoever.
Fix this by rephrasing existing description so it follows conventions used throughout IIO ABI docs.
--- Documentation/ABI/testing/sysfs-bus-iio | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio +2 -1
@@ -1491,7 +1491,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_voc_raw KernelVersion: 4.3 Contact: [email protected] Description: - Raw (unscaled no offset etc.) percentage reading of a substance. + Raw (unscaled no offset etc.) reading of a substance. Units + after application of scale and offset are percents. What: /sys/bus/iio/devices/iio:deviceX/in_resistance_raw What: /sys/bus/iio/devices/iio:deviceX/in_resistanceX_raw
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 112/212 leds: lm355x: avoid enum conversion warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 985b1f596f9ed56f42b8c2280005f943e1434c06 ]
clang points out that doing arithmetic between diffent enums is usually a mistake:
drivers/leds/leds-lm355x.c:167:28: warning: bitwise operation between different enumeration types ('enum lm355x_tx2' and 'enum lm355x_ntc') [-Wenum-enum-conversion]
reg_val = pdata->pin_tx2 | pdata->ntc_pin;
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
drivers/leds/leds-lm355x.c:178:28: warning: bitwise operation between different enumeration types ('enum lm355x_tx2' and 'enum lm355x_ntc') [-Wenum-enum-conversion]
reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode;
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~In this driver, it is intentional, so add a cast to hide the false-positive warning. It appears to be the only instance of this warning at the moment.
--- drivers/leds/leds-lm355x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/leds/leds-lm355x.c +4 -3
@@ -168,18 +168,19 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip)/* input and output pins configuration */ switch (chip->type) {case CHIP_LM3554 : - reg_val = pdata->pin_tx2 | pdata->ntc_pin; + reg_val = (u32 )pdata->pin_tx2 | (u32 )pdata->ntc_pin; ret =regmap_update_bits (chip->regmap,0xE0 ,0x28 , reg_val);if (ret <0 ) goto out; - reg_val = pdata->pass_mode; + reg_val = (u32 )pdata->pass_mode; ret =regmap_update_bits (chip->regmap,0xA0 ,0x04 , reg_val);if (ret <0 ) goto out;break ;case CHIP_LM3556 : - reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode; + reg_val = (u32 )pdata->pin_tx2 | (u32 )pdata->ntc_pin | + (u32 )pdata->pass_mode; ret =regmap_update_bits (chip->regmap,0x0A ,0xC4 , reg_val);if (ret <0 ) goto out;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 113/212 media: omap3isp: Add missed v4l2_ctrl_handler_free() for preview_init_entities()
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
[ Upstream commit dc7690a73017e1236202022e26a6aa133f239c8c ]
preview_init_entities() does not call v4l2_ctrl_handler_free() when it fails.
Add the missed function to fix it.
--- drivers/media/platform/omap3isp/isppreview.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/omap3isp/isppreview.c +3 -1
@@ -2290,7 +2290,7 @@ static int preview_init_entities(struct isp_prev_device *prev) me->ops = &preview_media_ops; ret =media_entity_pads_init (me,PREV_PADS_NUM , pads);if (ret <0 ) -return ret; + goto error_handler_free;preview_init_formats (sd,NULL );
@@ -2323,6 +2323,8 @@ static int preview_init_entities(struct isp_prev_device *prev)omap3isp_video_cleanup (&prev->video_in); error_video_in:media_entity_cleanup (&prev->subdev.entity); +error_handler_free: +v4l2_ctrl_handler_free (&prev->ctrls);return ret; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 114/212 scsi: cumana_2: Fix different dev_id between request_irq() and free_irq()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 040ab9c4fd0070cd5fa71ba3a7b95b8470db9b4d ]
The dev_id used in request_irq() and free_irq() should match. Use 'info' in both cases.
--- drivers/scsi/arm/cumana_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/arm/cumana_2.c +1 -1
@@ -454,7 +454,7 @@ static int cumanascsi2_probe(struct expansion_card *ec,if (info->info.scsi.dma !=NO_DMA )free_dma (info->info.scsi.dma); -free_irq (ec->irq, host); +free_irq (ec->irq, info); out_release:fas216_release (host);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 115/212 drm/mipi: use dcs write for mipi_dsi_dcs_set_tear_scanline
In reply to Greg Kroah-HartmanFrom: Emil Velikov <[email protected]>
[ Upstream commit 7a05c3b6d24b8460b3cec436cf1d33fac43c8450 ]
The helper uses the MIPI_DCS_SET_TEAR_SCANLINE, although it's currently using the generic write. This does not look right.
Perhaps some platforms don't distinguish between the two writers?
--- drivers/gpu/drm/drm_mipi_dsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_mipi_dsi.c +3 -3
@@ -1029,11 +1029,11 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);*/ int mipi_dsi_dcs_set_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline) { -u8 payload[3 ] = {MIPI_DCS_SET_TEAR_SCANLINE , scanline >>8 , - scanline &0xff }; +u8 payload[2 ] = { scanline >>8 , scanline &0xff };ssize_t err; - err =mipi_dsi_generic_write (dsi, payload,sizeof (payload)); + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_TEAR_SCANLINE , payload, +sizeof (payload));if (err <0 )return err;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 116/212 cxl: Fix kobject memleak
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 85c5cbeba8f4fb28e6b9bfb3e467718385f78f76 ]
Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject.
Fix it by adding a call to kobject_put() in the error path of kobject_init_and_add().
--- drivers/misc/cxl/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cxl/sysfs.c +1 -1
@@ -598,7 +598,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c rc =kobject_init_and_add (&cr->kobj, &afu_config_record_type, &afu->dev.kobj,"cr%i" , cr->cr);if (rc) - goto err; + goto err1; rc =sysfs_create_bin_file (&cr->kobj, &cr->config_attr);if (rc)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 117/212 drm/radeon: fix array out-of-bounds read and write issues
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 7ee78aff9de13d5dccba133f4a0de5367194b243 ]
There is an off-by-one bounds check on the index into arrays table->mc_reg_address and table->mc_reg_table_entry[k].mc_data[j] that can lead to reads and writes outside of arrays. Fix the bound checking off-by-one error.
Addresses-Coverity: ("Out-of-bounds read/write")
--- drivers/gpu/drm/radeon/ci_dpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/ci_dpm.c +1 -1
@@ -4348,7 +4348,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev, table->mc_reg_table_entry[k].mc_data[j] |=0x100 ; } j++; -if (j >SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE )return -EINVAL ;if (!pi->mem_gddr5) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 118/212 scsi: powertec: Fix different dev_id between request_irq() and free_irq()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d179f7c763241c1dc5077fca88ddc3c47d21b763 ]
The dev_id used in request_irq() and free_irq() should match. Use 'info' in both cases.
--- drivers/scsi/arm/powertec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/arm/powertec.c +1 -1
@@ -382,7 +382,7 @@ static int powertecscsi_probe(struct expansion_card *ec,if (info->info.scsi.dma !=NO_DMA )free_dma (info->info.scsi.dma); -free_irq (ec->irq, host); +free_irq (ec->irq, info); out_release:fas216_release (host);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 119/212 scsi: eesox: Fix different dev_id between request_irq() and free_irq()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 86f2da1112ccf744ad9068b1d5d9843faf8ddee6 ]
The dev_id used in request_irq() and free_irq() should match. Use 'info' in both cases.
--- drivers/scsi/arm/eesox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/arm/eesox.c +1 -1
@@ -575,7 +575,7 @@ static int eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id)if (info->info.scsi.dma !=NO_DMA )free_dma (info->info.scsi.dma); -free_irq (ec->irq, host); +free_irq (ec->irq, info); out_remove:fas216_remove (host);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 120/212 media: firewire: Using uninitialized values in node_probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 2505a210fc126599013aec2be741df20aaacc490 ]
If fw_csr_string() returns -ENOENT, then "name" is uninitialized. So then the "strlen(model_names[i]) <= name_len" is true because strlen() is unsigned and -ENOENT is type promoted to a very high positive value. Then the "strncmp(name, model_names[i], name_len)" uses uninitialized data because "name" is uninitialized.
--- drivers/media/firewire/firedtv-fw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/firewire/firedtv-fw.c +2 -0
@@ -271,6 +271,8 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) name_len =fw_csr_string (unit->directory,CSR_MODEL , name,sizeof (name)); +if (name_len <0 ) +return name_len;for (i =ARRAY_SIZE (model_names); --i; )if (strlen (model_names[i]) <= name_len &&strncmp (name, model_names[i], name_len) ==0 )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 121/212 media: exynos4-is: Add missed check for pinctrl_lookup_state()
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 18ffec750578f7447c288647d7282c7d12b1d969 ]
fimc_md_get_pinctrl() misses a check for pinctrl_lookup_state(). Add the missed check to fix it.
--- drivers/media/platform/exynos4-is/media-dev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/exynos4-is/media-dev.c +3 -0
@@ -1257,6 +1257,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd) pctl->state_idle =pinctrl_lookup_state (pctl->pinctrl,PINCTRL_STATE_IDLE ); +if (IS_ERR (pctl->state_idle)) +return PTR_ERR (pctl->state_idle); +return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 122/212 xfs: fix reflink quota reservation accounting error
In reply to Greg Kroah-HartmanFrom: Darrick J. Wong <[email protected]>
[ Upstream commit 83895227aba1ade33e81f586aa7b6b1e143096a5 ]
Quota reservations are supposed to account for the blocks that might be allocated due to a bmap btree split. Reflink doesn't do this, so fix this to make the quota accounting more accurate before we start rearranging things.
--- fs/xfs/xfs_reflink.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
fs/xfs/xfs_reflink.c +14 -7
@@ -1108,6 +1108,7 @@ xfs_reflink_remap_extent(xfs_filblks_t rlen;xfs_filblks_t unmap_len;xfs_off_t newlen; +int64_t qres;int error; unmap_len = irec->br_startoff + irec->br_blockcount - destoff;
@@ -1135,13 +1136,19 @@ xfs_reflink_remap_extent(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 ); -/* If we're not just clearing space, then do we have enough quota? */ -if (real_extent) { - error =xfs_trans_reserve_quota_nblks (tp, ip, - irec->br_blockcount,0 ,XFS_QMOPT_RES_REGBLKS ); -if (error) - goto out_cancel; - } +/* +* Reserve quota for this operation. We don't know if the first unmap +* in the dest file will cause a bmap btree split, so we always reserve +* at least enough blocks for that split. If the extent being mapped +* in is written, we need to reserve quota for that too. +*/ + qres =XFS_EXTENTADD_SPACE_RES (mp,XFS_DATA_FORK ); +if (real_extent) + qres += irec->br_blockcount; + error =xfs_trans_reserve_quota_nblks (tp, ip, qres,0 , +XFS_QMOPT_RES_REGBLKS ); +if (error) + goto out_cancel;trace_xfs_reflink_remap (ip, irec->br_startoff, irec->br_blockcount, irec->br_startblock);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 123/212 PCI: Fix pci_cfg_wait queue locking problem
In reply to Greg Kroah-HartmanFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit 2a7e32d0547f41c5ce244f84cf5d6ca7fccee7eb ]
The pci_cfg_wait queue is used to prevent user-space config accesses to devices while they are recovering from reset.
Previously we used these operations on pci_cfg_wait:
__add_wait_queue(&pci_cfg_wait, ...)
__remove_wait_queue(&pci_cfg_wait, ...)
wake_up_all(&pci_cfg_wait)
The wake_up acquires the wait queue lock, but the add and remove do not.
Originally these were all protected by the pci_lock, but cdcb33f98244 ("PCI: Avoid possible deadlock on pci_lock and p->pi_lock"), moved wake_up_all() outside pci_lock, so it could race with add/remove operations, which caused occasional kernel panics, e.g., during vfio-pci hotplug/unplug testing:
Unable to handle kernel read from unreadable memory at virtual address ffff802dac469000
Resolve this by using wait_event() instead of __add_wait_queue() and __remove_wait_queue(). The wait queue lock is held by both wait_event() and wake_up_all(), so it provides mutual exclusion.
Based-on: https://lore.kernel.org/linux-pci/[email protected]/
--- drivers/pci/access.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/pci/access.c +2 -6
@@ -185,17 +185,13 @@ EXPORT_SYMBOL(pci_bus_set_ops);static DECLARE_WAIT_QUEUE_HEAD (pci_cfg_wait); static noinline void pci_wait_cfg(struct pci_dev *dev) + __must_hold(&pci_lock) { -DECLARE_WAITQUEUE (wait, current); - -__add_wait_queue (&pci_cfg_wait, &wait);do { -set_current_state (TASK_UNINTERRUPTIBLE );raw_spin_unlock_irq (&pci_lock); -schedule (); +wait_event (pci_cfg_wait, !dev->block_cfg_access);raw_spin_lock_irq (&pci_lock); }while (dev->block_cfg_access); -__remove_wait_queue (&pci_cfg_wait, &wait); }/* Returns 0 on success, negative values indicate error. */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 124/212 leds: core: Flush scheduled work for system suspend
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 302a085c20194bfa7df52e0fe684ee0c41da02e6 ]
Sometimes LED won't be turned off by LED_CORE_SUSPENDRESUME flag upon system suspend.
led_set_brightness_nopm() uses schedule_work() to set LED brightness. However, there's no guarantee that the scheduled work gets executed because no one flushes the work.
So flush the scheduled work to make sure LED gets turned off.
--- drivers/leds/led-class.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/led-class.c +1 -0
@@ -110,6 +110,7 @@ void led_classdev_suspend(struct led_classdev *led_cdev) { led_cdev->flags |=LED_SUSPENDED ;led_set_brightness_nopm (led_cdev,0 ); +flush_work (&led_cdev->set_brightness_work); }EXPORT_SYMBOL_GPL (led_classdev_suspend);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 125/212 drm: panel: simple: Fix bpc for LG LB070WV8 panel
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit a6ae2fe5c9f9fd355a48fb7d21c863e5b20d6c9c ]
The LG LB070WV8 panel incorrectly reports a 16 bits per component value, while the panel uses 8 bits per component. Fix it.
--- drivers/gpu/drm/panel/panel-simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-simple.c +1 -1
@@ -1041,7 +1041,7 @@ static const struct drm_display_mode lg_lb070wv8_mode = {static const struct panel_desc lg_lb070wv8 = { .modes = &lg_lb070wv8_mode, .num_modes =1 , - .bpc =16 , + .bpc =8 , .size = { .width =151 , .height =91 ,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 126/212 scsi: scsi_debug: Add check for sdebug_max_queue during module init
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit c87bf24cfb60bce27b4d2c7e56ebfd86fb9d16bb ]
sdebug_max_queue should not exceed SDEBUG_CANQUEUE, otherwise crashes like this can be triggered by passing an out-of-range value:
Hardware name: Huawei D06 /D06, BIOS Hisilicon D06 UEFI RC0 - V1.16.01 03/15/2019 pstate: 20400009 (nzCv daif +PAN -UAO BTYPE=--) pc : schedule_resp+0x2a4/0xa70 [scsi_debug] lr : schedule_resp+0x52c/0xa70 [scsi_debug] sp : ffff800022ab36f0 x29: ffff800022ab36f0 x28: ffff0023a935a610 x27: ffff800008e0a648 x26: 0000000000000003 x25: ffff0023e84f3200 x24: 00000000003d0900 x23: 0000000000000000 x22: 0000000000000000 x21: ffff0023be60a320 x20: ffff0023be60b538 x19: ffff800008e13000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000001 x8 : 0000000000000000 x7 : 0000000000000000 x6 : 00000000000000c1 x5 : 0000020000200000 x4 : dead0000000000ff x3 : 0000000000000200 x2 : 0000000000000200 x1 : ffff800008e13d88 x0 : 0000000000000000 Call trace: schedule_resp+0x2a4/0xa70 [scsi_debug] scsi_debug_queuecommand+0x2c4/0x9e0 [scsi_debug] scsi_queue_rq+0x698/0x840 __blk_mq_try_issue_directly+0x108/0x228 blk_mq_request_issue_directly+0x58/0x98 blk_mq_try_issue_list_directly+0x5c/0xf0 blk_mq_sched_insert_requests+0x18c/0x200 blk_mq_flush_plug_list+0x11c/0x190 blk_flush_plug_list+0xdc/0x110 blk_finish_plug+0x38/0x210 blkdev_direct_IO+0x450/0x4d8 generic_file_read_iter+0x84/0x180 blkdev_read_iter+0x3c/0x50 aio_read+0xc0/0x170 io_submit_one+0x5c8/0xc98 __arm64_sys_io_submit+0x1b0/0x258 el0_svc_common.constprop.3+0x68/0x170 do_el0_svc+0x24/0x90 el0_sync_handler+0x13c/0x1a8 el0_sync+0x158/0x180 Code: 528847e0 72a001e0 6b00003f 540018cd (3941c340)
In addition, it should not be less than 1.
So add checks for these, and fail the module init for those cases.
[mkp: changed if condition to match error message]
--- drivers/scsi/scsi_debug.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/scsi_debug.c +6 -0
@@ -4986,6 +4986,12 @@ static int __init scsi_debug_init(void)pr_err ("submit_queues must be 1 or more\n" );return -EINVAL ; } + +if ((sdebug_max_queue >SDEBUG_CANQUEUE ) || (sdebug_max_queue <1 )) { +pr_err ("max_queue must be in range [1, %d]\n" ,SDEBUG_CANQUEUE ); +return -EINVAL ; + } + sdebug_q_arr =kcalloc (submit_queues,sizeof (struct sdebug_queue ),GFP_KERNEL );if (sdebug_q_arr ==NULL )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 127/212 mwifiex: Prevent memory corruption handling keys
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e18696786548244914f36ec3c46ac99c53df99c3 ]
The length of the key comes from the network and it's a 16 bit number. It needs to be capped to prevent a buffer overflow.
--- .../wireless/marvell/mwifiex/sta_cmdresp.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c +15 -7
@@ -586,6 +586,11 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv, {struct host_cmd_ds_802_11_key_material *key = &resp->params.key_material; +int len; + + len =le16_to_cpu (key->key_param_set.key_len); +if (len >sizeof (key->key_param_set.key)) +return -EINVAL ;if (le16_to_cpu (key->action) == HostCmd_ACT_GEN_SET) {if ((le16_to_cpu (key->key_param_set.key_info) &KEY_MCAST )) {
@@ -599,9 +604,8 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,memset (priv->aes_key.key_param_set.key,0 ,sizeof (key->key_param_set.key)); - priv->aes_key.key_param_set.key_len = key->key_param_set.key_len; -memcpy (priv->aes_key.key_param_set.key, key->key_param_set.key, -le16_to_cpu (priv->aes_key.key_param_set.key_len)); + priv->aes_key.key_param_set.key_len =cpu_to_le16 (len); +memcpy (priv->aes_key.key_param_set.key, key->key_param_set.key, len);return 0 ; }
@@ -616,9 +620,14 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) {struct host_cmd_ds_802_11_key_material_v2 *key_v2; -__le16 len; +int len; key_v2 = &resp->params.key_material_v2; + + len =le16_to_cpu (key_v2->key_param_set.key_params.aes.key_len); +if (len >WLAN_KEY_LEN_CCMP ) +return -EINVAL ; +if (le16_to_cpu (key_v2->action) == HostCmd_ACT_GEN_SET) {if ((le16_to_cpu (key_v2->key_param_set.key_info) &KEY_MCAST )) {mwifiex_dbg (priv->adapter,INFO ,"info: key: GTK is set\n" );
@@ -634,10 +643,9 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,memset (priv->aes_key_v2.key_param_set.key_params.aes.key,0 ,WLAN_KEY_LEN_CCMP ); priv->aes_key_v2.key_param_set.key_params.aes.key_len = - key_v2->key_param_set.key_params.aes.key_len; - len = priv->aes_key_v2.key_param_set.key_params.aes.key_len; +cpu_to_le16 (len);memcpy (priv->aes_key_v2.key_param_set.key_params.aes.key, - key_v2->key_param_set.key_params.aes.key,le16_to_cpu (len)); + key_v2->key_param_set.key_params.aes.key, len);return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 128/212 powerpc/vdso: Fix vdso cpu truncation
In reply to Greg Kroah-HartmanFrom: Milton Miller <[email protected]>
[ Upstream commit a9f675f950a07d5c1dbcbb97aabac56f5ed085e3 ]
The code in vdso_cpu_init that exposes the cpu and numa node to userspace via SPRG_VDSO incorrctly masks the cpu to 12 bits. This means that any kernel running on a box with more than 4096 threads (NR_CPUS advertises a limit of of 8192 cpus) would expose userspace to two cpu contexts running at the same time with the same cpu number.
Note: I'm not aware of any distro shipping a kernel with support for more than 4096 threads today, nor of any system image that currently exceeds 4096 threads. Found via code browsing.
--- arch/powerpc/kernel/vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/vdso.c +1 -1
@@ -704,7 +704,7 @@ int vdso_getcpu_init(void) node =cpu_to_node (cpu);WARN_ON_ONCE (node >0xffff ); - val = (cpu &0xfff ) | ((node &0xffff ) <<16 ); + val = (cpu &0xffff ) | ((node &0xffff ) <<16 );mtspr (SPRN_SPRG_VDSO_WRITE , val);get_paca ()->sprg_vdso = val;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 129/212 staging: rtl8192u: fix a dubious looking mask before a shift
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit c4283950a9a4d3bf4a3f362e406c80ab14f10714 ]
Currently the masking of ret with 0xff and followed by a right shift of 8 bits always leaves a zero result. It appears the mask of 0xff is incorrect and should be 0xff00, but I don't have the hardware to test this. Fix this to mask the upper 8 bits before shifting.
[ Not tested ]
Addresses-Coverity: ("Operands don't affect result")
--- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_core.c +1 -1
@@ -2522,7 +2522,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev) ret =eprom_read (dev, (EEPROM_TxPwIndex_CCK >>1 ));if (ret <0 )return ret; - priv->EEPROMTxPowerLevelCCK = ((u16 )ret &0xff ) >>8 ; + priv->EEPROMTxPowerLevelCCK = ((u16 )ret &0xff00 ) >>8 ; }else priv->EEPROMTxPowerLevelCCK =0x10 ;RT_TRACE (COMP_EPROM ,"CCK Tx Power Levl: 0x%02x\n" , priv->EEPROMTxPowerLevelCCK);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 130/212 PCI/ASPM: Add missing newline in sysfs policy
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 3167e3d340c092fd47924bc4d23117a3074ef9a9 ]
When I cat ASPM parameter 'policy' by sysfs, it displays as follows. Add a newline for easy reading. Other sysfs attributes already include a newline.
[root@localhost ~]# cat /sys/module/pcie_aspm/parameters/policy [default] performance powersave powersupersave [root@localhost ~]#
--- drivers/pci/pcie/aspm.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/pcie/aspm.c +1 -0
@@ -832,6 +832,7 @@ static int pcie_aspm_get_policy(char *buffer, struct kernel_param *kp) cnt +=sprintf (buffer + cnt,"[%s] " , policy_str[i]); else cnt += sprintf(buffer + cnt, "%s ", policy_str[i]); + cnt +=sprintf (buffer + cnt,"\n" );return cnt; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 131/212 drm/imx: tve: fix regulator_disable error path
In reply to Greg Kroah-HartmanFrom: Marco Felsch <[email protected]>
[ Upstream commit 7bb58b987fee26da2a1665c01033022624986b7c ]
Add missing regulator_disable() as devm_action to avoid dedicated unbind() callback and fix the missing error handling.
--- drivers/gpu/drm/imx/imx-tve.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/imx/imx-tve.c +10 -10
@@ -511,6 +511,13 @@ static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve)return 0 ; } +static void imx_tve_disable_regulator (void *data) +{ +struct imx_tve *tve = data; + +regulator_disable (tve->dac_reg); +} +static bool imx_tve_readable_reg (struct device *dev,unsigned int reg) {return (reg %4 ==0 ) && (reg <=0xdc );
@@ -635,6 +642,9 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) ret =regulator_enable (tve->dac_reg);if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx_tve_disable_regulator, tve); +if (ret) +return ret; } tve->clk =devm_clk_get (dev,"tve" );
@@ -681,18 +691,8 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)return 0 ; } -static void imx_tve_unbind (struct device *dev,struct device *master, -void *data) -{ -struct imx_tve *tve =dev_get_drvdata (dev); - -if (!IS_ERR (tve->dac_reg)) -regulator_disable (tve->dac_reg); -} -static const struct component_ops imx_tve_ops = { .bind = imx_tve_bind, - .unbind = imx_tve_unbind, };static int imx_tve_probe (struct platform_device *pdev)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 132/212 USB: serial: iuu_phoenix: fix led-activity helpers
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit de37458f8c2bfc465500a1dd0d15dbe96d2a698c ]
The set-led command is eight bytes long and starts with a command byte followed by six bytes of RGB data and ends with a byte encoding a frequency (see iuu_led() and iuu_rgbf_fill_buffer()).
The led activity helpers had a few long-standing bugs which corrupted the command packets by inserting a second command byte and thereby offsetting the RGB data and dropping the frequency in non-xmas mode.
In xmas mode, a related off-by-one error left the frequency field uninitialised.
--- drivers/usb/serial/iuu_phoenix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/usb/serial/iuu_phoenix.c +8 -6
@@ -369,10 +369,11 @@ static void iuu_led_activity_on(struct urb *urb)struct usb_serial_port *port = urb->context;int result;char *buf_ptr = port->write_urb->transfer_buffer; - *buf_ptr++ =IUU_SET_LED ; +if (xmas) { -get_random_bytes (buf_ptr,6 ); - *(buf_ptr+7 ) =1 ; + buf_ptr[0 ] =IUU_SET_LED ; +get_random_bytes (buf_ptr +1 ,6 ); + buf_ptr[7 ] =1 ; }else {iuu_rgbf_fill_buffer (buf_ptr,255 ,255 ,0 ,0 ,0 ,0 ,255 ); }
@@ -390,13 +391,14 @@ static void iuu_led_activity_off(struct urb *urb)struct usb_serial_port *port = urb->context;int result;char *buf_ptr = port->write_urb->transfer_buffer; +if (xmas) {iuu_rxcmd (urb);return ; - }else { - *buf_ptr++ =IUU_SET_LED ; -iuu_rgbf_fill_buffer (buf_ptr,0 ,0 ,255 ,255 ,0 ,0 ,255 ); } + +iuu_rgbf_fill_buffer (buf_ptr,0 ,0 ,255 ,255 ,0 ,0 ,255 ); + usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 133/212 usb: dwc2: Fix error path in gadget registration
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 33a06f1300a79cfd461cea0268f05e969d4f34ec ]
When gadget registration fails, one should not call usb_del_gadget_udc(). Ensure this by setting gadget->udc to NULL. Also in case of a failure there is no need to disable low-level hardware, so return immiedetly instead of jumping to error_init label.
This fixes the following kernel NULL ptr dereference on gadget failure (can be easily triggered with g_mass_storage without any module parameters):
dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter besl=1 dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter g_np_tx_fifo_size=1024 dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
no file given for LUN0g_mass_storage 12480000.hsotg: failed to start g_mass_storage: -22 8<--- cut here ---
Unable to handle kernel NULL pointer dereference at virtual address 00000104 pgd = (ptrval) [00000104] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.8.0-rc5 #3133 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events deferred_probe_work_func PC is at usb_del_gadget_udc+0x38/0xc4 LR is at __mutex_lock+0x31c/0xb18 ... Process kworker/0:1 (pid: 12, stack limit = 0x(ptrval)) Stack: (0xef121db0 to 0xef122000)
...
[<c076bf3c>] (usb_del_gadget_udc) from [<c0726bec>] (dwc2_hsotg_remove+0x10/0x20) [<c0726bec>] (dwc2_hsotg_remove) from [<c0711208>] (dwc2_driver_probe+0x57c/0x69c) [<c0711208>] (dwc2_driver_probe) from [<c06247c0>] (platform_drv_probe+0x6c/0xa4) [<c06247c0>] (platform_drv_probe) from [<c0621df4>] (really_probe+0x200/0x48c) [<c0621df4>] (really_probe) from [<c06221e8>] (driver_probe_device+0x78/0x1fc) [<c06221e8>] (driver_probe_device) from [<c061fcd4>] (bus_for_each_drv+0x74/0xb8) [<c061fcd4>] (bus_for_each_drv) from [<c0621b54>] (__device_attach+0xd4/0x16c) [<c0621b54>] (__device_attach) from [<c0620c98>] (bus_probe_device+0x88/0x90) [<c0620c98>] (bus_probe_device) from [<c06211b0>] (deferred_probe_work_func+0x3c/0xd0) [<c06211b0>] (deferred_probe_work_func) from [<c0149280>] (process_one_work+0x234/0x7dc) [<c0149280>] (process_one_work) from [<c014986c>] (worker_thread+0x44/0x51c) [<c014986c>] (worker_thread) from [<c0150b1c>] (kthread+0x158/0x1a0) [<c0150b1c>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
Exception stack(0xef121fb0 to 0xef121ff8) ... ---[ end trace 9724c2fc7cc9c982 ]---
While fixing this also fix the double call to dwc2_lowlevel_hw_disable() if dr_mode is set to USB_DR_MODE_PERIPHERAL. In such case low-level hardware is already disabled before calling usb_add_gadget_udc(). That function correctly preserves low-level hardware state, there is no need for the second unconditional dwc2_lowlevel_hw_disable() call.
--- drivers/usb/dwc2/platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/dwc2/platform.c +3 -1
@@ -668,6 +668,7 @@ static int dwc2_driver_probe(struct platform_device *dev)if (hsotg->gadget_enabled) { retval =usb_add_gadget_udc (hsotg->dev, &hsotg->gadget);if (retval) { + hsotg->gadget.udc =NULL ;dwc2_hsotg_remove (hsotg); goto error; }
@@ -676,7 +677,8 @@ static int dwc2_driver_probe(struct platform_device *dev)return 0 ; error: -dwc2_lowlevel_hw_disable (hsotg); +if (hsotg->dr_mode !=USB_DR_MODE_PERIPHERAL ) +dwc2_lowlevel_hw_disable (hsotg);return retval; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 134/212 scsi: mesh: Fix panic after host or bus reset
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit edd7dd2292ab9c3628b65c4d04514c3068ad54f6 ]
Booting Linux with a Conner CP3200 drive attached to the MESH SCSI bus results in EH measures and a panic:
[ 25.499838] mesh: configured for synchronous 5 MB/s [ 25.787154] mesh: performing initial bus reset... [ 29.867115] scsi host0: MESH [ 29.929527] mesh: target 0 synchronous at 3.6 MB/s [ 29.998763] scsi 0:0:0:0: Direct-Access CONNER CP3200-200mb-3.5 4040 PQ: 0 ANSI: 1 CCS [ 31.989975] sd 0:0:0:0: [sda] 415872 512-byte logical blocks: (213 MB/203 MiB) [ 32.070975] sd 0:0:0:0: [sda] Write Protect is off [ 32.137197] sd 0:0:0:0: [sda] Mode Sense: 5b 00 00 08 [ 32.209661] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 32.332708] sda: [mac] sda1 sda2 sda3 [ 32.417733] sd 0:0:0:0: [sda] Attached SCSI disk ... snip ... [ 76.687067] mesh_abort((ptrval)) [ 76.743606] mesh: state at (ptrval), regs at (ptrval), dma at (ptrval) [ 76.810798] ct=6000 seq=86 bs=4017 fc= 0 exc= 0 err= 0 im= 7 int= 0 sp=85 [ 76.880720] dma stat=84e0 cmdptr=1f73d000 [ 76.941387] phase=4 msgphase=0 conn_tgt=0 data_ptr=24576 [ 77.005567] dma_st=1 dma_ct=0 n_msgout=0 [ 77.065456] target 0: req=(ptrval) goes_out=0 saved_ptr=0 [ 77.130512] mesh_abort((ptrval)) [ 77.187670] mesh: state at (ptrval), regs at (ptrval), dma at (ptrval) [ 77.255594] ct=6000 seq=86 bs=4017 fc= 0 exc= 0 err= 0 im= 7 int= 0 sp=85 [ 77.325778] dma stat=84e0 cmdptr=1f73d000 [ 77.387239] phase=4 msgphase=0 conn_tgt=0 data_ptr=24576 [ 77.453665] dma_st=1 dma_ct=0 n_msgout=0 [ 77.515900] target 0: req=(ptrval) goes_out=0 saved_ptr=0 [ 77.582902] mesh_host_reset [ 88.187083] Kernel panic - not syncing: mesh: double DMA start ! [ 88.254510] CPU: 0 PID: 358 Comm: scsi_eh_0 Not tainted 5.6.13-pmac #1 [ 88.323302] Call Trace: [ 88.378854] [e16ddc58] [c0027080] panic+0x13c/0x308 (unreliable) [ 88.446221] [e16ddcb8] [c02b2478] mesh_start.part.12+0x130/0x414 [ 88.513298] [e16ddcf8] [c02b2fc8] mesh_queue+0x54/0x70 [ 88.577097] [e16ddd18] [c02a1848] scsi_send_eh_cmnd+0x374/0x384 [ 88.643476] [e16dddc8] [c02a1938] scsi_eh_tur+0x5c/0xb8 [ 88.707878] [e16dddf8] [c02a1ab8] scsi_eh_test_devices+0x124/0x178 [ 88.775663] [e16dde28] [c02a2094] scsi_eh_ready_devs+0x588/0x8a8 [ 88.843124] [e16dde98] [c02a31d8] scsi_error_handler+0x344/0x520 [ 88.910697] [e16ddf08] [c00409c8] kthread+0xe4/0xe8 [ 88.975166] [e16ddf38] [c000f234] ret_from_kernel_thread+0x14/0x1c [ 89.044112] Rebooting in 180 seconds..
In theory, a panic can happen after a bus or host reset with dma_started flag set. Fix this by halting the DMA before reinitializing the host. Don't assume that ms->current_req is set when halt_dma() is invoked as it may not hold for bus or host reset.
BTW, this particular Conner drive can be made to work by inhibiting disconnect/reselect with 'mesh.resel_targets=0'.
--- drivers/scsi/mesh.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/mesh.c +7 -1
@@ -1044,6 +1044,8 @@ static void handle_error(struct mesh_state *ms)while ((in_8 (&mr->bus_status1) &BS1_RST ) !=0 )udelay (1 );printk ("done\n" ); +if (ms->dma_started) +halt_dma (ms);handle_reset (ms);/* request_q is empty, no point in mesh_start() */ return ;
@@ -1356,7 +1358,8 @@ static void halt_dma(struct mesh_state *ms) ms->conn_tgt, ms->data_ptr,scsi_bufflen (cmd), ms->tgts[ms->conn_tgt].data_goes_out); } -scsi_dma_unmap (cmd); +if (cmd) +scsi_dma_unmap (cmd); ms->dma_started =0 ; }
@@ -1711,6 +1714,9 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)spin_lock_irqsave (ms->host->host_lock, flags); +if (ms->dma_started) +halt_dma (ms); +/* Reset the controller & dbdma channel */ out_le32 (&md->control, (RUN |PAUSE |FLUSH |WAKE ) <<16 );/* stop dma */ out_8 (&mr->exception,0xff );/* clear all exception bits */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 135/212 Smack: fix another vsscanf out of bounds
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a6bd4f6d9b07452b0b19842044a6c3ea384b0b88 ]
This is similar to commit 84e99e58e8d1 ("Smack: slab-out-of-bounds in vsscanf") where we added a bounds check on "rule".
--- security/smack/smackfs.c | 4 ++++ 1 file changed, 4 insertions(+)
security/smack/smackfs.c +4 -0
@@ -928,6 +928,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,for (i =0 ; i < catlen; i++) { rule +=SMK_DIGITLEN ; +if (rule > data + count) { + rc = -EOVERFLOW ; + goto out; + } ret =sscanf (rule,"%u" , &cat);if (ret !=1 || cat >SMACK_CIPSO_MAXCATNUM ) goto out;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 136/212 Smack: prevent underflow in smk_set_cipso()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 42a2df3e829f3c5562090391b33714b2e2e5ad4a ]
We have an upper bound on "maplevel" but forgot to check for negative values.
--- security/smack/smackfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smackfs.c +1 -1
@@ -907,7 +907,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, } ret =sscanf (rule,"%d" , &maplevel); -if (ret !=1 || maplevel >SMACK_CIPSO_MAXLEVEL ) +if (ret !=1 || maplevel <0 || maplevel >SMACK_CIPSO_MAXLEVEL ) goto out; rule +=SMK_DIGITLEN ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 137/212 power: supply: check if calc_soc succeeded in pm860x_init_battery
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit ccf193dee1f0fff55b556928591f7818bac1b3b1 ]
clang static analysis flags this error
88pm860x_battery.c:522:19: warning: Assigned value is
garbage or undefined [core.uninitialized.Assign]
info->start_soc = soc;
^ ~~~soc is set by calling calc_soc.
But calc_soc can return without setting soc.
So check the return status and bail similarly to other checks in pm860x_init_battery and initialize soc to silence the warning.
--- drivers/power/supply/88pm860x_battery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/88pm860x_battery.c +4 -2
@@ -436,7 +436,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)int ret;int data;int bat_remove; -int soc; +int soc =0 ;/* measure enable on GPADC1 */ data =MEAS1_GP1 ;
@@ -499,7 +499,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) }mutex_unlock (&info->lock); -calc_soc (info,OCV_MODE_ACTIVE , &soc); + ret =calc_soc (info,OCV_MODE_ACTIVE , &soc); +if (ret <0 ) + goto out; data =pm860x_reg_read (info->i2c,PM8607_POWER_UP_LOG ); bat_remove = data &BAT_WU_LOG ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 138/212 selftests/powerpc: Fix CPU affinity for child process
In reply to Greg Kroah-HartmanFrom: Harish <[email protected]>
[ Upstream commit 854eb5022be04f81e318765f089f41a57c8e5d83 ]
On systems with large number of cpus, test fails trying to set affinity by calling sched_setaffinity() with smaller size for affinity mask. This patch fixes it by making sure that the size of allocated affinity mask is dependent on the number of CPUs as reported by get_nprocs().
--- .../powerpc/benchmarks/context_switch.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
tools/testing/selftests/powerpc/benchmarks/context_switch.c +16 -5
@@ -22,6 +22,7 @@#include <limits.h> #include <sys/time.h> #include <sys/syscall.h> +#include <sys/sysinfo.h> #include <sys/types.h> #include <sys/shm.h> #include <linux/futex.h>
@@ -97,8 +98,9 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)static void start_process_on (void *(*fn)(void *),void *arg,unsigned long cpu) { -int pid; -cpu_set_t cpuset; +int pid, ncpus; +cpu_set_t *cpuset; +size_t size; pid =fork ();if (pid ==-1 ) {
@@ -109,14 +111,23 @@ static void start_process_on(void *(*fn)(void *), void *arg, unsigned long cpu)if (pid)return ; -CPU_ZERO (&cpuset); -CPU_SET (cpu, &cpuset); + ncpus =get_nprocs (); + size =CPU_ALLOC_SIZE (ncpus); + cpuset =CPU_ALLOC (ncpus); +if (!cpuset) { +perror ("malloc" ); +exit (1 ); + } +CPU_ZERO_S (size, cpuset); +CPU_SET_S (cpu, size, cpuset); -if (sched_setaffinity (0 ,sizeof (cpuset), &cpuset)) { +if (sched_setaffinity (0 , size, cpuset)) {perror ("sched_setaffinity" ); +CPU_FREE (cpuset);exit (1 ); } +CPU_FREE (cpuset);fn (arg);exit (0 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 139/212 selftests/powerpc: Fix online CPU selection
In reply to Greg Kroah-HartmanFrom: Sandipan Das <[email protected]>
[ Upstream commit dfa03fff86027e58c8dba5c03ae68150d4e513ad ]
The size of the CPU affinity mask must be large enough for systems with a very large number of CPUs. Otherwise, tests which try to determine the first online CPU by calling sched_getaffinity() will fail. This makes sure that the size of the allocated affinity mask is dependent on the number of CPUs as reported by get_nprocs_conf().
--- tools/testing/selftests/powerpc/utils.c | 37 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 12 deletions(-)
tools/testing/selftests/powerpc/utils.c +25 -12
@@ -12,6 +12,7 @@#include <sched.h> #include <stdio.h> #include <sys/stat.h> +#include <sys/sysinfo.h> #include <sys/types.h> #include <unistd.h>
@@ -62,26 +63,38 @@ void *get_auxv_entry(int type)int pick_online_cpu (void ) { -cpu_set_t mask; -int cpu; +int ncpus, cpu =-1 ; +cpu_set_t *mask; +size_t size; + + ncpus =get_nprocs_conf (); + size =CPU_ALLOC_SIZE (ncpus); + mask =CPU_ALLOC (ncpus); +if (!mask) { +perror ("malloc" ); +return -1 ; + } -CPU_ZERO (&mask); +CPU_ZERO_S (size, mask); -if (sched_getaffinity (0 ,sizeof (mask), &mask)) { +if (sched_getaffinity (0 , size, mask)) {perror ("sched_getaffinity" ); -return -1 ; + goto done; }/* We prefer a primary thread, but skip 0 */ -for (cpu =8 ; cpu <CPU_SETSIZE ; cpu +=8 ) -if (CPU_ISSET (cpu, &mask)) -return cpu; +for (cpu =8 ; cpu < ncpus; cpu +=8 ) +if (CPU_ISSET_S (cpu, size, mask)) + goto done;/* Search for anything, but in reverse */ -for (cpu =CPU_SETSIZE -1 ; cpu >=0 ; cpu--) -if (CPU_ISSET (cpu, &mask)) -return cpu; +for (cpu = ncpus -1 ; cpu >=0 ; cpu--) +if (CPU_ISSET_S (cpu, size, mask)) + goto done;printf ("No cpus in affinity mask?!\n" ); -return -1 ; + +done: +CPU_FREE (mask); +return cpu; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 140/212 s390/qeth: dont process empty bridge port events
In reply to Greg Kroah-HartmanFrom: Julian Wiedmann <[email protected]>
[ Upstream commit 02472e28b9a45471c6d8729ff2c7422baa9be46a ]
Discard events that don't contain any entries. This shouldn't happen, but subsequent code relies on being able to use entry 0. So better be safe than accessing garbage.
--- drivers/s390/net/qeth_l2_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/s390/net/qeth_l2_main.c +4 -0
@@ -1675,6 +1675,10 @@ static void qeth_bridge_state_change(struct qeth_card *card,int extrasize;QETH_CARD_TEXT (card,2 ,"brstchng" ); +if (qports->num_entries ==0 ) { +QETH_CARD_TEXT (card,2 ,"BPempty" ); +return ; + }if (qports->entry_length !=sizeof (struct qeth_sbp_port_entry )) {QETH_CARD_TEXT_ (card,2 ,"BPsz%04x" , qports->entry_length);return ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 141/212 wl1251: fix always return 0 error
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 20e6421344b5bc2f97b8e2db47b6994368417904 ]
wl1251_event_ps_report() should not always return 0 because wl1251_ps_set_mode() may fail. Change it to return 'ret'.
--- drivers/net/wireless/ti/wl1251/event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/event.c +1 -1
@@ -84,7 +84,7 @@ static int wl1251_event_ps_report(struct wl1251 *wl,break ; } -return 0 ; +return ret; }static void wl1251_event_mbox_dump (struct event_mailbox *mbox)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 142/212 net: spider_net: Fix the size used in a dma_free_coherent() call
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 36f28f7687a9ce665479cce5d64ce7afaa9e77ae ]
Update the size used in 'dma_free_coherent()' in order to match the one used in the corresponding 'dma_alloc_coherent()', in 'spider_net_init_chain()'.
--- drivers/net/ethernet/toshiba/spider_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/toshiba/spider_net.c +2 -2
@@ -296,8 +296,8 @@ spider_net_free_chain(struct spider_net_card *card, descr = descr->next; }while (descr != chain->ring); -dma_free_coherent (&card->pdev->dev, chain->num_desc, - chain->hwring, chain->dma_addr); +dma_free_coherent (&card->pdev->dev, chain->num_desc *sizeof (struct spider_net_hw_descr ), + chain->hwring, chain->dma_addr); }/**
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 143/212 fsl/fman: use 32-bit unsigned integer
In reply to Greg Kroah-HartmanFrom: Florinel Iordache <[email protected]>
[ Upstream commit 99f47abd9f7bf6e365820d355dc98f6955a562df ]
Potentially overflowing expression (ts_freq << 16 and intgr << 16) declared as type u32 (32-bit unsigned) is evaluated using 32-bit arithmetic and then used in a context that expects an expression of type u64 (64-bit unsigned) which ultimately is used as 16-bit unsigned by typecasting to u16. Fixed by using an unsigned 32-bit integer since the value is truncated anyway in the end.
--- drivers/net/ethernet/freescale/fman/fman.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/freescale/fman/fman.c +1 -2
@@ -1446,8 +1446,7 @@ static void enable_time_stamp(struct fman *fman) {struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs;u16 fm_clk_freq = fman->state->fm_clk_freq; -u32 tmp, intgr, ts_freq; -u64 frac; +u32 tmp, intgr, ts_freq, frac; ts_freq = (u32)(1 << fman->state->count1_micro_bit);/* configure timestamp so that bit 8 will count 1 microsecond
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 144/212 fsl/fman: fix dereference null return value
In reply to Greg Kroah-HartmanFrom: Florinel Iordache <[email protected]>
[ Upstream commit 0572054617f32670abab4b4e89a876954d54b704 ]
Check before using returned value to avoid dereferencing null pointer.
--- drivers/net/ethernet/freescale/fman/fman_port.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/fman_port.c +8 -1
@@ -1623,6 +1623,7 @@ static int fman_port_probe(struct platform_device *of_dev)struct fman_port *port;struct fman *fman;struct device_node *fm_node, *port_node; +struct platform_device *fm_pdev;struct resource res;struct resource *dev_res;u32 val;
@@ -1647,8 +1648,14 @@ static int fman_port_probe(struct platform_device *of_dev) goto return_err; } - fman =dev_get_drvdata (&of_find_device_by_node (fm_node)->dev); + fm_pdev =of_find_device_by_node (fm_node);of_node_put (fm_node); +if (!fm_pdev) { + err = -EINVAL ; + goto return_err; + } + + fman =dev_get_drvdata (&fm_pdev->dev);if (!fman) { err = -EINVAL ; goto return_err;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 145/212 fsl/fman: fix unreachable code
In reply to Greg Kroah-HartmanFrom: Florinel Iordache <[email protected]>
[ Upstream commit cc79fd8f557767de90ff199d3b6fb911df43160a ]
The parameter 'priority' is incorrectly forced to zero which ultimately induces logically dead code in the subsequent lines.
--- drivers/net/ethernet/freescale/fman/fman_memac.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/freescale/fman/fman_memac.c +0 -1
@@ -851,7 +851,6 @@ int memac_set_tx_pause_frames(struct fman_mac *memac, u8 priority, tmp =ioread32be (®s->command_config); tmp &= ~CMD_CFG_PFC_MODE ; - priority =0 ;iowrite32be (tmp, ®s->command_config);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 146/212 fsl/fman: check dereferencing null pointer
In reply to Greg Kroah-HartmanFrom: Florinel Iordache <[email protected]>
[ Upstream commit cc5d229a122106733a85c279d89d7703f21e4d4f ]
Add a safe check to avoid dereferencing null pointer
--- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 4 ++-- drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +- drivers/net/ethernet/freescale/fman/fman_tgec.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/freescale/fman/fman_dtsec.c +2 -2
@@ -1095,7 +1095,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)list_for_each (pos, &dtsec->multicast_addr_hash->lsts[bucket]) { hash_entry =ETH_HASH_ENTRY_OBJ (pos); -if (hash_entry->addr == addr) { +if (hash_entry && hash_entry->addr == addr) {list_del_init (&hash_entry->node);kfree (hash_entry);break ;
@@ -1108,7 +1108,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)list_for_each (pos, &dtsec->unicast_addr_hash->lsts[bucket]) { hash_entry =ETH_HASH_ENTRY_OBJ (pos); -if (hash_entry->addr == addr) { +if (hash_entry && hash_entry->addr == addr) {list_del_init (&hash_entry->node);kfree (hash_entry);break ;
drivers/net/ethernet/freescale/fman/fman_memac.c +1 -1
@@ -952,7 +952,7 @@ int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)list_for_each (pos, &memac->multicast_addr_hash->lsts[hash]) { hash_entry =ETH_HASH_ENTRY_OBJ (pos); -if (hash_entry->addr == addr) { +if (hash_entry && hash_entry->addr == addr) {list_del_init (&hash_entry->node);kfree (hash_entry);break ;
drivers/net/ethernet/freescale/fman/fman_tgec.c +1 -1
@@ -585,7 +585,7 @@ int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)list_for_each (pos, &tgec->multicast_addr_hash->lsts[hash]) { hash_entry =ETH_HASH_ENTRY_OBJ (pos); -if (hash_entry->addr == addr) { +if (hash_entry && hash_entry->addr == addr) {list_del_init (&hash_entry->node);kfree (hash_entry);break ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 147/212 fsl/fman: fix eth hash table allocation
In reply to Greg Kroah-HartmanFrom: Florinel Iordache <[email protected]>
[ Upstream commit 3207f715c34317d08e798e11a10ce816feb53c0f ]
Fix memory allocation for ethernet address hash table. The code was wrongly allocating an array for eth hash table which is incorrect because this is the main structure for eth hash table (struct eth_hash_t) that contains inside a number of elements.
--- drivers/net/ethernet/freescale/fman/fman_mac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/fman_mac.h +1 -1
@@ -252,7 +252,7 @@ static inline struct eth_hash_t *alloc_hash_table(u16 size)struct eth_hash_t *hash;/* Allocate address hash table */ - hash =kmalloc_array (size,sizeof (struct eth_hash_t *),GFP_KERNEL ); + hash =kmalloc (sizeof (*hash),GFP_KERNEL );if (!hash)return NULL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 148/212 dlm: Fix kobject memleak
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 0ffddafc3a3970ef7013696e7f36b3d378bc4c16 ]
Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject.
Set do_unreg = 1 before kobject_init_and_add() to ensure that kobject_put() can be called in its error patch.
--- fs/dlm/lockspace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/dlm/lockspace.c +3 -3
@@ -626,6 +626,9 @@ static int new_lockspace(const char *name, const char *cluster,wait_event (ls->ls_recover_lock_wait,test_bit (LSFL_RECOVER_LOCK , &ls->ls_flags)); +/* let kobject handle freeing of ls if there's an error */ + do_unreg =1 ; + ls->ls_kobj.kset = dlm_kset; error =kobject_init_and_add (&ls->ls_kobj, &dlm_ktype,NULL ,"%s" , ls->ls_name);
@@ -633,9 +636,6 @@ static int new_lockspace(const char *name, const char *cluster, goto out_recoverd;kobject_uevent (&ls->ls_kobj,KOBJ_ADD ); -/* let kobject handle freeing of ls if there's an error */ - do_unreg =1 ; -/* This uevent triggers dlm_controld in userspace to add us to the group of nodes that are members of this lockspace (managed by the cluster infrastructure.) Once it's done that, it tells us who the
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 149/212 pinctrl-single: fix pcs_parse_pinconf() return value
In reply to Greg Kroah-HartmanFrom: Drew Fustini <[email protected]>
[ Upstream commit f46fe79ff1b65692a65266a5bec6dbe2bf7fc70f ]
This patch causes pcs_parse_pinconf() to return -ENOTSUPP when no pinctrl_map is added. The current behavior is to return 0 when !PCS_HAS_PINCONF or !nconfs. Thus pcs_parse_one_pinctrl_entry() incorrectly assumes that a map was added and sets num_maps = 2.
Analysis:
=========
The function pcs_parse_one_pinctrl_entry() calls pcs_parse_pinconf() if PCS_HAS_PINCONF is enabled. The function pcs_parse_pinconf() returns 0 to indicate there was no error and num_maps is then set to 2:
980 static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
981 struct device_node *np,
982 struct pinctrl_map **map,
983 unsigned *num_maps,
984 const char **pgnames)
985 {
<snip>
1053 (*map)->type = PIN_MAP_TYPE_MUX_GROUP;
1054 (*map)->data.mux.group = np->name;
1055 (*map)->data.mux.function = np->name;1056
1057 if (PCS_HAS_PINCONF && function) {
1058 res = pcs_parse_pinconf(pcs, np, function, map);
1059 if (res)
1060 goto free_pingroups;
1061 *num_maps = 2;
1062 } else {
1063 *num_maps = 1;
1064 }
However, pcs_parse_pinconf() will also return 0 if !PCS_HAS_PINCONF or !nconfs. I believe these conditions should indicate that no map was added by returning -ENOTSUPP. Otherwise pcs_parse_one_pinctrl_entry() will set num_maps = 2 even though no maps were successfully added, as it does not reach "m++" on line 940:
895 static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
896 struct pcs_function *func,
897 struct pinctrl_map **map)
898
899 {
900 struct pinctrl_map *m = *map;
<snip>
917 /* If pinconf isn't supported, don't parse properties in below. */
918 if (!PCS_HAS_PINCONF)
919 return 0;
920
921 /* cacluate how much properties are supported in current node */
922 for (i = 0; i < ARRAY_SIZE(prop2); i++) {
923 if (of_find_property(np, prop2[i].name, NULL))
924 nconfs++;
925 }
926 for (i = 0; i < ARRAY_SIZE(prop4); i++) {
927 if (of_find_property(np, prop4[i].name, NULL))
928 nconfs++;
929 }
930 if (!nconfs)
919 return 0;
932
933 func->conf = devm_kcalloc(pcs->dev,
934 nconfs, sizeof(struct pcs_conf_vals),
935 GFP_KERNEL);
936 if (!func->conf)
937 return -ENOMEM;
938 func->nconfs = nconfs; 939 conf = &(func->conf[0]); 940 m++;
This situtation will cause a boot failure [0] on the BeagleBone Black (AM3358) when am33xx_pinmux node in arch/arm/boot/dts/am33xx-l4.dtsi has compatible = "pinconf-single" instead of "pinctrl-single".
The patch fixes this issue by returning -ENOSUPP when !PCS_HAS_PINCONF or !nconfs, so that pcs_parse_one_pinctrl_entry() will know that no map was added.
Logic is also added to pcs_parse_one_pinctrl_entry() to distinguish between -ENOSUPP and other errors. In the case of -ENOSUPP, num_maps is set to 1 as it is valid for pinconf to be enabled and a given pin group to not any pinconf properties.
[0] https://lore.kernel.org/linux-omap/20200529175544.GA3766151@x1/
--- drivers/pinctrl/pinctrl-single.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/pinctrl/pinctrl-single.c +7 -4
@@ -1078,7 +1078,7 @@ static int pcs_parse_pinconf(struct pcs_/* If pinconf isn't supported, don't parse properties in below. */ if (!PCS_HAS_PINCONF ) -return 0 ; +return -ENOTSUPP ;/* cacluate how much properties are supported in current node */ for (i =0 ; i <ARRAY_SIZE (prop2); i++) {
@@ -1090,7 +1090,7 @@ static int pcs_parse_pinconf(struct pcs_ nconfs++; }if (!nconfs) -return 0 ; +return -ENOTSUPP ; func->conf = devm_kzalloc(pcs->dev, sizeof(struct pcs_conf_vals) * nconfs,
@@ -1203,9 +1203,12 @@ static int pcs_parse_one_pinctrl_entry(sif (PCS_HAS_PINCONF ) { res =pcs_parse_pinconf (pcs, np, function, map); -if (res) +if (res ==0 ) + *num_maps =2 ; +else if (res == -ENOTSUPP ) + *num_maps =1 ; +else goto free_pingroups; - *num_maps =2 ; }else { *num_maps =1 ; }
Greg Kroah-Hartman
maintainerPATCH 150/212 drivers/net/wan/lapbether: Added needed_headroom and a skb->len check
In reply to Greg Kroah-HartmanFrom: Xie He <[email protected]>
[ Upstream commit c7ca03c216acb14466a713fedf1b9f2c24994ef2 ]
1. Added a skb->len check
This driver expects upper layers to include a pseudo header of 1 byte when passing down a skb for transmission. This driver will read this 1-byte header. This patch added a skb->len check before reading the header to make sure the header exists.
2. Changed to use needed_headroom instead of hard_header_len to request necessary headroom to be allocated
In net/packet/af_packet.c, the function packet_snd first reserves a headroom of length (dev->hard_header_len + dev->needed_headroom). Then if the socket is a SOCK_DGRAM socket, it calls dev_hard_header, which calls dev->header_ops->create, to create the link layer header. If the socket is a SOCK_RAW socket, it "un-reserves" a headroom of length (dev->hard_header_len), and assumes the user to provide the appropriate link layer header.
So according to the logic of af_packet.c, dev->hard_header_len should be the length of the header that would be created by dev->header_ops->create.
However, this driver doesn't provide dev->header_ops, so logically dev->hard_header_len should be 0.
So we should use dev->needed_headroom instead of dev->hard_header_len to request necessary headroom to be allocated.
This change fixes kernel panic when this driver is used with AF_PACKET SOCK_RAW sockets.
Call stack when panic:
[ 168.399197] skbuff: skb_under_panic: text:ffffffff819d95fb len:20 put:14 head:ffff8882704c0a00 data:ffff8882704c09fd tail:0x11 end:0xc0 dev:veth0 ... [ 168.399255] Call Trace: [ 168.399259] skb_push.cold+0x14/0x24 [ 168.399262] eth_header+0x2b/0xc0 [ 168.399267] lapbeth_data_transmit+0x9a/0xb0 [lapbether] [ 168.399275] lapb_data_transmit+0x22/0x2c [lapb] [ 168.399277] lapb_transmit_buffer+0x71/0xb0 [lapb] [ 168.399279] lapb_kick+0xe3/0x1c0 [lapb] [ 168.399281] lapb_data_request+0x76/0xc0 [lapb] [ 168.399283] lapbeth_xmit+0x56/0x90 [lapbether] [ 168.399286] dev_hard_start_xmit+0x91/0x1f0 [ 168.399289] ? irq_init_percpu_irqstack+0xc0/0x100 [ 168.399291] __dev_queue_xmit+0x721/0x8e0 [ 168.399295] ? packet_parse_headers.isra.0+0xd2/0x110 [ 168.399297] dev_queue_xmit+0x10/0x20 [ 168.399298] packet_sendmsg+0xbf0/0x19b0
......
--- drivers/net/wan/lapbether.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/wan/lapbether.c +9 -1
@@ -160,6 +160,12 @@ static netdev_tx_t lapbeth_xmit(struct sif (!netif_running (dev)) goto drop; +/* There should be a pseudo header of 1 byte added by upper layers. +* Check to make sure it is there before reading it. +*/ +if (skb->len <1 ) + goto drop; +switch (skb->data[0 ]) {case X25_IFACE_DATA :break ;
@@ -308,6 +314,7 @@ static void lapbeth_setup(struct net_dev dev->netdev_ops = &lapbeth_netdev_ops; dev->destructor = free_netdev; dev->type =ARPHRD_X25 ; + dev->hard_header_len =0 ; dev->mtu =1000 ; dev->addr_len =0 ; }
@@ -334,7 +341,8 @@ static int lapbeth_new_device(struct net* then this driver prepends a length field of 2 bytes, * then the underlying Ethernet device prepends its own header. */ - ndev->hard_header_len =-1 +3 +2 + dev->hard_header_len; + ndev->needed_headroom =-1 +3 +2 + dev->hard_header_len + + dev->needed_headroom; lapbeth =netdev_priv (ndev); lapbeth->axdev = ndev;
Greg Kroah-Hartman
maintainerPATCH 151/212 net/nfc/rawsock.c: add CAP_NET_RAW check.
In reply to Greg Kroah-HartmanFrom: Qingyu Li <[email protected]>
[ Upstream commit 26896f01467a28651f7a536143fe5ac8449d4041 ]
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
--- net/nfc/rawsock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/nfc/rawsock.c +5 -2
@@ -344,10 +344,13 @@ static int rawsock_create(struct net *neif ((sock->type !=SOCK_SEQPACKET ) && (sock->type !=SOCK_RAW ))return -ESOCKTNOSUPPORT ; -if (sock->type ==SOCK_RAW ) +if (sock->type ==SOCK_RAW ) { +if (!capable (CAP_NET_RAW )) +return -EPERM ; sock->ops = &rawsock_raw_ops; -else + }else { sock->ops = &rawsock_ops; + } sk =sk_alloc (net,PF_NFC ,GFP_ATOMIC , nfc_proto->proto, kern);if (!sk)
Greg Kroah-Hartman
maintainerPATCH 152/212 net: Set fput_needed iff FDPUT_FPUT is set
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit ce787a5a074a86f76f5d3fd804fa78e01bfb9e89 ]
We should fput() file iff FDPUT_FPUT is set. So we should set fput_needed accordingly.
--- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +1 -1
@@ -498,7 +498,7 @@ static struct socket *sockfd_lookup_lighif (f.file) { sock =sock_from_file (f.file, err);if (likely (sock)) { - *fput_needed = f.flags; + *fput_needed = f.flags &FDPUT_FPUT ;return sock; }fdput (f);
Greg Kroah-Hartman
maintainerPATCH 153/212 USB: serial: cp210x: re-enable auto-RTS on open
In reply to Greg Kroah-HartmanFrom: Brant Merryman <[email protected]>
commit c7614ff9b73a1e6fb2b1b51396da132ed22fecdb upstream.
CP210x hardware disables auto-RTS but leaves auto-CTS when in hardware flow control mode and UART on cp210x hardware is disabled. When re-opening the port, if auto-CTS is enabled on the cp210x, then auto-RTS must be re-enabled in the driver.
--- drivers/usb/serial/cp210x.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/usb/serial/cp210x.c +17 -0
@@ -765,6 +765,7 @@ static void cp210x_get_termios_port(struu32 baud;u16 bits;u32 ctl_hs; +u32 flow_repl;cp210x_read_u32_reg (port,CP210X_GET_BAUDRATE , &baud);
@@ -865,6 +866,22 @@ static void cp210x_get_termios_port(stru ctl_hs =le32_to_cpu (flow_ctl.ulControlHandshake);if (ctl_hs &CP210X_SERIAL_CTS_HANDSHAKE ) {dev_dbg (dev,"%s - flow control = CRTSCTS\n" , __func__); +/* +* When the port is closed, the CP210x hardware disables +* auto-RTS and RTS is deasserted but it leaves auto-CTS when +* in hardware flow control mode. When re-opening the port, if +* auto-CTS is enabled on the cp210x, then auto-RTS must be +* re-enabled in the driver. +*/ + flow_repl =le32_to_cpu (flow_ctl.ulFlowReplace); + flow_repl &= ~CP210X_SERIAL_RTS_MASK ; + flow_repl |=CP210X_SERIAL_RTS_SHIFT (CP210X_SERIAL_RTS_FLOW_CTL ); + flow_ctl.ulFlowReplace =cpu_to_le32 (flow_repl); +cp210x_write_reg_block (port, +CP210X_SET_FLOW , + &flow_ctl, +sizeof (flow_ctl)); + cflag |=CRTSCTS ; }else {dev_dbg (dev,"%s - flow control = NONE\n" , __func__);
Greg Kroah-Hartman
maintainerPATCH 154/212 USB: serial: cp210x: enable usb generic throttle/unthrottle
In reply to Greg Kroah-HartmanFrom: Brant Merryman <[email protected]>
commit 4387b3dbb079d482d3c2b43a703ceed4dd27ed28 upstream.
Assign the .throttle and .unthrottle functions to be generic function in the driver structure to prevent data loss that can otherwise occur if the host does not enable USB throttling.
--- drivers/usb/serial/cp210x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/cp210x.c +2 -0
@@ -255,6 +255,8 @@ static struct usb_serial_driver cp210x_d .break_ctl = cp210x_break_ctl, .set_termios = cp210x_set_termios, .tx_empty = cp210x_tx_empty, + .throttle = usb_serial_generic_throttle, + .unthrottle = usb_serial_generic_unthrottle, .tiocmget = cp210x_tiocmget, .tiocmset = cp210x_tiocmset, .port_probe = cp210x_port_probe,
Greg Kroah-Hartman
maintainerPATCH 155/212 ALSA: usb-audio: Creative USB X-Fi Pro SB1095 volume knob support
In reply to Greg Kroah-HartmanFrom: Mirko Dietrich <[email protected]>
commit fec9008828cde0076aae595ac031bfcf49d335a4 upstream.
Adds an entry for Creative USB X-Fi to the rc_config array in mixer_quirks.c to allow use of volume knob on the device. Adds support for newer X-Fi Pro card, known as "Model No. SB1095" with USB ID "041e:3263"
--- sound/usb/mixer_quirks.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/mixer_quirks.c +1 -0
@@ -195,6 +195,7 @@ static const struct rc_config { { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */ { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ + { USB_ID(0x041e, 0x3263), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ };
Greg Kroah-Hartman
maintainerPATCH 156/212 ALSA: usb-audio: fix overeager device match for MacroSilicon MS2109
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 14a720dc1f5332f3bdf30a23a3bc549e81be974c upstream.
Matching by device matches all interfaces, which breaks the video/HID portions of the device depending on module load order.
--- sound/usb/quirks-table.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/usb/quirks-table.h +7 -1
@@ -3335,7 +3335,13 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge* with. */ { - USB_DEVICE(0x534d, 0x2109), + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | +USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS, + .idVendor = 0x534d, + .idProduct = 0x2109, + .bInterfaceClass = USB_CLASS_AUDIO, + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { .vendor_name ="MacroSilicon" , .product_name ="MS2109" ,
Greg Kroah-Hartman
maintainerPATCH 157/212 ALSA: usb-audio: add quirk for Pioneer DDJ-RB
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 6e8596172ee1cd46ec0bfd5adcf4ff86371478b6 upstream.
This is just another Pioneer device with fixed endpoints. Input is dummy but used as feedback (it always returns silence).
--- sound/usb/quirks-table.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
sound/usb/quirks-table.h +56 -0
@@ -3380,5 +3380,61 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge } } }, +{ +/* +* PIONEER DJ DDJ-RB +* PCM is 4 channels out, 2 dummy channels in @ 44.1 fixed +* The feedback for the output is the dummy input. +*/ + USB_DEVICE_VENDOR_SPEC(0x2b73, 0x000e), + .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + .ifnum =QUIRK_ANY_INTERFACE , + .type =QUIRK_COMPOSITE , + .data = (const struct snd_usb_audio_quirk []) { + { + .ifnum =0 , + .type =QUIRK_AUDIO_FIXED_ENDPOINT , + .data = &(const struct audioformat ) { + .formats =SNDRV_PCM_FMTBIT_S24_3LE , + .channels =4 , + .iface =0 , + .altsetting =1 , + .altset_idx =1 , + .endpoint =0x01 , + .ep_attr =USB_ENDPOINT_XFER_ISOC | +USB_ENDPOINT_SYNC_ASYNC , + .rates =SNDRV_PCM_RATE_44100 , + .rate_min =44100 , + .rate_max =44100 , + .nr_rates =1 , + .rate_table = (unsigned int []) {44100 } + } + }, + { + .ifnum =0 , + .type =QUIRK_AUDIO_FIXED_ENDPOINT , + .data = &(const struct audioformat ) { + .formats =SNDRV_PCM_FMTBIT_S24_3LE , + .channels =2 , + .iface =0 , + .altsetting =1 , + .altset_idx =1 , + .endpoint =0x82 , + .ep_attr =USB_ENDPOINT_XFER_ISOC | +USB_ENDPOINT_SYNC_ASYNC | +USB_ENDPOINT_USAGE_IMPLICIT_FB , + .rates =SNDRV_PCM_RATE_44100 , + .rate_min =44100 , + .rate_max =44100 , + .nr_rates =1 , + .rate_table = (unsigned int []) {44100 } + } + }, + { + .ifnum =-1 + } + } + } +}, #undef USB_DEVICE_VENDOR_SPEC
Greg Kroah-Hartman
maintainerPATCH 158/212 crypto: qat - fix double free in qat_uclo_create_batch_init_list
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit c06c76602e03bde24ee69a2022a829127e504202 upstream.
clang static analysis flags this error
qat_uclo.c:297:3: warning: Attempt to free released memory
[unix.Malloc]
kfree(*init_tab_base);
^~~~~~~~~~~~~~~~~~~~~When input *init_tab_base is null, the function allocates memory for the head of the list. When there is problem allocating other list elements the list is unwound and freed. Then a check is made if the list head was allocated and is also freed.
Keeping track of the what may need to be freed is the variable 'tail_old'. The unwinding/freeing block is
while (tail_old) {
mem_init = tail_old->next;
kfree(tail_old);
tail_old = mem_init;
}The problem is that the first element of tail_old is also what was allocated for the list head
init_header = kzalloc(sizeof(*init_header), GFP_KERNEL); ... *init_tab_base = init_header; flag = 1; } tail_old = init_header;
So *init_tab_base/init_header are freed twice.
There is another problem.
When the input *init_tab_base is non null the tail_old is calculated by traveling down the list to first non null entry.
tail_old = init_header; while (tail_old->next) tail_old = tail_old->next;
When the unwinding free happens, the last entry of the input list will be freed.
So the freeing needs a general changed.
If locally allocated the first element of tail_old is freed, else it is skipped. As a bit of cleanup, reset *init_tab_base if it came in as null.
--- drivers/crypto/qat/qat_common/qat_uclo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/qat_uclo.c +7 -2
@@ -332,13 +332,18 @@ static int qat_uclo_create_batch_init_li }return 0 ; out_err: +/* Do not free the list head unless we allocated it. */ + tail_old = tail_old->next; +if (flag) { +kfree (*init_tab_base); + *init_tab_base =NULL ; + } +while (tail_old) { mem_init = tail_old->next;kfree (tail_old); tail_old = mem_init; } -if (flag) -kfree (*init_tab_base);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 159/212 crypto: ccp - Fix use of merged scatterlists
In reply to Greg Kroah-HartmanFrom: John Allen <[email protected]>
commit 8a302808c60d441d9884cb00ea7f2b534f2e3ca5 upstream.
Running the crypto manager self tests with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS may result in several types of errors when using the ccp-crypto driver:
alg: skcipher: cbc-des3-ccp encryption failed on test vector 0; expected_error=0, actual_error=-5 ...
alg: skcipher: ctr-aes-ccp decryption overran dst buffer on test vector 0 ...
alg: ahash: sha224-ccp test failed (wrong result) on test vector ...
These errors are the result of improper processing of scatterlists mapped for DMA.
Given a scatterlist in which entries are merged as part of mapping the scatterlist for DMA, the DMA length of a merged entry will reflect the combined length of the entries that were merged. The subsequent scatterlist entry will contain DMA information for the scatterlist entry after the last merged entry, but the non-DMA information will be that of the first merged entry.
The ccp driver does not take this scatterlist merging into account. To address this, add a second scatterlist pointer to track the current position in the DMA mapped representation of the scatterlist. Both the DMA representation and the original representation of the scatterlist must be tracked as while most of the driver can use just the DMA representation, scatterlist_map_and_copy() must use the original representation and expects the scatterlist pointer to be accurate to the original representation.
In order to properly walk the original scatterlist, the scatterlist must be walked until the combined lengths of the entries seen is equal to the DMA length of the current entry being processed in the DMA mapped representation.
--- drivers/crypto/ccp/ccp-dev.h | 1 + drivers/crypto/ccp/ccp-ops.c | 37 ++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-)
drivers/crypto/ccp/ccp-dev.h +1 -0
@@ -444,6 +444,7 @@ struct ccp_sg_workarea {int nents;struct scatterlist *dma_sg; +struct scatterlist *dma_sg_head;struct device *dma_dev;unsigned int dma_count;enum dma_data_direction dma_dir;
drivers/crypto/ccp/ccp-ops.c +26 -11
@@ -52,7 +52,7 @@ static u32 ccp_gen_jobid(struct ccp_devistatic void ccp_sg_free (struct ccp_sg_workarea *wa) {if (wa->dma_count) -dma_unmap_sg (wa->dma_dev, wa->dma_sg, wa->nents, wa->dma_dir); +dma_unmap_sg (wa->dma_dev, wa->dma_sg_head, wa->nents, wa->dma_dir); wa->dma_count =0 ; }
@@ -81,6 +81,7 @@ static int ccp_init_sg_workarea(struct creturn 0 ; wa->dma_sg = sg; + wa->dma_sg_head = sg; wa->dma_dev = dev; wa->dma_dir = dma_dir; wa->dma_count =dma_map_sg (dev, sg, wa->nents, dma_dir);
@@ -93,14 +94,28 @@ static int ccp_init_sg_workarea(struct cstatic void ccp_update_sg_workarea (struct ccp_sg_workarea *wa,unsigned int len) {unsigned int nbytes =min_t (u64, len, wa->bytes_left); +unsigned int sg_combined_len =0 ;if (!wa->sg)return ; wa->sg_used += nbytes; wa->bytes_left -= nbytes; -if (wa->sg_used == wa->sg->length) { - wa->sg =sg_next (wa->sg); +if (wa->sg_used ==sg_dma_len (wa->dma_sg)) { +/* Advance to the next DMA scatterlist entry */ + wa->dma_sg =sg_next (wa->dma_sg); + +/* In the case that the DMA mapped scatterlist has entries +* that have been merged, the non-DMA mapped scatterlist +* must be advanced multiple times for each merged entry. +* This ensures that the current non-DMA mapped entry +* corresponds to the current DMA mapped entry. +*/ +do { + sg_combined_len += wa->sg->length; + wa->sg =sg_next (wa->sg); + }while (wa->sg_used > sg_combined_len); + wa->sg_used =0 ; } }
@@ -298,7 +313,7 @@ static unsigned int ccp_queue_buf(struct/* Update the structures and generate the count */ buf_count =0 ;while (sg_wa->bytes_left && (buf_count < dm_wa->length)) { - nbytes =min (sg_wa->sg->length - sg_wa->sg_used, + nbytes =min (sg_dma_len (sg_wa->dma_sg) - sg_wa->sg_used, dm_wa->length - buf_count); nbytes =min_t (u64, sg_wa->bytes_left, nbytes);
@@ -330,11 +345,11 @@ static void ccp_prepare_data(struct ccp_* and destination. The resulting len values will always be <= UINT_MAX * because the dma length is an unsigned int. */ - sg_src_len =sg_dma_len (src->sg_wa.sg) - src->sg_wa.sg_used; + sg_src_len =sg_dma_len (src->sg_wa.dma_sg) - src->sg_wa.sg_used; sg_src_len =min_t (u64, src->sg_wa.bytes_left, sg_src_len);if (dst) { - sg_dst_len =sg_dma_len (dst->sg_wa.sg) - dst->sg_wa.sg_used; + sg_dst_len =sg_dma_len (dst->sg_wa.dma_sg) - dst->sg_wa.sg_used; sg_dst_len =min_t (u64, src->sg_wa.bytes_left, sg_dst_len); op_len =min (sg_src_len, sg_dst_len); }else {
@@ -364,7 +379,7 @@ static void ccp_prepare_data(struct ccp_/* Enough data in the sg element, but we need to * adjust for any previously copied data */ - op->src.u.dma.address =sg_dma_address (src->sg_wa.sg); + op->src.u.dma.address =sg_dma_address (src->sg_wa.dma_sg); op->src.u.dma.offset = src->sg_wa.sg_used; op->src.u.dma.length = op_len & ~(block_size -1 );
@@ -385,7 +400,7 @@ static void ccp_prepare_data(struct ccp_/* Enough room in the sg element, but we need to * adjust for any previously used area */ - op->dst.u.dma.address =sg_dma_address (dst->sg_wa.sg); + op->dst.u.dma.address =sg_dma_address (dst->sg_wa.dma_sg); op->dst.u.dma.offset = dst->sg_wa.sg_used; op->dst.u.dma.length = op->src.u.dma.length; }
@@ -1447,7 +1462,7 @@ static int ccp_run_passthru_cmd(struct c dst.sg_wa.sg_used =0 ;for (i =1 ; i <= src.sg_wa.dma_count; i++) {if (!dst.sg_wa.sg || - (dst.sg_wa.sg->length < src.sg_wa.sg->length)) { + (sg_dma_len (dst.sg_wa.sg) <sg_dma_len (src.sg_wa.sg))) { ret = -EINVAL ; goto e_dst; }
@@ -1473,8 +1488,8 @@ static int ccp_run_passthru_cmd(struct c goto e_dst; } - dst.sg_wa.sg_used += src.sg_wa.sg->length; -if (dst.sg_wa.sg_used == dst.sg_wa.sg->length) { + dst.sg_wa.sg_used +=sg_dma_len (src.sg_wa.sg); +if (dst.sg_wa.sg_used ==sg_dma_len (dst.sg_wa.sg)) { dst.sg_wa.sg =sg_next (dst.sg_wa.sg); dst.sg_wa.sg_used =0 ; }
Greg Kroah-Hartman
maintainerPATCH 160/212 fs/minix: check return value of sb_getblk()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit da27e0a0e5f655f0d58d4e153c3182bb2b290f64 upstream.
Patch series "fs/minix: fix syzbot bugs and set s_maxbytes".
This series fixes all syzbot bugs in the minix filesystem:
KASAN: null-ptr-deref Write in get_block KASAN: use-after-free Write in get_block KASAN: use-after-free Read in get_block WARNING in inc_nlink KMSAN: uninit-value in get_block WARNING in drop_nlink
It also fixes the minix filesystem to set s_maxbytes correctly, so that userspace sees the correct behavior when exceeding the max file size.
This patch (of 6):
sb_getblk() can fail, so check its return value.
This fixes a NULL pointer dereference.
Originally from Qiujun Huang.
--- fs/minix/itree_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/minix/itree_common.c +7 -1
@@ -74,6 +74,7 @@ static int alloc_branch(struct inode *inint n =0 ;int i;int parent =minix_new_block (inode); +int err = -ENOSPC ; branch[0 ].key =cpu_to_block (parent);if (parent)for (n =1 ; n < num; n++) {
@@ -84,6 +85,11 @@ static int alloc_branch(struct inode *inbreak ; branch[n].key =cpu_to_block (nr); bh =sb_getblk (inode->i_sb, parent); +if (!bh) { +minix_free_block (inode, nr); + err = -ENOMEM ; +break ; + }lock_buffer (bh);memset (bh->b_data,0 , bh->b_size); branch[n].bh = bh;
@@ -102,7 +108,7 @@ static int alloc_branch(struct inode *inbforget (branch[i].bh);for (i =0 ; i < n; i++)minix_free_block (inode,block_to_cpu (branch[i].key)); -return -ENOSPC ; +return err; } static inline int splice_branch(struct inode *inode,
Greg Kroah-Hartman
maintainerPATCH 161/212 fs/minix: dont allow getting deleted inodes
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit facb03dddec04e4aac1bb2139accdceb04deb1f3 upstream.
If an inode has no links, we need to mark it bad rather than allowing it to be accessed. This avoids WARNINGs in inc_nlink() and drop_nlink() when doing directory operations on a fuzzed filesystem.
--- fs/minix/inode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/minix/inode.c +14 -0
@@ -472,6 +472,13 @@ static struct inode *V1_minix_iget(struciget_failed (inode);return ERR_PTR (-EIO ); } +if (raw_inode->i_nlinks ==0 ) { +printk ("MINIX-fs: deleted inode referenced: %lu\n" , + inode->i_ino); +brelse (bh); +iget_failed (inode); +return ERR_PTR (-ESTALE ); + } inode->i_mode = raw_inode->i_mode;i_uid_write (inode, raw_inode->i_uid);i_gid_write (inode, raw_inode->i_gid);
@@ -505,6 +512,13 @@ static struct inode *V2_minix_iget(struciget_failed (inode);return ERR_PTR (-EIO ); } +if (raw_inode->i_nlinks ==0 ) { +printk ("MINIX-fs: deleted inode referenced: %lu\n" , + inode->i_ino); +brelse (bh); +iget_failed (inode); +return ERR_PTR (-ESTALE ); + } inode->i_mode = raw_inode->i_mode;i_uid_write (inode, raw_inode->i_uid);i_gid_write (inode, raw_inode->i_gid);
Greg Kroah-Hartman
maintainerPATCH 162/212 fs/minix: reject too-large maximum file size
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 270ef41094e9fa95273f288d7d785313ceab2ff3 upstream.
If the minix filesystem tries to map a very large logical block number to its on-disk location, block_to_path() can return offsets that are too large, causing out-of-bounds memory accesses when accessing indirect index blocks. This should be prevented by the check against the maximum file size, but this doesn't work because the maximum file size is read directly from the on-disk superblock and isn't validated itself.
Fix this by validating the maximum file size at mount time.
--- fs/minix/inode.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
fs/minix/inode.c +20 -2
@@ -155,6 +155,23 @@ static int minix_remount (struct super_breturn 0 ; } +static bool minix_check_superblock (struct minix_sb_info *sbi) +{ +if (sbi->s_imap_blocks ==0 || sbi->s_zmap_blocks ==0 ) +return false; + +/* +* s_max_size must not exceed the block mapping limitation. This check +* is only needed for V1 filesystems, since V2/V3 support an extra level +* of indirect blocks which places the limit well above U32_MAX. +*/ +if (sbi->s_version ==MINIX_V1 && + sbi->s_max_size > (7 +512 +512 *512 ) *BLOCK_SIZE ) +return false; + +return true; +} +static int minix_fill_super (struct super_block *s,void *data,int silent) {struct buffer_head *bh;
@@ -233,11 +250,12 @@ static int minix_fill_super(struct super }else goto out_no_fs; +if (!minix_check_superblock (sbi)) + goto out_illegal_sb; +/* * Allocate the buffer map to keep the superblock small. */ -if (sbi->s_imap_blocks ==0 || sbi->s_zmap_blocks ==0 ) - goto out_illegal_sb; i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) *sizeof (bh); map =kzalloc (i,GFP_KERNEL );if (!map)
Greg Kroah-Hartman
maintainerPATCH 163/212 ALSA: usb-audio: work around streaming quirk for MacroSilicon MS2109
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 1b7ecc241a67ad6b584e071bd791a54e0cd5f097 upstream.
Further investigation of the L-R swap problem on the MS2109 reveals that the problem isn't that the channels are swapped, but rather that they are swapped and also out of phase by one sample. In other words, the issue is actually that the very first frame that comes from the hardware is a half-frame containing only the right channel, and after that everything becomes offset.
So introduce a new quirk field to drop the very first 2 bytes that come in after the format is configured and a capture stream starts. This puts the channels in phase and in the correct order.
--- sound/usb/card.h | 1 + sound/usb/pcm.c | 6 ++++++ sound/usb/quirks.c | 3 +++ sound/usb/stream.c | 1 + 4 files changed, 11 insertions(+)
sound/usb/card.h +1 -0
@@ -125,6 +125,7 @@ struct snd_usb_substream { unsigned int tx_length_quirk:1; /* add length specifier to transfers */unsigned int fmt_type;/* USB audio format type (1-3) */ unsigned int pkt_offset_adj;/* Bytes to drop from beginning of packets (for non-compliant devices) */ +unsigned int stream_offset_adj;/* Bytes to drop from beginning of stream (for non-compliant devices) */ unsigned int running: 1; /* running status */
sound/usb/pcm.c +6 -0
@@ -1312,6 +1312,12 @@ static void retire_capture_urb(struct sn// continue; } bytes = urb->iso_frame_desc[i].actual_length; +if (subs->stream_offset_adj >0 ) { +unsigned int adj =min (subs->stream_offset_adj, bytes); + cp += adj; + bytes -= adj; + subs->stream_offset_adj -= adj; + } frames = bytes / stride;if (!subs->txfr_quirk) bytes = frames * stride;
sound/usb/quirks.c +3 -0
@@ -1121,6 +1121,9 @@ void snd_usb_set_format_quirk(struct sndcase USB_ID (0x041e ,0x3f19 ):/* E-Mu 0204 USB */ set_format_emu_quirk (subs, fmt);break ; +case USB_ID (0x534d ,0x2109 ):/* MacroSilicon MS2109 */ + subs->stream_offset_adj =2 ; +break ; } }
sound/usb/stream.c +1 -0
@@ -95,6 +95,7 @@ static void snd_usb_init_substream(struc subs->tx_length_quirk = as->chip->tx_length_quirk; subs->speed =snd_usb_get_speed (subs->dev); subs->pkt_offset_adj =0 ; + subs->stream_offset_adj =0 ;snd_usb_set_pcm_ops (as->pcm, stream);
Greg Kroah-Hartman
maintainerPATCH 164/212 9p: Fix memory leak in v9fs_mount
In reply to Greg Kroah-HartmanFrom: Zheng Bin <[email protected]>
commit cb0aae0e31c632c407a2cab4307be85a001d4d98 upstream.
v9fs_mount
v9fs_session_init
v9fs_cache_session_get_cookie
v9fs_random_cachetag -->alloc cachetag
v9ses->fscache = fscache_acquire_cookie -->maybe NULL
sb = sget -->fail, goto clunk
clunk_fid:
v9fs_session_close
if (v9ses->fscache) -->NULL
kfree(v9ses->cachetag)Thus memleak happens.
--- fs/9p/v9fs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/9p/v9fs.c +2 -3
@@ -457,10 +457,9 @@ void v9fs_session_close(struct v9fs_sess }#ifdef CONFIG_9P_FSCACHE -if (v9ses->fscache) { +if (v9ses->fscache)v9fs_cache_session_put_cookie (v9ses); -kfree (v9ses->cachetag); - } +kfree (v9ses->cachetag);#endif kfree (v9ses->uname);kfree (v9ses->aname);
Greg Kroah-Hartman
maintainerPATCH 165/212 parisc: mask out enable and reserved bits from sba imask
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 5b24993c21cbf2de11aff077a48c5cb0505a0450 upstream.
When using kexec the SBA IOMMU IBASE might still have the RE bit set. This triggers a WARN_ON when trying to write back the IBASE register later, and it also makes some mask calculations fail.
--- drivers/parisc/sba_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parisc/sba_iommu.c +1 -1
@@ -1283,7 +1283,7 @@ sba_ioc_init_pluto(struct parisc_device** (one that doesn't overlap memory or LMMIO space) in the ** IBASE and IMASK registers. */ - ioc->ibase =READ_REG (ioc->ioc_hpa +IOC_IBASE ); + ioc->ibase =READ_REG (ioc->ioc_hpa +IOC_IBASE ) & ~0x1fffffULL ; iova_space_size = ~(READ_REG (ioc->ioc_hpa +IOC_IMASK ) &0xFFFFFFFFUL ) +1 ;if ((ioc->ibase <0xfed00000UL ) && ((ioc->ibase + iova_space_size) >0xfee00000UL )) {
Greg Kroah-Hartman
maintainerPATCH 166/212 ARM: 8992/1: Fix unwind_frame for clang-built kernels
In reply to Greg Kroah-HartmanFrom: Nathan Huckleberry <[email protected]>
commit b4d5ec9b39f8b31d98f65bc5577b5d15d93795d7 upstream.
Since clang does not push pc and sp in function prologues, the current implementation of unwind_frame does not work. By using the previous frame's lr/fp instead of saved pc/sp we get valid unwinds on clang-built kernels.
The bounds check on next frame pointer must be changed as well since there are 8 less bytes between frames.
This fixes /proc/<pid>/stack.
--- arch/arm/kernel/stacktrace.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/kernel/stacktrace.c +24 -0
@@ -19,6 +19,19 @@* A simple function epilogue looks like this: * ldm sp, {fp, sp, pc} * +* When compiled with clang, pc and sp are not pushed. A simple function +* prologue looks like this when built with clang: +* +* stmdb {..., fp, lr} +* add fp, sp, #x +* sub sp, sp, #y +* +* A simple function epilogue looks like this when built with clang: +* +* sub sp, fp, #x +* ldm {..., fp, pc} +* +* * Note that with framepointer enabled, even the leaf functions have the same * prologue and epilogue, therefore we can ignore the LR value in this case. */
@@ -31,6 +44,16 @@ int notrace unwind_frame(struct stackfra low = frame->sp; high =ALIGN (low,THREAD_SIZE ); +#ifdef CONFIG_CC_IS_CLANG +/* check current frame pointer is within bounds */ +if (fp < low +4 || fp > high -4 ) +return -EINVAL ; + + frame->sp = frame->fp; + frame->fp = *(unsigned long *)(fp); + frame->pc = frame->lr; + frame->lr = *(unsigned long *)(fp +4 ); +#else /* check current frame pointer is within bounds */ if (fp < low +12 || fp > high -4 )return -EINVAL ;
@@ -39,6 +62,7 @@ int notrace unwind_frame(struct stackfra frame->fp = *(unsigned long *)(fp -12 ); frame->sp = *(unsigned long *)(fp -8 ); frame->pc = *(unsigned long *)(fp -4 ); +#endif return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 167/212 xen/balloon: fix accounting in alloc_xenballooned_pages error path
In reply to Greg Kroah-HartmanFrom: Roger Pau Monne <[email protected]>
commit 1951fa33ec259abdf3497bfee7b63e7ddbb1a394 upstream.
target_unpopulated is incremented with nr_pages at the start of the function, but the call to free_xenballooned_pages will only subtract pgno number of pages, and thus the rest need to be subtracted before returning or else accounting will be skewed.
--- drivers/xen/balloon.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/xen/balloon.c +6 -0
@@ -694,6 +694,12 @@ int alloc_xenballooned_pages(int nr_page out_undo:mutex_unlock (&balloon_mutex);free_xenballooned_pages (pgno, pages); +/* +* NB: free_xenballooned_pages will only subtract pgno pages, but since +* target_unpopulated is incremented with nr_pages at the start we need +* to remove the remaining ones also, or accounting will be screwed. +*/ + balloon_stats.target_unpopulated -= nr_pages - pgno;return ret; }EXPORT_SYMBOL (alloc_xenballooned_pages);
Greg Kroah-Hartman
maintainerPATCH 168/212 xen/balloon: make the balloon wait interruptible
In reply to Greg Kroah-HartmanFrom: Roger Pau Monne <[email protected]>
commit 88a479ff6ef8af7f07e11593d58befc644244ff7 upstream.
So it can be killed, or else processes can get hung indefinitely waiting for balloon pages.
--- drivers/xen/balloon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/xen/balloon.c +4 -2
@@ -634,11 +634,13 @@ static int add_ballooned_pages(int nr_paif (xen_hotplug_unpopulated) { st =reserve_additional_memory ();if (st !=BP_ECANCELED ) { +int rc; +mutex_unlock (&balloon_mutex); -wait_event (balloon_wq, + rc =wait_event_interruptible (balloon_wq, !list_empty (&ballooned_pages));mutex_lock (&balloon_mutex); -return 0 ; +return rc ? -ENOMEM :0 ; } }
Greg Kroah-Hartman
maintainerPATCH 169/212 smb3: warn on confusing error scenario with sec=krb5
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit 0a018944eee913962bce8ffebbb121960d5125d9 upstream.
When mounting with Kerberos, users have been confused about the default error returned in scenarios in which either keyutils is not installed or the user did not properly acquire a krb5 ticket. Log a warning message in the case that "ENOKEY" is returned from the get_spnego_key upcall so that users can better understand why mount failed in those two cases.
--- fs/cifs/smb2pdu.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/smb2pdu.c +2 -0
@@ -776,6 +776,8 @@ SMB2_auth_kerberos(struct SMB2_sess_data spnego_key =cifs_get_spnego_key (ses);if (IS_ERR (spnego_key)) { rc =PTR_ERR (spnego_key); +if (rc == -ENOKEY ) +cifs_dbg (VFS ,"Verify user has a krb5 ticket and keyutils is installed\n" ); spnego_key =NULL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 170/212 PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit dae68d7fd4930315389117e9da35b763f12238f9 upstream.
If context is not NULL in acpiphp_grab_context(), but the is_going_away flag is set for the device's parent, the reference counter of the context needs to be decremented before returning NULL or the context will never be freed, so make that happen.
--- drivers/pci/hotplug/acpiphp_glue.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +11 -3
@@ -136,13 +136,21 @@ static struct acpiphp_context *acpiphp_gstruct acpiphp_context *context;acpi_lock_hp_context (); + context =acpiphp_get_context (adev); -if (!context || context->func.parent->is_going_away) { -acpi_unlock_hp_context (); -return NULL ; +if (!context) + goto unlock; + +if (context->func.parent->is_going_away) { +acpiphp_put_context (context); + context =NULL ; + goto unlock; } +get_bridge (context->func.parent);acpiphp_put_context (context); + +unlock:acpi_unlock_hp_context ();return context; }
Greg Kroah-Hartman
maintainerPATCH 171/212 btrfs: dont allocate anonymous block device for user invisible roots
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 851fd730a743e072badaf67caf39883e32439431 upstream.
[BUG]
When a lot of subvolumes are created, there is a user report about transaction aborted:
BTRFS: Transaction aborted (error -24)
WARNING: CPU: 17 PID: 17041 at fs/btrfs/transaction.c:1576 create_pending_snapshot+0xbc4/0xd10 [btrfs] RIP: 0010:create_pending_snapshot+0xbc4/0xd10 [btrfs] Call Trace: create_pending_snapshots+0x82/0xa0 [btrfs] btrfs_commit_transaction+0x275/0x8c0 [btrfs] btrfs_mksubvol+0x4b9/0x500 [btrfs] btrfs_ioctl_snap_create_transid+0x174/0x180 [btrfs] btrfs_ioctl_snap_create_v2+0x11c/0x180 [btrfs] btrfs_ioctl+0x11a4/0x2da0 [btrfs] do_vfs_ioctl+0xa9/0x640 ksys_ioctl+0x67/0x90 __x64_sys_ioctl+0x1a/0x20 do_syscall_64+0x5a/0x110 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ---[ end trace 33f2f83f3d5250e9 ]--- BTRFS: error (device sda1) in create_pending_snapshot:1576: errno=-24 unknown BTRFS info (device sda1): forced readonly BTRFS warning (device sda1): Skipping commit of aborted transaction. BTRFS: error (device sda1) in cleanup_transaction:1831: errno=-24 unknown
[CAUSE]
The error is EMFILE (Too many files open) and comes from the anonymous block device allocation. The ids are in a shared pool of size 1<<20.
The ids are assigned to live subvolumes, ie. the root structure exists in memory (eg. after creation or after the root appears in some path). The pool could be exhausted if the numbers are not reclaimed fast enough, after subvolume deletion or if other system component uses the anon block devices.
[WORKAROUND]
Since it's not possible to completely solve the problem, we can only minimize the time the id is allocated to a subvolume root.
Firstly, we can reduce the use of anon_dev by trees that are not subvolume roots, like data reloc tree.
This patch will do extra check on root objectid, to skip roots that don't need anon_dev. Currently it's only data reloc tree and orphan roots.
--- fs/btrfs/disk-io.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +10 -3
@@ -1527,9 +1527,16 @@ int btrfs_init_fs_root(struct btrfs_rootspin_lock_init (&root->ino_cache_lock);init_waitqueue_head (&root->ino_cache_wait); - ret =get_anon_bdev (&root->anon_dev); -if (ret) - goto fail; +/* +* Don't assign anonymous block device to roots that are not exposed to +* userspace, the id pool is limited to 1M +*/ +if (is_fstree (root->root_key.objectid) && +btrfs_root_refs (&root->root_item) >0 ) { + ret =get_anon_bdev (&root->anon_dev); +if (ret) + goto fail; + }mutex_lock (&root->objectid_mutex); ret = btrfs_find_highest_objectid(root,
Greg Kroah-Hartman
maintainerPATCH 172/212 btrfs: only search for left_info if there is no right_info in try_merge_free_space
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit bf53d4687b8f3f6b752f091eb85f62369a515dfd upstream.
In try_to_merge_free_space we attempt to find entries to the left and right of the entry we are adding to see if they can be merged. We search for an entry past our current info (saved into right_info), and then if right_info exists and it has a rb_prev() we save the rb_prev() into left_info.
However there's a slight problem in the case that we have a right_info, but no entry previous to that entry. At that point we will search for an entry just before the info we're attempting to insert. This will simply find right_info again, and assign it to left_info, making them both the same pointer.
Now if right_info _can_ be merged with the range we're inserting, we'll add it to the info and free right_info. However further down we'll access left_info, which was right_info, and thus get a use-after-free.
Fix this by only searching for the left entry if we don't find a right entry at all.
The CVE referenced had a specially crafted file system that could trigger this use-after-free. However with the tree checker improvements we no longer trigger the conditions for the UAF. But the original conditions still apply, hence this fix.
Reference: CVE-2019-19448
--- fs/btrfs/free-space-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/free-space-cache.c +2 -2
@@ -2152,7 +2152,7 @@ out:static bool try_merge_free_space (struct btrfs_free_space_ctl *ctl,struct btrfs_free_space *info,bool update_stat) { -struct btrfs_free_space *left_info; +struct btrfs_free_space *left_info =NULL ;struct btrfs_free_space *right_info;bool merged = false;u64 offset = info->offset;
@@ -2167,7 +2167,7 @@ static bool try_merge_free_space(structif (right_info &&rb_prev (&right_info->offset_index)) left_info =rb_entry (rb_prev (&right_info->offset_index), struct btrfs_free_space, offset_index); -else +else if (!right_info) left_info =tree_search_offset (ctl, offset -1 ,0 ,0 );if (right_info && !right_info->bitmap) {
Greg Kroah-Hartman
maintainerPATCH 173/212 btrfs: fix memory leaks after failure to lookup checksums during inode logging
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 4f26433e9b3eb7a55ed70d8f882ae9cd48ba448b upstream.
While logging an inode, at copy_items(), if we fail to lookup the checksums for an extent we release the destination path, free the ins_data array and then return immediately. However a previous iteration of the for loop may have added checksums to the ordered_sums list, in which case we leak the memory used by them.
So fix this by making sure we iterate the ordered_sums list and free all its checksums before returning.
--- fs/btrfs/tree-log.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/btrfs/tree-log.c +2 -6
@@ -3755,11 +3755,8 @@ static noinline int copy_items(struct bt log->fs_info->csum_root, ds + cs, ds + cs + cl -1 , &ordered_sums, 0); -if (ret) { -btrfs_release_path (dst_path); -kfree (ins_data); -return ret; - } +if (ret) +break ; } } }
@@ -3772,7 +3769,6 @@ static noinline int copy_items(struct bt* we have to do this after the loop above to avoid changing the * log tree while trying to change the log tree. */ - ret =0 ;while (!list_empty (&ordered_sums)) { struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next, struct btrfs_ordered_sum,
Greg Kroah-Hartman
maintainerPATCH 174/212 iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw()
In reply to Greg Kroah-HartmanFrom: Alexandru Ardelean <[email protected]>
commit 65afb0932a81c1de719ceee0db0b276094b10ac8 upstream.
There are 2 exit paths where the lock isn't held, but try to unlock the mutex when exiting. In these places we should just return from the function.
A neater approach would be to cleanup the ad5592r_read_raw(), but that would make this patch more difficult to backport to stable versions.
Fixes 56ca9db862bf3: ("iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs")
--- drivers/iio/dac/ad5592r-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/dac/ad5592r-base.c +2 -2
@@ -417,7 +417,7 @@ static int ad5592r_read_raw(struct iio_ds64 tmp = *val * (3767897513LL /25LL ); *val =div_s64_rem (tmp,1000000000LL , val2); - ret =IIO_VAL_INT_PLUS_MICRO ; +return IIO_VAL_INT_PLUS_MICRO ; }else {int mult;
@@ -448,7 +448,7 @@ static int ad5592r_read_raw(struct iio_d ret =IIO_VAL_INT ;break ;default : - ret = -EINVAL ; +return -EINVAL ; } unlock: