linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 (VMware)" <rostedt@goodmis.org>
Subject: [PATCH 3.18 15/32] ring-buffer: Mask out the info bits when returning buffer page length
Date: Mon,  1 Jan 2018 15:22:22 +0100	[thread overview]
Message-ID: <20180101140015.924350345@linuxfoundation.org> (raw)
In-Reply-To: <20180101140012.582300879@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

commit 45d8b80c2ac5d21cd1e2954431fb676bc2b1e099 upstream.

Two info bits were added to the "commit" part of the ring buffer data page
when returned to be consumed. This was to inform the user space readers that
events have been missed, and that the count may be stored at the end of the
page.

What wasn't handled, was the splice code that actually called a function to
return the length of the data in order to zero out the rest of the page
before sending it up to user space. These data bits were returned with the
length making the value negative, and that negative value was not checked.
It was compared to PAGE_SIZE, and only used if the size was less than
PAGE_SIZE. Luckily PAGE_SIZE is unsigned long which made the compare an
unsigned compare, meaning the negative size value did not end up causing a
large portion of memory to be randomly zeroed out.

Fixes: 66a8cb95ed040 ("ring-buffer: Add place holder recording of dropped events")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/trace/ring_buffer.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data
 /* Missed count stored at end */
 #define RB_MISSED_STORED	(1 << 30)
 
+#define RB_MISSED_FLAGS		(RB_MISSED_EVENTS|RB_MISSED_STORED)
+
 struct buffer_data_page {
 	u64		 time_stamp;	/* page time stamp */
 	local_t		 commit;	/* write committed index */
@@ -387,7 +389,9 @@ static void rb_init_page(struct buffer_d
  */
 size_t ring_buffer_page_len(void *page)
 {
-	return local_read(&((struct buffer_data_page *)page)->commit)
+	struct buffer_data_page *bpage = page;
+
+	return (local_read(&bpage->commit) & ~RB_MISSED_FLAGS)
 		+ BUF_PAGE_HDR_SIZE;
 }
 

  parent reply	other threads:[~2018-01-01 14:23 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01 14:22 [PATCH 3.18 00/32] 3.18.91-stable review Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 01/32] ACPI: APEI / ERST: Fix missing error handling in erst_reader() Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 02/32] crypto: mcryptd - protect the per-CPU queue with a lock Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 03/32] mfd: twl4030-audio: Fix sibling-node lookup Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 04/32] mfd: twl6040: Fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 05/32] ALSA: rawmidi: Avoid racy info ioctl via ctl device Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 06/32] ALSA: usb-audio: Fix the missing ctl name suffix at parsing SU Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 07/32] PCI / PM: Force devices to D0 in pci_pm_thaw_noirq() Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 08/32] parisc: Hide Diva-built-in serial aux and graphics card Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 09/32] KVM: X86: Fix load RFLAGS w/o the fixed bit Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 10/32] powerpc/perf: Dereference BHRB entries safely Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 11/32] net: mvneta: clear interface link status on port disable Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 12/32] tracing: Remove extra zeroing out of the ring buffer page Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 13/32] tracing: Fix possible double free on failure of allocating trace buffer Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 14/32] tracing: Fix crash when it fails to alloc ring buffer Greg Kroah-Hartman
2018-01-01 14:22 ` Greg Kroah-Hartman [this message]
2018-01-01 14:22 ` [PATCH 3.18 16/32] ASoC: twl4030: fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 17/32] kbuild: add -fno-stack-check to kernel build options Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 18/32] ipv4: igmp: guard against silly MTU values Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 19/32] ipv6: mcast: better catch silly mtu values Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 20/32] net: igmp: Use correct source address on IGMPv3 reports Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 21/32] netlink: Add netns check on taps Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 22/32] net: qmi_wwan: add Sierra EM7565 1199:9091 Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 23/32] tcp md5sig: Use skbs saddr when replying to an incoming segment Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 24/32] tg3: Fix rx hang on MTU change with 5717/5719 Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 25/32] net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 26/32] sctp: Replace use of sockets_allocated with specified macro Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 27/32] net: ipv4: fix for a race condition in raw_sendmsg Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 28/32] USB: serial: option: add support for Telit ME910 PID 0x1101 Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 29/32] usb: Add device quirk for Logitech HD Pro Webcam C925e Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 30/32] usb: add RESET_RESUME for ELSA MicroLink 56K Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 31/32] usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201 Greg Kroah-Hartman
2018-01-01 14:22 ` [PATCH 3.18 32/32] n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD) Greg Kroah-Hartman
2018-01-01 18:07 ` [PATCH 3.18 00/32] 3.18.91-stable review kernelci.org bot
2018-01-02 16:46 ` Guenter Roeck
2018-01-02 22:22 ` 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=20180101140015.924350345@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).