Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

Re: + binfmt-introduce-coredump-parameter-structure.patch added to -mm tree

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


kosaki.motohiro at jp

Nov 26, 2009, 12:53 AM

Post #1 of 4 (139 views)
Permalink
Re: + binfmt-introduce-coredump-parameter-structure.patch added to -mm tree

Hi Hiramatsu-san,

>
> The patch titled
> binfmt: introduce coredump parameter structure
> has been added to the -mm tree. Its filename is
> binfmt-introduce-coredump-parameter-structure.patch
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>
> See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
> out what to do about this
>
> The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
>
> ------------------------------------------------------
> Subject: binfmt: introduce coredump parameter structure
> From: Masami Hiramatsu <mhiramat [at] redhat>
>
> These patches are for fixing coredump mm->flags consistency issue.
>
> ---
> 1787 if (mm->core_state || !get_dumpable(mm)) { <- (1)
> 1788 up_write(&mm->mmap_sem);
> 1789 put_cred(cred);
> 1790 goto fail;
> 1791 }
> 1792
> [...]
> 1798 if (get_dumpable(mm) == 2) { /* Setuid core dump mode */ <-(2)
> 1799 flag = O_EXCL; /* Stop rewrite attacks */
> 1800 cred->fsuid = 0; /* Dump root private */
> 1801 }
> ---
>
> Since dumpable bits are not protected by lock, there is a chance to change
> these bits between (1) and (2).
>
> To solve this issue, this patch copies mm->flags to
> coredump_params.mm_flags at the beginning of do_coredump() and uses it
> instead of get_dumpable() while dumping core. This series also introduce
> coredump parameter structure for simplify bimfmt->core_dump interface.
>
>
>
> This patch:
>
> Introduce coredump parameter data structure (struct coredump_params) for
> simplifying binfmt->core_dump() arguments. This also cleanup DUMP_WRITE()
> in elf_core_dump() by style issue.


This patch break ia64 because arch specific ELF_CORE_EXTRA_PHDRS and
ELF_CORE_WRITE_EXTRA_DATA still use DUMP_WRITE. I expect this patch
break uml too.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mhiramat at redhat

Nov 26, 2009, 7:50 AM

Post #2 of 4 (135 views)
Permalink
Re: + binfmt-introduce-coredump-parameter-structure.patch added to -mm tree [In reply to]

Hi Kosaki-san,

KOSAKI Motohiro wrote:
> Hi Hiramatsu-san,
>
>>
>> The patch titled
>> binfmt: introduce coredump parameter structure
>> has been added to the -mm tree. Its filename is
>> binfmt-introduce-coredump-parameter-structure.patch
>>
>> Before you just go and hit "reply", please:
>> a) Consider who else should be cc'ed
>> b) Prefer to cc a suitable mailing list as well
>> c) Ideally: find the original patch on the mailing list and do a
>> reply-to-all to that, adding suitable additional cc's
>>
>> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>>
>> See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
>> out what to do about this
>>
>> The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
>>
>> ------------------------------------------------------
>> Subject: binfmt: introduce coredump parameter structure
>> From: Masami Hiramatsu <mhiramat [at] redhat>
>>
>> These patches are for fixing coredump mm->flags consistency issue.
>>
>> ---
>> 1787 if (mm->core_state || !get_dumpable(mm)) { <- (1)
>> 1788 up_write(&mm->mmap_sem);
>> 1789 put_cred(cred);
>> 1790 goto fail;
>> 1791 }
>> 1792
>> [...]
>> 1798 if (get_dumpable(mm) == 2) { /* Setuid core dump mode */ <-(2)
>> 1799 flag = O_EXCL; /* Stop rewrite attacks */
>> 1800 cred->fsuid = 0; /* Dump root private */
>> 1801 }
>> ---
>>
>> Since dumpable bits are not protected by lock, there is a chance to change
>> these bits between (1) and (2).
>>
>> To solve this issue, this patch copies mm->flags to
>> coredump_params.mm_flags at the beginning of do_coredump() and uses it
>> instead of get_dumpable() while dumping core. This series also introduce
>> coredump parameter structure for simplify bimfmt->core_dump interface.
>>
>>
>>
>> This patch:
>>
>> Introduce coredump parameter data structure (struct coredump_params) for
>> simplifying binfmt->core_dump() arguments. This also cleanup DUMP_WRITE()
>> in elf_core_dump() by style issue.
>
>
> This patch break ia64 because arch specific ELF_CORE_EXTRA_PHDRS and
> ELF_CORE_WRITE_EXTRA_DATA still use DUMP_WRITE. I expect this patch
> break uml too.

