Re: [PATCH] i386 and x86_64: randomize brk()

From: Andrew Morton
Date: Sun Sep 02 2007 - 16:29:24 EST


> On Sat, 01 Sep 2007 22:19:01 +0200 Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote:
> Hello Andrew,
>
> Andrew Morton wrote:
> > On Thu, 30 Aug 2007 17:10:03 +0200 (CEST) Jiri Kosina <jkosina@xxxxxxx> wrote:
> >> Andrew, do you still strongly oppose to having ARCH_HAS_RANDOMIZE_BRK
> >> macro instead please?
> >>
> >
> > Not strongly, but the general opinion seems to be that ARCH_HAS_FOO is
> > sucky. It should at least be done in Kconfig rather than in .h, but even
> > better is just to implement the thing for all architectures.
> >
>
> Sorry for asking again but the initial poster haven't taken time to
> answer to my feedbacks...
>
> What about using a weak function in that case ? It actually gives a
> default implementation in _one_ place and can be changed easily from
> a nop to something more complex later.

Yeah, weak functions are by far the cleanest way of doing this - they're
most elegant. But they do add the overhead of an empty call/return, so
some thought needs to go into the tradeoff.

> Another point is that the current prototype of arch_randomize_brk()
> could be slightly improved IMHO.
>
> The proposed prototype is:
>
> void arch_randomize_brk(void)
>
> and I think it could be:
>
> unsigned long randomize_brk(unsigned long brk)
>
> Because the current code of exec syscall is rather.. hmm "tricky",
> _hiding_ "current" global usage inside this function is error prone:
> if this function is moved later, its use of "current->mm" could
> reference the old mm process and it's hard to notice/fix.

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