From: Chunyu Hu <chuhu@redhat.com>
To: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] proc: add proc_seq_release
Date: Tue, 26 Jun 2018 08:20:52 -0400 (EDT) [thread overview]
Message-ID: <1113263100.13594710.1530015652549.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20180611062354.GA32641@lst.de>
----- Original Message -----
> From: "Christoph Hellwig" <hch@lst.de>
> To: "Chunyu Hu" <chuhu@redhat.com>
> Cc: viro@zeniv.linux.org.uk, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
> Sent: Monday, June 11, 2018 2:23:54 PM
> Subject: Re: [PATCH] proc: add proc_seq_release
>
> On Sun, Jun 10, 2018 at 03:51:24AM +0800, Chunyu Hu wrote:
> > kmemleak reported some memory leak on reading proc files. After adding
> > some debug lines, find that proc_seq_fops is using seq_release as
> > release handler, which won't handle the free of 'private' field of
> > seq_file, while in fact the open handler proc_seq_open could create
> > the private data with __seq_open_private when state_size is greater
> > than zero. So after reading files created with proc_create_seq_private,
> > such as /proc/timer_list and /proc/vmallocinfo, the private mem of a
> > seq_file is not freed. Fix it by adding the paired proc_seq_release
> > as the default release handler of proc_seq_ops instead of seq_release.
>
> Indeed, thanks for the patch.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
What's our plan for this issue? We can still see the leaking in 4.18-RC2.
1) Run 'cat /proc/timer_list' then
2) echo scan > /sys/kernel/debug/kmemleak
3) cat /sys/kernel/debug/kmemleak
each time, it leaks 16 bytes.
unreferenced object 0xffff880017525120 (size 16):
comm "cat", pid 4682, jiffies 4294964743 (age 46.880s)
hex dump (first 16 bytes):
04 00 00 00 01 00 00 00 42 00 96 e7 3f 00 00 00 ........B...?...
backtrace:
[<000000006f6b5d90>] seq_open_private+0x25/0x40
[<00000000d94d91aa>] proc_seq_open+0xca/0x120
[<00000000d5609077>] proc_reg_open+0x1d4/0x5b0
[<0000000036a3d49c>] do_dentry_open+0x7d6/0x1010
[<00000000d4fb0a82>] vfs_open+0x170/0x2b0
[<00000000f3bf21b4>] path_openat+0x760/0x3750
[<00000000b0d4e66c>] do_filp_open+0x1bb/0x2c0
[<0000000063b53236>] do_sys_open+0x2b2/0x490
[<00000000a5249c62>] do_syscall_64+0xd3/0x6e0
[<000000006f9f8436>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[<000000001d702cb2>] 0xffffffffffffffff
--
Regards,
Chunyu Hu
next prev parent reply other threads:[~2018-06-26 12:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-09 19:51 [PATCH] proc: add proc_seq_release Chunyu Hu
2018-06-11 6:23 ` Christoph Hellwig
2018-06-26 12:20 ` Chunyu Hu [this message]
2018-06-27 7:09 ` Christoph Hellwig
2018-06-28 0:43 ` Al Viro
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=1113263100.13594710.1530015652549.JavaMail.zimbra@redhat.com \
--to=chuhu@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).