Burned by address space layout randomization

238 Views Asked by At

I'm porting a bunch of unix apps to linux, and one of them has a problem with address space randomization. The app is part of a system of shared apps that save 'state' info to disk. Each transaction for a given user could be performed by either the same or a different instance of an app. So in this one app, the programmer got clever and stored pointers to functions in the state file. Works fine on the original AIX system. But on linux, if the next transaction is performed by a different app instance it segfaults. With address randomization, those function pointers are no longer valid. If it lucks out and gets the same app instance it works fine.

So, I either have to disable address space randomization, or restructure his code. Is it possible to set an attribute on an executable so that only that executable operates with randomization disabled. Or can it only be disabled globally? I saw another post that mentions setarch $(uname -m) -R /bin/bash as a way to do that for all apps launched by a shell instance. But I don't want to disable it for every app - just the one that uses this dodgy technique.

One more thing. uname -m on my system returns X86_64, but the app in question was built in 32-bit mode, so would I need to tweak the setarch command to deal with 32-bit apps on a 64-bit system differently?

1

There are 1 best solutions below

0
On

Thanks, Lorinczy Zsigmond. -no-pie did the trick.