From: Oleg Nesterov <oleg@redhat.com>
To: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Roland McGrath <roland@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct
Date: Fri, 24 Jul 2009 18:14:49 +0200 [thread overview]
Message-ID: <20090724161449.GA3509@redhat.com> (raw)
In-Reply-To: <4A693569.1090009@ct.jp.nec.com>
On 07/24, Hiroshi Shimamoto wrote:
>
> int set_binfmt(struct linux_binfmt *new)
> {
> - struct linux_binfmt *old = current->binfmt;
> + struct linux_binfmt *old;
>
> + if (!current->mm)
> + return -1;
> +
> + old = current->mm->binfmt;
> if (new) {
> if (!try_module_get(new->module))
> return -1;
> }
> - current->binfmt = new;
> + current->mm->binfmt = new;
Hmm. Of-topic, but I think set_binfmt() is buggy (with or without this patch),
it should use __module_get(). I'll send the fix in a minute.
> @@ -1730,7 +1734,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
>
> audit_core_dumps(signr);
>
> - binfmt = current->binfmt;
> + binfmt = current->mm ? current->mm->binfmt : NULL;
current->mm can't be NULL here. And please note we already have
struct mm_struct *mm = current->mm, so the above should be
binfmt = mm->binfmt;
> @@ -953,6 +953,9 @@ NORET_TYPE void do_exit(long code)
> tsk->exit_code = code;
> taskstats_exit(tsk, group_dead);
>
> + if (tsk->mm && tsk->mm->binfmt)
> + module_put(tsk->mm->binfmt->module);
This is not right. We leak ->binfmt on exec.
Seems to be fixed by the next patch, but still this is not good.
I'd suggest you to merge these 2 patches into single patch, because
module_put(->binfmt) should go to mmput() from the very beginning.
Oleg.
next prev parent reply other threads:[~2009-07-24 16:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 8:42 [RFC 1/2] move binfmt filed to signal_struct Hiroshi Shimamoto
2009-07-10 8:43 ` [RFC 2/2] make binfmt module get and put per signal_struct Hiroshi Shimamoto
2009-07-22 20:23 ` [RFC 1/2] move binfmt filed to signal_struct Andrew Morton
2009-07-22 22:03 ` Roland McGrath
2009-07-23 16:18 ` Oleg Nesterov
2009-07-24 0:15 ` Hiroshi Shimamoto
2009-07-24 4:15 ` [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct Hiroshi Shimamoto
2009-07-24 4:17 ` [PATCH 2/2] task_struct cleanup: make binfmt module get and put per mm_struct Hiroshi Shimamoto
2009-07-24 16:14 ` Oleg Nesterov [this message]
2009-07-27 0:27 ` [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct Hiroshi Shimamoto
2009-07-27 16:59 ` Oleg Nesterov
2009-07-28 6:21 ` Hiroshi Shimamoto
2009-07-28 14:37 ` Oleg Nesterov
2009-07-30 0:42 ` [PATCH 0/1] " Hiroshi Shimamoto
2009-07-30 0:43 ` [PATCH 1/1] " Hiroshi Shimamoto
2009-07-30 17:55 ` Oleg Nesterov
2009-07-30 19:27 ` Roland McGrath
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=20090724161449.GA3509@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=h-shimamoto@ct.jp.nec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
/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