[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit target
From: |
Laurent Vivier |
Subject: |
[PULL 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets. |
Date: |
Mon, 15 Feb 2021 13:45:15 +0100 |
From: Stefan <stefan-guix@vodafonemail.de>
The sizeof(struct ifreq) is 40 for 64 bit and 32 for 32 bit architectures.
This structure contains a union of other structures, of which struct ifmap
is the biggest for 64 bit architectures. Calling ioclt(…, SIOCGIFCONF, …)
fills a struct sockaddr of that union, and do_ioctl_ifconf() only considered
that struct sockaddr for the size of the union, which has the same size as
struct ifmap on 32 bit architectures. So do_ioctl_ifconf() assumed a wrong
size of 32 for struct ifreq instead of the correct size of 40 on 64 bit
architectures.
The fix makes do_ioctl_ifconf() handle struct ifmap as the biggest part of
the union, treating struct ifreq with the correct size.
Signed-off-by: Stefan <stefan-guix@vodafonemail.de>
Message-Id: <60AA0765-53DD-43D1-A3D2-75F1778526F6@vodafonemail.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dcb4009e2f17..6fea00869e6b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4914,6 +4914,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie,
uint8_t *buf_temp,
struct ifconf *host_ifconf;
uint32_t outbufsz;
const argtype ifreq_arg_type[] = { MK_STRUCT(STRUCT_sockaddr_ifreq) };
+ const argtype ifreq_max_type[] = { MK_STRUCT(STRUCT_ifmap_ifreq) };
int target_ifreq_size;
int nb_ifreq;
int free_buf = 0;
@@ -4937,7 +4938,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie,
uint8_t *buf_temp,
host_ifconf = (struct ifconf *)(unsigned long)buf_temp;
target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf;
- target_ifreq_size = thunk_type_size(ifreq_arg_type, 0);
+ target_ifreq_size = thunk_type_size(ifreq_max_type, 0);
if (target_ifc_buf != 0) {
target_ifc_len = host_ifconf->ifc_len;
--
2.29.2
- [PULL 00/13] Linux user for 6.0 patches, Laurent Vivier, 2021/02/15
- [PULL 05/13] linux-user: fix O_NONBLOCK usage for hppa target, Laurent Vivier, 2021/02/15
- [PULL 06/13] linux-user: fix O_NONBLOCK in signalfd4() and eventfd2() syscalls, Laurent Vivier, 2021/02/15
- [PULL 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets.,
Laurent Vivier <=
- [PULL 07/13] linux-user: Fix loading of BSS segments, Laurent Vivier, 2021/02/15
- [PULL 04/13] linux-user: Add missing TARGET___O_TMPFILE for hppa and alpha, Laurent Vivier, 2021/02/15
- [PULL 12/13] docs/user: Remove outdated 'Quick Start' section, Laurent Vivier, 2021/02/15
- [PULL 13/13] linux-user/mips: Support the n32 ABI for the R5900, Laurent Vivier, 2021/02/15
- [PULL 10/13] linux-user: add TARGET_SO_{DOMAIN,PROTOCOL}, Laurent Vivier, 2021/02/15
- [PULL 08/13] linux-user/mmap: Avoid asserts for out of range mremap calls, Laurent Vivier, 2021/02/15
- [PULL 02/13] linux-user/mips64: Support o32 ABI syscalls, Laurent Vivier, 2021/02/15
- [PULL 01/13] linux-user/mips64: Restore setup_frame() for o32 ABI, Laurent Vivier, 2021/02/15
- [PULL 11/13] linux-user: target: signal: Support TARGET_SS_AUTODISARM, Laurent Vivier, 2021/02/15
- [PULL 03/13] linux-user/signal: Decode waitid si_code, Laurent Vivier, 2021/02/15