From: Vlastimil Babka <vbabka@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Subject: Re: fs/exec.c: fix minor memory leak
Date: Mon, 16 May 2016 16:57:27 +0200 [thread overview]
Message-ID: <5739DFD7.8030905@suse.cz> (raw)
In-Reply-To: <20160421141523.d5a96fd694dd8681be5b1d36@linux-foundation.org>
On 04/21/2016 11:15 PM, Andrew Morton wrote:
>
> Could someone please double-check this?
Looks OK to me.
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: fs/exec.c: fix minor memory leak
>
> When the to-be-removed argument's trailing '\0' is the final byte in the
> page, remove_arg_zero()'s logic will avoid freeing the page, will break
> from the loop and will then advance bprm->p to point at the first byte in
> the next page. Net result: the final page for the zeroeth argument is
> unfreed.
>
> It isn't a very important leak - that page will be freed later by the
> bprm-wide sweep in free_arg_pages().
>
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=116841
> Reported by: hujunjie <jj.net@163.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>
> fs/exec.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff -puN fs/exec.c~fs-execc-fix-minor-memory-leak fs/exec.c
> --- a/fs/exec.c~fs-execc-fix-minor-memory-leak
> +++ a/fs/exec.c
> @@ -1482,8 +1482,15 @@ int remove_arg_zero(struct linux_binprm
> kunmap_atomic(kaddr);
> put_arg_page(page);
>
> - if (offset == PAGE_SIZE)
> + if (offset == PAGE_SIZE) {
> free_arg_page(bprm, (bprm->p >> PAGE_SHIFT) - 1);
> + } else if (offset == PAGE_SIZE - 1) {
> + /*
> + * The trailing '\0' is the last byte in a page - we're
> + * about to advance past that byte so free its page now
> + */
> + free_arg_page(bprm, (bprm->p >> PAGE_SHIFT));
> + }
> } while (offset == PAGE_SIZE);
>
> bprm->p++;
> _
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-05-16 14:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 21:15 fs/exec.c: fix minor memory leak Andrew Morton
2016-05-16 14:57 ` Vlastimil Babka [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-05-16 20:43 Oleg Nesterov
2016-05-16 20:55 ` Andrew Morton
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=5739DFD7.8030905@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).