From: Pekka Enberg <penberg@kernel.org>
To: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Christoph Lameter <cl@linux.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Matt Mackall <mpm@selenic.com>
Subject: Re: Memory allocator semantics
Date: Tue, 11 Feb 2014 15:20:01 +0200 [thread overview]
Message-ID: <CAOJsxLET90NRnEKeFjWKWTgZm+otSSwfCkhFga2hGjhV12nz9Q@mail.gmail.com> (raw)
In-Reply-To: <20140211121426.GQ4250@linux.vnet.ibm.com>
On Tue, Feb 11, 2014 at 2:14 PM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
> In contrast, from kfree() to a kmalloc() returning some of the kfree()ed
> memory, I believe the kfree()/kmalloc() implementation must do any needed
> synchronization and ordering. But that is a different set of examples,
> for example, this one:
>
> CPU 0 CPU 1
> p->a = 42; q = kmalloc(...); /* returning p */
> kfree(p); q->a = 5;
> BUG_ON(q->a != 5);
>
> Unlike the situation with (A), (B), and (C), in this case I believe
> that it is kfree()'s and kmalloc()'s responsibility to ensure that
> the BUG_ON() never triggers.
>
> Make sense?
I'm not sure...
It's the caller's responsibility not to touch "p" after it's handed over to
kfree() - otherwise that's a "use-after-free" error. If there's some reordering
going on here, I'm tempted to blame the caller for lack of locking.
Pekka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-02-11 13:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-02 20:33 Paul E. McKenney
2014-01-03 3:39 ` Josh Triplett
2014-01-03 5:14 ` Paul E. McKenney
2014-01-03 5:47 ` Josh Triplett
2014-01-03 7:57 ` Paul E. McKenney
2014-01-03 8:42 ` Josh Triplett
2014-02-08 10:27 ` Pekka Enberg
2014-02-09 2:00 ` Paul E. McKenney
2014-02-11 8:50 ` Pekka Enberg
2014-02-11 12:09 ` Paul E. McKenney
2014-02-11 18:43 ` Christoph Lameter
2014-02-14 17:30 ` Paul E. McKenney
2014-02-10 19:07 ` Christoph Lameter
2014-02-11 12:14 ` Paul E. McKenney
2014-02-11 13:20 ` Pekka Enberg [this message]
2014-02-11 15:01 ` 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=CAOJsxLET90NRnEKeFjWKWTgZm+otSSwfCkhFga2hGjhV12nz9Q@mail.gmail.com \
--to=penberg@kernel.org \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=paulmck@linux.vnet.ibm.com \
/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