From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 3.14 072/114] ring-buffer: Up rb_iter_peek() loop count to 3
Date: Mon, 15 Sep 2014 12:26:12 -0700 [thread overview]
Message-ID: <20140915192643.695147330@linuxfoundation.org> (raw)
In-Reply-To: <20140915192641.428509513@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
commit 021de3d904b88b1771a3a2cfc5b75023c391e646 upstream.
After writting a test to try to trigger the bug that caused the
ring buffer iterator to become corrupted, I hit another bug:
WARNING: CPU: 1 PID: 5281 at kernel/trace/ring_buffer.c:3766 rb_iter_peek+0x113/0x238()
Modules linked in: ipt_MASQUERADE sunrpc [...]
CPU: 1 PID: 5281 Comm: grep Tainted: G W 3.16.0-rc3-test+ #143
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS SDBLI944.86P 05/08/2007
0000000000000000 ffffffff81809a80 ffffffff81503fb0 0000000000000000
ffffffff81040ca1 ffff8800796d6010 ffffffff810c138d ffff8800796d6010
ffff880077438c80 ffff8800796d6010 ffff88007abbe600 0000000000000003
Call Trace:
[<ffffffff81503fb0>] ? dump_stack+0x4a/0x75
[<ffffffff81040ca1>] ? warn_slowpath_common+0x7e/0x97
[<ffffffff810c138d>] ? rb_iter_peek+0x113/0x238
[<ffffffff810c138d>] ? rb_iter_peek+0x113/0x238
[<ffffffff810c14df>] ? ring_buffer_iter_peek+0x2d/0x5c
[<ffffffff810c6f73>] ? tracing_iter_reset+0x6e/0x96
[<ffffffff810c74a3>] ? s_start+0xd7/0x17b
[<ffffffff8112b13e>] ? kmem_cache_alloc_trace+0xda/0xea
[<ffffffff8114cf94>] ? seq_read+0x148/0x361
[<ffffffff81132d98>] ? vfs_read+0x93/0xf1
[<ffffffff81132f1b>] ? SyS_read+0x60/0x8e
[<ffffffff8150bf9f>] ? tracesys+0xdd/0xe2
Debugging this bug, which triggers when the rb_iter_peek() loops too
many times (more than 2 times), I discovered there's a case that can
cause that function to legitimately loop 3 times!
rb_iter_peek() is different than rb_buffer_peek() as the rb_buffer_peek()
only deals with the reader page (it's for consuming reads). The
rb_iter_peek() is for traversing the buffer without consuming it, and as
such, it can loop for one more reason. That is, if we hit the end of
the reader page or any page, it will go to the next page and try again.
That is, we have this:
1. iter->head > iter->head_page->page->commit
(rb_inc_iter() which moves the iter to the next page)
try again
2. event = rb_iter_head_event()
event->type_len == RINGBUF_TYPE_TIME_EXTEND
rb_advance_iter()
try again
3. read the event.
But we never get to 3, because the count is greater than 2 and we
cause the WARNING and return NULL.
Up the counter to 3.
Fixes: 69d1b839f7ee "ring-buffer: Bind time extend and data events together"
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/ring_buffer.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1981,7 +1981,7 @@ rb_add_time_stamp(struct ring_buffer_eve
/**
* rb_update_event - update event type and data
- * @event: the even to update
+ * @event: the event to update
* @type: the type of event
* @length: the size of the event field in the ring buffer
*
@@ -3756,12 +3756,14 @@ rb_iter_peek(struct ring_buffer_iter *it
return NULL;
/*
- * We repeat when a time extend is encountered.
- * Since the time extend is always attached to a data event,
- * we should never loop more than once.
- * (We never hit the following condition more than twice).
+ * We repeat when a time extend is encountered or we hit
+ * the end of the page. Since the time extend is always attached
+ * to a data event, we should never loop more than three times.
+ * Once for going to next page, once on time extend, and
+ * finally once to get the event.
+ * (We never hit the following condition more than thrice).
*/
- if (RB_WARN_ON(cpu_buffer, ++nr_loops > 2))
+ if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3))
return NULL;
if (rb_per_cpu_empty(cpu_buffer))
next prev parent reply other threads:[~2014-09-15 19:26 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 19:25 [PATCH 3.14 000/114] 3.14.19-stable review Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 001/114] media: xc5000: Fix get_frequency() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 002/114] media: xc4000: " Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 003/114] media: au0828: Only alt setting logic when needed Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 005/114] media: mt9v032: fix hblank calculation Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 006/114] media: v4l: vsp1: Remove the unneeded vsp1_video_buffer video field Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 007/114] media: sms: Remove CONFIG_ prefix from Kconfig symbols Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 008/114] iommu/amd: Fix cleanup_domain for mass device removal Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 009/114] spi: orion: fix incorrect handling of cell-index DT property Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 010/114] spi: omap2-mcspi: Configure hardware when slave driver changes mode Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 011/114] s390/locking: Reenable optimistic spinning Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 013/114] firmware: Do not use WARN_ON(!spin_is_locked()) Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 014/114] tpm: missing tpm_chip_put in tpm_get_random() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 015/114] tpm: Provide a generic means to override the chip returned timeouts Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 016/114] tpm: Properly clean sysfs entries in error path Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 017/114] CAPABILITIES: remove undefined caps from all processes Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 018/114] kernel/smp.c:on_each_cpu_cond(): fix warning in fallback path Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 019/114] mfd: omap-usb-host: Fix improper mask use Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 020/114] regulator: arizona-ldo1: remove bypass functionality Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 021/114] powerpc/mm/numa: Fix break placement Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 022/114] powerpc/mm: Use read barrier when creating real_pte Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 023/114] powerpc/pseries: Failure on removing device node Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 024/114] powerpc/pseries: Avoid deadlock on removing ddw Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 025/114] powerpc/thp: Add write barrier after updating the valid bit Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 026/114] powerpc/thp: Dont recompute vsid and ssize in loop on invalidate Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 027/114] powerpc/thp: Invalidate old 64K based hash page mapping before insert of 4k pte Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 028/114] powerpc/thp: Handle combo pages in invalidate Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 029/114] powerpc/thp: Invalidate with vpn in loop Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 030/114] powerpc/thp: Use ACCESS_ONCE when loading pmdp Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 031/114] Drivers: scsi: storvsc: Implement a eh_timed_out handler Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 032/114] Drivers: scsi: storvsc: Filter commands based on the storage protocol version Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 033/114] Drivers: scsi: storvsc: Change the limits to reflect the values on the host Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 034/114] Drivers: scsi: storvsc: Set cmd_per_lun to reflect value supported by the Host Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 035/114] Drivers: scsi: storvsc: Fix a bug in handling VMBUS protocol version Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 036/114] drivers: scsi: storvsc: Set srb_flags in all cases Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 037/114] drivers: scsi: storvsc: Correctly handle TEST_UNIT_READY failure Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 038/114] scsi_scan: Restrict sequential scan to 256 LUNs Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 039/114] scsi: add a blacklist flag which enables VPD page inquiries Greg Kroah-Hartman
2014-09-15 21:23 ` Sitsofe Wheeler
2014-09-15 19:25 ` [PATCH 3.14 040/114] scsi: do not issue SCSI RSOC command to Promise Vtrak E610f Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 041/114] scsi_transport_srp: Fix fast_io_fail_tmo=dev_loss_tmo=off behavior Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 042/114] MIPS: GIC: Prevent array overrun Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 043/114] MIPS: O32/32-bit: Fix bug which can cause incorrect system call restarts Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 044/114] MIPS: ptrace: Test correct tasks flags in task_user_regset_view() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 045/114] MIPS: ptrace: Change GP regset to use correct core dump register layout Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 046/114] MIPS: Prevent user from setting FCSR cause bits Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 047/114] MIPS: tlbex: Fix a missing statement for HUGETLB Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 048/114] MIPS: Remove BUG_ON(!is_fpu_owner()) in do_ade() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 049/114] MIPS: asm/reg.h: Make 32- and 64-bit definitions available at the same time Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 050/114] MIPS: OCTEON: make get_system_type() thread-safe Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 051/114] ASoC: wm8994: Prevent double lock of accdet_lock mutex on wm1811 Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 052/114] ASoC: pcm: fix dpcm_path_put in dpcm runtime update Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 053/114] ASoC: wm_adsp: Add missing MODULE_LICENSE Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 054/114] ASoC: blackfin: use samples to set silence Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 055/114] ASoC: samsung: Correct I2S DAI suspend/resume ops Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 056/114] ASoC: adau1701: fix adau1701_reg_read() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 057/114] ASoC: max98090: Fix missing free_irq Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 058/114] ASoC: pxa: pxa-ssp: small leak in probe() Greg Kroah-Hartman
2014-09-15 19:25 ` [PATCH 3.14 059/114] ASoC: pxa-ssp: drop SNDRV_PCM_FMTBIT_S24_LE Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 061/114] ASoC: rt5640: Do not allow regmap to use bulk read-write operations Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 062/114] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 063/114] bq2415x_charger: Fix Atomic Sleep Bug Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 064/114] ACPICA: Utilities: Fix memory leak in acpi_ut_copy_iobject_to_iobject Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 065/114] ACPI / hotplug: Check scan handlers in acpi_scan_hot_remove() Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 066/114] spi/pxa2xx: Add ACPI ID for Intel Braswell Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 067/114] ACPI: Run fixed event device notifications in process context Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 068/114] ACPI / scan: not cache _SUN value in struct acpi_device_pnp Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 069/114] ACPI / cpuidle: fix deadlock between cpuidle_lock and cpu_hotplug.lock Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 070/114] xen/events/fifo: reset control block and local HEADs on resume Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 071/114] ring-buffer: Always reset iterator to reader page Greg Kroah-Hartman
2014-09-15 19:26 ` Greg Kroah-Hartman [this message]
2014-09-15 19:26 ` [PATCH 3.14 073/114] mnt: Only change user settable mount flags in remount Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 074/114] mnt: Move the test for MNT_LOCK_READONLY from change_mount_flags into do_remount Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 075/114] mnt: Correct permission checks in do_remount Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 076/114] mnt: Change the default remount atime from relatime to the existing value Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 077/114] mnt: Add tests for unprivileged remount cases that have found to be faulty Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 078/114] get rid of propagate_umount() mistakenly treating slaves as busy Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 079/114] fix EBUSY on umount() from MNT_SHRINKABLE Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 080/114] Bluetooth: btmrvl: wait for HOST_SLEEP_ENABLE event in suspend Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 081/114] Bluetooth: never linger on process exit Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 082/114] Bluetooth: Avoid use of session socket after the session gets freed Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 083/114] fix copy_tree() regression Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 084/114] md/raid1,raid10: always abort recover on write error Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 085/114] md/raid6: avoid data corruption during recovery of double-degraded RAID6 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 086/114] md/raid10: fix memory leak when reshaping a RAID10 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 087/114] md/raid10: Fix memory leak when raid10 reshape completes Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 088/114] RDMA/iwcm: Use a default listen backlog if needed Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 089/114] RDMA/uapi: Include socket.h in rdma_user_cm.h Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 090/114] xfs: ensure verifiers are attached to recovered buffers Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 091/114] xfs: quotacheck leaves dquot buffers without verifiers Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 092/114] xfs: dont dirty buffers beyond EOF Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 093/114] xfs: dont zero partial page cache pages during O_DIRECT writes Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 094/114] xfs: dont zero partial page cache pages during O_DIRECT write Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 095/114] libceph: set last_piece in ceph_msg_data_pages_cursor_init() correctly Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 096/114] libceph: add process_one_ticket() helper Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 097/114] libceph: do not hard code max auth ticket len Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 098/114] CIFS: Fix STATUS_CANNOT_DELETE error mapping for SMB2 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 099/114] CIFS: Fix async reading on reconnects Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 100/114] CIFS: Possible null ptr deref in SMB2_tcon Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 101/114] CIFS: Fix wrong directory attributes after rename Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 102/114] vfs: add d_is_dir() Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 103/114] CIFS: Fix directory rename error Greg Kroah-Hartman
2014-09-16 5:17 ` Pavel Shilovsky
2014-09-16 14:40 ` Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 104/114] CIFS: Fix wrong filename length for SMB2 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 105/114] CIFS: Fix wrong restart readdir for SMB1 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 106/114] mtd/ftl: fix the double free of the buffers allocated in build_maps() Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 107/114] mtd: nand: omap: Fix 1-bit Hamming code scheme, omap_calculate_ecc() Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 108/114] blkcg: dont call into policy draining if root_blkg is already gone Greg Kroah-Hartman
2014-09-17 11:16 ` Ben Hutchings
2014-09-17 16:22 ` Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 109/114] IB/srp: Fix deadlock between host removal and multipathd Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 110/114] drm/nouveau: Bump version from 1.1.1 to 1.1.2 Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 111/114] vfs: fix bad hashing of dentries Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 112/114] libceph: gracefully handle large reply messages from the mon Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 113/114] KEYS: Fix use-after-free in assoc_array_gc() Greg Kroah-Hartman
2014-09-15 19:26 ` [PATCH 3.14 114/114] KEYS: Fix termination condition in assoc array garbage collection Greg Kroah-Hartman
2014-09-15 21:36 ` [PATCH 3.14 000/114] 3.14.19-stable review Holger Hoffstätte
2014-09-16 1:55 ` Guenter Roeck
2014-09-16 18:41 ` Shuah Khan
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=20140915192643.695147330@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--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).