128 Commits

Author SHA1 Message Date
lucaswei
fe4d25c70e Merge android-4.9-q (4.9.200) into android-msm-pixel-4.9-lts
Merge 4.9.200 into android-4.9-q
Linux 4.9.200
  * alarmtimer: Change remaining ENOTSUPP to EOPNOTSUPP
      kernel/time/alarmtimer.c
    dmaengine: qcom: bam_dma: Fix resource leak
  * net/flow_dissector: switch to siphash
      include/linux/skbuff.h
      include/net/flow_dissector.h
      net/core/flow_dissector.c
      net/sched/sch_fq_codel.c
  * kbuild: add -fcf-protection=none when using retpoline flags
      Makefile
  * kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
      Makefile
  * Kbuild: make designated_init attribute fatal
      Makefile
  * inet: stop leaking jiffies on the wire
      net/ipv4/datagram.c
      net/ipv4/tcp_ipv4.c
    net/mlx4_core: Dynamically set guaranteed amount of counters per VF
    vxlan: check tun_info options_len properly
    net: bcmgenet: reset 40nm EPHY on energy detect
    net: dsa: fix switch tree list
  * net: add READ_ONCE() annotation in __skb_wait_for_more_packets()
      net/core/datagram.c
    selftests: net: reuseport_dualstack: fix uninitalized parameter
  * net: Zeroing the structure ethtool_wolinfo in ethtool_get_wol()
      net/core/ethtool.c
    net: hisilicon: Fix ping latency when deal with high throughput
  * net: fix sk_page_frag() recursion from memory reclaim
      include/linux/gfp.h
      include/net/sock.h
    dccp: do not leak jiffies on the wire
    cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs
    MIPS: bmips: mark exception vectors as char arrays
    of: unittest: fix memory leak in unittest_data_add
    scsi: target: core: Do not overwrite CDB byte 1
    ARM: davinci: dm365: Fix McBSP dma_slave_map entry
    perf kmem: Fix memory leak in compact_gfp_flags()
    ARM: dts: imx7s: Correct GPT's ipg clock source
  * scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE
      drivers/scsi/Kconfig
    scsi: sni_53c710: fix compilation error
    scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions
    ARM: mm: fix alignment handler faults under memory pressure
    pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable()
    ARM: dts: logicpd-torpedo-som: Remove twl_keypad
    ASoc: rockchip: i2s: Fix RPM imbalance
    ASoC: wm_adsp: Don't generate kcontrols without READ flags
    regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized
    regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone
    UPSTREAM: HID: steam: fix deadlock with input devices.
    UPSTREAM: HID: steam: fix boot loop with bluetooth firmware
    UPSTREAM: HID: steam: remove input device when a hid client is running.
    UPSTREAM: HID: steam: use hid_device.driver_data instead of hid_set_drvdata()
    UPSTREAM: HID: steam: add missing fields in client initialization
    UPSTREAM: HID: steam: add battery device.
  * UPSTREAM: HID: add driver for Valve Steam Controller
      drivers/hid/Kconfig
      drivers/hid/Makefile
      drivers/hid/hid-core.c
      drivers/hid/hid-ids.h
      include/linux/hid.h
  * UPSTREAM: HID: sony: Fix memory corruption issue on cleanup.
      drivers/hid/hid-sony.c
  * UPSTREAM: HID: sony: Fix race condition between rumble and device remove.
      drivers/hid/hid-sony.c
    Merge 4.9.199 into android-4.9-q
Linux 4.9.199
    Revert "ALSA: hda: Flush interrupts on disabling"
  * ALSA: timer: Fix mutex deadlock at releasing card
      sound/core/timer.c
  * ALSA: timer: Simplify error path in snd_timer_open()
      sound/core/timer.c
  * ALSA: timer: Limit max instances per timer
      include/sound/timer.h
      sound/core/timer.c
  * ALSA: timer: Follow standard EXPORT_SYMBOL() declarations
      sound/core/timer.c
    xfs: Correctly invert xfs_buftarg LRU isolation logic
    sctp: not bind the socket in sctp_connect
  * sctp: fix the issue that flags are ignored when using kernel_connect
      include/net/sctp/sctp.h
  * sch_netem: fix rcu splat in netem_enqueue()
      include/net/sch_generic.h
      net/sched/sch_netem.c
    net: usb: sr9800: fix uninitialized local variable
  * bonding: fix potential NULL deref in bond_update_slave_arr
      drivers/net/bonding/bond_main.c
    llc: fix sk_buff leak in llc_conn_service()
    llc: fix sk_buff leak in llc_sap_state_process()
    dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle
    rtlwifi: Fix potential overflow on P2P code
    s390/cmm: fix information leak in cmm_timeout_handler()
  * nl80211: fix validation of mesh path nexthop
      net/wireless/nl80211.c
  * HID: fix error message in hid_open_report()
      drivers/hid/hid-core.c
  * HID: Fix assumption that devices have inputs
      drivers/hid/hid-dr.c
      drivers/hid/hid-gaff.c
      drivers/hid/hid-sony.c
    HID: i2c-hid: add Trekstor Primebook C11B to descriptor override
    USB: serial: whiteheat: fix line-speed endianness
    USB: serial: whiteheat: fix potential slab corruption
    USB: ldusb: fix control-message timeout
    USB: ldusb: fix ring-buffer locking
  * usb-storage: Revert commit 747668dbc061 ("usb-storage: Set virt_boundary_mask to avoid SG overflows")
      drivers/usb/storage/scsiglue.c
  * USB: gadget: Reject endpoints with 0 maxpacket value
      drivers/usb/gadget/udc/core.c
    UAS: Revert commit 3ae62a42090f ("UAS: fix alignment of scatter/gather segments")
    ALSA: bebob: Fix prototype of helper function to return negative value
  * fuse: truncate pending writes on O_TRUNC
      fs/fuse/file.c
  * fuse: flush dirty data/metadata before non-truncate setattr
      fs/fuse/dir.c
    ath6kl: fix a NULL-ptr-deref bug in ath6kl_usb_alloc_urb_from_pipe()
    thunderbolt: Use 32-bit writes when writing ring producer/consumer
    USB: legousbtower: fix a signedness bug in tower_probe()
  * tracing: Initialize iter->seq after zeroing in tracing_read_pipe()
      kernel/trace/trace.c
    s390/uaccess: avoid (false positive) compiler warnings
    NFSv4: Fix leak of clp->cl_acceptor string
    MIPS: fw: sni: Fix out of bounds init of o32 stack
    fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc()
    fs: ocfs2: fix a possible null-pointer dereference in ocfs2_write_end_nolock()
    fs: ocfs2: fix possible null-pointer dereferences in ocfs2_xa_prepare_entry()
    ocfs2: clear zero in unaligned direct IO
    efi/x86: Do not clean dummy variable in kexec path
    efi/cper: Fix endianness of PCIe class code
    serial: mctrl_gpio: Check for NULL pointer
    fs: cifs: mute -Wunused-const-variable message
    gpio: max77620: Use correct unit for debounce times
    RDMA/iwcm: Fix a lock inversion issue
    staging: rtl8188eu: fix null dereference when kzalloc fails
    perf jevents: Fix period for Intel fixed counters
    perf map: Fix overlapped map handling
    iio: fix center temperature of bmc150-accel-core
  * exec: load_script: Do not exec truncated interpreter path
      fs/binfmt_script.c
    rtc: pcf8523: set xtal load capacitance from DT
  * usb: handle warm-reset port requests on hub resume
      drivers/usb/core/hub.c
  * scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks
      scripts/setlocalversion
    HID: i2c-hid: Add Odys Winbook 13 to descriptor override
    x86/cpu: Add Atom Tremont (Jacobsville)
    HID: i2c-hid: add Direkt-Tek DTLAPY133-1 to descriptor override
    sc16is7xx: Fix for "Unexpected interrupt: 8"
  * dm: Use kzalloc for all structs with embedded biosets/mempools
      drivers/md/dm-io.c
      drivers/md/dm-kcopyd.c
    dm snapshot: rework COW throttling to fix deadlock
    dm snapshot: introduce account_start_copy() and account_end_copy()
    dm snapshot: use mutex instead of rw_semaphore
  * binder: binder: fix possible UAF when freeing buffer
      drivers/android/binder.c
  * BACKPORT: dm bufio: introduce a global cache replacement
      drivers/md/dm-bufio.c
  * BACKPORT: dm bufio: remove old-style buffer cleanup
      drivers/md/dm-bufio.c
  * BACKPORT: dm bufio: introduce a global queue
      drivers/md/dm-bufio.c
  * BACKPORT: dm bufio: refactor adjust_total_allocated
      drivers/md/dm-bufio.c
  * BACKPORT: dm bufio: call adjust_total_allocated from __link_buffer and __unlink_buffer
      drivers/md/dm-bufio.c
    cuttlefish-4.9: Enable CONFIG_DM_SNAPSHOT
    Merge 4.9.198 into android-4.9-q
