Laurent ALFONSI 14322bad88 linux-user: Define AT_RANDOM to support target stack protection mechanism.
The dynamic linker from the GNU C library v2.10+ uses the ELF
auxiliary vector AT_RANDOM [1] as a pointer to 16 bytes with random
values to initialize the stack protection mechanism.  Technically the
emulated GNU dynamic linker crashes due to a NULL pointer
derefencement if it is built with stack protection enabled and if
AT_RANDOM is not defined by the QEMU ELF loader.

[1] This ELF auxiliary vector was introduced in Linux v2.6.29.

This patch can be tested with the code above:

    #include <elf.h>       /* Elf*_auxv_t, AT_RANDOM, */
    #include <stdio.h>     /* printf(3), */
    #include <stdlib.h>    /* exit(3), EXIT_*, */
    #include <stdint.h>    /* uint8_t, */
    #include <string.h>    /* memcpy(3), */

    #if defined(__LP64__) || defined(__ILP64__) || defined(__LLP64__)
    #    define Elf_auxv_t Elf64_auxv_t
    #else
    #    define Elf_auxv_t Elf32_auxv_t
    #endif

    main(int argc, char* argv[], char* envp[])
    {
        Elf_auxv_t *auxv;

        /* *envp = NULL marks end of envp. */
        while (*envp++ != NULL);

        /* auxv->a_type = AT_NULL marks the end of auxv. */
        for (auxv = (Elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
            if (auxv->a_type == AT_RANDOM) {
                int i;
                uint8_t rand_bytes[16];

                printf("AT_RANDOM is: 0x%x\n", auxv->a_un.a_val);
                memcpy(rand_bytes, (const uint8_t *)auxv->a_un.a_val, sizeof(rand_bytes));
                printf("it points to: ");
                for (i = 0; i < 16; i++) {
                    printf("0x%02x ", rand_bytes[i]);
                }
                printf("\n");
                exit(EXIT_SUCCESS);
            }
        }
        exit(EXIT_FAILURE);
    }

Changes introduced in v2 and v3:

    * Fix typos + thinko (AT_RANDOM is used for stack canary, not for
      ASLR)

    * AT_RANDOM points to 16 random bytes stored inside the user
      stack.

    * Add a small test program.

Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>
Signed-off-by: Laurent ALFONSI <laurent.alfonsi@st.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21 20:30:09 +03:00
2011-06-14 12:56:49 +02:00
2011-06-08 09:04:29 +01:00
2011-06-03 13:34:01 +02:00
2011-05-20 17:35:12 +02:00
2011-06-14 09:34:35 -05:00
2011-06-03 13:34:02 +02:00
2011-04-16 12:24:28 +01:00
2011-04-08 13:03:34 -06:00
2008-12-13 09:32:43 +00:00
2009-09-12 07:36:22 +00:00
2009-05-13 20:54:26 +01:00
2004-08-01 21:54:53 +00:00
2011-05-08 10:09:59 +02:00
2011-05-08 10:09:59 +02:00
2010-04-09 18:55:56 +02:00
2011-06-08 11:56:40 +02:00
2011-01-10 10:55:10 +01:00
2009-03-10 21:43:35 +00:00
2010-11-01 00:54:06 +03:00
2011-02-20 18:45:09 +01:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2011-01-20 20:58:56 +00:00
2011-06-10 23:18:19 +02:00
2010-10-20 16:15:04 -05:00
2011-06-15 19:58:48 +00:00
2011-03-22 08:39:12 -05:00
2008-10-12 17:54:42 +00:00
2011-03-16 17:11:07 -03:00
2010-05-24 15:18:23 -05:00
2011-06-15 14:36:16 +02:00
2009-09-12 07:36:22 +00:00
2011-06-07 13:52:10 -05:00
2011-06-07 13:52:10 -05:00
2011-06-07 13:52:10 -05:00
2011-01-20 20:54:21 +00:00
2009-12-17 18:12:04 +01:00
2007-09-16 20:03:23 +00:00
2010-05-22 08:02:12 +00:00
2011-04-09 10:56:17 +01:00
2009-10-01 16:12:16 -05:00
2011-03-06 21:01:32 +01:00
2010-11-21 09:16:57 -06:00
2010-11-21 09:16:57 -06:00
2010-05-10 11:36:03 -05:00
2010-05-10 11:36:03 -05:00
2011-06-14 03:08:57 +02:00
2008-12-14 08:50:18 +00:00
2011-05-31 10:18:04 -07:00
2011-06-14 09:34:34 -05:00
2010-03-21 08:28:47 +00:00
2010-05-22 08:24:49 +00:00
2010-01-08 09:58:40 -06:00
2009-09-12 07:36:22 +00:00
2010-12-09 14:23:24 +01:00
2011-06-15 19:58:48 +00:00
2011-06-15 19:58:48 +00:00
2011-06-15 19:58:48 +00:00
2011-02-09 10:33:54 +02:00
2011-05-08 16:55:24 +00:00
2010-05-19 12:45:54 -03:00
2009-11-17 08:49:39 -06:00
2010-07-01 14:27:13 -03:00
2010-07-01 14:27:13 -03:00
2009-10-27 12:28:59 -05:00
2011-06-06 09:14:42 +02:00
2010-09-21 18:36:42 +02:00
2010-05-19 12:45:54 -03:00
2011-01-09 20:59:53 +00:00
2011-03-13 14:44:22 +00:00
2011-06-06 08:54:55 -05:00
2010-05-19 12:45:54 -03:00
2009-11-17 08:49:38 -06:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-10-01 10:12:43 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-05-19 12:45:54 -03:00
2010-09-18 05:53:14 +00:00
2008-12-14 08:50:18 +00:00
2011-06-14 09:34:34 -05:00
2009-09-13 19:38:43 +00:00
2010-03-14 22:04:50 +01:00
2008-12-04 11:29:42 +00:00
2009-10-01 16:12:16 -05:00
2009-03-05 23:01:23 +00:00
2011-02-02 08:39:28 +01:00
2008-09-06 16:31:30 +00:00
2011-06-15 19:58:48 +00:00
2011-05-08 10:10:01 +02:00
2011-05-08 10:10:01 +02:00

Read the documentation in qemu-doc.html.

Fabrice Bellard.
Description
No description provided
Readme 431 MiB
Languages
C 82.9%
C++ 6.4%
Python 3.2%
Dylan 2.9%
Shell 1.6%
Other 2.8%