From: Andrew Morton <akpm@osdl.org>
To: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix memory leak while coredumping
Date: Mon, 2 Feb 2004 14:17:18 -0800 [thread overview]
Message-ID: <20040202141718.48f32dc4.akpm@osdl.org> (raw)
In-Reply-To: <20040202105335.DFE88700A2@sv1.valinux.co.jp>
IWAMOTO Toshihiro <iwamoto@valinux.co.jp> wrote:
>
> Hi,
>
> with some help of coworker, I found a bug in binfmt_elf.c.
> The bug exists in linux-2.6.1 and linux-2.6.2-rc2-mm2.
>
> This patch fixes a memory leak that happens when a core file hits the
> process's resource limit.
> I've tested the DUMP_WRITE case only a little, and the DUMP_SEEK case
> is only compile tested.
>
> --- old/fs/binfmt_elf.c Fri Jan 16 12:12:24 2004
> +++ new/fs/binfmt_elf.c Mon Feb 2 19:31:42 2004
> @@ -1441,12 +1441,22 @@
> DUMP_SEEK (file->f_pos + PAGE_SIZE);
> } else {
> if (page == ZERO_PAGE(addr)) {
> - DUMP_SEEK (file->f_pos + PAGE_SIZE);
> + if (!dump_seek(file,
> + file->f_pos + PAGE_SIZE)) {
> + page_cache_release(page);
> + goto end_coredump;
> + }
There's no point in doing page_cache_release() of the zero page.
> } else {
> void *kaddr;
> flush_cache_page(vma, addr);
> kaddr = kmap(page);
> - DUMP_WRITE(kaddr, PAGE_SIZE);
> + if ((size += PAGE_SIZE) > limit ||
> + !dump_write(file, kaddr,
> + PAGE_SIZE)) {
> + kunmap(page);
> + page_cache_release(page);
> + goto end_coredump;
> + }
> kunmap(page);
> }
> page_cache_release(page);
This chunk is good, thanks.
Those macros are foul.
prev parent reply other threads:[~2004-02-02 22:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-02 10:53 IWAMOTO Toshihiro
2004-02-02 22:17 ` Andrew Morton [this message]
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=20040202141718.48f32dc4.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=iwamoto@valinux.co.jp \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®