Re: A note about testing EXEC_BACKEND on recent Linuxen

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: A note about testing EXEC_BACKEND on recent Linuxen
Date: 2006-02-01 19:32:21
Message-ID: 20060201193221.GC9888@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 01, 2006 at 10:59:39AM -0500, Bruce Momjian wrote:
> * Attach process to shared data structures. If testing
> * EXEC_BACKEND on Linux, you must run this as root
> * before starting the postmaster:
> *
> * echo 0 >/proc/sys/kernel/randomize_va_space
> *
> * This prevents a randomized stack base address that causes
> * child shared memory to be at a different address than
> * the parent, making it impossible to attached to shared
> * memory. Return the value to '1' when finished.

Hmm, are there no other ways that this problem can manifest itself?
ISTM that we're relying completely on the kernel to map it in the same
place each time. Maybe one day someone changes the startup procedure to
allocate some more memory and it gets mapped somewhere else.

A better solution would be to explicitly map it in the child processes.
Basically, store the shared memory base at the beginning of the shared
memory block. Then when the child maps it it can verify the location.
It if doesn't match, unmap and remap at the right place.

The first half should probably at least be implemented to detect the
situation (ERROR: Shared memory block mapped at wrong location). But
given that you could probably solve the problem completely... Ofcourse,
there's the risk the child has already allocated memory where it should
be (the randomize space flag might cause this).

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-02-01 19:38:08 Re: A note about testing EXEC_BACKEND on recent Linuxen
Previous Message Bruce Momjian 2006-02-01 18:32:24 Re: TODO-Item: B-tree fillfactor control