linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.19 100/100] tracing: Initialize iter->seq after zeroing in tracing_read_pipe()
Date: Fri, 18 Oct 2019 18:05:25 -0400	[thread overview]
Message-ID: <20191018220525.9042-100-sashal@kernel.org> (raw)
In-Reply-To: <20191018220525.9042-1-sashal@kernel.org>

From: Petr Mladek <pmladek@suse.com>

[ Upstream commit d303de1fcf344ff7c15ed64c3f48a991c9958775 ]

A customer reported the following softlockup:

[899688.160002] NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [test.sh:16464]
[899688.160002] CPU: 0 PID: 16464 Comm: test.sh Not tainted 4.12.14-6.23-azure #1 SLE12-SP4
[899688.160002] RIP: 0010:up_write+0x1a/0x30
[899688.160002] Kernel panic - not syncing: softlockup: hung tasks
[899688.160002] RIP: 0010:up_write+0x1a/0x30
[899688.160002] RSP: 0018:ffffa86784d4fde8 EFLAGS: 00000257 ORIG_RAX: ffffffffffffff12
[899688.160002] RAX: ffffffff970fea00 RBX: 0000000000000001 RCX: 0000000000000000
[899688.160002] RDX: ffffffff00000001 RSI: 0000000000000080 RDI: ffffffff970fea00
[899688.160002] RBP: ffffffffffffffff R08: ffffffffffffffff R09: 0000000000000000
[899688.160002] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8b59014720d8
[899688.160002] R13: ffff8b59014720c0 R14: ffff8b5901471090 R15: ffff8b5901470000
[899688.160002]  tracing_read_pipe+0x336/0x3c0
[899688.160002]  __vfs_read+0x26/0x140
[899688.160002]  vfs_read+0x87/0x130
[899688.160002]  SyS_read+0x42/0x90
[899688.160002]  do_syscall_64+0x74/0x160

It caught the process in the middle of trace_access_unlock(). There is
no loop. So, it must be looping in the caller tracing_read_pipe()
via the "waitagain" label.

Crashdump analyze uncovered that iter->seq was completely zeroed
at this point, including iter->seq.seq.size. It means that
print_trace_line() was never able to print anything and
there was no forward progress.

The culprit seems to be in the code:

	/* reset all but tr, trace, and overruns */
	memset(&iter->seq, 0,
	       sizeof(struct trace_iterator) -
	       offsetof(struct trace_iterator, seq));

It was added by the commit 53d0aa773053ab182877 ("ftrace:
add logic to record overruns"). It was v2.6.27-rc1.
It was the time when iter->seq looked like:

     struct trace_seq {
	unsigned char		buffer[PAGE_SIZE];
	unsigned int		len;
     };

There was no "size" variable and zeroing was perfectly fine.

The solution is to reinitialize the structure after or without
zeroing.

Link: http://lkml.kernel.org/r/20191011142134.11997-1-pmladek@suse.com

Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 3b0de19b9ed75..706155ca344b0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5753,6 +5753,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
 	       sizeof(struct trace_iterator) -
 	       offsetof(struct trace_iterator, seq));
 	cpumask_clear(iter->started);
+	trace_seq_init(&iter->seq);
 	iter->pos = -1;
 
 	trace_event_read_lock();
