ADDR_NO_RANDOMIZE personality not respected

Bug #616001 reported by Ulrich Weigand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GDB
Invalid
Low
Ulrich Weigand
Linaro Linux
Fix Released
Medium
Nicolas Pitre

Bug Description

FAIL: gdb.mi/mi-var-cmd.exp: in-and-out-of-scope: in scope now

Needs further analysis.

Tags: testsuite
Revision history for this message
Yao Qi (yao-codesourcery) wrote :

[CdoeSourecry #6202]

Changed in gdb-linaro:
status: New → Confirmed
Revision history for this message
Ulrich Weigand (uweigand) wrote :

This test assumes running the program from scratch twice to the same point will result in the frame being at the same address. This is not true on Ubuntu due to the address-space randomization feature ...

The test case should probably be modified to get rid of this assumption.

Changed in gdb-linaro:
importance: Undecided → Low
Revision history for this message
Yao Qi (yao-codesourcery) wrote :

Yes. test case passes when disable stack randomization in kernel via,

   sudo sysctl -w kernel.randomize_va_space=0

Note that test case passes on x86 when kernel.randomize_va_space is 2, because, x86 linux kernel does not randomize stack location unless current->personality permits it. http://lkml.indiana.edu/hypermail/linux/kernel/0607.1/1260.html

Michael Hope (michaelh1)
tags: added: testsuite
Changed in gdb-linaro:
assignee: nobody → Ulrich Weigand (uweigand)
Revision history for this message
Ulrich Weigand (uweigand) wrote :

This test case
FAIL: gdb.base/randomize.exp: fixed addresses should match
also fails because of the same reason.

It seems this is actually a kernel problem: on ARM, for some reason, the ADDR_NO_RANDOMIZE personality is not respected, and address space is randomized anyway ...

Revision history for this message
Ulrich Weigand (uweigand) wrote :

This does indeed appear to be a kernel problem. If you build the attached test case using
  gcc -o randomize randomize.c

and run with and without the -p flag, you get on i386 something like:

uweigand@br8ermyc:~$ ./randomize 10
0xbfa943dc 0x9109008
0xbff84b9c 0x98c2008
0xbfd3fd1c 0x9107008
0xbf828adc 0x8b96008
0xbf85b87c 0x86cf008
0xbfcf5bac 0x9dc8008
0xbfd89a3c 0x8dd0008
0xbff279cc 0x9d42008
0xbfb8dccc 0x8429008
0xbf8daaac 0x8a8a008

uweigand@br8ermyc:~$ ./randomize 10 -p
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008
0xbffff30c 0x804b008

That is, by default addresses are randomized, but when the ADDR_NO_RANDOMIZE personality is used, the randomization is disabled.

However, when running the same test on ARM (Linaro 2.6.38 kernel on vexpress), I get instead:

uweigand@localhost:~$ ./randomize 10
0xbec8764c 0x1006008
0xbe85664c 0x19fb008
0xbeff664c 0x182e008
0xbeccb64c 0x1c36008
0xbeb2664c 0x7e008
0xbee1d64c 0xd54008
0xbe8ef64c 0x1c0b008
0xbebda64c 0x343008
0xbe99564c 0x1bce008
0xbee4164c 0x18d6008

uweigand@localhost:~$ ./randomize 10 -p
0xbe85b64c 0x8b008
0xbeedd64c 0x2003008
0xbe8f564c 0xe42008
0xbefff64c 0x104c008
0xbeb7b64c 0x1da008
0xbec2864c 0x18c1008
0xbea7664c 0x2e1008
0xbe94564c 0x959008
0xbef6764c 0x4f7008
0xbea2864c 0x65008

That is, the ADDR_NO_RANDOMIZE setting seems to be simply ignored.

summary: - gdb.mi/mi-var-cmd.exp failure
+ ADDR_NO_RANDOMIZE personality not respected
Revision history for this message
Ulrich Weigand (uweigand) wrote :
Changed in gdb-linaro:
status: Confirmed → Triaged
Revision history for this message
Nicolas Pitre (npitre) wrote :

Fix committed to linaro-2.6.38

Changed in linux-linaro:
assignee: nobody → Nicolas Pitre (npitre)
status: New → Fix Committed
Changed in linux-linaro:
importance: Undecided → Medium
Revision history for this message
Ulrich Weigand (uweigand) wrote :

Setting GDB status to Invalid since there's nothing to fix on the GDB side.

Changed in gdb-linaro:
status: Triaged → Invalid
Changed in linux-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.