Fixes for epoll_ctl and stack_t

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAl+sWkASHGxhdXJlbnRA
 dml2aWVyLmV1AAoJEPMMOL0/L748ncsQAI6JaS5BJM25vFslcplXyX1jBd8sXk+Z
 CnzgI/moLKr1HZRc3DecHbttApptHg+B4Twp/FqBCTk1gpqDsAUKmIgdqPZhP7Xj
 rsaUqXLJkChJtA5IFImMtI1XhQhuoI+S/AJ6l2gwnXaRqb0xILbonSXk9d2t+qpN
 aq9ho8yZfrB4025kSkEvE7YogPOKdNJdNGjPLn1MSiDP8syzgAKTSOcMehjiGQoC
 90uyDDZqBx6JcFzF7kKl3K0MJxpKrqaEkV8iELQ6UI/SHfVPp/ToaYvgPvy+kloh
 iAuy71PrVWHredeLmyzgwB+fZyq0O+XWFfhw9r37Lo6fn6MQ1xIaNAUzF7+fEBB5
 +2tIxpkeWrOfb2Eu0aagAVEHpFR+1MmtGYwdoxNXFvP15IOLFpGyxAY86m6haBsA
 j3w6lyt51iK6vJt4IYZJjMnh81LZ2fxTCBQs23kH+cxRu2wEc97qkkgNJSjzCCOv
 rgkHpw2cxT16IkqSlFZVu9w8Rv+sibUJWxtcJsYo9Xwy0R5tHoZNn5uzwdo1wTHJ
 ZUY3s9ag6dEle63jMwATZDsekvQVW6AHceFkc7OIr6mMvIynijSQAoi+JZbs4ysD
 NaNklc01H3IJMIv6e5iiWhFVdJL6Nm/mRXU6GC6yn2bp5dhY++GGcPevz+BDfP+v
 FzxALaxQoIHP
 =bIlV
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.2-pull-request' into staging

Fixes for epoll_ctl and stack_t

# gpg: Signature made Wed 11 Nov 2020 21:40:16 GMT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-5.2-pull-request:
  linux-user: Prevent crash in epoll_ctl
  linux-user: Correct definition of stack_t

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-11-11 21:54:01 +00:00
commit 674ee1245b
16 changed files with 56 additions and 49 deletions

View File

@ -42,8 +42,7 @@
typedef struct target_sigaltstack {
abi_ulong ss_sp;
int32_t ss_flags;
int32_t dummy;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_ulong ss_size;
abi_long ss_flags;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -44,7 +44,7 @@
typedef struct target_sigaltstack {
abi_ulong ss_sp;
int32_t ss_flags;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_ulong ss_size;
abi_long ss_flags;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -45,9 +45,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_long ss_sp;
abi_ulong ss_size;
abi_long ss_flags;
abi_ulong ss_sp;
abi_ulong ss_size;
abi_int ss_flags;
} target_stack_t;

View File

@ -45,12 +45,11 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_long ss_sp;
abi_ulong ss_size;
abi_int ss_flags;
abi_ulong ss_sp;
abi_ulong ss_size;
abi_int ss_flags;
} target_stack_t;
/*
* sigaltstack controls
*/

View File

@ -4,11 +4,12 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_long ss_sp;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
abi_long ss_flags;
} target_stack_t;
/* sigaltstack controls */
#define TARGET_SS_ONSTACK 1
#define TARGET_SS_DISABLE 2

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
int ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -3,7 +3,7 @@
typedef struct target_sigaltstack {
abi_ulong ss_sp;
int ss_flags;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -42,9 +42,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;

View File

@ -12590,17 +12590,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
struct epoll_event ep;
struct epoll_event *epp = 0;
if (arg4) {
struct target_epoll_event *target_ep;
if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) {
return -TARGET_EFAULT;
if (arg2 != EPOLL_CTL_DEL) {
struct target_epoll_event *target_ep;
if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) {
return -TARGET_EFAULT;
}
ep.events = tswap32(target_ep->events);
/*
* The epoll_data_t union is just opaque data to the kernel,
* so we transfer all 64 bits across and need not worry what
* actual data type it is.
*/
ep.data.u64 = tswap64(target_ep->data.u64);
unlock_user_struct(target_ep, arg4, 0);
}
ep.events = tswap32(target_ep->events);
/* The epoll_data_t union is just opaque data to the kernel,
* so we transfer all 64 bits across and need not worry what
* actual data type it is.
/*
* before kernel 2.6.9, EPOLL_CTL_DEL operation required a
* non-null pointer, even though this argument is ignored.
*
*/
ep.data.u64 = tswap64(target_ep->data.u64);
unlock_user_struct(target_ep, arg4, 0);
epp = &ep;
}
return get_errno(epoll_ctl(arg1, arg2, arg3, epp));

View File

@ -4,9 +4,9 @@
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
abi_ulong ss_sp;
abi_int ss_flags;
abi_ulong ss_size;
} target_stack_t;