Linux 4.9.198
    RDMA/cxgb4: Do not dma memory off of the stack
  * Revert "net: sit: fix memory leak in sit_init_net()"
      net/ipv6/sit.c
  * PCI: PM: Fix pci_power_up()
      drivers/pci/pci.c
    xen/netback: fix error path of xenvif_connect_data()
  * cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown
      drivers/base/core.c
      drivers/cpufreq/cpufreq.c
    memstick: jmb38x_ms: Fix an error handling path in 'jmb38x_ms_probe()'
    btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group()
    CIFS: avoid using MID 0xFFFF
    parisc: Fix vmap memory leak in ioremap()/iounmap()
    xtensa: drop EXPORT_SYMBOL for outs*/ins*
  * mm/slub: fix a deadlock in show_slab_objects()
      mm/slub.c
    scsi: zfcp: fix reaction on bit error threshold notification
  * drm/edid: Add 6 bpc quirk for SDC panel in Lenovo G50
      drivers/gpu/drm/drm_edid.c
    mac80211: Reject malformed SSID elements
    cfg80211: wext: avoid copying malformed SSIDs
    ASoC: rsnd: Reinitialize bit clock inversion flag for every format setting
    Input: da9063 - fix capability and drop KEY_SLEEP
  * scsi: core: try to get module before removing device
      drivers/scsi/scsi_sysfs.c
    staging: wlan-ng: fix exit return when sme->key_idx >= NUM_WEPKEYS
    MIPS: tlbex: Fix build_restore_pagemask KScratch restore
    USB: ldusb: fix read info leaks
    USB: usblp: fix use-after-free on disconnect
    USB: ldusb: fix memleak on disconnect
    USB: serial: ti_usb_3410_5052: fix port-close races
    usb: udc: lpc32xx: fix bad bit shift operation
    ALSA: hda/realtek - Add support for ALC711
    USB: legousbtower: fix memleak on disconnect
  * memfd: Fix locking when tagging pins
      mm/shmem.c
  * ipv4: Return -ENETUNREACH if we can't create route but saddr is valid
      net/ipv4/route.c
  * net: avoid potential infinite loop in tc_ctl_action()
      net/sched/act_api.c
    sctp: change sctp_prot .no_autobind with true
    net: bcmgenet: Set phydev->dev_flags only for internal PHYs
    net: bcmgenet: Fix RGMII_MODE_EN value for GENET v1/2/3
  * loop: Add LOOP_SET_DIRECT_IO to compat ioctl
      drivers/block/loop.c
    ocfs2: fix panic due to ocfs2_wq is null
    Revert "drm/radeon: Fix EEH during kexec"
    namespace: fix namespace.pl script to support relative paths
    net: hisilicon: Fix usage of uninitialized variable in function mdio_sc_cfg_reg_write()
    mips: Loongson: Fix the link time qualifier of 'serial_exit()'
    mac80211: fix txq null pointer dereference
  * nl80211: fix null pointer dereference
      net/wireless/nl80211.c
    MIPS: dts: ar9331: fix interrupt-controller size
    ARM: dts: am4372: Set memory bandwidth limit for DISPC
    ARM: OMAP2+: Fix missing reset done flag for am3 and am43
    scsi: qla2xxx: Fix unbound sleep in fcport delete path.
    scsi: megaraid: disable device when probe failed after enabled device
  * scsi: ufs: skip shutdown if hba is not powered
      drivers/scsi/ufs/ufshcd.c
    rtlwifi: Fix potential overflow on P2P code
    ANDROID: clang: update to 9.0.8 based on r365631c
  * ANDROID: move up spin_unlock_bh() ahead of remove_proc_entry()
      net/netfilter/xt_quota2.c
    ANDROID: refactor build.config files to remove duplication
    Merge 4.9.197 into android-4.9-q
Linux 4.9.197
    xfs: clear sb->s_fs_info on mount failure
    x86/asm: Fix MWAITX C-state hint value
  * tracing: Get trace_array reference for available_tracers files
      kernel/trace/trace.c
    tracing/hwlat: Don't ignore outer-loop duration when calculating max_latency
    tracing/hwlat: Report total time spent in all NMIs during the sample
    media: stkwebcam: fix runtime PM after driver unbind
  * Fix the locking in dcache_readdir() and friends
      fs/libfs.c
    MIPS: Disable Loongson MMI instructions for kernel build
    Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
    staging: fbtft: Stop using BL_CORE_DRIVER1
  * kernel/sysctl.c: do not override max_threads provided by userspace
      kernel/fork.c
    CIFS: Force reval dentry if LOOKUP_REVAL flag is set
    CIFS: Force revalidate inode when dentry is stale
    CIFS: Gracefully handle QueryInfo errors during open
    perf inject jit: Fix JIT_CODE_MOVE filename
    perf llvm: Don't access out-of-scope array
    efivar/ssdt: Don't iterate over EFI vars if no SSDT override was specified
    iio: light: opt3001: fix mutex unlock race
    iio: adc: ad799x: fix probe error handling
    staging: vt6655: Fix memory leak in vt6655_probe
    USB: legousbtower: fix use-after-free on release
    USB: legousbtower: fix open after failed reset request
    USB: legousbtower: fix potential NULL-deref on disconnect
    USB: legousbtower: fix deadlock on disconnect
    USB: legousbtower: fix slab info leak at probe
    usb: renesas_usbhs: gadget: Fix usb_ep_set_{halt,wedge}() behavior
    usb: renesas_usbhs: gadget: Do not discard queues in usb_ep_set_{halt,wedge}()
    USB: dummy-hcd: fix power budget for SuperSpeed mode
    USB: microtek: fix info-leak at probe
    USB: usblcd: fix I/O after disconnect
    USB: serial: fix runtime PM after driver unbind
    USB: serial: option: add support for Cinterion CLS8 devices
    USB: serial: option: add Telit FN980 compositions
    USB: serial: ftdi_sio: add device IDs for Sienna and Echelon PL-20
    USB: serial: keyspan: fix NULL-derefs on open() and write()
    serial: uartlite: fix exit path null pointer
    USB: ldusb: fix NULL-derefs on driver unbind
    USB: chaoskey: fix use-after-free on release
    USB: usblp: fix runtime PM after driver unbind
    USB: iowarrior: fix use-after-free after driver unbind
    USB: iowarrior: fix use-after-free on release
    USB: iowarrior: fix use-after-free on disconnect
    USB: adutux: fix use-after-free on release
    USB: adutux: fix NULL-derefs on disconnect
    USB: adutux: fix use-after-free on disconnect
    USB: adutux: remove redundant variable minor
  * xhci: Increase STS_SAVE timeout in xhci_suspend()
      drivers/usb/host/xhci.c
  * usb: xhci: wait for CNR controller not ready bit in xhci resume
      drivers/usb/host/xhci.c
  * xhci: Check all endpoints for LPM timeout
      drivers/usb/host/xhci.c
  * xhci: Prevent device initiated U1/U2 link pm if exit latency is too long
      drivers/usb/host/xhci.c
  * xhci: Fix false warning message about wrong bounce buffer write length
      drivers/usb/host/xhci-ring.c
    USB: usb-skeleton: fix NULL-deref on disconnect
    USB: usb-skeleton: fix runtime PM after driver unbind
    USB: yurex: fix NULL-derefs on disconnect
    USB: yurex: Don't retry on unexpected errors
  * USB: rio500: Remove Rio 500 kernel driver
      drivers/usb/misc/Kconfig
      drivers/usb/misc/Makefile
  * panic: ensure preemption is disabled during panic()
      kernel/panic.c
    ASoC: sgtl5000: Improve VAG power and mute control
  * nl80211: validate beacon head
      net/wireless/nl80211.c
  * cfg80211: Use const more consistently in for_each_element macros
      include/linux/ieee80211.h
  * cfg80211: add and use strongly typed element iteration macros
      include/linux/ieee80211.h
      net/wireless/scan.c
    coresight: etm4x: Use explicit barriers on enable/disable
    crypto: caam - fix concurrency issue in givencrypt descriptor
    perf stat: Reset previous counts on repeat with interval
    perf stat: Fix a segmentation fault when using repeat forever
    perf tools: Fix segfault in cpu_cache_level__read()
    tools lib traceevent: Do not free tep->cmdlines in add_new_comm() on failure
  * kernel/elfcore.c: include proper prototypes
      kernel/elfcore.c
  * sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr()
      kernel/sched/core.c
    fuse: fix memleak in cuse_channel_open
  * thermal: Fix use-after-free when unregistering thermal zone device
      drivers/thermal/thermal_core.c
    drm/amdgpu: Check for valid number of registers to read
    ceph: reconnect connection if session hang in opening state
    ceph: fix directories inode i_blkbits initialization
    xen/pci: reserve MCFG areas earlier
    9p: avoid attaching writeback_fid on mmap with type PRIVATE
    fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
    ima: always return negative code for error
  * cfg80211: initialize on-stack chandefs
      net/wireless/nl80211.c
      net/wireless/reg.c
    ieee802154: atusb: fix use-after-free at disconnect
    watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout
  * timer: Read jiffies once when forwarding base clk
      kernel/time/timer.c
  * usercopy: Avoid HIGHMEM pfn warning
      mm/usercopy.c
    crypto: qat - Silence smp_processor_id() warning
    can: mcp251x: mcp251x_hw_reset(): allow more time after a reset
    powerpc/powernv: Restrict OPAL symbol map to only be readable by root
  * ASoC: Define a set of DAPM pre/post-up events
      include/sound/soc-dapm.h
    KVM: nVMX: handle page fault in vmread fix
    s390/cio: exclude subchannels with no parent from pseudo check
    s390/cio: avoid calling strlen on null pointer
    s390/topology: avoid firing events before kobjs are created
    KVM: s390: Test for bad access register and size at the start of S390_MEM_OP
    ANDROID: cuttlefish_defconfig: Enable BPF_JIT and BPF_JIT_ALWAYS_ON

