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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+FuTSeTu-LUBvewPiM5FFGuEiAvmp-ukdjFn4UvYwTZViCqbg@mail.gmail.com>
Date:   Fri, 30 Oct 2020 19:31:08 -0400
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Xiaochen Shen <xiaochen.shen@...el.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>, mingo@...hat.com,
        bp@...en8.de, HPA <hpa@...or.com>, tony.luck@...el.com,
        Fenghua Yu <fenghua.yu@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>, x86@...nel.org,
        linux-kernel <linux-kernel@...r.kernel.org>, pei.p.jia@...el.com
Subject: Re: [PATCH 1/3] x86/resctrl: Remove superfluous kernfs_get() calls to
 prevent refcount leak

On Fri, Oct 30, 2020 at 2:45 PM Xiaochen Shen <xiaochen.shen@...el.com> wrote:
>
> Willem reported growing of kernfs_node_cache entries in slabtop when
> repeatedly creating and removing resctrl subdirectories as well as when
> repeatedly mounting and unmounting resctrl filesystem.
>
> On resource group (control as well as monitoring) creation via a mkdir
> an extra kernfs_node reference is obtained to ensure that the rdtgroup
> structure remains accessible for the rdtgroup_kn_unlock() calls where it
> is removed on deletion. The kernfs_node reference count is dropped by
> kernfs_put() in rdtgroup_kn_unlock().
>
> With the above explaining the need for one kernfs_get()/kernfs_put()
> pair in resctrl there are more places where a kernfs_node reference is
> obtained without a corresponding release. The excessive amount of
> reference count on kernfs nodes will never be dropped to 0 and the
> kernfs nodes will never be freed in the call paths of rmdir and umount.
> It leads to reference count leak and kernfs_node_cache memory leak.
>
> Remove the superfluous kernfs_get() calls and expand the existing
> comments surrounding the remaining kernfs_get()/kernfs_put() pair that
> remains in use.
>
> Superfluous kernfs_get() calls are removed from two areas:
>
>   (1) In call paths of mount and mkdir, when kernfs nodes for "info",
>   "mon_groups" and "mon_data" directories and sub-directories are
>   created, the reference count of newly created kernfs node is set to 1.
>   But after kernfs_create_dir() returns, superfluous kernfs_get() are
>   called to take an additional reference.
>
>   (2) kernfs_get() calls in rmdir call paths.
>
> Cc: stable@...r.kernel.org
> Fixes: 17eafd076291 ("x86/intel_rdt: Split resource group removal in two")
> Fixes: 4af4a88e0c92 ("x86/intel_rdt/cqm: Add mount,umount support")
> Fixes: f3cbeacaa06e ("x86/intel_rdt/cqm: Add rmdir support")
> Fixes: d89b7379015f ("x86/intel_rdt/cqm: Add mon_data")
> Fixes: c7d9aac61311 ("x86/intel_rdt/cqm: Add mkdir support for RDT monitoring")
> Fixes: 5dc1d5c6bac2 ("x86/intel_rdt: Simplify info and base file lists")
> Fixes: 60cf5e101fd4 ("x86/intel_rdt: Add mkdir to resctrl file system")
> Fixes: 4e978d06dedb ("x86/intel_rdt: Add "info" files to resctrl file system")
> Reported-by: Willem de Bruijn <willemb@...gle.com>
> Signed-off-by: Xiaochen Shen <xiaochen.shen@...el.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@...el.com>

Tested-by: Willem de Bruijn <willemb@...gle.com>

This addresses both kernfs_node_cache slab leaks I previously
observed. Thanks for fixing these!

for i in {1..100000}; do mount -t resctrl resctrl /sys/fs/resctrl;
umount /sys/fs/resctrl; done
for i in {1..100000}; do mkdir /sys/fs/resctrl/task1; rmdir
/sys/fs/resctrl/task1; done

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