This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix default stack guard.


Hi,

the following tests fail with glibc trunk for i686-pc-linux-gnu running on an
ubuntu 2.6.24-28-server kernel:
- elf/tst-stackguard1
- elf/tst-stackguard1-static
- nptl/tst-stackguard1
- nptl/tst-stackguard1-static

The tests fail because the default stack guard in the testcases is not the same
as the one in _dl_setup_stack_chk_guard in sysdeps/unix/sysv/linux/dl-osinfo.h.

The reasons for which we choose (in _dl_setup_stack_chk_guard) to use the
default stack guard are:
- __ASSUME_AT_RANDOM is not defined. This is because we compile with
  --enable-kernel=2.6.9. AT_RANDOM is supported from 2.6.29 onwards.
- _dl_random is NULL.  This is because the ubuntu 2.6.24-28-server kernel
  doesn't support AT_RANDOM, so it doesn't pass it in the auxiliary vector, so
  _dl_random is not set in _dl_sysdep_start.
- ENABLE_STACKGUARD_RANDOMIZE is not defined, because
  --enable-stackguard-randomization is not used.

The patch fixes the failing test-cases by restoring the default stack guard to
what it was before the commit 'Make stack canary value harder to read through
read overflow' (15a856b1090669df0aec536edbdf240e71a470ca).

Tested on i686-pc-linux-gnu/2.6.24-28-server system.

Thanks,
- Tom

2012-02-15  Tom de Vries  <tom@codesourcery.com>

	* sysdeps/generic/dl-osinfo.h (_dl_setup_stack_chk_guard): Ensure
	default stack guard is set in last bytes.
	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard): Same.

diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h
index 2eaab3b..548fc46 100644
--- sysdeps/generic/dl-osinfo.h
+++ sysdeps/generic/dl-osinfo.h
@@ -30,8 +30,8 @@ _dl_setup_stack_chk_guard (void *dl_random)
 
   if (dl_random == NULL)
     {
-      ret.bytes[sizeof (ret) - 2] = 255;
-      ret.bytes[sizeof (ret) - 3] = '\n';
+      ret.bytes[sizeof (ret) - 1] = 255;
+      ret.bytes[sizeof (ret) - 2] = '\n';
     }
   else
     {
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 874660b..780b20a 100644
--- sysdeps/unix/sysv/linux/dl-osinfo.h
+++ sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -84,8 +84,8 @@ _dl_setup_stack_chk_guard (void *dl_random)
 	    return ret.num;
 	}
 # endif
-      ret.bytes[filllen - 2] = 255;
-      ret.bytes[filllen - 3] = '\n';
+      ret.bytes[filllen] = 255;
+      ret.bytes[filllen - 1] = '\n';
     }
   else
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]