Change-Id: Ie9c99a9fcb1ee411aea4da0b1c4a454989142343
Signed-off-by: lucaswei <lucaswei@google.com>
2019-11-22 13:45:46 +08:00
Greg Kroah-Hartman
e9766ef8f1 Merge 4.9.197 into android-4.9-q
Changes in 4.9.197
	KVM: s390: Test for bad access register and size at the start of S390_MEM_OP
	s390/topology: avoid firing events before kobjs are created
	s390/cio: avoid calling strlen on null pointer
	s390/cio: exclude subchannels with no parent from pseudo check
	KVM: nVMX: handle page fault in vmread fix
	ASoC: Define a set of DAPM pre/post-up events
	powerpc/powernv: Restrict OPAL symbol map to only be readable by root
	can: mcp251x: mcp251x_hw_reset(): allow more time after a reset
	crypto: qat - Silence smp_processor_id() warning
	usercopy: Avoid HIGHMEM pfn warning
	timer: Read jiffies once when forwarding base clk
	watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout
	ieee802154: atusb: fix use-after-free at disconnect
	cfg80211: initialize on-stack chandefs
	ima: always return negative code for error
	fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
	9p: avoid attaching writeback_fid on mmap with type PRIVATE
	xen/pci: reserve MCFG areas earlier
	ceph: fix directories inode i_blkbits initialization
	ceph: reconnect connection if session hang in opening state
	drm/amdgpu: Check for valid number of registers to read
	thermal: Fix use-after-free when unregistering thermal zone device
	fuse: fix memleak in cuse_channel_open
	sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr()
	kernel/elfcore.c: include proper prototypes
	tools lib traceevent: Do not free tep->cmdlines in add_new_comm() on failure
	perf tools: Fix segfault in cpu_cache_level__read()
	perf stat: Fix a segmentation fault when using repeat forever
	perf stat: Reset previous counts on repeat with interval
	crypto: caam - fix concurrency issue in givencrypt descriptor
	coresight: etm4x: Use explicit barriers on enable/disable
	cfg80211: add and use strongly typed element iteration macros
	cfg80211: Use const more consistently in for_each_element macros
	nl80211: validate beacon head
	ASoC: sgtl5000: Improve VAG power and mute control
	panic: ensure preemption is disabled during panic()
	USB: rio500: Remove Rio 500 kernel driver
	USB: yurex: Don't retry on unexpected errors
	USB: yurex: fix NULL-derefs on disconnect
	USB: usb-skeleton: fix runtime PM after driver unbind
	USB: usb-skeleton: fix NULL-deref on disconnect
	xhci: Fix false warning message about wrong bounce buffer write length
	xhci: Prevent device initiated U1/U2 link pm if exit latency is too long
	xhci: Check all endpoints for LPM timeout
	usb: xhci: wait for CNR controller not ready bit in xhci resume
	xhci: Increase STS_SAVE timeout in xhci_suspend()
	USB: adutux: remove redundant variable minor
	USB: adutux: fix use-after-free on disconnect
	USB: adutux: fix NULL-derefs on disconnect
	USB: adutux: fix use-after-free on release
	USB: iowarrior: fix use-after-free on disconnect
	USB: iowarrior: fix use-after-free on release
	USB: iowarrior: fix use-after-free after driver unbind
	USB: usblp: fix runtime PM after driver unbind
	USB: chaoskey: fix use-after-free on release
	USB: ldusb: fix NULL-derefs on driver unbind
	serial: uartlite: fix exit path null pointer
	USB: serial: keyspan: fix NULL-derefs on open() and write()
	USB: serial: ftdi_sio: add device IDs for Sienna and Echelon PL-20
	USB: serial: option: add Telit FN980 compositions
	USB: serial: option: add support for Cinterion CLS8 devices
	USB: serial: fix runtime PM after driver unbind
	USB: usblcd: fix I/O after disconnect
	USB: microtek: fix info-leak at probe
	USB: dummy-hcd: fix power budget for SuperSpeed mode
	usb: renesas_usbhs: gadget: Do not discard queues in usb_ep_set_{halt,wedge}()
	usb: renesas_usbhs: gadget: Fix usb_ep_set_{halt,wedge}() behavior
	USB: legousbtower: fix slab info leak at probe
	USB: legousbtower: fix deadlock on disconnect
	USB: legousbtower: fix potential NULL-deref on disconnect
	USB: legousbtower: fix open after failed reset request
	USB: legousbtower: fix use-after-free on release
	staging: vt6655: Fix memory leak in vt6655_probe
	iio: adc: ad799x: fix probe error handling
	iio: light: opt3001: fix mutex unlock race
	efivar/ssdt: Don't iterate over EFI vars if no SSDT override was specified
	perf llvm: Don't access out-of-scope array
	perf inject jit: Fix JIT_CODE_MOVE filename
	CIFS: Gracefully handle QueryInfo errors during open
	CIFS: Force revalidate inode when dentry is stale
	CIFS: Force reval dentry if LOOKUP_REVAL flag is set
	kernel/sysctl.c: do not override max_threads provided by userspace
	staging: fbtft: Stop using BL_CORE_DRIVER1
	Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
	MIPS: Disable Loongson MMI instructions for kernel build
	Fix the locking in dcache_readdir() and friends
	media: stkwebcam: fix runtime PM after driver unbind
	tracing/hwlat: Report total time spent in all NMIs during the sample
	tracing/hwlat: Don't ignore outer-loop duration when calculating max_latency
	tracing: Get trace_array reference for available_tracers files
	x86/asm: Fix MWAITX C-state hint value
	xfs: clear sb->s_fs_info on mount failure
	Linux 4.9.197

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2019-10-17 13:54:42 -07:00
Will Deacon
9489b435dd panic: ensure preemption is disabled during panic()
commit 20bb759a66be52cf4a9ddd17fddaf509e11490cd upstream.

Calling 'panic()' on a kernel with CONFIG_PREEMPT=y can leave the
calling CPU in an infinite loop, but with interrupts and preemption
enabled.  From this state, userspace can continue to be scheduled,
despite the system being "dead" as far as the kernel is concerned.

This is easily reproducible on arm64 when booting with "nosmp" on the
command line; a couple of shell scripts print out a periodic "Ping"
message whilst another triggers a crash by writing to
/proc/sysrq-trigger:

  | sysrq: Trigger a crash
  | Kernel panic - not syncing: sysrq triggered crash
  | CPU: 0 PID: 1 Comm: init Not tainted 5.2.15 #1
  | Hardware name: linux,dummy-virt (DT)
  | Call trace:
  |  dump_backtrace+0x0/0x148
  |  show_stack+0x14/0x20
  |  dump_stack+0xa0/0xc4
  |  panic+0x140/0x32c
  |  sysrq_handle_reboot+0x0/0x20
  |  __handle_sysrq+0x124/0x190
  |  write_sysrq_trigger+0x64/0x88
  |  proc_reg_write+0x60/0xa8
  |  __vfs_write+0x18/0x40
  |  vfs_write+0xa4/0x1b8
  |  ksys_write+0x64/0xf0
  |  __arm64_sys_write+0x14/0x20
  |  el0_svc_common.constprop.0+0xb0/0x168
  |  el0_svc_handler+0x28/0x78
  |  el0_svc+0x8/0xc
  | Kernel Offset: disabled
  | CPU features: 0x0002,24002004
  | Memory Limit: none
  | ---[ end Kernel panic - not syncing: sysrq triggered crash ]---
  |  Ping 2!
  |  Ping 1!
  |  Ping 1!
  |  Ping 2!

The issue can also be triggered on x86 kernels if CONFIG_SMP=n,
otherwise local interrupts are disabled in 'smp_send_stop()'.

Disable preemption in 'panic()' before re-enabling interrupts.

