From: Steven Rostedt <srostedt@redhat.com>
To: David Sharp <dhsharp@google.com>
Cc: linux-kernel@vger.kernel.org, mrubin@google.com,
jiayingz@google.com, Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] ring_buffer: wrap a list.next reference with rb_list_head()
Date: Wed, 06 Jan 2010 20:33:10 -0500 [thread overview]
Message-ID: <1262827990.2737.31.camel@localhost.localdomain> (raw)
In-Reply-To: <1262826727-9090-1-git-send-email-dhsharp@google.com>
Just a FYI, it's best to send me email to my rostedt@goodmis.org
account. I don't always read my messages on my redhat account.
On Wed, 2010-01-06 at 17:12 -0800, David Sharp wrote:
> This reference at the end of rb_get_reader_page() was causing off-by-one
> writes to the prev pointer of the page after the reader page when that
> page is the head page, and therefore the reader page has the RB_PAGE_HEAD
> flag in its list.next pointer. This eventually results in a GPF in a
> subsequent call to rb_set_head_page() (usually from rb_get_reader_page())
> when that prev pointer is dereferenced. The dereferenced register would
> characteristically have an address that appears shifted left by one byte
> (eg, ffxxxxxxxxxxxxyy instead of ffffxxxxxxxxxxxx) due to being written at
> an address one byte too high.
>
> Signed-off-by: David Sharp <dhsharp@google.com>
> ---
> kernel/trace/ring_buffer.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 2326b04..d5b7308 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -2906,7 +2906,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
> *
> * Now make the new head point back to the reader page.
> */
> - reader->list.next->prev = &cpu_buffer->reader_page->list;
> + rb_list_head(reader->list.next)->prev = &cpu_buffer->reader_page->list;
> rb_inc_page(cpu_buffer, &cpu_buffer->head_page);
Wow, this is a nasty little race. The writer had to move the header page
forward by one between the time we swapped to now, which is the command
just outside the diff.
>
> /* Finally update the reader page to the new head */
We probably should add a change at the top too, just to be safe.
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2326b04..edefe3b 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2869,7 +2869,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
* Splice the empty reader page into the list around the head.
*/
reader = rb_set_head_page(cpu_buffer);
- cpu_buffer->reader_page->list.next = reader->list.next;
+ cpu_buffer->reader_page->list.next = rb_list_head(reader->list.next);
cpu_buffer->reader_page->list.prev = reader->list.prev;
/*
Thanks, I'll apply this.
-- Steve
next prev parent reply other threads:[~2010-01-07 1:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-07 1:12 [PATCH] ring_buffer: wrap a list.next reference with rb_list_head() David Sharp
2010-01-07 1:33 ` Steven Rostedt [this message]
2010-01-08 9:33 ` [tip:tracing/urgent] ring-buffer: Wrap " tip-bot for David Sharp
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=1262827990.2737.31.camel@localhost.localdomain \
--to=srostedt@redhat.com \
--cc=dhsharp@google.com \
--cc=jiayingz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mrubin@google.com \
--cc=rostedt@goodmis.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