Re: [PATCH] kernfs: fix memleak in kernel_ops_readdir()
From: Tejun Heo
Date: Wed Aug 07 2019 - 14:45:24 EST
Hello,
On Wed, Aug 07, 2019 at 06:29:28AM -0700, Tony Lindgren wrote:
> Hi,
>
> * Tejun Heo <tj@xxxxxxxxxx> [691231 23:00]:
> > From: Andrea Arcangeli <aarcange@xxxxxxxxxx>
> >
> > If getdents64 is killed or hits on segfault, it'll leave cgroups
> > directories in sysfs pinned leaking memory because the kernfs node
> > won't be freed on rmdir and the parent neither.
>
> Somehow this causes a regression in Linux next for me where I'm seeing
> lots of sysfs entries now missing under /sys/bus/platform/devices.
>
> For example, I now only see one .serial entry show up in sysfs.
> Things work again if I revert commit cc798c83898e ("kernfs: fix memleak
> inkernel_ops_readdir()"). Any ideas why that would be?
>
> Below is a diff -u of ls /sys/bus/platform/devices for reference
> showing the missing entries with cc798c83898e.
Ugh, you're right. It can get double-put cuz ctx->pos is put by
release too. Greg, sorry about the noise but can you please revert
the patch? I'll look into why this looked like memory leak from
slabinfo side.
Thanks.
--
tejun