linux-user important fixes for 2.7

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIVAwUAV6NM8bRIkN7ePJvAAQiK0BAAmmTJgRhaUxxm17gR5H9FH7db7knwmeir
 YliQAQDLeQi7h2CPHPnZ5swWxRpfFbfkRq3QlFhGisGK/DuVKhUkTADIHcrfGOQV
 9+yO/jF+uTqTV69mvbgvmPusyuJEXHk44IQ41k6F0ygTln1mrEwNsbz7/gfynVUd
 0SJSli1cThZHbr04YolW4UeIwHb4EP9ZGuB1QpyHMSJsBEmLt/0i7wqqth0734tV
 gLVNwTnlqZTiX9VpPeFheFAdUJ7a4eRYp5ydsxqnR/EcYE94MzQHvZVEsw9njy6Z
 hNTNoCVKXWxySd7kAsd3FsXfRxQTVksHIXwxnjyfjV8upv4O7Za3MCKQiE1XMu6v
 26ZVccLnoZEL+76yRDGjcHBTDFVV6TF0Z7dg7fOiXPn8EVg01fFeSBWiUDOnf9tj
 0E4CXlfH7yMczqasgFxuhgFk2V0xUq3UVB2Z7nxHEP+M9Hl6Vu5SlmybBJQ+36Nj
 hHZZPMMfwkQ721xjrIu2tzruU7gKt0a+T/4GaPWNcQ7HNplG4vlLJllcwRxsXn3q
 eN2NoRlf6nhhpxas8Jb7bEL2ThnpMPziXfuHNGeXB9AH6rFL4JvVjEK8QKhuuvac
 cyv08e0W6e+Z226KEsywi0GPnxo4/bSUa7JxbiB6PVal/Rfp9k1/hO7wzgNRrfv+
 PlQRKbfOwk4=
 =TVF0
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160804' into staging

linux-user important fixes for 2.7

# gpg: Signature made Thu 04 Aug 2016 15:10:57 BST
# gpg:                using RSA key 0xB44890DEDE3C9BC0
# gpg: Good signature from "Riku Voipio <riku.voipio@iki.fi>"
# gpg:                 aka "Riku Voipio <riku.voipio@linaro.org>"
# Primary key fingerprint: FF82 03C8 C391 98AE 0581  41EF B448 90DE DE3C 9BC0

* remotes/riku/tags/pull-linux-user-20160804:
  linux-user: Handle brk() attempts with very large sizes
  linux-user: Fix target_semid_ds structure definition
  linux-user: Don't write off end of new_utsname buffer
  linux-user: Fix memchr() argument in open_self_cmdline()
  linux-user: Use correct alignment for long long on i386 guests

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2016-08-04 18:36:05 +01:00
commit 42e0d60f16
3 changed files with 36 additions and 12 deletions

View File

@ -15,6 +15,10 @@
#define ABI_LLONG_ALIGNMENT 2
#endif
#if defined(TARGET_I386) && !defined(TARGET_X86_64)
#define ABI_LLONG_ALIGNMENT 4
#endif
#ifndef ABI_SHORT_ALIGNMENT
#define ABI_SHORT_ALIGNMENT 2
#endif

View File

@ -839,7 +839,7 @@ void target_set_brk(abi_ulong new_brk)
abi_long do_brk(abi_ulong new_brk)
{
abi_long mapped_addr;
int new_alloc_size;
abi_ulong new_alloc_size;
DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk);
@ -3754,27 +3754,30 @@ static struct shm_region {
bool in_use;
} shm_regions[N_SHM_REGIONS];
struct target_semid_ds
#ifndef TARGET_SEMID64_DS
/* asm-generic version of this struct */
struct target_semid64_ds
{
struct target_ipc_perm sem_perm;
abi_ulong sem_otime;
#if !defined(TARGET_PPC64)
#if TARGET_ABI_BITS == 32
abi_ulong __unused1;
#endif
abi_ulong sem_ctime;
#if !defined(TARGET_PPC64)
#if TARGET_ABI_BITS == 32
abi_ulong __unused2;
#endif
abi_ulong sem_nsems;
abi_ulong __unused3;
abi_ulong __unused4;
};
#endif
static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip,
abi_ulong target_addr)
{
struct target_ipc_perm *target_ip;
struct target_semid_ds *target_sd;
struct target_semid64_ds *target_sd;
if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1))
return -TARGET_EFAULT;
@ -3802,7 +3805,7 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr,
struct ipc_perm *host_ip)
{
struct target_ipc_perm *target_ip;
struct target_semid_ds *target_sd;
struct target_semid64_ds *target_sd;
if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0))
return -TARGET_EFAULT;
@ -3829,7 +3832,7 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr,
static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
abi_ulong target_addr)
{
struct target_semid_ds *target_sd;
struct target_semid64_ds *target_sd;
if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1))
return -TARGET_EFAULT;
@ -3845,7 +3848,7 @@ static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
static inline abi_long host_to_target_semid_ds(abi_ulong target_addr,
struct semid_ds *host_sd)
{
struct target_semid_ds *target_sd;
struct target_semid64_ds *target_sd;
if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0))
return -TARGET_EFAULT;
@ -6856,7 +6859,7 @@ static int open_self_cmdline(void *cpu_env, int fd)
if (!word_skipped) {
/* Skip the first string, which is the path to qemu-*-static
instead of the actual command. */
cp_buf = memchr(buf, 0, sizeof(buf));
cp_buf = memchr(buf, 0, nb_read);
if (cp_buf) {
/* Null byte found, skip one string */
cp_buf++;
@ -9237,12 +9240,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
goto efault;
ret = get_errno(sys_uname(buf));
if (!is_error(ret)) {
/* Overrite the native machine name with whatever is being
/* Overwrite the native machine name with whatever is being
emulated. */
strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
/* Allow the user to override the reported release. */
if (qemu_uname_release && *qemu_uname_release)
strcpy (buf->release, qemu_uname_release);
if (qemu_uname_release && *qemu_uname_release) {
g_strlcpy(buf->release, qemu_uname_release,
sizeof(buf->release));
}
}
unlock_user_struct(buf, arg1, 1);
}

View File

@ -55,4 +55,19 @@ struct target_shmid_ds {
abi_ulong __unused5;
};
/* The x86 definition differs from the generic one in that the
* two padding fields exist whether the ABI is 32 bits or 64 bits.
*/
#define TARGET_SEMID64_DS
struct target_semid64_ds {
struct target_ipc_perm sem_perm;
abi_ulong sem_otime;
abi_ulong __unused1;
abi_ulong sem_ctime;
abi_ulong __unused2;
abi_ulong sem_nsems;
abi_ulong __unused3;
abi_ulong __unused4;
};
#endif