From: Matthew Wilcox <willy@infradead.org>
To: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: linux-mm@kvack.org, Matthew Wilcox <mawilcox@microsoft.com>,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH 3/4] mm: Add free()
Date: Fri, 23 Mar 2018 09:15:12 -0700 [thread overview]
Message-ID: <20180323161512.GD5624@bombadil.infradead.org> (raw)
In-Reply-To: <20180323151421.GC5624@bombadil.infradead.org>
On Fri, Mar 23, 2018 at 08:14:21AM -0700, Matthew Wilcox wrote:
> > One more thing, there is
> > some kasan checks on the main way of kfree(), and there is no guarantee they
> > reflected in kmem_cache_free() identical.
>
> Which function are you talking about here?
>
> slub calls slab_free() for both kfree() and kmem_cache_free().
> slab calls __cache_free() for both kfree() and kmem_cache_free().
> Each of them do their kasan handling in the called function.
... except for where slub can free large objects without calling slab_free():
if (unlikely(!PageSlab(page))) {
BUG_ON(!PageCompound(page));
kfree_hook(object);
__free_pages(page, compound_order(page));
return;
}
slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_);
If you call kmalloc(16384, GFP_KERNEL), slub will hand back an order-2
page without setting PageSlab on it. So if that gets passed to free(),
it'll call __put_page() which calls free_compound_page() which calls
__free_pages_ok(). Looks like we want another compound_dtor to be sure
we call the kfree hook.
next prev parent reply other threads:[~2018-03-23 16:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-22 19:58 [PATCH 0/4] Add free() function Matthew Wilcox
2018-03-22 19:58 ` [PATCH 1/4] decompression: Rename malloc and free Matthew Wilcox
2018-03-22 19:58 ` [PATCH 2/4] Rename 'free' functions Matthew Wilcox
2018-03-22 19:58 ` [PATCH 3/4] mm: Add free() Matthew Wilcox
2018-03-23 8:04 ` Rasmus Villemoes
2018-03-23 14:34 ` Matthew Wilcox
2018-04-03 8:50 ` Pavel Machek
2018-04-03 11:41 ` Matthew Wilcox
2018-03-23 13:33 ` Kirill Tkhai
2018-03-23 15:14 ` Matthew Wilcox
2018-03-23 15:49 ` Kirill Tkhai
2018-03-23 16:15 ` Matthew Wilcox [this message]
2018-03-25 23:56 ` Matthew Wilcox
2018-03-24 7:38 ` kbuild test robot
2018-03-22 19:58 ` [PATCH 4/4] rcu: Switch to using free() instead of kfree() Matthew Wilcox
2018-03-24 7:07 ` kbuild test robot
2018-03-24 8:20 ` kbuild test robot
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=20180323161512.GD5624@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.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;
as well as URLs for NNTP newsgroup(s).