kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Kaitao Cheng <pilgrimtao@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] kernel/smp: Fix an off by one in csd_lock_wait_toolong()
Date: Thu, 09 Jul 2020 10:48:18 +0000	[thread overview]
Message-ID: <20200709104818.GC20875@mwanda> (raw)

The __per_cpu_offset[] array has "nr_cpu_ids" elements so change the >
>= to prevent a read one element beyond the end of the array.

Fixes: 0504bc41a62c ("kernel/smp: Provide CSD lock timeout diagnostics")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index 78b602cae6c2..f49966713ac3 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -171,7 +171,7 @@ static __always_inline bool csd_lock_wait_toolong(call_single_data_t *csd, u64 t
 		*bug_id = atomic_inc_return(&csd_bug_count);
 	cpu = csd_lock_wait_getcpu(csd);
 	smp_mb(); // No stale cur_csd values!
-	if (WARN_ONCE(cpu < 0 || cpu > nr_cpu_ids, "%s: cpu = %d\n", __func__, cpu))
+	if (WARN_ONCE(cpu < 0 || cpu >= nr_cpu_ids, "%s: cpu = %d\n", __func__, cpu))
 		cpu_cur_csd = READ_ONCE(per_cpu(cur_csd, 0));
 	else
 		cpu_cur_csd = READ_ONCE(per_cpu(cur_csd, cpu));
-- 
2.27.0

             reply	other threads:[~2020-07-09 10:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 10:48 Dan Carpenter [this message]
2020-07-09 10:59 ` [PATCH] kernel/smp: Fix an off by one in csd_lock_wait_toolong() Peter Zijlstra
2020-07-09 11:49   ` Sebastian Andrzej Siewior
2020-07-09 14:36     ` Paul E. McKenney
2020-07-09 14:32   ` Paul E. McKenney
2020-07-09 16:59 ` Paul E. McKenney

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=20200709104818.GC20875@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=bigeasy@linutronix.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pilgrimtao@gmail.com \
    --cc=tglx@linutronix.de \
    /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).