Kernel-Janitors Archive on
 help / color / Atom feed
From: Dan Carpenter <>
To: Steven Rostedt <>
Cc: Ingo Molnar <>,,
Subject: [PATCH] tracing: Fix an off by one in __next()
Date: Wed, 20 Jun 2018 11:08:00 +0000
Message-ID: <20180620110758.crunhd5bfep7zuiz@kili.mountain> (raw)

The > should be >= to prevent an off by one bug.

From reviewing the code, it seems possible for
stack_trace_max.nr_entries to be set to .max_entries and in that case we
would be reading one element beyond the end of the stack_dump_trace[]
array.  If it's not set to .max_entries then the bug doesn't affect

Signed-off-by: Dan Carpenter <>

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 4237eba4ef20..6e3edd745c68 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -286,7 +286,7 @@ __next(struct seq_file *m, loff_t *pos)
 	long n = *pos - 1;
-	if (n > stack_trace_max.nr_entries || stack_dump_trace[n] = ULONG_MAX)
+	if (n >= stack_trace_max.nr_entries || stack_dump_trace[n] = ULONG_MAX)
 		return NULL;
 	m->private = (void *)n;

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 11:08 Dan Carpenter [this message]
2018-11-27 18:44 ` Steven Rostedt
2018-11-27 20:04   ` Dan Carpenter

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:

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

  git send-email \
    --in-reply-to=20180620110758.crunhd5bfep7zuiz@kili.mountain \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Kernel-Janitors Archive on

Archives are clonable:
	git clone --mirror kernel-janitors/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernel-janitors kernel-janitors/ \
	public-inbox-index kernel-janitors

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone