lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221024074232.151383-1-liushixin2@huawei.com>
Date:   Mon, 24 Oct 2022 15:42:28 +0800
From:   Liu Shixin <liushixin2@...wei.com>
To:     Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        "David Rientjes" <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        "Andrew Morton" <akpm@...ux-foundation.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        "Roman Gushchin" <roman.gushchin@...ux.dev>,
        Hyeonggon Yoo <42.hyeyoo@...il.com>
CC:     <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
        Liu Shixin <liushixin2@...wei.com>
Subject: [PATCH 0/4] Refactor __kmem_cache_create() and fix memory leak

I found a memory leak of kobj->name in sysfs_slab_add() which is introduced
by 80da026a8e5d ("mm/slub: fix slab double-free in case of duplicate sysfs filename").
Following the rules stated in the comment for kobject_init_and_add():

 If this function returns an error, kobject_put() must be called to
 properly clean up the memory associated with the object.

We should use kobject_put() to free kobject.

But we can't simply add kobject_put() since it will free kmem_cache too.
If we use kobject_put(), we need to skip other release functions.

In this series, We refactor the code to separate sysfs_slab_add() and
debugfs_slab_add() from __kmem_cache_create(), and then use kobject_put()
to free kobject in sysfs_slab_add(). This can fix the memory leak of
kobject->name.

Liu Shixin (4):
  mm/slab_common: Move cache_name to create_cache()
  mm/slub: rename kmem_cache_release to slab_release in slub.c
  mm/slab_common: Separate sysfs_slab_add() and debugfs_slab_add() from
    __kmem_cache_create()
  mm/slab_common: Fix memory leak of kobj->name in sysfs_slab_add()

 include/linux/slub_def.h | 11 ++++++++
 mm/slab_common.c         | 42 ++++++++++++++++--------------
 mm/slub.c                | 56 +++++++++++-----------------------------
 3 files changed, 48 insertions(+), 61 deletions(-)

-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