From: "Paul E. McKenney" <paulmck@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
tglx@linutronix.de, bigeasy@linutronix.de, frederic@kernel.org
Subject: Re: [PATCH smp 2/2] kernel/smp: Provide CSD lock timeout diagnostics
Date: Fri, 24 Jul 2020 11:19:13 -0700 [thread overview]
Message-ID: <20200724181913.GA25015@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20200723225057.GB9247@paulmck-ThinkPad-P72>
On Thu, Jul 23, 2020 at 03:50:57PM -0700, Paul E. McKenney wrote:
> On Thu, Jul 23, 2020 at 03:55:56PM +0200, Peter Zijlstra wrote:
[ . . . ]
> > > + ts2 = sched_clock();
> > > + ts_delta = ts2 - *ts1;
> > > + if (likely(ts_delta <= CSD_LOCK_TIMEOUT)) {
> > > + cpu_relax();
> > > + return false;
> > > + }
> > > +
> > > + firsttime = !*bug_id;
> > > + if (firsttime)
> > > + *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))
> > > + cpu_cur_csd = READ_ONCE(per_cpu(cur_csd, 0));
> > > + else
> > > + cpu_cur_csd = READ_ONCE(per_cpu(cur_csd, cpu));
> >
> > This is a potential user-after-free, func() may free the csd when async.
> > Although I don't believe anybody does so.
>
> Huh. This will require some thought. The one that the CPU is currently
> executing is available, so this is a problem only when they stack up.
Bah. This is exactly why the cur_csd_func and cur_csd_info per-CPU
variables exist, and so I just need to actually use them. :-/
Thanx, Paul
next prev parent reply other threads:[~2020-07-24 18:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 23:54 [PATCH smp 0/2] Provide CSD lock timeout diagnostics Paul E. McKenney
2020-07-09 23:55 ` [PATCH smp 1/2] smp: Add source and destination CPUs to __call_single_data paulmck
2020-07-09 23:55 ` [PATCH smp 2/2] kernel/smp: Provide CSD lock timeout diagnostics paulmck
2020-07-10 10:32 ` Peter Zijlstra
2020-07-10 21:28 ` Paul E. McKenney
2020-07-10 22:58 ` Paul E. McKenney
2020-07-23 13:55 ` Peter Zijlstra
2020-07-23 22:50 ` Paul E. McKenney
2020-07-24 18:19 ` Paul E. McKenney [this message]
2020-07-27 23:53 ` [PATCH smp 0/2] " Paul E. McKenney
2020-07-27 23:55 ` [PATCH smp v2 1/3] smp: Add source and destination CPUs to __call_single_data paulmck
2020-07-27 23:55 ` [PATCH smp v2 2/3] kernel/smp: Provide CSD lock timeout diagnostics paulmck
2020-07-27 23:55 ` [PATCH smp v2 3/3] smp: Make symbol 'csd_bug_count' static paulmck
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=20200724181913.GA25015@paulmck-ThinkPad-P72 \
--to=paulmck@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--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