Link: http://lkml.kernel.org/r/20191002123538.22609-1-will@kernel.org
Link: https://lore.kernel.org/r/BX1W47JXPMR8.58IYW53H6M5N@dragonstone
Signed-off-by: Will Deacon <will@kernel.org>
Reported-by: Xogium <contact@xogium.me>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Feng Tang <feng.tang@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-17 13:42:25 -07:00
Petri Gynther
b5d151ed14 Merge android-4.9 (4.9.165+) into android-msm-bluecross-4.9-lts
commit 86a136d920 ("Revert "ANDROID: input: keychord: Add keychord driver"")
is the base for android-4.9-q branch.

  * Revert "ANDROID: input: keychord: Add keychord driver"
      drivers/input/misc/Kconfig
      drivers/input/misc/Makefile
    Revert "ANDROID: input: misc: keychord: move header to uapi"
    Revert "ANDROID: input: misc: keychord: log when keychord triggered"
    Revert "ANDROID: keychord: Fix a slab out-of-bounds read."
    Revert "Use %zu to print resid (size_t)."
    Revert "ANDROID: keychord: Fix races in keychord_write."
    Revert "ANDROID: keychord: Fix for a memory leak in keychord."
    Revert "ANDROID: keychord: Check for write data size"
    ANDROID: drop CONFIG_INPUT_KEYCHORD from cuttlefish and ranchu
  * BACKPORT: mm/debug.c: provide useful debugging information for VM_BUG
      mm/debug.c
  * UPSTREAM: bug: use %pB in BUG and stack protector failure
      kernel/panic.c
      lib/bug.c
    UPSTREAM: x86/alternative: Print unadorned pointers
    UPSTREAM: trace_uprobe: Display correct offset in uprobe_events
  * UPSTREAM: usercopy: Remove pointer from overflow report
      mm/usercopy.c
    UPSTREAM: Do not hash userspace addresses in fault handlers
    UPSTREAM: mm/slab.c: do not hash pointers when debugging slab
    UPSTREAM: kasan: use %px to print addresses instead of %p
  * BACKPORT: vsprintf: add printk specifier %px
      lib/vsprintf.c
  * BACKPORT: printk: hash addresses printed with %p
      lib/vsprintf.c
  * ANDROID: Fix race in crng_reseed()
      drivers/char/random.c
  * UPSTREAM: siphash: implement HalfSipHash1-3 for hash tables
      include/linux/siphash.h
      lib/siphash.c
  * UPSTREAM: siphash: add cryptographically secure PRF
      include/linux/siphash.h
      lib/Kconfig.debug
      lib/Makefile
      lib/siphash.c
  * BACKPORT: vsprintf: refactor %pK code out of pointer()
      lib/vsprintf.c
    BACKPORT: docs: correct documentation for %pK
    Merge upstream-f2fs-stable-linux-4.9.y into android-4.9
  * BACKPORT: filemap: add a comment about FAULT_FLAG_RETRY_NOWAIT behavior
      mm/filemap.c
  * BACKPORT: filemap: drop the mmap_sem for all blocking operations
      mm/filemap.c
  * BACKPORT: filemap: kill page_cache_read usage in filemap_fault
      include/linux/pagemap.h
      mm/filemap.c
  * ANDROID: binder: remove extra declaration left after backport
      drivers/android/binder.c
  * UPSTREAM: net: socket: set sock->sk to NULL after calling proto_ops::release()
      net/socket.c
  * FROMGIT: binder: fix BUG_ON found by selinux-testsuite
      drivers/android/binder.c
    ANDROID: dm-bow: Fix 32 bit compile errors
  * ANDROID: fix 4.9 backport of psi header refactoring
      kernel/sched/core.c
  * UPSTREAM: mm: proc: smaps_rollup: fix pss_locked calculation
      fs/proc/task_mmu.c
  * UPSTREAM: binder: fix handling of misaligned binder object
      drivers/android/binder.c
    UPSTREAM: binder: fix sparse issue in binder_alloc_selftest.c
  * BACKPORT: binder: use userspace pointer as base of buffer space
      drivers/android/binder.c
      drivers/android/binder_alloc.c
      drivers/android/binder_alloc.h
      drivers/android/binder_trace.h
  * UPSTREAM: binder: fix kerneldoc header for struct binder_buffer
      drivers/android/binder_alloc.h
  * BACKPORT: binder: remove user_buffer_offset
      drivers/android/binder.c
      drivers/android/binder_alloc.c
      drivers/android/binder_alloc.h
  * UPSTREAM: binder: remove kernel vm_area for buffer space
      drivers/android/binder_alloc.c
  * UPSTREAM: binder: avoid kernel vm_area for buffer fixups
      drivers/android/binder.c
  * BACKPORT: binder: add function to copy binder object from buffer
      drivers/android/binder.c
  * BACKPORT: binder: add functions to copy to/from binder buffers
      drivers/android/binder.c
      drivers/android/binder_alloc.c
      drivers/android/binder_alloc.h
  * UPSTREAM: binder: create userspace-to-binder-buffer copy function
      drivers/android/binder.c
      drivers/android/binder_alloc.c
      drivers/android/binder_alloc.h
    ANDROID: Add dm-bow to cuttlefish configuration
    ANDROID: dm-bow: Backport to 4.9
    ANDROID: dm-bow: backport to 4.14
  * ANDROID: dm-bow: Add dm-bow feature
      drivers/md/Kconfig
      drivers/md/Makefile
  * f2fs: set pin_file under CAP_SYS_ADMIN
      fs/f2fs/file.c
  * f2fs: fix to avoid deadlock in f2fs_read_inline_dir()
      fs/f2fs/inline.c
  * f2fs: fix to adapt small inline xattr space in __find_inline_xattr()
      fs/f2fs/xattr.c
  * f2fs: fix to do sanity check with inode.i_inline_xattr_size
      fs/f2fs/inode.c
      fs/f2fs/super.c
      fs/f2fs/xattr.h
  * f2fs: give some messages for inline_xattr_size
      fs/f2fs/super.c
  * f2fs: don't trigger read IO for beyond EOF page
      fs/f2fs/data.c
  * f2fs: fix to add refcount once page is tagged PG_private
      fs/f2fs/checkpoint.c
      fs/f2fs/data.c
      fs/f2fs/dir.c
      fs/f2fs/f2fs.h
      fs/f2fs/node.c
      fs/f2fs/segment.c
  * f2fs: remove wrong comment in f2fs_invalidate_page()
      fs/f2fs/data.c
  * f2fs: fix to use kvfree instead of kzfree
      fs/f2fs/xattr.c
  * f2fs: print more parameters in trace_f2fs_map_blocks
      include/trace/events/f2fs.h
  * f2fs: trace f2fs_ioc_shutdown
      fs/f2fs/file.c
      include/trace/events/f2fs.h
  * f2fs: fix to avoid deadlock of atomic file operations
      fs/f2fs/segment.c
  * f2fs: fix to dirty inode for i_mode recovery
      fs/f2fs/file.c
  * f2fs: give random value to i_generation
      fs/f2fs/f2fs.h
      fs/f2fs/namei.c
      fs/f2fs/super.c
  * f2fs: no need to take page lock in readdir
      fs/f2fs/dir.c
  * f2fs: fix to update iostat correctly in IPU path
      fs/f2fs/segment.c
  * f2fs: fix encrypted page memory leak
      fs/f2fs/data.c
  * f2fs: make fault injection covering __submit_flush_wait()
      fs/f2fs/segment.c
  * f2fs: fix to retry fill_super only if recovery failed
      fs/f2fs/super.c
  * f2fs: silence VM_WARN_ON_ONCE in mempool_alloc
      fs/f2fs/data.c
  * f2fs: correct spelling mistake
      include/linux/f2fs_fs.h
  * f2fs: fix wrong #endif
      fs/f2fs/f2fs.h
  * f2fs: don't clear CP_QUOTA_NEED_FSCK_FLAG
      fs/f2fs/checkpoint.c
  * f2fs: don't allow negative ->write_io_size_bits
      fs/f2fs/super.c
  * f2fs: fix to check inline_xattr_size boundary correctly
      fs/f2fs/f2fs.h
      fs/f2fs/super.c
      include/linux/f2fs_fs.h
  * Revert "f2fs: fix to avoid deadlock of atomic file operations"
      fs/f2fs/segment.c
  * Revert "f2fs: fix to check inline_xattr_size boundary correctly"
      fs/f2fs/f2fs.h
      fs/f2fs/super.c
      include/linux/f2fs_fs.h
    f2fs: do not use mutex lock in atomic context
  * f2fs: fix potential data inconsistence of checkpoint
      fs/f2fs/data.c
      fs/f2fs/f2fs.h
      fs/f2fs/file.c
      fs/f2fs/inline.c
  * f2fs: fix to avoid deadlock of atomic file operations
      fs/f2fs/segment.c
  * f2fs: fix to check inline_xattr_size boundary correctly
      fs/f2fs/f2fs.h
      fs/f2fs/super.c
      include/linux/f2fs_fs.h
  * f2fs: jump to label 'free_node_inode' when failing from d_make_root()
      fs/f2fs/super.c
    f2fs: fix to document inline_xattr_size option
  * f2fs: fix to data block override node segment by mistake
      fs/f2fs/super.c
  * f2fs: fix typos in code comments
      include/linux/f2fs_fs.h
  * f2fs: use xattr_prefix to wrap up
      fs/f2fs/xattr.c
  * f2fs: sync filesystem after roll-forward recovery
      fs/f2fs/checkpoint.c
      fs/f2fs/node.c
      fs/f2fs/super.c
  * fs: export evict_inodes
      fs/inode.c
      fs/internal.h
      include/linux/fs.h
  * f2fs: flush quota blocks after turnning it off
      fs/f2fs/super.c
  * f2fs: avoid null pointer exception in dcc_info
      fs/f2fs/f2fs.h
  * f2fs: don't wake up too frequently, if there is lots of IOs
      fs/f2fs/segment.h
  * f2fs: try to keep CP_TRIMMED_FLAG after successful umount
      fs/f2fs/segment.c
  * f2fs: add quick mode of checkpoint=disable for QA
      fs/f2fs/checkpoint.c
      fs/f2fs/f2fs.h
      fs/f2fs/file.c
      fs/f2fs/segment.c
      fs/f2fs/super.c
      include/linux/f2fs_fs.h
  * f2fs: run discard jobs when put_super
      fs/f2fs/f2fs.h
      fs/f2fs/segment.c
      fs/f2fs/super.c
      fs/f2fs/sysfs.c
  * f2fs: fix to set sbi dirty correctly
      fs/f2fs/f2fs.h
  * f2fs: UBSAN: set boolean value iostat_enable correctly
      fs/f2fs/sysfs.c
  * f2fs: add brackets for macros
      fs/f2fs/f2fs.h
  * f2fs: check if file namelen exceeds max value
      fs/f2fs/dir.c
  * f2fs: fix to trigger fsck if dirent.name_len is zero
      fs/f2fs/dir.c
  * f2fs: no need to check return value of debugfs_create functions
      fs/f2fs/debug.c
      fs/f2fs/f2fs.h
      fs/f2fs/super.c
  * f2fs: export FS_NOCOW_FL flag to user
      fs/f2fs/f2fs.h
      fs/f2fs/file.c
  * f2fs: check inject_rate validity during configuring
      fs/f2fs/sysfs.c
  * f2fs: remove set but not used variable 'err'
      fs/f2fs/data.c
  * f2fs: fix compile warnings: 'struct *' declared inside parameter list
      include/trace/events/f2fs.h
  * f2fs: change error code to -ENOMEM from -EINVAL
      fs/f2fs/super.c

Change-Id: I199547b8a925245ea0fd613296fc5cedb762c5f6
Signed-off-by: Petri Gynther <pgynther@google.com>
2019-03-29 16:45:44 -07:00
Kees Cook
96dc04da6c UPSTREAM: bug: use %pB in BUG and stack protector failure
The BUG and stack protector reports were still using a raw %p.  This
changes it to %pB for more meaningful output.

Link: http://lkml.kernel.org/r/20180301225704.GA34198@beast
Fixes: ad67b74d2469 ("printk: hash addresses printed with %p")
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Richard Weinberger <richard.weinberger@gmail.com>,
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 0862ca422b79cb5aa70823ee0f07f6b468f86070)
Signed-off-by: Sandeep Patil <sspatil@android.com>

Bug: 78533979
Test: Build and boot cuttlefish
Change-Id: Id4ff4ef7d236f1d7ce6d61ef071bd0d4414c8dd2
2019-03-28 21:13:06 -07:00
Eva Huang
7ac7541935 arm64/config: b1c1: support panic on warn by config
Add config:
  CONFIG_PANIC_ON_WARN_DEFAULT_ENABLE

This patchset adds CONFIG_PANIC_ON_DEFAULT_ENABLE to determine
the behavior at build time. Even though we could do same thing
by kernel parameter, it's not handy for vendor kernel because
they usually store kernel cmd parameter into different partition
with kernel so that it needs platform image rebuild to change
kernel cmd line as well as kernel image.

To remove such dependency to save much time, this patch adds
default enable by Kconfig at build time.

Bug: 119288681
Change-Id: Ib73e6e2c8d2c2e87ad96cd4c59feeb1c8102d041
Signed-off-by: Eva Huang <evahuang@google.com>
2019-03-29 11:50:21 +08:00
Petri Gynther
c55d52516c Merge 4.9.148 into android-msm-bluecross-4.9-lts
Linux 4.9.148
  * drm/ioctl: Fix Spectre v1 vulnerabilities
      drivers/gpu/drm/drm_ioctl.c
  * proc/sysctl: don't return ENOMEM on lookup when a table is unregistering
      fs/proc/proc_sysctl.c
  * panic: avoid deadlocks in re-entrant console drivers
      kernel/panic.c
    ubifs: Handle re-linking of inodes correctly while recovery
    x86/fpu: Disable bottom halves while loading FPU registers
    x86/mtrr: Don't copy uninitialized gentry fields back to userspace
    Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
    gpio: max7301: fix driver for use with CONFIG_VMAP_STACK
    mmc: omap_hsmmc: fix DMA API warning
    mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl
    mmc: core: Allow BKOPS and CACHE ctrl even if no HPI support
    mmc: core: Reset HPI enabled state during re-init and in case of errors
    USB: serial: option: add Telit LN940 series
    USB: serial: option: add Fibocom NL668 series
    USB: serial: option: add Simcom SIM7500/SIM7600 (MBIM mode)
    USB: serial: option: add HP lt4132
    USB: serial: option: add GosunCn ZTE WeLink ME3630
  * xhci: Don't prevent USB2 bus suspend in state check intended for USB3 only
      drivers/usb/host/xhci-hub.c
    USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data
    ib_srpt: Fix a use-after-free in __srpt_close_all_ch()
  * block: fix infinite loop if the device loses discard capability
      block/blk-lib.c
  * block: break discard submissions into the user defined size
      block/blk-lib.c