$ grep -r DUMP_WRITE arch/*/include
arch/ia64/include/asm/elf.h: DUMP_WRITE(&phdr, sizeof(phdr)); \
arch/ia64/include/asm/elf.h: DUMP_WRITE((void *) gate_phdrs[\

Oops, certainly, that's a problem.
IMHO, we should not do like that, all parameter required by a macro should be
specified explicitly, since it reduces readability so much...
I think we'd better make those macros inline function, check it's return value
for error handling.

What would you think about it?

Thank you,

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat [at] redhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


oleg at redhat

Nov 26, 2009, 8:51 AM

Post #3 of 4 (135 views)
Permalink
Re: + binfmt-introduce-coredump-parameter-structure.patch added to -mm tree [In reply to]

On 11/26, Masami Hiramatsu wrote:
>
> $ grep -r DUMP_WRITE arch/*/include
> arch/ia64/include/asm/elf.h: DUMP_WRITE(&phdr, sizeof(phdr)); \
> arch/ia64/include/asm/elf.h: DUMP_WRITE((void *) gate_phdrs[\

arch/um/sys-i386/asm/elf.h uses DUMP_WRITE() too.

> Oops, certainly, that's a problem.
> IMHO, we should not do like that, all parameter required by a macro should be
> specified explicitly, since it reduces readability so much...
> I think we'd better make those macros inline function, check it's return value
> for error handling.

Agreed, DUMP_WRITE() in its current form should die. Not only
it has implicit parameter, it does "goto" from the macro body
and it has multiple definitions withing the same file.

But perhaps this needs a separate patch? It is not trivial to kill
DUMP_WRITE(), you can fix this patch if you change DUMP_WRITE()
to use cprm->file instead of file.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mhiramat at redhat

Nov 28, 2009, 7:59 PM

Post #4 of 4 (125 views)
Permalink
Re: + binfmt-introduce-coredump-parameter-structure.patch added to -mm tree [In reply to]

Oleg Nesterov wrote:
> On 11/26, Masami Hiramatsu wrote:
>>
>> $ grep -r DUMP_WRITE arch/*/include
>> arch/ia64/include/asm/elf.h: DUMP_WRITE(&phdr, sizeof(phdr)); \
>> arch/ia64/include/asm/elf.h: DUMP_WRITE((void *) gate_phdrs[\
>
> arch/um/sys-i386/asm/elf.h uses DUMP_WRITE() too.
>
>> Oops, certainly, that's a problem.
>> IMHO, we should not do like that, all parameter required by a macro should be
>> specified explicitly, since it reduces readability so much...
>> I think we'd better make those macros inline function, check it's return value
>> for error handling.
>
> Agreed, DUMP_WRITE() in its current form should die. Not only
> it has implicit parameter, it does "goto" from the macro body
> and it has multiple definitions withing the same file.
>
> But perhaps this needs a separate patch? It is not trivial to kill
> DUMP_WRITE(), you can fix this patch if you change DUMP_WRITE()
> to use cprm->file instead of file.

Hmm, certainly, that should be separated. So I just change DUMP_WRITE()
to use cprm->limit/file.

Thank you,

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat [at] redhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.