From patchwork Mon Jul 16 16:10:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142043 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2604107ljj; Mon, 16 Jul 2018 09:12:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfXlJsq7TnYUbPngqJMdV8e9ZvBjIS2/kJDiOJfJHWTp1ucoRPKKJd/pFY2mdym+75HODhB X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr16016805pgb.452.1531757525060; Mon, 16 Jul 2018 09:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531757525; cv=none; d=google.com; s=arc-20160816; b=v8hXheDPWverywRDHV69ZM/FQXPGGgP0zWtm517Q0gKMh4/XT1NV1NoHurKDHCoepJ IV9WcLe2gwxKdwbnwA+DB+55ASP/gAg9EkXgCF3WT9SS0j65Ayvk4TgMqAmkTlQ14a8i dToZXKPDyj5VNuAIxHvXd7OyWGCM45u4rqzPBQkcptmL+uS9sYXsvhPOlgyYJDDWtadL Do85NtUHJwyBguIb0q8TG+ucHDakT9r1t9UVx1Q5PAR6W6N/QRKHQjeU3wNANQA5kY/E yG8EH5/S3Zs7BYl3QbssmL8vmB+m7ljZSUoRLS7tT1Mb9I/4RRQibf++HW1QXFFniRay N6Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OlECP7fOxVe8dNo6xDpLknyaDUc4A/y5FGLEtPWDcLg=; b=N8PL46NmlodaaPKr4wyTlYD795YoppbLdwDsZz4EjMEuc1MdgrcoliguhIJnd2d7wX s6+ZJtGS5ypV+2+7jpdJDPz5YKI6BmUtaIFhIz9keKq2xkLNUpM4Ze8XhhHICUEneGGx 3C3xshR/rracYKNnBtS3/htht0XtlhLzi+vgbdrzUn229DI4ccxGkNLSdVb2BW9g9RkW Cdu914nzCMyE3R/fKg18DFJXP1sfe0qDGD+pR+Th2CcjHlnPMye88I5TSzel3x7jA3N8 PU8V+fR2X7kAGxoLrg7K0/avRKzY18dnj/pJ2XzmgfQv/+c1hzC4+GJlZGhuoi6+wyLN Sayw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18-v6si30410996pfh.84.2018.07.16.09.12.04; Mon, 16 Jul 2018 09:12:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730710AbeGPQkI (ORCPT + 10 others); Mon, 16 Jul 2018 12:40:08 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:46951 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730079AbeGPQkI (ORCPT ); Mon, 16 Jul 2018 12:40:08 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0M6t73-1g05JT0wOT-00wmvD; Mon, 16 Jul 2018 18:11:10 +0200 From: Arnd Bergmann To: tglx@linutronix.de Cc: y2038@lists.linaro.org, hch@infradead.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, albert.aribaud@3adev.fr, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, peterz@infradead.org, dvhart@infradead.org, ebiederm@xmission.com, linux@dominikbrodowski.net, Arnd Bergmann Subject: [PATCH v2 07/17] y2038: Compile utimes()/futimesat() conditionally Date: Mon, 16 Jul 2018 18:10:53 +0200 Message-Id: <20180716161103.16239-8-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180716161103.16239-1-arnd@arndb.de> References: <20180716161103.16239-1-arnd@arndb.de> X-Provags-ID: V03:K1:AIKjKnAv/8yUsKblZ6iCmDsRB5OJVhUFV1UYn2eDpG7tHQ7bZwa R/Hptho2x6kRu8YU1OQw3VGim+sMYzwAdsYka7+yC7RtPoNEBcWdPkcy0glwKmsGzifThK+ UUAkF56ZQ64NZeeoFodjieCM4wFfPqJZMInqGJnezdmzeiyHxF0gYtg9KZhuMsh8qupmXLY Ji1iJA6PdIESrc4ryFaDA== X-UI-Out-Filterresults: notjunk:1; V01:K0:3jUKL2eKf5c=:BtCnuBOB2lDJ0zaf9iR1ep JxCR2IbsXR/EfTKVWUTtozBl8cCufgTH1DdSRbo6rGhVaiDorS8spTQJvxawvQOcocp00q985 nVzZB3njAhGjz0a3BW0LSW9XblnNYPbO+zmcpkhBG8khp0YV7YNIjfWlRWdcJ2QFHxPQEzqBB IXfpntTkC7RkjSRB4ZhlskDthbtI1ICMaLCY5sG5Lic8uMRux6XtPrAIbxSuaEVHRWqbBJs21 ONTryp/WeeG/jM1ThiDtsn1BJJZ3M1IUNnoEbIGJjgQ5qQKZBF4QicrGBoKOdZb5ZzoM4qHel Q3c3sz/Eo/hNTU0EOd8TU1IMUARxjvsfGNwolBxLD76hvhyeCib+k0HC6xxwYv76chKKILWYx aewDmwm+nkJX3tWGCaWyGglQbT4NQ/twsGubOx6hdGluY8eX4rw/sjjniMWj2/gURk4OdVHBs 1zZ0aDiSvJfx2jQWaDRjVrfk1+sTfECmUAgxJYuIc/+T+JXHsnLQTC9ujARrLJE6VB/zL2zr2 VPcIOQTroHj90dQADOPcb6CIjeMMrye24ak8JTJoGuxFyKn8A3DR+BN4z5dkkEZWGP7gQb1DM SdR7bUU7ofQmDcztOgltp8KRg9c1gLiArxgICTfaNapj+sWRmrq2xgW6wCmUtTEQnZnQL2+uK JLN3HfDgIUeFN4BO/j9VuoxUZGevg+32QkEapAcuB27OQPc6Qsycl5oo0PPkqT6C5/DE= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are four generations of utimes() syscalls: utime(), utimes(), futimesat() and utimensat(), each one being a superset of the previous one. For y2038 support, we have to add another one, which is the same as the existing utimensat() but always passes 64-bit times_t based timespec values. There are currently 10 architectures that only use utimensat(), two that use utimes(), futimesat() and utimensat() but not utime(), and 11 architectures that have all four, and those define __ARCH_WANT_SYS_UTIME in order to get a sys_utime implementation. Since all the new architectures only want utimensat(), moving all the legacy entry points into a common __ARCH_WANT_SYS_UTIME guard simplifies the logic. Only alpha and ia64 grow a tiny bit as they now also get an unused sys_utime(), but it didn't seem worth the extra complexity of adding yet another ifdef for those. Signed-off-by: Arnd Bergmann --- arch/alpha/include/asm/unistd.h | 1 + arch/arm/include/asm/unistd.h | 2 +- arch/ia64/include/asm/unistd.h | 1 + fs/utimes.c | 51 ++++++++++++++++++----------------------- include/linux/syscalls.h | 10 ++++---- 5 files changed, 31 insertions(+), 34 deletions(-) -- 2.9.0 diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index edc090470023..9ff37aa1165f 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h @@ -14,6 +14,7 @@ #define __ARCH_WANT_SYS_GETPGRP #define __ARCH_WANT_SYS_OLDUMOUNT #define __ARCH_WANT_SYS_SIGPENDING +#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_FORK #define __ARCH_WANT_SYS_VFORK #define __ARCH_WANT_SYS_CLONE diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index 8f1159c26f20..88ef2ce1f69a 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h @@ -26,13 +26,13 @@ #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_OLD_MMAP #define __ARCH_WANT_SYS_OLD_SELECT +#define __ARCH_WANT_SYS_UTIME #if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT) #define __ARCH_WANT_SYS_TIME #define __ARCH_WANT_SYS_IPC #define __ARCH_WANT_SYS_OLDUMOUNT #define __ARCH_WANT_SYS_ALARM -#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_OLD_GETRLIMIT #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_SYS_SOCKETCALL diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h index c5b2620c4a4c..49e34db2529c 100644 --- a/arch/ia64/include/asm/unistd.h +++ b/arch/ia64/include/asm/unistd.h @@ -29,6 +29,7 @@ #define __IGNORE_umount2 /* umount() */ #define __ARCH_WANT_NEW_STAT +#define __ARCH_WANT_SYS_UTIME #if !defined(__ASSEMBLY__) && !defined(ASSEMBLER) diff --git a/fs/utimes.c b/fs/utimes.c index ca2c02a7985c..ebc7fb713d91 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -8,35 +8,6 @@ #include #include -#ifdef __ARCH_WANT_SYS_UTIME - -/* - * sys_utime() can be implemented in user-level using sys_utimes(). - * Is this for backwards compatibility? If so, why not move it - * into the appropriate arch directory (for those architectures that - * need it). - */ - -/* If times==NULL, set access and modification to current time, - * must be owner or have write permission. - * Else, update from *times, must be owner or super user. - */ -SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times) -{ - struct timespec64 tv[2]; - - if (times) { - if (get_user(tv[0].tv_sec, ×->actime) || - get_user(tv[1].tv_sec, ×->modtime)) - return -EFAULT; - tv[0].tv_nsec = 0; - tv[1].tv_nsec = 0; - } - return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0); -} - -#endif - static bool nsec_valid(long nsec) { if (nsec == UTIME_OMIT || nsec == UTIME_NOW) @@ -184,6 +155,13 @@ SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, return do_utimes(dfd, filename, utimes ? tstimes : NULL, flags); } +#ifdef __ARCH_WANT_SYS_UTIME +/* + * futimesat(), utimes() and utime() are older versions of utimensat() + * that are provided for compatibility with traditional C libraries. + * On modern architectures, we always use libc wrappers around + * utimensat() instead. + */ static long do_futimesat(int dfd, const char __user *filename, struct timeval __user *utimes) { @@ -225,6 +203,21 @@ SYSCALL_DEFINE2(utimes, char __user *, filename, return do_futimesat(AT_FDCWD, filename, utimes); } +SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times) +{ + struct timespec64 tv[2]; + + if (times) { + if (get_user(tv[0].tv_sec, ×->actime) || + get_user(tv[1].tv_sec, ×->modtime)) + return -EFAULT; + tv[0].tv_nsec = 0; + tv[1].tv_nsec = 0; + } + return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0); +} +#endif + #ifdef CONFIG_COMPAT /* * Not all architectures have sys_utime, so implement this in terms diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 45c04d75eb95..312c248f1fe6 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -965,8 +965,6 @@ asmlinkage long sys_access(const char __user *filename, int mode); asmlinkage long sys_rename(const char __user *oldname, const char __user *newname); asmlinkage long sys_symlink(const char __user *old, const char __user *new); -asmlinkage long sys_utimes(char __user *filename, - struct timeval __user *utimes); #if defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_COMPAT_STAT64) asmlinkage long sys_stat64(const char __user *filename, struct stat64 __user *statbuf); @@ -996,14 +994,18 @@ asmlinkage long sys_alarm(unsigned int seconds); asmlinkage long sys_getpgrp(void); asmlinkage long sys_pause(void); asmlinkage long sys_time(time_t __user *tloc); +#ifdef __ARCH_WANT_SYS_UTIME asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times); +asmlinkage long sys_utimes(char __user *filename, + struct timeval __user *utimes); +asmlinkage long sys_futimesat(int dfd, const char __user *filename, + struct timeval __user *utimes); +#endif asmlinkage long sys_creat(const char __user *pathname, umode_t mode); asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user *dirent, unsigned int count); -asmlinkage long sys_futimesat(int dfd, const char __user *filename, - struct timeval __user *utimes); asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp); asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,