From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct
Date: Tue, 28 Jul 2009 15:21:16 +0900 [thread overview]
Message-ID: <4A6E98DC.5020200@ct.jp.nec.com> (raw)
In-Reply-To: <20090727165901.GA8854@redhat.com>
Oleg Nesterov wrote:
> (add Rusty)
>
> On 07/27, Hiroshi Shimamoto wrote:
>> void set_binfmt(struct linux_binfmt *new)
>> {
>> - if (current->binfmt)
>> - module_put(current->binfmt->module);
>> + struct mm_struct *mm = current->mm;
>> +
>> + BUG_ON(!mm);
>> + if (mm->binfmt)
>
> I am not sure we need this BUG_ON() above. If mm == NULL we will
> have the same debug info after the crash.
Ah, right. It will crash at accessing mm->binfmt and we'll get the
same information. I didn't think seriously.
BTW, now I noticed that it looks similar the security issue with
NULL page mapping. If the kernel has the page mapping to NULL,
it causes unstable behavior, no?
>
>> @@ -619,6 +621,9 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
>> mm->hiwater_rss = get_mm_rss(mm);
>> mm->hiwater_vm = mm->total_vm;
>>
>> + if (mm->binfmt && !try_module_get(mm->binfmt->module))
>> + goto free_pt;
>
> free_pt does mmput() which calls module_put(mm->binfmt->module). This
> is not right when try_module_get() fails. Hmm, the same if dup_mmap()
> fails, we are doing an extra module_put().
Good catch, should avoid over putting binfmt->module.
>
> Perhaps we can use __module_get() again, current->mm->binfmt holds a
> reference. But this is a user-visible change, currently fork() can't
> succeed if ->module->state == MODULE_STATE_GOING.
>
> So I think we need another small change:
>
> free_pt:
> + mm->binfmt = NULL;
> mmput(mm);
looks good for me.
Will send an update.
thanks,
Hiroshi
next prev parent reply other threads:[~2009-07-28 6:23 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 ` [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct Oleg Nesterov
2009-07-27 0:27 ` Hiroshi Shimamoto
2009-07-27 16:59 ` Oleg Nesterov
2009-07-28 6:21 ` Hiroshi Shimamoto [this message]
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=4A6E98DC.5020200@ct.jp.nec.com \
--to=h-shimamoto@ct.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=rusty@rustcorp.com.au \
/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