All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Rustam Kovhaev <rkovhaev@gmail.com>
Cc: djwong@kernel.org, linux-xfs@vger.kernel.org, cl@linux.com,
	penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com,
	akpm@linux-foundation.org, vbabka@suse.cz,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH] xfs: use kmem_cache_free() for kmem_cache objects
Date: Thu, 30 Sep 2021 14:42:02 +1000	[thread overview]
Message-ID: <20210930044202.GP2361455@dread.disaster.area> (raw)
In-Reply-To: <20210929212347.1139666-1-rkovhaev@gmail.com>

On Wed, Sep 29, 2021 at 02:23:47PM -0700, Rustam Kovhaev wrote:
> For kmalloc() allocations SLOB prepends the blocks with a 4-byte header,
> and it puts the size of the allocated blocks in that header.
> Blocks allocated with kmem_cache_alloc() allocations do not have that
> header.
> 
> SLOB explodes when you allocate memory with kmem_cache_alloc() and then
> try to free it with kfree() instead of kmem_cache_free().
> SLOB will assume that there is a header when there is none, read some
> garbage to size variable and corrupt the adjacent objects, which
> eventually leads to hang or panic.
> 
> Let's make XFS work with SLOB by using proper free function.
> 
> Fixes: 9749fee83f38 ("xfs: enable the xfs_defer mechanism to process extents to free")
> Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>

IOWs, XFS has been broken on SLOB for over 5 years and nobody
anywhere has noticed.

And we've just had a discussion where the very best solution was to
use kfree() on kmem_cache_alloc() objects so we didn't ahve to spend
CPU doing global type table lookups or use an extra 8 bytes of
memory per object to track the slab cache just so we could call
kmem_cache_free() with the correct slab cache.

But, of course, SLOB doesn't allow this and I was really tempted to
solve that by adding a Kconfig "depends on SLAB|SLUB" option so that
we don't have to care about SLOB not working.

However, as it turns out that XFS on SLOB has already been broken
for so long, maybe we should just not care about SLOB code and
seriously consider just adding a specific dependency on SLAB|SLUB...

Thoughts?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2021-09-30  4:42 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 21:23 [PATCH] xfs: use kmem_cache_free() for kmem_cache objects Rustam Kovhaev
2021-09-30  4:42 ` Dave Chinner [this message]
2021-09-30  8:13   ` Vlastimil Babka
2021-09-30 18:48     ` Rustam Kovhaev
2021-09-30 21:10       ` Vlastimil Babka
2021-10-01  0:32         ` Rustam Kovhaev
2021-10-04  1:07           ` David Rientjes
2021-10-04  1:07             ` David Rientjes
2021-10-12 20:43             ` Darrick J. Wong
2021-10-12 20:43               ` Darrick J. Wong
2021-10-12 21:32                 ` Vlastimil Babka
2021-10-12 23:22                   ` Darrick J. Wong
2021-10-13  7:38                     ` Vlastimil Babka
2021-10-13 16:56                       ` Rustam Kovhaev
2021-10-15  0:57                         ` Darrick J. Wong
2021-10-18  3:38                           ` [PATCH] slob: add size header to all allocations Rustam Kovhaev
2021-10-18  9:22                             ` Vlastimil Babka
2021-10-19  1:22                               ` Rustam Kovhaev
2021-10-20 11:46                             ` Hyeonggon Yoo
2021-10-21 17:36                               ` Vlastimil Babka
2021-10-23  6:41                                 ` [PATCH v2] " Rustam Kovhaev
2021-10-25  9:36                                   ` Vlastimil Babka
2021-10-25 21:49                                     ` Rustam Kovhaev
2021-10-29  3:05                                     ` [PATCH v3] " Rustam Kovhaev
2021-11-16 11:26                                       ` Vlastimil Babka
2021-11-16 23:19                                         ` Rustam Kovhaev
2021-11-22  1:30                                         ` [PATCH v4] " Rustam Kovhaev
2021-11-22  9:22                                           ` Christoph Lameter
2021-11-22  9:40                                             ` Vlastimil Babka
2021-11-22 10:36                                               ` Christoph Lameter
2021-11-22 10:45                                                 ` Vlastimil Babka
2021-11-22 11:40                                                   ` Christoph Lameter
2021-11-22 11:49                                                     ` Vlastimil Babka
2021-11-23 10:18                                                   ` David Laight
2021-11-30  7:00                                                     ` Rustam Kovhaev
2021-11-30  9:23                                                       ` David Laight
2021-11-30  9:41                                                       ` Christoph Lameter
2021-11-30 14:55                                                     ` Vlastimil Babka
2021-11-30 15:21                                                       ` David Laight
2021-11-30 15:39                                                         ` Vlastimil Babka
2021-11-30 15:26                                                       ` Christoph Lameter
2021-10-24 10:43                                 ` [PATCH] " Hyeonggon Yoo
2021-10-25  8:19                                   ` Vlastimil Babka

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=20210930044202.GP2361455@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=djwong@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=rkovhaev@gmail.com \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.