1

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?

littlenoodles
  • 435
  • 4
  • 13
  • I tried 'setarch i386 -R ' and it actually runs the app - doesn't set an attribute on the executable. That won't work for me, since the app is launched automatically by a central app dispatcher on demand. I suppose I could launch the dispatcher that way, but that would disable randomization for all apps in this whole subsystem, May as well just disable it globally on the box at that point. – littlenoodles Sep 03 '20 at 17:08
  • Could you launch a wrapper instead? eg, a script that runs something like 'exec setarch ... ` – Milag Sep 04 '20 at 01:17
  • I think it would be `-no-pie` gcc-option at linkage-time. _"Don't produce a position independent executable."_ – Lorinczy Zsigmond Sep 04 '20 at 05:03

1 Answers1

1

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

littlenoodles
  • 435
  • 4
  • 13