From nobody Sat May 4 22:31:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495205542971920.7687630588804; Fri, 19 May 2017 07:52:22 -0700 (PDT) Received: from localhost ([::1]:59115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBjGO-0005BD-Kx for importer@patchew.org; Fri, 19 May 2017 10:52:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBjEu-0004LH-CE for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBjEr-0004Kh-9I for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44299 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBjEr-0004KV-39 for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:45 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JETp9i139833 for ; Fri, 19 May 2017 10:50:44 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2aj2cah9qr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 May 2017 10:50:44 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 May 2017 10:50:43 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 May 2017 10:50:40 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4JEofDN46006286; Fri, 19 May 2017 14:50:41 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36BC3112051; Fri, 19 May 2017 10:50:49 -0400 (EDT) Received: from [192.168.0.243] (unknown [9.164.171.209]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 8AF0111204B; Fri, 19 May 2017 10:50:48 -0400 (EDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 16:50:38 +0200 In-Reply-To: <149520531371.9327.383828886525307842.stgit@bahia> References: <149520531371.9327.383828886525307842.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 17051914-0044-0000-0000-00000332A41F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007085; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00862633; UDB=6.00428030; IPR=6.00642383; BA=6.00005358; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015510; XFM=3.00000015; UTC=2017-05-19 14:50:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051914-0045-0000-0000-00000760B160 Message-Id: <149520543823.9327.7184796595968970706.stgit@bahia> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190092 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 1/2] 9pfs: assume utimensat() and futimens() are present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The utimensat() and futimens() syscalls have been around for ages (ie, glibc 2.6 and linux 2.6.22), and the decision was already taken to switch to utimensat() anyway when fixing CVE-2016-9602 in 2.9. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- fsdev/virtfs-proxy-helper.c | 3 ++- hw/9pfs/9p-handle.c | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 54f7ad1c48f0..617e19cd0b88 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -945,7 +945,8 @@ static int process_requests(int sock) &spec[0].tv_sec, &spec[0].tv_nsec, &spec[1].tv_sec, &spec[1].tv_nsec); if (retval > 0) { - retval =3D qemu_utimens(path.data, spec); + retval =3D utimensat(AT_FDCWD, path.data, spec, + AT_SYMLINK_NOFOLLOW); if (retval < 0) { retval =3D -errno; } diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c index 1687661bc95a..9875f1894cc5 100644 --- a/hw/9pfs/9p-handle.c +++ b/hw/9pfs/9p-handle.c @@ -378,7 +378,6 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *f= s_path, const struct timespec *buf) { int ret; -#ifdef CONFIG_UTIMENSAT int fd; struct handle_data *data =3D (struct handle_data *)ctx->private; =20 @@ -388,10 +387,6 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *= fs_path, } ret =3D futimens(fd, buf); close(fd); -#else - ret =3D -1; - errno =3D ENOSYS; -#endif return ret; } =20 From nobody Sat May 4 22:31:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495205642752404.77590084245867; Fri, 19 May 2017 07:54:02 -0700 (PDT) Received: from localhost ([::1]:59119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBjI1-0006d2-Fa for importer@patchew.org; Fri, 19 May 2017 10:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBjF1-0004Pj-1o for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBjEx-0004M1-S4 for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38018 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBjEx-0004Ls-MQ for qemu-devel@nongnu.org; Fri, 19 May 2017 10:50:51 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JEkIEO121384 for ; Fri, 19 May 2017 10:50:51 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ahvaxu388-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 May 2017 10:50:50 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 May 2017 10:50:50 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 May 2017 10:50:47 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4JEogqw10158486; Fri, 19 May 2017 14:50:47 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B3F4AE034; Fri, 19 May 2017 10:50:35 -0400 (EDT) Received: from [192.168.0.243] (unknown [9.164.171.209]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id D9037AE051; Fri, 19 May 2017 10:50:34 -0400 (EDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 16:50:45 +0200 In-Reply-To: <149520531371.9327.383828886525307842.stgit@bahia> References: <149520531371.9327.383828886525307842.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 17051914-0040-0000-0000-00000343392C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007085; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00862633; UDB=6.00428030; IPR=6.00642383; BA=6.00005358; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015511; XFM=3.00000015; UTC=2017-05-19 14:50:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051914-0041-0000-0000-0000073769C6 Message-Id: <149520544530.9327.4054335919728922017.stgit@bahia> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190092 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 2/2] util: drop old utimensat() compat code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Now that 9pfs and virtfs-proxy-helper have been converted to utimensat(), we don't need to keep qemu_utimens() anymore. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- configure | 22 --------------------- include/sysemu/os-posix.h | 11 ----------- util/oslib-posix.c | 47 -----------------------------------------= ---- 3 files changed, 80 deletions(-) diff --git a/configure b/configure index 139638e922e0..1dea17ed2e73 100755 --- a/configure +++ b/configure @@ -3623,25 +3623,6 @@ if compile_prog "" "" ; then inotify1=3Dyes fi =20 -# check if utimensat and futimens are supported -utimens=3Dno -cat > $TMPC << EOF -#define _ATFILE_SOURCE -#include -#include -#include - -int main(void) -{ - utimensat(AT_FDCWD, "foo", NULL, 0); - futimens(0, NULL); - return 0; -} -EOF -if compile_prog "" "" ; then - utimens=3Dyes -fi - # check if pipe2 is there pipe2=3Dno cat > $TMPC << EOF @@ -5427,9 +5408,6 @@ fi if test "$curses" =3D "yes" ; then echo "CONFIG_CURSES=3Dy" >> $config_host_mak fi -if test "$utimens" =3D "yes" ; then - echo "CONFIG_UTIMENSAT=3Dy" >> $config_host_mak -fi if test "$pipe2" =3D "yes" ; then echo "CONFIG_PIPE2=3Dy" >> $config_host_mak fi diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h index 900bdcb45ad0..629c8c648b7a 100644 --- a/include/sysemu/os-posix.h +++ b/include/sysemu/os-posix.h @@ -51,17 +51,6 @@ int os_mlock(void); typedef struct timeval qemu_timeval; #define qemu_gettimeofday(tp) gettimeofday(tp, NULL) =20 -#ifndef CONFIG_UTIMENSAT -#ifndef UTIME_NOW -# define UTIME_NOW ((1l << 30) - 1l) -#endif -#ifndef UTIME_OMIT -# define UTIME_OMIT ((1l << 30) - 2l) -#endif -#endif -typedef struct timespec qemu_timespec; -int qemu_utimens(const char *path, const qemu_timespec *times); - bool is_daemonized(void); =20 /** diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4d9189e9efcf..7e28c161b257 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -207,53 +207,6 @@ int qemu_pipe(int pipefd[2]) return ret; } =20 -int qemu_utimens(const char *path, const struct timespec *times) -{ - struct timeval tv[2], tv_now; - struct stat st; - int i; -#ifdef CONFIG_UTIMENSAT - int ret; - - ret =3D utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); - if (ret !=3D -1 || errno !=3D ENOSYS) { - return ret; - } -#endif - /* Fallback: use utimes() instead of utimensat() */ - - /* happy if special cases */ - if (times[0].tv_nsec =3D=3D UTIME_OMIT && times[1].tv_nsec =3D=3D UTIM= E_OMIT) { - return 0; - } - if (times[0].tv_nsec =3D=3D UTIME_NOW && times[1].tv_nsec =3D=3D UTIME= _NOW) { - return utimes(path, NULL); - } - - /* prepare for hard cases */ - if (times[0].tv_nsec =3D=3D UTIME_NOW || times[1].tv_nsec =3D=3D UTIME= _NOW) { - gettimeofday(&tv_now, NULL); - } - if (times[0].tv_nsec =3D=3D UTIME_OMIT || times[1].tv_nsec =3D=3D UTIM= E_OMIT) { - stat(path, &st); - } - - for (i =3D 0; i < 2; i++) { - if (times[i].tv_nsec =3D=3D UTIME_NOW) { - tv[i].tv_sec =3D tv_now.tv_sec; - tv[i].tv_usec =3D tv_now.tv_usec; - } else if (times[i].tv_nsec =3D=3D UTIME_OMIT) { - tv[i].tv_sec =3D (i =3D=3D 0) ? st.st_atime : st.st_mtime; - tv[i].tv_usec =3D 0; - } else { - tv[i].tv_sec =3D times[i].tv_sec; - tv[i].tv_usec =3D times[i].tv_nsec / 1000; - } - } - - return utimes(path, &tv[0]); -} - char * qemu_get_local_state_pathname(const char *relative_pathname) {