Change-Id: Iee286561029e9846bf68e73351e8694ba17b423f
Signed-off-by: Petri Gynther <pgynther@google.com>
2019-01-02 15:53:20 -08:00
Sergey Senozhatsky
6c976b42dc panic: avoid deadlocks in re-entrant console drivers
commit c7c3f05e341a9a2bd1a92993d4f996cfd6e7348e upstream.

From printk()/serial console point of view panic() is special, because
it may force CPU to re-enter printk() or/and serial console driver.
Therefore, some of serial consoles drivers are re-entrant. E.g. 8250:

serial8250_console_write()
{
	if (port->sysrq)
		locked = 0;
	else if (oops_in_progress)
		locked = spin_trylock_irqsave(&port->lock, flags);
	else
		spin_lock_irqsave(&port->lock, flags);
	...
}

panic() does set oops_in_progress via bust_spinlocks(1), so in theory
we should be able to re-enter serial console driver from panic():

	CPU0
	<NMI>
	uart_console_write()
	serial8250_console_write()		// if (oops_in_progress)
						//    spin_trylock_irqsave()
	call_console_drivers()
	console_unlock()
	console_flush_on_panic()
	bust_spinlocks(1)			// oops_in_progress++
	panic()
	<NMI/>
	spin_lock_irqsave(&port->lock, flags)   // spin_lock_irqsave()
	serial8250_console_write()
	call_console_drivers()
	console_unlock()
	printk()
	...

However, this does not happen and we deadlock in serial console on
port->lock spinlock. And the problem is that console_flush_on_panic()
called after bust_spinlocks(0):

void panic(const char *fmt, ...)
{
	bust_spinlocks(1);
	...
	bust_spinlocks(0);
	console_flush_on_panic();
	...
}

bust_spinlocks(0) decrements oops_in_progress, so oops_in_progress
can go back to zero. Thus even re-entrant console drivers will simply
spin on port->lock spinlock. Given that port->lock may already be
locked either by a stopped CPU, or by the very same CPU we execute
panic() on (for instance, NMI panic() on printing CPU) the system
deadlocks and does not reboot.

Fix this by removing bust_spinlocks(0), so oops_in_progress is always
set in panic() now and, thus, re-entrant console drivers will trylock
the port->lock instead of spinning on it forever, when we call them
from console_flush_on_panic().

Link: http://lkml.kernel.org/r/20181025101036.6823-1-sergey.senozhatsky@gmail.com
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Daniel Wang <wonderfly@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Peter Feiner <pfeiner@google.com>
Cc: linux-serial@vger.kernel.org
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-29 13:40:16 +01:00
Lingutla Chandrasekhar
be48b0764d soc: qcom: Register default dump entries to minidump table
Add below common dump entries to minidump table:
All memory dump table entries, kernel data/bss sections,
percpu static sections, rtb, logbuf, wdogdata, lpm_debug,
stackpointer, and current task struct.
Also add name for memory dump table entries to accommodate
Minidump support.

Change-Id: I45d121bc36b40332cfd0a0f5142572c6ce8f8a26
Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
2017-11-27 14:22:11 +05:30
Rama Aparna Mallavarapu
d16ae5ddbc coresight: abort coresight tracing on kernel crash
Add trace events to control aborting CoreSight trace
dynamically based on module parameter.
Coresight driver will dump any trace present in the current sink
in case we hit a kernel panic, user fault or an undefined instruction.

Change-Id: I668c8cda285250a0b8dcccd2c1d2a8471977ce5c
Signed-off-by: Satyajit Desai <sadesai@codeaurora.org>
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
2017-08-30 16:50:09 -07:00
Jiri Slaby
c5c8743642 kernel/panic.c: add missing \n
[ Upstream commit ff7a28a074ccbea999dadbb58c46212cf90984c6 ]

When a system panics, the "Rebooting in X seconds.." message is never
printed because it lacks a new line.  Fix it.

Link: http://lkml.kernel.org/r/20170119114751.2724-1-jslaby@suse.cz
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-05 14:40:24 +02:00
Hidehiro Kawai
0ee59413c9 x86/panic: replace smp_send_stop() with kdump friendly version in panic path
Daniel Walker reported problems which happens when
crash_kexec_post_notifiers kernel option is enabled
(https://lkml.org/lkml/2015/6/24/44).

In that case, smp_send_stop() is called before entering kdump routines
which assume other CPUs are still online.  As the result, for x86, kdump
routines fail to save other CPUs' registers and disable virtualization
extensions.

To fix this problem, call a new kdump friendly function,
crash_smp_send_stop(), instead of the smp_send_stop() when
crash_kexec_post_notifiers is enabled.  crash_smp_send_stop() is a weak
function, and it just call smp_send_stop().  Architecture codes should
override it so that kdump can work appropriately.  This patch only
provides x86-specific version.

For Xen's PV kernel, just keep the current behavior.

NOTES:

- Right solution would be to place crash_smp_send_stop() before
  __crash_kexec() invocation in all cases and remove smp_send_stop(), but
  we can't do that until all architectures implement own
  crash_smp_send_stop()

- crash_smp_send_stop()-like work is still needed by
  machine_crash_shutdown() because crash_kexec() can be called without
  entering panic()

Fixes: f06e5153f4 (kernel/panic.c: add "crash_kexec_post_notifiers" option)
Link: http://lkml.kernel.org/r/20160810080948.11028.15344.stgit@sysi4-13.yrl.intra.hitachi.co.jp
Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Reported-by: Daniel Walker <dwalker@fifo99.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Daniel Walker <dwalker@fifo99.com>
Cc: Xunlei Pang <xpang@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Toshi Kani <toshi.kani@hpe.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Daney <david.daney@cavium.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: "Steven J. Hill" <steven.hill@cavium.com>
Cc: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-10-11 15:06:32 -07:00
Hidehiro Kawai
b26e27ddfd kexec: use core_param for crash_kexec_post_notifiers boot option
crash_kexec_post_notifiers ia a boot option which controls whether the
1st kernel calls panic notifiers or not before booting the 2nd kernel.
However, there is no need to limit it to being modifiable only at boot
time.  So, use core_param instead of early_param.

Link: http://lkml.kernel.org/r/20160705113327.5864.43139.stgit@softrs
Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-08-02 19:35:29 -04:00
Petr Mladek
cf9b1106c8 printk/nmi: flush NMI messages on the system panic
In NMI context, printk() messages are stored into per-CPU buffers to
avoid a possible deadlock.  They are normally flushed to the main ring
buffer via an IRQ work.  But the work is never called when the system
calls panic() in the very same NMI handler.

This patch tries to flush NMI buffers before the crash dump is
generated.  In this case it does not risk a double release and bails out
when the logbuf_lock is already taken.  The aim is to get the messages
into the main ring buffer when possible.  It makes them better
accessible in the vmcore.

Then the patch tries to flush the buffers second time when other CPUs
are down.  It might be more aggressive and reset logbuf_lock.  The aim
is to get the messages available for the consequent kmsg_dump() and
console_flush_on_panic() calls.

The patch causes vprintk_emit() to be called even in NMI context again.
But it is done via printk_deferred() so that the console handling is
skipped.  Consoles use internal locks and we could not prevent a
deadlock easily.  They are explicitly called later when the crash dump
is not generated, see console_flush_on_panic().

Signed-off-by: Petr Mladek <pmladek@suse.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: David Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jiri Kosina <jkosina@suse.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-05-20 17:58:30 -07:00
Hidehiro Kawai
ebc41f20d7 panic: change nmi_panic from macro to function
Commit 1717f2096b ("panic, x86: Fix re-entrance problem due to panic
on NMI") and commit 58c5661f21 ("panic, x86: Allow CPUs to save
registers even if looping in NMI context") introduced nmi_panic() which
prevents concurrent/recursive execution of panic().  It also saves
registers for the crash dump on x86.

However, there are some cases where NMI handlers still use panic().
This patch set partially replaces them with nmi_panic() in those cases.

Even this patchset is applied, some NMI or similar handlers (e.g.  MCE
handler) continue to use panic().  This is because I can't test them
well and actual problems won't happen.  For example, the possibility
that normal panic and panic on MCE happen simultaneously is very low.

This patch (of 3):

Convert nmi_panic() to a proper function and export it instead of
exporting internal implementation details to modules, for obvious
reasons.

Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Gobinda Charan Maji <gobinda.cemk07@gmail.com>
Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-22 15:36:02 -07:00
Josh Poimboeuf
2553b67a1f lib/bug.c: use common WARN helper
The traceoff_on_warning option doesn't have any effect on s390, powerpc,
arm64, parisc, and sh because there are two different types of WARN
implementations:

1) The above mentioned architectures treat WARN() as a special case of a
   BUG() exception.  They handle warnings in report_bug() in lib/bug.c.

2) All other architectures just call warn_slowpath_*() directly.  Their
   warnings are handled in warn_slowpath_common() in kernel/panic.c.

Support traceoff_on_warning on all architectures and prevent any future
divergence by using a single common function to emit the warning.

Also remove the '()' from '%pS()', because the parentheses look funky:

  [   45.607629] WARNING: at /root/warn_mod/warn_mod.c:17 .init_dummy+0x20/0x40 [warn_mod]()

Reported-by: Chunyu Hu <chuhu@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Tested-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-17 15:09:34 -07:00
Tejun Heo
8d91f8b153 printk: do cond_resched() between lines while outputting to consoles
@console_may_schedule tracks whether console_sem was acquired through
lock or trylock.  If the former, we're inside a sleepable context and
console_conditional_schedule() performs cond_resched().  This allows
console drivers which use console_lock for synchronization to yield
while performing time-consuming operations such as scrolling.

However, the actual console outputting is performed while holding
irq-safe logbuf_lock, so console_unlock() clears @console_may_schedule
before starting outputting lines.  Also, only a few drivers call
console_conditional_schedule() to begin with.  This means that when a
lot of lines need to be output by console_unlock(), for example on a
console registration, the task doing console_unlock() may not yield for
a long time on a non-preemptible kernel.

If this happens with a slow console devices, for example a serial
console, the outputting task may occupy the cpu for a very long time.
Long enough to trigger softlockup and/or RCU stall warnings, which in
turn pile more messages, sometimes enough to trigger the next cycle of
warnings incapacitating the system.

