lkml.org 
[lkml]   [2009]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] task_struct cleanup: move binfmt field to mm_struct
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.



\
 
 \ /
  Last update: 2009-07-24 18:21    [W:0.104 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site