-- 
2.20.1


      parent reply	other threads:[~2019-10-18 22:08 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 22:03 [PATCH AUTOSEL 4.19 001/100] wil6210: fix freeing of rx buffers in EDMA mode Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 002/100] f2fs: flush quota blocks after turnning it off Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 003/100] scsi: lpfc: Fix a duplicate 0711 log message number Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 004/100] sc16is7xx: Fix for "Unexpected interrupt: 8" Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 005/100] powerpc/powernv: hold device_hotplug_lock when calling memtrace_offline_pages() Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 006/100] f2fs: fix to recover inode's i_gc_failures during POR Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 007/100] f2fs: fix to recover inode->i_flags of inode block " Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 008/100] HID: i2c-hid: add Direkt-Tek DTLAPY133-1 to descriptor override Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 009/100] usb: dwc2: fix unbalanced use of external vbus-supply Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 010/100] tools/power turbostat: fix goldmont C-state limit decoding Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 011/100] x86/cpu: Add Atom Tremont (Jacobsville) Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 012/100] drm/msm/dpu: handle failures while initializing displays Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 013/100] bcache: fix input overflow to writeback_rate_minimum Sasha Levin
2019-10-18 22:03 ` [PATCH AUTOSEL 4.19 014/100] PCI: Fix Switchtec DMA aliasing quirk dmesg noise Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 015/100] Btrfs: fix deadlock on tree root leaf when finding free extent Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 016/100] netfilter: ipset: Make invalid MAC address checks consistent Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 017/100] HID: i2c-hid: Disable runtime PM for LG touchscreen Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 018/100] HID: i2c-hid: Ignore input report if there's no data present on Elan touchpanels Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 019/100] HID: i2c-hid: Add Odys Winbook 13 to descriptor override Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 020/100] platform/x86: Add the VLV ISP PCI ID to atomisp2_pm Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 021/100] platform/x86: Fix config space access for intel_atomisp2_pm Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 022/100] ath10k: assign 'n_cipher_suites = 11' for WCN3990 to enable WPA3 Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 023/100] clk: boston: unregister clks on failure in clk_boston_setup() Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 024/100] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 025/100] staging: mt7621-pinctrl: use pinconf-generic for 'dt_node_to_map' and 'dt_free_map' Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 026/100] HID: Add ASUS T100CHI keyboard dock battery quirks Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 027/100] NFSv4: Ensure that the state manager exits the loop on SIGKILL Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 028/100] HID: steam: fix boot loop with bluetooth firmware Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 029/100] HID: steam: fix deadlock with input devices Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 030/100] samples: bpf: fix: seg fault with NULL pointer arg Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 031/100] usb: dwc3: gadget: early giveback if End Transfer already completed Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 032/100] usb: dwc3: gadget: clear DWC3_EP_TRANSFER_STARTED on cmd complete Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 033/100] ALSA: usb-audio: Add quirk for MOTU MicroBook II Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 034/100] ALSA: usb-audio: Cleanup DSD whitelist Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 035/100] usb: handle warm-reset port requests on hub resume Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 036/100] rtc: pcf8523: set xtal load capacitance from DT Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 037/100] mlxsw: spectrum: Set LAG port collector only when active Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 038/100] net: stmmac: Fix NAPI poll in TX path when in multi-queue Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 039/100] scsi: lpfc: Correct localport timeout duration error Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 040/100] CIFS: Respect SMB2 hdr preamble size in read responses Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 041/100] cifs: add credits from unmatched responses/messages Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 042/100] ALSA: hda/realtek - Apply ALC294 hp init also for S4 resume Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 043/100] media: vimc: Remove unused but set variables Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 044/100] ext4: disallow files with EXT4_JOURNAL_DATA_FL from EXT4_IOC_SWAP_BOOT Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 045/100] exec: load_script: Do not exec truncated interpreter path Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 046/100] net: dsa: mv88e6xxx: Release lock while requesting IRQ Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 047/100] PCI/PME: Fix possible use-after-free on remove Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 048/100] drm/amd/display: fix odm combine pipe reset Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 049/100] power: supply: max14656: fix potential use-after-free Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 050/100] iio: adc: meson_saradc: Fix memory allocation order Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 051/100] iio: fix center temperature of bmc150-accel-core Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 052/100] libsubcmd: Make _FORTIFY_SOURCE defines dependent on the feature Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 053/100] perf tests: Avoid raising SEGV using an obvious NULL dereference Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 054/100] perf map: Fix overlapped map handling Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 055/100] perf script brstackinsn: Fix recovery from LBR/binary mismatch Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 056/100] perf jevents: Fix period for Intel fixed counters Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 057/100] perf tools: Propagate get_cpuid() error Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 058/100] perf annotate: Propagate perf_env__arch() error Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 059/100] perf annotate: Fix the signedness of failure returns Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 060/100] perf annotate: Propagate the symbol__annotate() error return Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 061/100] perf annotate: Return appropriate error code for allocation failures Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 062/100] staging: rtl8188eu: fix null dereference when kzalloc fails Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 063/100] crypto: arm/aes-ce - add dependency on AES library Sasha Levin
2019-10-21  6:08   ` Ard Biesheuvel
2019-10-29  9:19     ` Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 064/100] RDMA/hfi1: Prevent memory leak in sdma_init Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 065/100] RDMA/iwcm: Fix a lock inversion issue Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 066/100] HID: hyperv: Use in-place iterator API in the channel callback Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 067/100] nfs: Fix nfsi->nrequests count error on nfs_inode_remove_request Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 068/100] arm64: ftrace: Ensure synchronisation in PLT setup for Neoverse-N1 #1542419 Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 069/100] tty: serial: owl: Fix the link time qualifier of 'owl_uart_exit()' Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 070/100] tty: n_hdlc: fix build on SPARC Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 071/100] RDMA/cxgb4: Do not dma memory off of the stack Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 072/100] gpio: max77620: Use correct unit for debounce times Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 073/100] fs: cifs: mute -Wunused-const-variable message Sasha Levin
2019-10-18 22:04 ` [PATCH AUTOSEL 4.19 074/100] serial: mctrl_gpio: Check for NULL pointer Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 075/100] efi/cper: Fix endianness of PCIe class code Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 076/100] efi/x86: Do not clean dummy variable in kexec path Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 077/100] kbuild: fix build error of 'make nsdeps' in clean tree Sasha Levin
2019-10-19  0:13   ` Masahiro Yamada
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 078/100] MIPS: include: Mark __cmpxchg as __always_inline Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 079/100] x86/xen: Return from panic notifier Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 080/100] ocfs2: clear zero in unaligned direct IO Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 081/100] fs: ocfs2: fix possible null-pointer dereferences in ocfs2_xa_prepare_entry() Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 082/100] fs: ocfs2: fix a possible null-pointer dereference in ocfs2_write_end_nolock() Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 083/100] fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 084/100] arm64: armv8_deprecated: Checking return value for memory allocation Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 085/100] x86/cpu: Add Comet Lake to the Intel CPU models header Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 086/100] sched/vtime: Fix guest/system mis-accounting on task switch Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 087/100] perf/x86/amd: Change/fix NMI latency mitigation to use a timestamp Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 088/100] drm/amdgpu: fix memory leak Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 089/100] iio: adc: hx711: fix bug in sampling of data Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 090/100] iio: imu: adis16400: release allocated memory on failure Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 091/100] iio: adc: ad799x: fix probe error handling Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 092/100] iio: light: opt3001: fix mutex unlock race Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 093/100] MIPS: include: Mark __xchg as __always_inline Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 094/100] MIPS: fw: sni: Fix out of bounds init of o32 stack Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 095/100] USB: usb-skeleton: fix use-after-free after driver unbind Sasha Levin
2019-10-18 22:22   ` Greg Kroah-Hartman
2019-10-29  9:04     ` Sasha Levin
2019-10-29  9:43       ` Greg Kroah-Hartman
2019-10-29 10:04         ` Johan Hovold
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 096/100] virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 097/100] nbd: fix possible sysfs duplicate warning Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 098/100] NFSv4: Fix leak of clp->cl_acceptor string Sasha Levin
2019-10-18 22:05 ` [PATCH AUTOSEL 4.19 099/100] s390/uaccess: avoid (false positive) compiler warnings Sasha Levin
2019-10-18 22:05 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191018220525.9042-100-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).