Andrea Arcangeli wrote: > > elf_core_dump should call down_write to prevent concurrent expand_stack > > expand_stack doesn't need the write sem, see the locking comments in the > 00_silent-stack-overflow patch in -aa. > You misunderstood me, it's the other way around: elf_core_dump walks the vma list twice and assumes that the segment sizes don't change --> elf_core_dump needs a write lock to ensure that. > > calls, and acquire the pagetable_lock around some lines (right now it > > walks the page tables without locking). I'll check the other coredump > > Also expand_stack needs the page_table_lock, that's ok. > Dito: elf_core_dump walks the page tables without locking. > > I'll write a patch that moves the locking into the coredump handlers, > > then we can compare that with Andrea's proposal. > > Ok. > Attached is a beta version: * remove {down,up}_read from fs/exec.c::do_coredump * add down_read into each arch/*/process.c::dump_thread. Most of them are probably save without the locking, but it's better for the consistency. Most of them access mm->brk and perform some calculations. * explicit memset(,0,) around all structures that are dumped in fs/binfmt_elf.c: depending on the structure alignment, we could otherwise leak kernel stack. * Do not walk the vma list twice, copy it into a temporary kernel buffer. down_write around it to prevent concurrent expand_stack. * spin_lock(¤t->mm->page_table_lock) around the code that walks the page tables. * all other binfmt's have trivial coredump implementation that only call dump_thread, or no coredump at all. I'll do more extensive testing tomorrow. -- Manfred