LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-26-2006, 05:58 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
Variable at random location in memory?


IIRC global variables like PATH used to exist at a certain memory address. But now it seems you never know where it is. I made a program before that printed out the address of a variable, and when I use it now it keeps showing up seemingly random addresses.

Code:
/* getenvaddr.c */
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
        char *addr;
        addr = getenv(argv[1]);
        printf("Addr: %p\n", addr);
}
Code:
[root@garanka laboratory] # ./getenvaddr PATH
Addr: 0xaf9dfe9b
[root@garanka laboratory] # ./getenvaddr PATH
Addr: 0xafe83e9b
[root@garanka laboratory] # ./getenvaddr PATH
Addr: 0xaf88be9b
What has happened and why?
 
Old 08-26-2006, 10:59 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
This may be part of the Execshield implementation:

cat /proc/sys/kernel/exec-shield-randomize

0 — Randomized VM mapping is disabled
1 — Randomized VM mapping is enabled

Update: on later kernels, the value may be in:

cat /proc/sys/kernel/randomize_va_space

Last edited by macemoneta; 08-26-2006 at 11:07 PM.
 
Old 08-27-2006, 05:49 AM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Yeah I've read a little bit and it seems that we now have ASLR in Linux. On an interesting note this will also come to Vista (in a lesser secure way it seems, though).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Random Variable Daniel Programming 14 12-03-2007 05:00 AM
Location of Environment Variable Settings in Slackware Psibur Linux - General 1 01-27-2006 11:23 PM
Random crashes (memory problem?) Cadmium Linux - Hardware 5 01-27-2006 06:05 AM
Random crashes (memory problem?) Cadmium Mandriva 1 01-16-2006 05:52 AM


All times are GMT -5. The time now is 10:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration