From nobody Thu Nov 13 20:42:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1582587080; cv=none; d=zohomail.com; s=zohoarc; b=cIwyynemFvtUc/5e9DI5sFpqEmtcXTY+v4ho+qjw/Svy/1aBul4IGJEVFCZDAYxY9bNuxIEuPNtGgD5Tl1lGM3s8qpaaCEYFQ/xef5IsdPtVeijmZmP0KbHmKmUlFL7UvRfeCuL9xWazi0dKaZq7hGrlXJ7n6FzU+CAZEjCJ780= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582587080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RBOItDOn7916uMhHDY3XA5eRf0XV6V2eyRE01N1t4P0=; b=QggeWvzBhNULDOnka26sBZ+WRFoeTX5BOOWc8qgde3z9xGKUCE60dNGe8a6d+dvxdN4D3K68tBKK+w5FYdIv8gvLk9Xh3zDfrVjDGUmqjepLEX66giA40sADmfKCCuhM1EbLteoLk73fw+QcLh0UEr0AyimOQknE5J12AuO2AJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582587080413791.5312017356249; Mon, 24 Feb 2020 15:31:20 -0800 (PST) Received: from localhost ([::1]:46060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6NC3-0004ev-2P for importer@patchew.org; Mon, 24 Feb 2020 18:31:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45962) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6N9v-0001xI-Jp for qemu-devel@nongnu.org; Mon, 24 Feb 2020 18:29:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6N9u-0003hN-A2 for qemu-devel@nongnu.org; Mon, 24 Feb 2020 18:29:07 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:4174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6N9u-0003gT-0e; Mon, 24 Feb 2020 18:29:06 -0500 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 25 Feb 2020 07:29:03 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 15:21:30 -0800 Received: from risc6-mainframe.sdcorp.global.sandisk.com (HELO risc6-mainframe.int.fusionio.com) ([10.196.158.235]) by uls-op-cesaip01.wdc.com with ESMTP; 24 Feb 2020 15:29:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1582586946; x=1614122946; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WR1s30QTxgrMwzoOjNhcXBMg/VXTr9of7TRctj5C1jE=; b=OL1M6bsu+mZEYD0RBtqYJUSFr/lnptJwmNY0k+aKtZ6PBAhcWnKeH5B9 wlrp1eQgQuUaMKd8TULeNvZeWHCDWN3OD8ptl1IW6LsbWk6zMXspv71a0 x7z1ntSr6gtVEsB6DwVd/QUNkk4ZwuCgjQ/HrTbUiMknc9zInxIOrTvYc u+8w2WLqLqX6Ah2F9xcAkMQz9MQf0B9qflHO4I2okY6KP+RK+vv4xrQVk yDYAJwGZcAqclF4sMSluVsMfStTdJoYxvxAMFa94GBq9KVfbJxy/ncQWJ a/4qlirsuN+5I+G3t5HvqddvFLNHEgafYmj++l/OgnfjgUvL7mZnacozB Q==; IronPort-SDR: Z1btjKQrhNk3gfnN53R0b8AgBJ+E4Ig2m4IPw4VwJF3FEvnX3LLGIoycWlj/nNrSJA9z17232m Yz4OcRKE24tvr/+rxSOqjMyYerdArL9kX1+pwjwCAwUdLuLqHtWffeZHiqLxgINmpdou8S131K n4Hg+HUMW4IoNItqyf8TA5ImRT876itG0djAJU39jWgtKG06K5g6nLJBfP/UUPrMhiRrzCKMLx M4Zi5sruQwP6G0NgP8EBnSUzYBeXbJJyXYDQMaQOoxltqd6Ci6Le4cvRIYLzydbfdkgf16TCx/ O44= X-IronPort-AV: E=Sophos;i="5.70,481,1574092800"; d="scan'208";a="131148352" IronPort-SDR: EX5DvkacbNYjOFpSZ1+WDz/N8GaIuCSEm1xQKm0qi/lrJcCx32WPGFju/p31kVK63F0YZEL4UB KlRzdSngIp7GDFMAQk/qKz0aaET/SHBn5MWqDCog2JdIZHk4AAYhD3BRps4bLUv0Ux4YtZrNfO Ch+2emp5CmlGV/6svXrpEdXrZdFDzX20wYLLWq5geHlGz5Ueqs/AZoULj1CL416HxyeLxGz3ni 8XRoN2x0mYri5Cw3Tn1YOPLrDI8Y+CqNz9EqzzB8OANsn3MhXRH4J8sK7A6RYHa4yhRbQUKRUX aLJYC99HLOUzwyx5V/vPjARS IronPort-SDR: vRFHye3atgXhC6Dcx4xIWLih/7iFpzder6ER0y3PCuRKjk61zeVHk1KRlXGJOS2PGNEcIlZHPe nmvQHNX+JPI1MRHDzP1qRoAj7GTbKFFIlYM+2TzoNeElwhmYA+LgiicTPT0DN6ctAc8VEgPE2P 7p1V8wgope565WhuUh5B4oYRvFXn6gM/asVzsBmr8zIlHMC4Zfa9xXMFxHVXlcJkYehLwuNU3H XQ6ordH54sFzReaq/ObNHmR/0W2HOpA16KOGavlzP8SlrgLj1O/UAtWpsjl805umUZ15Gd5pqB 3i4= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, laurent@vivier.eu Subject: [PATCH v2 1/2] linux-user: Protect more syscalls Date: Mon, 24 Feb 2020 15:21:54 -0800 Message-Id: <205d84c5c51c54c8bb6a4a2927b7e1729fe42cdd.1582586444.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 216.71.153.144 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) New y2038 safe 32-bit architectures (like RISC-V) don't support old syscalls with a 32-bit time_t. The kernel defines new *_time64 versions of these syscalls. Add some more #ifdefs to syscall.c in linux-user to allow us to compile without these old syscalls. Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/strace.c | 2 ++ linux-user/syscall.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 4f7130b2ff..6420ccd97b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -775,6 +775,7 @@ print_syscall_ret_newselect(const struct syscallname *n= ame, abi_long ret) #define TARGET_TIME_OOP 3 /* leap second in progress */ #define TARGET_TIME_WAIT 4 /* leap second has occurred */ #define TARGET_TIME_ERROR 5 /* clock not synchronized */ +#ifdef TARGET_NR_adjtimex static void print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) { @@ -813,6 +814,7 @@ print_syscall_ret_adjtimex(const struct syscallname *na= me, abi_long ret) =20 qemu_log("\n"); } +#endif =20 UNUSED static struct flags access_flags[] =3D { FLAG_GENERIC(F_OK), diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8d27d10807..5a2156f95a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -742,8 +742,10 @@ safe_syscall3(ssize_t, read, int, fd, void *, buff, si= ze_t, count) safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count) safe_syscall4(int, openat, int, dirfd, const char *, pathname, \ int, flags, mode_t, mode) +#if defined(TARGET_NR_wait4) safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ struct rusage *, rusage) +#endif safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop,= \ int, options, struct rusage *, rusage) safe_syscall3(int, execve, const char *, filename, char **, argv, char **,= envp) @@ -780,8 +782,10 @@ safe_syscall4(int, rt_sigtimedwait, const sigset_t *, = these, siginfo_t *, uinfo, const struct timespec *, uts, size_t, sigsetsize) safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *,= len, int, flags) +#if defined(TARGET_NR_nanosleep) safe_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) +#endif #ifdef TARGET_NR_clock_nanosleep safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, const struct timespec *, req, struct timespec *, rem) @@ -1067,6 +1071,7 @@ static inline abi_long host_to_target_rusage(abi_ulon= g target_addr, return 0; } =20 +#ifdef TARGET_NR_setrlimit static inline rlim_t target_to_host_rlim(abi_ulong target_rlim) { abi_ulong target_rlim_swap; @@ -1082,7 +1087,9 @@ static inline rlim_t target_to_host_rlim(abi_ulong ta= rget_rlim) =20 return result; } +#endif =20 +#if defined(TARGET_NR_getrlimit) || defined(TARGET_NR_ugetrlimit) static inline abi_ulong host_to_target_rlim(rlim_t rlim) { abi_ulong target_rlim_swap; @@ -1096,6 +1103,7 @@ static inline abi_ulong host_to_target_rlim(rlim_t rl= im) =20 return result; } +#endif =20 static inline int target_to_host_resource(int code) { @@ -1228,6 +1236,7 @@ static inline abi_long host_to_target_timespec64(abi_= ulong target_addr, return 0; } =20 +#if defined(TARGET_NR_settimeofday) static inline abi_long copy_from_user_timezone(struct timezone *tz, abi_ulong target_tz_addr) { @@ -1244,6 +1253,7 @@ static inline abi_long copy_from_user_timezone(struct= timezone *tz, =20 return 0; } +#endif =20 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) #include @@ -8629,6 +8639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, } } return ret; +#if defined(TARGET_NR_gettimeofday) case TARGET_NR_gettimeofday: { struct timeval tv; @@ -8639,6 +8650,8 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, } } return ret; +#endif +#if defined(TARGET_NR_settimeofday) case TARGET_NR_settimeofday: { struct timeval tv, *ptv =3D NULL; @@ -8660,6 +8673,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, =20 return get_errno(settimeofday(ptv, ptz)); } +#endif #if defined(TARGET_NR_select) case TARGET_NR_select: #if defined(TARGET_WANT_NI_OLD_SELECT) @@ -9305,6 +9319,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); #endif +#if defined(TARGET_NR_wait4) case TARGET_NR_wait4: { int status; @@ -9332,6 +9347,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, } } return ret; +#endif #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p =3D lock_user_string(arg1))) @@ -9476,6 +9492,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, return do_vm86(cpu_env, arg1, arg2); #endif #endif +#if defined(TARGET_NR_adjtimex) case TARGET_NR_adjtimex: { struct timex host_buf; @@ -9491,6 +9508,7 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, } } return ret; +#endif #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) case TARGET_NR_clock_adjtime: { @@ -10016,6 +10034,7 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, } } return ret; +#if defined(TARGET_NR_nanosleep) case TARGET_NR_nanosleep: { struct timespec req, rem; @@ -10026,6 +10045,7 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, } } return ret; +#endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: --=20 2.25.0