From patchwork Tue Mar 1 05:20:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 8461991 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A39089F372 for ; Tue, 1 Mar 2016 05:20:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 664EA20304 for ; Tue, 1 Mar 2016 05:20:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20370202FF for ; Tue, 1 Mar 2016 05:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751172AbcCAFUa (ORCPT ); Tue, 1 Mar 2016 00:20:30 -0500 Received: from mail-ig0-f172.google.com ([209.85.213.172]:34835 "EHLO mail-ig0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbcCAFU3 (ORCPT ); Tue, 1 Mar 2016 00:20:29 -0500 Received: by mail-ig0-f172.google.com with SMTP id hb3so10899060igb.0; Mon, 29 Feb 2016 21:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=jBo5C1WXFVg55suXAFyd16biT73+xx7QYAV711SZAlY=; b=pqJBasHJAKeifAIBqFn80DVMYFncfvdeMkRw4K4ewwcv6a5iWwXR0BnzknkP2vaG02 kNh3oqFbBrSE0Fa393x4Bscnf3+Y/W6iArDhsz8DaZd6NvKIoLaIpbKSN7HPGTtQYUyR ph48IOwBlEomdYQYJjNY5Ha8WS0K/bVtki2u/MYIP1fxJZ8OvnkKjT+02bPB6zYF/dlo Bca4lty6AdWFwcgAMSFt0fFf/a818c2453I9mI7crIuPjevxvK9ckT+894UhhGbGpbiU qLmPUG1psyavtqkRVAhviwDEOrIGDX3vpYd5naVqcEVc8bg95hfH670SrH0EyH+GC+rd JnVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jBo5C1WXFVg55suXAFyd16biT73+xx7QYAV711SZAlY=; b=M/KVxi/t/leswvHjB/slaZ+tU2Oeosn8LyFPm4PdFL1MOPLrmrChCPyDrgHbHEJpUZ 6sb9k4LF1IuELvC0pFXrYoeqmUVh4U59HPpLjZvyhKlBcwf7LBKyzRXjCmx48xvyjgFW WCfBNvP/sJnC31ic4iv/T7SxC9OQ79v1kMGqR9VO13uF2M/7YuR2Ye4kcPtwVXZzt7DL bA/HlTXsNHTSVyegdWzlBXlVt3OzwLIVn5fHPdH3dyDg9NHElySD0m+kCz9RxWsdRfg0 SGo98rJxRacLkabP8ZPZYdh+OcZvC1tAX1Obm2fBukH5+XDOJf13dHrvjdLrDFBhEB4L S0LQ== X-Gm-Message-State: AD7BkJLzyWscqCenuIC5V7Ca76FAv1A/RFWM4HJ+uujuWsqwjEvRZaTSgE2AJC/5fb9XEA== X-Received: by 10.50.156.35 with SMTP id wb3mr1750084igb.60.1456809628808; Mon, 29 Feb 2016 21:20:28 -0800 (PST) Received: from localhost.localdomain (c-24-7-245-123.hsd1.mn.comcast.net. [24.7.245.123]) by smtp.gmail.com with ESMTPSA id s38sm12201944ioe.33.2016.02.29.21.20.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 21:20:28 -0800 (PST) From: Eric Biggers To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH] vfs: constify arguments to utime family of system calls Date: Mon, 29 Feb 2016 23:20:09 -0600 Message-Id: <1456809609-29137-1-git-send-email-ebiggers3@gmail.com> X-Mailer: git-send-email 2.7.2 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The system calls to set file times: utime(), utimes(), futimesat(), and utimensat(), all take in pointers to a filename and time information, neither of which is modified. Mark the pointed-to data as 'const' to better reflect the semantics. Signed-off-by: Eric Biggers --- arch/alpha/kernel/osf_sys.c | 2 +- fs/compat.c | 13 +++++++++---- fs/utimes.c | 17 +++++++++-------- include/linux/compat.h | 8 ++++---- include/linux/syscalls.h | 12 ++++++------ include/linux/time.h | 3 ++- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 6cc0816..f3e557c 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -1065,7 +1065,7 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in, } SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, - struct timeval32 __user *, tvs) + const struct timeval32 __user *, tvs) { struct timespec tv[2]; diff --git a/fs/compat.c b/fs/compat.c index a71936a..5a6aa35 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -73,7 +73,7 @@ int compat_printk(const char *fmt, ...) * of sys_utimes. */ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, - struct compat_utimbuf __user *, t) + const struct compat_utimbuf __user *, t) { struct timespec tv[2]; @@ -87,7 +87,9 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); } -COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags) +COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, + const char __user *, filename, + const struct compat_timespec __user *, t, int, flags) { struct timespec tv[2]; @@ -102,7 +104,9 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena return do_utimes(dfd, filename, t ? tv : NULL, flags); } -COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t) +COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, + const char __user *, filename, + const struct compat_timeval __user *, t) { struct timespec tv[2]; @@ -121,7 +125,8 @@ COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filena return do_utimes(dfd, filename, t ? tv : NULL, 0); } -COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t) +COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, + const struct compat_timeval __user *, t) { return compat_sys_futimesat(AT_FDCWD, filename, t); } diff --git a/fs/utimes.c b/fs/utimes.c index 85c40f4..4954214 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -24,7 +24,8 @@ * 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) +SYSCALL_DEFINE2(utime, const char __user *, filename, + const struct utimbuf __user *, times) { struct timespec tv[2]; @@ -48,7 +49,7 @@ static bool nsec_valid(long nsec) return nsec >= 0 && nsec <= 999999999; } -static int utimes_common(struct path *path, struct timespec *times) +static int utimes_common(struct path *path, const struct timespec *times) { int error; struct iattr newattrs; @@ -133,8 +134,8 @@ out: * must be owner or have write permission. * Else, update from *times, must be owner or super user. */ -long do_utimes(int dfd, const char __user *filename, struct timespec *times, - int flags) +long do_utimes(int dfd, const char __user *filename, + const struct timespec *times, int flags) { int error = -EINVAL; @@ -183,7 +184,7 @@ out: } SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, - struct timespec __user *, utimes, int, flags) + const struct timespec __user *, utimes, int, flags) { struct timespec tstimes[2]; @@ -201,7 +202,7 @@ SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, } SYSCALL_DEFINE3(futimesat, int, dfd, const char __user *, filename, - struct timeval __user *, utimes) + const struct timeval __user *, utimes) { struct timeval times[2]; struct timespec tstimes[2]; @@ -228,8 +229,8 @@ SYSCALL_DEFINE3(futimesat, int, dfd, const char __user *, filename, return do_utimes(dfd, filename, utimes ? tstimes : NULL, 0); } -SYSCALL_DEFINE2(utimes, char __user *, filename, - struct timeval __user *, utimes) +SYSCALL_DEFINE2(utimes, const char __user *, filename, + const struct timeval __user *, utimes) { return sys_futimesat(AT_FDCWD, filename, utimes); } diff --git a/include/linux/compat.h b/include/linux/compat.h index a76c917..d9bbfdb 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -453,10 +453,10 @@ asmlinkage long compat_sys_epoll_pwait(int epfd, compat_size_t sigsetsize); asmlinkage long compat_sys_utime(const char __user *filename, - struct compat_utimbuf __user *t); + const struct compat_utimbuf __user *t); asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, - struct compat_timespec __user *t, + const struct compat_timespec __user *t, int flags); asmlinkage long compat_sys_time(compat_time_t __user *tloc); @@ -477,9 +477,9 @@ asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, int flags); asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, - struct compat_timeval __user *t); + const struct compat_timeval __user *t); asmlinkage long compat_sys_utimes(const char __user *filename, - struct compat_timeval __user *t); + const struct compat_timeval __user *t); asmlinkage long compat_sys_newstat(const char __user *filename, struct compat_stat __user *statbuf); asmlinkage long compat_sys_newlstat(const char __user *filename, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 185815c..a82bb1f 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -550,10 +550,10 @@ asmlinkage long sys_getgid16(void); asmlinkage long sys_getegid16(void); #endif -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_utime(const char __user *filename, + const struct utimbuf __user *times); +asmlinkage long sys_utimes(const char __user *filename, + const struct timeval __user *utimes); asmlinkage long sys_lseek(unsigned int fd, off_t offset, unsigned int whence); asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high, @@ -765,7 +765,7 @@ asmlinkage long sys_renameat2(int olddfd, const char __user *oldname, int newdfd, const char __user *newname, unsigned int flags); asmlinkage long sys_futimesat(int dfd, const char __user *filename, - struct timeval __user *utimes); + const struct timeval __user *utimes); asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode); asmlinkage long sys_fchmodat(int dfd, const char __user * filename, umode_t mode); @@ -778,7 +778,7 @@ asmlinkage long sys_newfstatat(int dfd, const char __user *filename, asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf, int bufsiz); asmlinkage long sys_utimensat(int dfd, const char __user *filename, - struct timespec __user *utimes, int flags); + const struct timespec __user *utimes, int flags); asmlinkage long sys_unshare(unsigned long unshare_flags); asmlinkage long sys_splice(int fd_in, loff_t __user *off_in, diff --git a/include/linux/time.h b/include/linux/time.h index 297f09f..20b28fb 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -174,7 +174,8 @@ extern int do_getitimer(int which, struct itimerval *value); extern unsigned int alarm_setitimer(unsigned int seconds); -extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags); +extern long do_utimes(int dfd, const char __user *filename, + const struct timespec *times, int flags); struct tms; extern void do_sys_times(struct tms *);