Fix it by making console_unlock() insert cond_resched() between lines if
@console_may_schedule.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Calvin Owens <calvinowens@fb.com>
Acked-by: Jan Kara <jack@suse.com>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Kyle McMartin <kyle@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-01-16 11:17:25 -08:00
Hidehiro Kawai
7bbee5ca38 kexec: Fix race between panic() and crash_kexec()
Currently, panic() and crash_kexec() can be called at the same time.
For example (x86 case):

CPU 0:
  oops_end()
    crash_kexec()
      mutex_trylock() // acquired
        nmi_shootdown_cpus() // stop other CPUs

CPU 1:
  panic()
    crash_kexec()
      mutex_trylock() // failed to acquire
    smp_send_stop() // stop other CPUs
    infinite loop

If CPU 1 calls smp_send_stop() before nmi_shootdown_cpus(), kdump
fails.

In another case:

CPU 0:
  oops_end()
    crash_kexec()
      mutex_trylock() // acquired
        <NMI>
        io_check_error()
          panic()
            crash_kexec()
              mutex_trylock() // failed to acquire
            infinite loop

Clearly, this is an undesirable result.

To fix this problem, this patch changes crash_kexec() to exclude others
by using the panic_cpu atomic.

Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: kexec@lists.infradead.org
Cc: linux-doc@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Minfei Huang <mnfhuang@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: x86-ml <x86@kernel.org>
Link: http://lkml.kernel.org/r/20151210014630.25437.94161.stgit@softrs
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-12-19 11:07:01 +01:00
Hidehiro Kawai
58c5661f21 panic, x86: Allow CPUs to save registers even if looping in NMI context
Currently, kdump_nmi_shootdown_cpus(), a subroutine of crash_kexec(),
sends an NMI IPI to CPUs which haven't called panic() to stop them,
save their register information and do some cleanups for crash dumping.
However, if such a CPU is infinitely looping in NMI context, we fail to
save its register information into the crash dump.

For example, this can happen when unknown NMIs are broadcast to all
CPUs as follows:

  CPU 0                             CPU 1
  ===========================       ==========================
  receive an unknown NMI
  unknown_nmi_error()
    panic()                         receive an unknown NMI
      spin_trylock(&panic_lock)     unknown_nmi_error()
      crash_kexec()                   panic()
                                        spin_trylock(&panic_lock)
                                        panic_smp_self_stop()
                                          infinite loop
        kdump_nmi_shootdown_cpus()
          issue NMI IPI -----------> blocked until IRET
                                          infinite loop...

Here, since CPU 1 is in NMI context, the second NMI from CPU 0 is
blocked until CPU 1 executes IRET. However, CPU 1 never executes IRET,
so the NMI is not handled and the callback function to save registers is
never called.

In practice, this can happen on some servers which broadcast NMIs to all
CPUs when the NMI button is pushed.

To save registers in this case, we need to:

  a) Return from NMI handler instead of looping infinitely
  or
  b) Call the callback function directly from the infinite loop

Inherently, a) is risky because NMI is also used to prevent corrupted
data from being propagated to devices.  So, we chose b).

This patch does the following:

1. Move the infinite looping of CPUs which haven't called panic() in NMI
   context (actually done by panic_smp_self_stop()) outside of panic() to
   enable us to refer pt_regs. Please note that panic_smp_self_stop() is
   still used for normal context.

