mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Unbacked shared memory not included in ELF core dump
@ 2005-03-01 17:06 Jochen Suckfuell
  2005-03-08 13:43 ` 2.6.11 bug: unbacked private shared memory segments missing in " Jochen Suckfuell
  0 siblings, 1 reply; 4+ messages in thread
From: Jochen Suckfuell @ 2005-03-01 17:06 UTC (permalink / raw)
  To: linux-kernel

Hi!

Since 2.6.10, unbacked shared memory allocated via shmget is not
included in core dumps. The relevant patch has been done to binfmt_elf.c
after the discussion to "include all vmas with unbacked pages in ELF
core dumps", here:
http://www.ussg.iu.edu/hypermail/linux/kernel/0410.2/1890.html

The result was:

static int maydump(struct vm_area_struct *vma)
{
	/* Do not dump I/O mapped devices, shared memory, or special mappings */
	if (vma->vm_flags & (VM_IO | VM_SHARED | VM_RESERVED))
		return 0;
...

I consider this a bug, since we clearly lose unbacked shared memory in
the process.

bye
Jochen Suckfüll


^ permalink raw reply	[flat|nested] 4+ messages in thread

* 2.6.11 bug: unbacked private shared memory segments missing in core dump
  2005-03-01 17:06 Unbacked shared memory not included in ELF core dump Jochen Suckfuell
@ 2005-03-08 13:43 ` Jochen Suckfuell
  2005-03-21 23:29   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Jochen Suckfuell @ 2005-03-08 13:43 UTC (permalink / raw)
  To: linux-kernel

Hello!

Since 2.6.10, unbacked private shared memory allocated via shmget is not
included in core dumps.

This is a simple example code demonstrating the bug:

#include <sys/shm.h>

int main(int argc, char ** argv)
{
	int size = 1000;
	int id = shmget(IPC_PRIVATE, size, (IPC_CREAT | 0660));
	if(id < 0) return(1);
	int *buffer = (int *)shmat(id, 0, 0);
	int i;
	for(i = 0; i < 1000; i++)
		buffer[i] = i;

	// now dump core
	*((unsigned long *)1) = 0;

	// The private shared memory is not included in the core dump,
	// although it's not backed and cannot be accessed any more in any
	// way.
	return 0;
}

This bug was introduced in 2.6.10 by a patch to binfmt_elf.c that
resulted in:

static int maydump(struct vm_area_struct *vma)
{
	/* Do not dump I/O mapped devices, shared memory, or special mappings */
	if (vma->vm_flags & (VM_IO | VM_SHARED | VM_RESERVED))
		return 0;
...

(See the thread at
http://www.ussg.iu.edu/hypermail/linux/kernel/0410.2/1890.html)

Excluding all pages with VM_SHARED set is also excluding the unbacked
private mapping and should be replaced by a more specific criterion.

Bye
Jochen


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 2.6.11 bug: unbacked private shared memory segments missing in core dump
  2005-03-08 13:43 ` 2.6.11 bug: unbacked private shared memory segments missing in " Jochen Suckfuell
@ 2005-03-21 23:29   ` Andrew Morton
  2005-03-23  9:38     ` Jochen Suckfuell
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2005-03-21 23:29 UTC (permalink / raw)
  To: Jochen Suckfuell; +Cc: linux-kernel

Jochen Suckfuell <jo-lkml@suckfuell.net> wrote:
>
> Hello!
> 
> Since 2.6.10, unbacked private shared memory allocated via shmget is not
> included in core dumps.

Can you please confirm that 2.6.12-rc1 fixed this?

Thanks.

> This is a simple example code demonstrating the bug:
> 
> #include <sys/shm.h>
> 
> int main(int argc, char ** argv)
> {
> 	int size = 1000;
> 	int id = shmget(IPC_PRIVATE, size, (IPC_CREAT | 0660));
> 	if(id < 0) return(1);
> 	int *buffer = (int *)shmat(id, 0, 0);
> 	int i;
> 	for(i = 0; i < 1000; i++)
> 		buffer[i] = i;
> 
> 	// now dump core
> 	*((unsigned long *)1) = 0;
> 
> 	// The private shared memory is not included in the core dump,
> 	// although it's not backed and cannot be accessed any more in any
> 	// way.
> 	return 0;
> }
> 
> This bug was introduced in 2.6.10 by a patch to binfmt_elf.c that
> resulted in:
> 
> static int maydump(struct vm_area_struct *vma)
> {
> 	/* Do not dump I/O mapped devices, shared memory, or special mappings */
> 	if (vma->vm_flags & (VM_IO | VM_SHARED | VM_RESERVED))
> 		return 0;
> ...
> 
> (See the thread at
> http://www.ussg.iu.edu/hypermail/linux/kernel/0410.2/1890.html)
> 
> Excluding all pages with VM_SHARED set is also excluding the unbacked
> private mapping and should be replaced by a more specific criterion.
> 
> Bye
> Jochen
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 2.6.11 bug: unbacked private shared memory segments missing in core dump
  2005-03-21 23:29   ` Andrew Morton
@ 2005-03-23  9:38     ` Jochen Suckfuell
  0 siblings, 0 replies; 4+ messages in thread
From: Jochen Suckfuell @ 2005-03-23  9:38 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel


On Mon, Mar 21, 2005 at 03:29:48PM -0800, Andrew Morton wrote:
> Jochen Suckfuell <jo-lkml@suckfuell.net> wrote:
> >
> > Hello!
> > 
> > Since 2.6.10, unbacked private shared memory allocated via shmget is not
> > included in core dumps.
> 
> Can you please confirm that 2.6.12-rc1 fixed this?

Yes, it's fixed. 

Thanks to everyone involved.


Bye
Jochen Suckfuell


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-03-23  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-01 17:06 Unbacked shared memory not included in ELF core dump Jochen Suckfuell
2005-03-08 13:43 ` 2.6.11 bug: unbacked private shared memory segments missing in " Jochen Suckfuell
2005-03-21 23:29   ` Andrew Morton
2005-03-23  9:38     ` Jochen Suckfuell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®