From nobody Thu Nov 13 22:08:03 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=1582752927; cv=none; d=zohomail.com; s=zohoarc; b=H/QNLF1fcvmIZAJF8HgIjv1pC7BJpP8v92utib9V3PQY/mWaDiqmeoubZxxit9z0+Contyhnm6eCLBqGpsh41YfijLfvUap/gaXj/bv2fVKiIThXJ0TL+ZEzfS2SruE4hKXgWmfLwrod3Il4IjNs5Td7cF2koOx4LPznEgD6Z8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582752927; 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=mUWklJrwQfaH7a9ZIcqB2Vx5fUV2hTeWTbn989tFtX8=; b=hjlavu/49H1guz8Kmq4PWMijMOWlyuESD7f8WDat/dKh6jwKsiEy3aIJVoQFjD5cxa3i1Oc3zFNFaBhPbu9pidLYsS8Wn3bWHe6MBdpzMM3qpQnMTVnW3gzAGS2KPgiPHb0rLEOe0ifksOkMsSsZ9nYwz/wSZy4nyYMFub9avUM= 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 1582752926983414.773432855131; Wed, 26 Feb 2020 13:35:26 -0800 (PST) Received: from localhost ([::1]:50430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j74Kz-0007hf-DI for importer@patchew.org; Wed, 26 Feb 2020 16:35:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j74Jb-0006OA-6n for qemu-devel@nongnu.org; Wed, 26 Feb 2020 16:34:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j74JZ-00081m-Qe for qemu-devel@nongnu.org; Wed, 26 Feb 2020 16:33:59 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:40502) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j74JY-0007l8-By; Wed, 26 Feb 2020 16:33:57 -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; 27 Feb 2020 05:33:54 +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; 26 Feb 2020 13:26:19 -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; 26 Feb 2020 13:33:54 -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=1582752836; x=1614288836; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0c0ugoYRAqKkS8oTvWREh22YI+VnP4cmxoY3AkUADw=; b=GXDDeCPyeNSlkg3vlvaPY2Z1Lgc6gNEoRwO6P8LshDnVkS4xTEXVce5N zJ9CCMMywziHIFNoDm9Qt2buWWJGRQwPtdiq1+/byXeRW2tBw4iip8EGG T2IXMcPOR7wsNoNd+v8kXUTJGB1Umv8+SDRlgfUg64S9n8y9Ur8pofJwm 54/wRP0C45hcKYXEDJTau8wmcod1g5CT7vt5PzUfanScMHxrAn76+ZLZi aupoiZXFNpSDjsgC9deURw97vf9RxQMN3KgSBEowlvYt9IUH2MQLKUgTd Tvc9VtrXby3HwNGqy13cZB/7m2sQHjRj/LHQY+O/fxKWtnMWujCXneKai w==; IronPort-SDR: 9XJkbXv3UBQHMAPuSmlOf7BZLDM5b8lhMIExkv1+ONrSymJgxKs85/bU6Cydk9jNKORwedjTfG HUZCa5hUABOIz42T03Ksr44otGDj6gjj+m7ElVv7ycgqXDZDky7xBnwivXExyXoiY+tCm6IhH0 lhJNdqvnM3luTPGPOFN/dXR9eGjVTUW5zBYVtFe3XjvhzYkWFCIpSHMSLqDGhF/Edrl7cllRtS H1ym5KFxPkt1vqymoxg/tnLeOEHrB/2CiFk7mkYG+avQICniZrLj7aB2gl3HyBvnjqnblFEa/+ b08= X-IronPort-AV: E=Sophos;i="5.70,489,1574092800"; d="scan'208";a="130835626" IronPort-SDR: 3sxEvDpgXBFnFuAkZ4fsQTOauJNM3IVzAbWn3gky5bNdx0pGJ68E/jNbPfeil28dxsNbjJS/6b 5/tB2xAI70dcIRrHodFQZ0RmeGuoiUh4cM13ueQADE1m9YN0oH8o0OE2XiXi02081FFBFo+IVG tKYdHEdiz9Fyzgy2qSS5dSjM6SfXuPM8Xf52VuBxtur1AmtceDR8zBGAmwwEWi2rb9yBgmJuow Od37VwreflL60u+0wSimfvEHgDmGYGXVmgtKBffidLeJjOgjBqxxbNtjD0Rx+P919ugaE/peuW RzkbMiiyFDMx8XbtXtCNS79m IronPort-SDR: jXanbtO3S8mzfyjy7qeA5A7aZpxN+ak+16a+VGd7vUcwNU5T01McMcC02ZMX5UT1QmTJUNLZuS IuGEXlNQ011he9Ua2e7+kaKwWBY2YUCpb4s6clElWUkiY48MQ+sT6MAFTtog2Kmm8Et58K61w9 Hq2gBHQ+HUaY0/kARLn805xGVUp0/6rwDifUPLKuCyuf6dTubxgCtNqSk2DRRuIqQwVWc5Z239 SkNTmSrTZLfQkLsLxsBDRq+m45qm9n9dayxEk3VRadHyz8HNrl7I9vMogTXu+DEdD1fBpMuGuG +ck= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, laurent@vivier.eu Subject: [PATCH v3 1/2] linux-user: Protect more syscalls Date: Wed, 26 Feb 2020 13:26:43 -0800 Message-Id: <116a3b5db2bd582b6f94f3816818ebbeb5f84e47.1582752329.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.154.42 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..fecb58773b 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) || defined(TARGET_NR_waitpid) 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