2. Call a callback of kdump_nmi_shootdown_cpus() directly to save
   registers and do some cleanups after setting waiting_for_crash_ipi which
   is used for counting down the number of CPUs which handled the callback

Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Gobinda Charan Maji <gobinda.cemk07@gmail.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: kexec@lists.infradead.org
Cc: linux-doc@vger.kernel.org
Cc: lkml <linux-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Link: http://lkml.kernel.org/r/20151210014628.25437.75256.stgit@softrs
[ Cleanup comments, fixup formatting. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-12-19 11:07:01 +01:00
Hidehiro Kawai
1717f2096b panic, x86: Fix re-entrance problem due to panic on NMI
If panic on NMI happens just after panic() on the same CPU, panic() is
recursively called. Kernel stalls, as a result, after failing to acquire
panic_lock.

To avoid this problem, don't call panic() in NMI context if we've
already entered panic().

For that, introduce nmi_panic() macro to reduce code duplication. In
the case of panic on NMI, don't return from NMI handlers if another CPU
already panicked.

Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Gobinda Charan Maji <gobinda.cemk07@gmail.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: kexec@lists.infradead.org
Cc: linux-doc@vger.kernel.org
Cc: lkml <linux-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Link: http://lkml.kernel.org/r/20151210014626.25437.13302.stgit@softrs
[ Cleanup comments, fixup formatting. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-12-19 11:07:00 +01:00
Vitaly Kuznetsov
7625b3a000 kernel/panic.c: turn off locks debug before releasing console lock
Commit 08d78658f3 ("panic: release stale console lock to always get the
logbuf printed out") introduced an unwanted bad unlock balance report when
panic() is called directly and not from OOPS (e.g.  from out_of_memory()).
The difference is that in case of OOPS we disable locks debug in
oops_enter() and on direct panic call nobody does that.

Fixes: 08d78658f3 ("panic: release stale console lock to always get the logbuf printed out")
Reported-by: kernel test robot <ying.huang@linux.intel.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Baoquan He <bhe@redhat.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Xie XiuQi <xiexiuqi@huawei.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Petr Mladek <pmladek@suse.cz>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-20 16:17:32 -08:00
Vitaly Kuznetsov
08d78658f3 panic: release stale console lock to always get the logbuf printed out
In some cases we may end up killing the CPU holding the console lock
while still having valuable data in logbuf. E.g. I'm observing the
following:

- A crash is happening on one CPU and console_unlock() is being called on
  some other.

- console_unlock() tries to print out the buffer before releasing the lock
  and on slow console it takes time.

- in the meanwhile crashing CPU does lots of printk()-s with valuable data
  (which go to the logbuf) and sends IPIs to all other CPUs.

- console_unlock() finishes printing previous chunk and enables interrupts
  before trying to print out the rest, the CPU catches the IPI and never
  releases console lock.

This is not the only possible case: in VT/fb subsystems we have many other
console_lock()/console_unlock() users.  Non-masked interrupts (or
receiving NMI in case of extreme slowness) will have the same result.
Getting the whole console buffer printed out on crash should be top
priority.

[akpm@linux-foundation.org: tweak comment text]
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Baoquan He <bhe@redhat.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Xie XiuQi <xiexiuqi@huawei.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 17:50:42 -08:00
HATAYAMA Daisuke
5375b708f2 kernel/panic/kexec: fix "crash_kexec_post_notifiers" option issue in oops path
Commit f06e5153f4 ("kernel/panic.c: add "crash_kexec_post_notifiers"
option for kdump after panic_notifers") introduced
"crash_kexec_post_notifiers" kernel boot option, which toggles wheather
panic() calls crash_kexec() before panic_notifiers and dump kmsg or after.

The problem is that the commit overlooks panic_on_oops kernel boot option.
 If it is enabled, crash_kexec() is called directly without going through
panic() in oops path.

To fix this issue, this patch adds a check to "crash_kexec_post_notifiers"
in the condition of kexec_should_crash().

Also, put a comment in kexec_should_crash() to explain not obvious things
on this patch.

Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Acked-by: Baoquan He <bhe@redhat.com>
Tested-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-30 19:44:57 -07:00
HATAYAMA Daisuke
f45d85ff1f kernel/panic: call the 2nd crash_kexec() only if crash_kexec_post_notifiers is enabled
For compatibility with the behaviour before the commit f06e5153f4
("kernel/panic.c: add "crash_kexec_post_notifiers" option for kdump after
panic_notifers"), the 2nd crash_kexec() should be called only if
crash_kexec_post_notifiers is enabled.

Note that crash_kexec() returns immediately if kdump crash kernel is not
loaded, so in this case, this patch makes no functionality change, but the
point is to make it explicit, from the caller panic() side, that the 2nd
crash_kexec() does nothing.

Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-30 19:44:57 -07:00
Seth Jennings
c5f4546593 livepatch: kernel: add TAINT_LIVEPATCH
This adds a new taint flag to indicate when the kernel or a kernel
module has been live patched.  This will provide a clean indication in
bug reports that live patching was used.

Additionally, if the crash occurs in a live patched function, the live
patch module will appear beside the patched function in the backtrace.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-12-22 15:40:48 +01:00
Prarit Bhargava
9e3961a097 kernel: add panic_on_warn
There have been several times where I have had to rebuild a kernel to
cause a panic when hitting a WARN() in the code in order to get a crash
dump from a system.  Sometimes this is easy to do, other times (such as
in the case of a remote admin) it is not trivial to send new images to
the user.

A much easier method would be a switch to change the WARN() over to a
panic.  This makes debugging easier in that I can now test the actual
image the WARN() was seen on and I do not have to engage in remote
debugging.

This patch adds a panic_on_warn kernel parameter and
/proc/sys/kernel/panic_on_warn calls panic() in the
warn_slowpath_common() path.  The function will still print out the
location of the warning.

An example of the panic_on_warn output:

The first line below is from the WARN_ON() to output the WARN_ON()'s
location.  After that the panic() output is displayed.

    WARNING: CPU: 30 PID: 11698 at /home/prarit/dummy_module/dummy-module.c:25 init_dummy+0x1f/0x30 [dummy_module]()
    Kernel panic - not syncing: panic_on_warn set ...

    CPU: 30 PID: 11698 Comm: insmod Tainted: G        W  OE  3.17.0+ #57
    Hardware name: Intel Corporation S2600CP/S2600CP, BIOS RMLSDP.86I.00.29.D696.1311111329 11/11/2013
     0000000000000000 000000008e3f87df ffff88080f093c38 ffffffff81665190
     0000000000000000 ffffffff818aea3d ffff88080f093cb8 ffffffff8165e2ec
     ffffffff00000008 ffff88080f093cc8 ffff88080f093c68 000000008e3f87df
    Call Trace:
     [<ffffffff81665190>] dump_stack+0x46/0x58
     [<ffffffff8165e2ec>] panic+0xd0/0x204
     [<ffffffffa038e05f>] ? init_dummy+0x1f/0x30 [dummy_module]
     [<ffffffff81076b90>] warn_slowpath_common+0xd0/0xd0
     [<ffffffffa038e040>] ? dummy_greetings+0x40/0x40 [dummy_module]
     [<ffffffff81076c8a>] warn_slowpath_null+0x1a/0x20
     [<ffffffffa038e05f>] init_dummy+0x1f/0x30 [dummy_module]
     [<ffffffff81002144>] do_one_initcall+0xd4/0x210
     [<ffffffff811b52c2>] ? __vunmap+0xc2/0x110
     [<ffffffff810f8889>] load_module+0x16a9/0x1b30
     [<ffffffff810f3d30>] ? store_uevent+0x70/0x70
     [<ffffffff810f49b9>] ? copy_module_from_fd.isra.44+0x129/0x180
     [<ffffffff810f8ec6>] SyS_finit_module+0xa6/0xd0
     [<ffffffff8166cf29>] system_call_fastpath+0x12/0x17

Successfully tested by me.

hpa said: There is another very valid use for this: many operators would
rather a machine shuts down than being potentially compromised either
functionally or security-wise.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-12-10 17:41:10 -08:00
Xie XiuQi
bc53a3f46d kernel/panic.c: update comments for print_tainted
Commit 69361eef90 ("panic: add TAINT_SOFTLOCKUP") added the 'L' flag,
but failed to update the comments for print_tainted().  So, update the
comments.

Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-11-13 16:17:06 -08:00
Josh Hunt
69361eef90 panic: add TAINT_SOFTLOCKUP
This taint flag will be set if the system has ever entered a softlockup
state.  Similar to TAINT_WARN it is useful to know whether or not the
system has been in a softlockup state when debugging.

[akpm@linux-foundation.org: apply the taint before calling panic()]
Signed-off-by: Josh Hunt <johunt@akamai.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-08 15:57:24 -07:00
Masami Hiramatsu
f06e5153f4 kernel/panic.c: add "crash_kexec_post_notifiers" option for kdump after panic_notifers
Add a "crash_kexec_post_notifiers" boot option to run kdump after
running panic_notifiers and dump kmsg.  This can help rare situations
where kdump fails because of unstable crashed kernel or hardware failure
(memory corruption on critical data/code), or the 2nd kernel is already
broken by the 1st kernel (it's a broken behavior, but who can guarantee
that the "crashed" kernel works correctly?).

Usage: add "crash_kexec_post_notifiers" to kernel boot option.

Note that this actually increases risks of the failure of kdump.  This
option should be set only if you worry about the rare case of kdump
failure rather than increasing the chance of success.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Motohiro Kosaki <Motohiro.Kosaki@us.fujitsu.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Satoru MORIYA <satoru.moriya.br@hitachi.com>
Cc: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-06-06 16:08:12 -07:00
Fabian Frederick
d7c0847fe3 kernel/panic.c: display reason at end + pr_emerg
Currently, booting without initrd specified on 80x25 screen gives a call
trace followed by atkbd : Spurious ACK.  Original message ("VFS: Unable
to mount root fs") is not available.  Of course this could happen in
other situations...

This patch displays panic reason after call trace which could help lot
of people even if it's not the very last line on screen.

Also, convert all panic.c printk(KERN_EMERG to pr_emerg(

[akpm@linux-foundation.org: missed a couple of pr_ conversions]
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-04-07 16:36:08 -07:00
Linus Torvalds
6f4c98e1c2 Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull module updates from Rusty Russell:
 "Nothing major: the stricter permissions checking for sysfs broke a
  staging driver; fix included.  Greg KH said he'd take the patch but
  hadn't as the merge window opened, so it's included here to avoid
  breaking build"

* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
  staging: fix up speakup kobject mode
  Use 'E' instead of 'X' for unsigned module taint flag.
  VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.
  kallsyms: fix percpu vars on x86-64 with relocation.
  kallsyms: generalize address range checking
  module: LLVMLinux: Remove unused function warning from __param_check macro
  Fix: module signature vs tracepoints: add new TAINT_UNSIGNED_MODULE
  module: remove MODULE_GENERIC_TABLE
  module: allow multiple calls to MODULE_DEVICE_TABLE() per module
  module: use pr_cont
2014-04-06 09:38:07 -07:00
Linus Torvalds
176ab02d49 Merge branch 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 LTO changes from Peter Anvin:
 "More infrastructure work in preparation for link-time optimization
  (LTO).  Most of these changes is to make sure symbols accessed from
  assembly code are properly marked as visible so the linker doesn't
  remove them.

  My understanding is that the changes to support LTO are still not
  upstream in binutils, but are on the way there.  This patchset should
  conclude the x86-specific changes, and remaining patches to actually
  enable LTO will be fed through the Kbuild tree (other than keeping up
  with changes to the x86 code base, of course), although not
  necessarily in this merge window"

* 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
  Kbuild, lto: Handle basic LTO in modpost
  Kbuild, lto: Disable LTO for asm-offsets.c
  Kbuild, lto: Add a gcc-ld script to let run gcc as ld
  Kbuild, lto: add ld-version and ld-ifversion macros
  Kbuild, lto: Drop .number postfixes in modpost
  Kbuild, lto, workaround: Don't warn for initcall_reference in modpost
  lto: Disable LTO for sys_ni
  lto: Handle LTO common symbols in module loader
  lto, workaround: Add workaround for initcall reordering
  lto: Make asmlinkage __visible
  x86, lto: Disable LTO for the x86 VDSO
  initconst, x86: Fix initconst mistake in ts5500 code
  initconst: Fix initconst mistake in dcdbas
  asmlinkage: Make trace_hardirqs_on/off_caller visible
  asmlinkage, x86: Fix 32bit memcpy for LTO
  asmlinkage Make __stack_chk_failed and memcmp visible
  asmlinkage: Mark rwsem functions that can be called from assembler asmlinkage
  asmlinkage: Make main_extable_sort_needed visible
  asmlinkage, mutex: Mark __visible
  asmlinkage: Make trace_hardirq visible
  ...
2014-03-31 14:13:25 -07:00
Rusty Russell
57673c2b0b Use 'E' instead of 'X' for unsigned module taint flag.
Takashi Iwai <tiwai@suse.de> says:
> The letter 'X' has been already used for SUSE kernels for very long
> time, to indicate the external supported modules.  Can the new flag be
> changed to another letter for avoiding conflict...?
> (BTW, we also use 'N' for "no support", too.)

Note: this code should be cleaned up, so we don't have such maps in
three places!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-03-31 14:52:43 +10:30
Dave Jones
8c90487cdc Rename TAINT_UNSAFE_SMP to TAINT_CPU_OUT_OF_SPEC
Rename TAINT_UNSAFE_SMP to TAINT_CPU_OUT_OF_SPEC, so we can repurpose
the flag to encompass a wider range of pushing the CPU beyond its
warrany.

Signed-off-by: Dave Jones <davej@fedoraproject.org>
Link: http://lkml.kernel.org/r/20140226154949.GA770@redhat.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-03-20 16:28:09 -07:00
Mathieu Desnoyers
66cc69e34e Fix: module signature vs tracepoints: add new TAINT_UNSIGNED_MODULE
Users have reported being unable to trace non-signed modules loaded
within a kernel supporting module signature.

This is caused by tracepoint.c:tracepoint_module_coming() refusing to
take into account tracepoints sitting within force-loaded modules
(TAINT_FORCED_MODULE). The reason for this check, in the first place, is
that a force-loaded module may have a struct module incompatible with
the layout expected by the kernel, and can thus cause a kernel crash
upon forced load of that module on a kernel with CONFIG_TRACEPOINTS=y.

Tracepoints, however, specifically accept TAINT_OOT_MODULE and
TAINT_CRAP, since those modules do not lead to the "very likely system
crash" issue cited above for force-loaded modules.

With kernels having CONFIG_MODULE_SIG=y (signed modules), a non-signed
module is tainted re-using the TAINT_FORCED_MODULE taint flag.
Unfortunately, this means that Tracepoints treat that module as a
force-loaded module, and thus silently refuse to consider any tracepoint
within this module.

Since an unsigned module does not fit within the "very likely system
crash" category of tainting, add a new TAINT_UNSIGNED_MODULE taint flag
to specifically address this taint behavior, and accept those modules
within Tracepoints. We use the letter 'X' as a taint flag character for
a module being loaded that doesn't know how to sign its name (proposed
by Steven Rostedt).

Also add the missing 'O' entry to trace event show_module_flags() list
for the sake of completeness.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
NAKed-by: Ingo Molnar <mingo@redhat.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: David Howells <dhowells@redhat.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-03-13 12:11:51 +10:30
Andi Kleen
a7330c997d asmlinkage Make __stack_chk_failed and memcmp visible
In LTO symbols implicitely referenced by the compiler need
to be visible. Earlier these symbols were visible implicitely
from being exported, but we disabled implicit visibility fo
 EXPORTs when modules are disabled to improve code size. So
now these symbols have to be marked visible explicitely.

Do this for __stack_chk_fail (with stack protector)
and memcmp.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391845930-28580-10-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-02-13 18:13:43 -08:00
Jason Baron
5800dc3cff panic: Make panic_timeout configurable
The panic_timeout value can be set via the command line option
'panic=x', or via /proc/sys/kernel/panic, however that is not
sufficient when the panic occurs before we are able to set up
these values. Thus, add a CONFIG_PANIC_TIMEOUT so that we can
set the desired value from the .config.

The default panic_timeout value continues to be 0 - wait
forever. Also adds set_arch_panic_timeout(new_timeout,
arch_default_timeout), which is intended to be used by arches in
arch_setup(). The idea being that the new_timeout is only set if
the user hasn't changed from the arch_default_timeout.

Signed-off-by: Jason Baron <jbaron@akamai.com>
Cc: benh@kernel.crashing.org
Cc: paulus@samba.org
Cc: ralf@linux-mips.org
Cc: mpe@ellerman.id.au
Cc: felipe.contreras@gmail.com
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1a1674daec27c534df409697025ac568ebcee91e.1385418410.git.jbaron@akamai.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2013-11-26 12:12:26 +01:00
Chen Gang
0128476471 kernel/panic.c: reduce 1 byte usage for print tainted buffer
sizeof("Tainted: ") already counts '\0', and after first sprintf(), 's'
will start from the current string end (its' value is '\0').

So need not add additional 1 byte for maximized usage of 'buf' in
print_tainted().

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-11-13 12:09:35 +09:00
Kees Cook
6723734cdf panic: call panic handlers before kmsg_dump
Since the panic handlers may produce additional information (via printk)
for the kernel log, it should be reported as part of the panic output
saved by kmsg_dump().  Without this re-ordering, nothing that adds
information to a panic will show up in pstore's view when kmsg_dump runs,
and is therefore not visible to crash reporting tools that examine pstore
output.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Vikram Mulukutla <markivx@codeaurora.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-11 15:59:30 -07:00
Linus Torvalds
c72bb31691 Merge tag 'trace-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing changes from Steven Rostedt:
 "The majority of the changes here are cleanups for the large changes
  that were added to 3.10, which includes several bug fixes that have
  been marked for stable.

  As for new features, there were a few, but nothing to write to LWN
  about.  These include:

  New function trigger called "dump" and "cpudump" that will cause
  ftrace to dump its buffer to the console when the function is called.
  The difference between "dump" and "cpudump" is that "dump" will dump
  the entire contents of the ftrace buffer, where as "cpudump" will only
  dump the contents of the ftrace buffer for the CPU that called the
  function.

  Another small enhancement is a new sysctl switch called
  "traceoff_on_warning" which, when enabled, will disable tracing if any
  WARN_ON() is triggered.  This is useful if you want to debug what
  caused a warning and do not want to risk losing your trace data by the
  ring buffer overwriting the data before you can disable it.  There's
  also a kernel command line option that will make this enabled at boot
  up called the same thing"

* tag 'trace-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (34 commits)
  tracing: Make tracing_open_generic_{tr,tc}() static
  tracing: Remove ftrace() function
  tracing: Remove TRACE_EVENT_TYPE enum definition
  tracing: Make tracer_tracing_{off,on,is_on}() static
  tracing: Fix irqs-off tag display in syscall tracing
  uprobes: Fix return value in error handling path
  tracing: Fix race between deleting buffer and setting events
  tracing: Add trace_array_get/put() to event handling
  tracing: Get trace_array ref counts when accessing trace files
  tracing: Add trace_array_get/put() to handle instance refs better
  tracing: Protect ftrace_trace_arrays list in trace_events.c
  tracing: Make trace_marker use the correct per-instance buffer
  ftrace: Do not run selftest if command line parameter is set
  tracing/kprobes: Don't pass addr=ip to perf_trace_buf_submit()
  tracing: Use flag buffer_disabled for irqsoff tracer
  tracing/kprobes: Turn trace_probe->files into list_head
  tracing: Fix disabling of soft disable
  tracing: Add missing syscall_metadata comment
  tracing: Simplify code for showing of soft disabled flag
  tracing/kprobes: Kill probe_enable_lock
  ...
2013-07-11 09:02:09 -07:00
Alex Thorlton
dcb6b45254 panic: add cpu/pid to warn_slowpath_common in WARNING printk()s
Add the cpu/pid that called WARN() so that the stack traces can be
matched up with the WARNING messages.

[akpm@linux-foundation.org: remove stray quote]
Signed-off-by: Alex Thorlton <athorlton@sgi.com>
Reviewed-by: Robin Holt <holt@sgi.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Vikram Mulukutla <markivx@codeaurora.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-09 10:33:25 -07:00
Steven Rostedt (Red Hat)
de7edd3145 tracing: Disable tracing on warning
Add a traceoff_on_warning option in both the kernel command line as well
as a sysctl option. When set, any WARN*() function that is hit will cause
the tracing_on variable to be cleared, which disables writing to the
ring buffer.

This is useful especially when tracing a bug with function tracing. When
a warning is hit, the print caused by the warning can flood the trace with
the functions that producing the output for the warning. This can make the
resulting trace useless by either hiding where the bug happened, or worse,
by overflowing the buffer and losing the trace of the bug totally.

Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2013-06-19 23:32:07 -04:00
Tejun Heo
98e5e1bf72 dump_stack: implement arch-specific hardware description in task dumps
x86 and ia64 can acquire extra hardware identification information
from DMI and print it along with task dumps; however, the usage isn't
consistent.

* x86 show_regs() collects vendor, product and board strings and print
  them out with PID, comm and utsname.  Some of the information is
  printed again later in the same dump.

* warn_slowpath_common() explicitly accesses the DMI board and prints
  it out with "Hardware name:" label.  This applies to both x86 and
  ia64 but is irrelevant on all other archs.

* ia64 doesn't show DMI information on other non-WARN dumps.

This patch introduces arch-specific hardware description used by
dump_stack().  It can be set by calling dump_stack_set_arch_desc()
during boot and, if exists, printed out in a separate line with
"Hardware name:" label.

dmi_set_dump_stack_arch_desc() is added which sets arch-specific
description from DMI data.  It uses dmi_ids_string[] which is set from
dmi_present() used for DMI debug message.  It is superset of the
information x86 show_regs() is using.  The function is called from x86
and ia64 boot code right after dmi_scan_machine().

This makes the explicit DMI handling in warn_slowpath_common()
unnecessary.  Removed.

show_regs() isn't yet converted to use generic debug information
printing and this patch doesn't remove the duplicate DMI handling in
x86 show_regs().  The next patch will unify show_regs() handling and
remove the duplication.

An example WARN dump follows.

 WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505()
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #3
 Hardware name: empty empty/S3992, BIOS 080011  10/26/2007
  0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48
  ffffffff8108f500 ffffffff82228240 0000000000000040 ffffffff8234a08e
  0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58
 Call Trace:
  [<ffffffff81c614dc>] dump_stack+0x19/0x1b
  [<ffffffff8108f500>] warn_slowpath_common+0x70/0xa0
  [<ffffffff8108f54a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff8234a0c3>] init_workqueues+0x35/0x505
  ...

v2: Use the same string as the debug message from dmi_present() which
    also contains BIOS information.  Move hardware name into its own
    line as warn_slowpath_common() did.  This change was suggested by
    Bjorn Helgaas.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-30 17:04:02 -07:00
Rusty Russell
373d4d0997 taint: add explicit flag to show whether lock dep is still OK.
Fix up all callers as they were before, with make one change: an
unsigned module taints the kernel, but doesn't turn off lockdep.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-01-21 17:17:57 +10:30
Vikram Mulukutla
190320c3b6 panic: fix a possible deadlock in panic()
panic_lock is meant to ensure that panic processing takes place only on
one cpu; if any of the other cpus encounter a panic, they will spin
waiting to be shut down.

However, this causes a regression in this scenario:

1. Cpu 0 encounters a panic and acquires the panic_lock
   and proceeds with the panic processing.
2. There is an interrupt on cpu 0 that also encounters
   an error condition and invokes panic.
3. This second invocation fails to acquire the panic_lock
   and enters the infinite while loop in panic_smp_self_stop.

Thus all panic processing is stopped, and the cpu is stuck for eternity
in the while(1) inside panic_smp_self_stop.

To address this, disable local interrupts with local_irq_disable before
acquiring the panic_lock.  This will prevent interrupt handlers from
executing during the panic processing, thus avoiding this particular
problem.

Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-07-30 17:25:13 -07:00
Seiji Aguchi
62be73eafa kdump: Execute kmsg_dump(KMSG_DUMP_PANIC) after smp_send_stop()
This patch moves kmsg_dump(KMSG_DUMP_PANIC) below smp_send_stop(),
to serialize the crash-logging process via smp_send_stop() and to
thus retrieve a more stable crash image of all CPUs stopped.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Cc: dle-develop@lists.sourceforge.net <dle-develop@lists.sourceforge.net>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: a.p.zijlstra@chello.nl <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/5C4C569E8A4B9B42A84A977CF070A35B2E4D7A5CE2@USINDEVS01.corp.hds.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2012-05-18 14:02:10 +02:00
Kyle McMartin
2a01bb3885 panic: Make panic_on_oops configurable
Several distros set this by default by patching panic_on_oops.
It seems to fit with the BOOTPARAM_{HARD,SOFT}_PANIC options
though, so let's add a Kconfig entry and reduce some more
upstream delta.

Signed-off-by: Kyle McMartin <kyle@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20120411121529.GH26688@redacted.bos.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2012-05-07 14:45:29 +02:00
Jason Wessel
026ee1f66a panic: fix stack dump print on direct call to panic()
Commit 6e6f0a1f0f ("panic: don't print redundant backtraces on oops")
causes a regression where no stack trace will be printed at all for the
case where kernel code calls panic() directly while not processing an
oops, and of course there are 100's of instances of this type of call.

The original commit executed the check (!oops_in_progress), but this will
always be false because just before the dump_stack() there is a call to
bust_spinlocks(1), which does the following:

  void __attribute__((weak)) bust_spinlocks(int yes)
  {
	if (yes) {
		++oops_in_progress;

The proper way to resolve the problem that original commit tried to
solve is to avoid printing a stack dump from panic() when the either of
the following conditions is true:

  1) TAINT_DIE has been set (this is done by oops_end())
     This indicates and oops has already been printed.
  2) oops_in_progress > 1
     This guards against the rare case where panic() is invoked
     a second time, or in between oops_begin() and oops_end()

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: <stable@vger.kernel.org>	[3.3+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-12 13:12:12 -07:00
Andi Kleen
6e6f0a1f0f panic: don't print redundant backtraces on oops
When an oops causes a panic and panic prints another backtrace it's pretty
common to have the original oops data be scrolled away on a 80x50 screen.

The second backtrace is quite redundant and not needed anyways.

So don't print the panic backtrace when oops_in_progress is true.

[akpm@linux-foundation.org: add comment]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-12 20:13:11 -08:00
Michael Holzheu
93e13a360b kdump: fix crash_kexec()/smp_send_stop() race in panic()
When two CPUs call panic at the same time there is a possible race
condition that can stop kdump.  The first CPU calls crash_kexec() and the
second CPU calls smp_send_stop() in panic() before crash_kexec() finished
on the first CPU.  So the second CPU stops the first CPU and therefore
kdump fails:

1st CPU:
  panic()->crash_kexec()->mutex_trylock(&kexec_mutex)-> do kdump

2nd CPU:
  panic()->crash_kexec()->kexec_mutex already held by 1st CPU
       ->smp_send_stop()-> stop 1st CPU (stop kdump)

This patch fixes the problem by introducing a spinlock in panic that
allows only one CPU to process crash_kexec() and the subsequent panic
code.

All other CPUs call the weak function panic_smp_self_stop() that stops the
CPU itself.  This function can be overloaded by architecture code.  For
example "tile" can use their lower-power "nap" instruction for that.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-12 20:13:11 -08:00