From patchwork Fri Apr 1 01:51:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 8719801 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3F270C0553 for ; Fri, 1 Apr 2016 01:53:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AAF9201CE for ; Fri, 1 Apr 2016 01:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8BD72015A for ; Fri, 1 Apr 2016 01:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753695AbcDABxC (ORCPT ); Thu, 31 Mar 2016 21:53:02 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:38008 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422AbcDABxA (ORCPT ); Thu, 31 Mar 2016 21:53:00 -0400 Received: by mail-ig0-f179.google.com with SMTP id ui10so3153644igc.1; Thu, 31 Mar 2016 18:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BzW+jAkZ9572se3AS6Hmig3CtiVBX+gzaJe+yfsdfTI=; b=nNX2z+sdpRxzp+dSc7idE6VtwAwd8296W3PzPsFJZynUR1EcoyXJxW8uc2oQeZ0icx IVOL9wtIUyCEWAdKpifdMvq3wwe1m62ipvR5E6zjQ5wMeQBDomEO8ISjY1khpYkS5wml LFzKpvZGyYXN10eP28xgAYy77fT515OxbPTaX3HRqt/47WOX+95Wqgru95G/QLXsPr9b kXWcpI26c/+i8EsQk3BJQZwrhcONsaRxpdfCUuxYJahNWauESgzIlgs5TaEq0OGItO/u uPX67xVvTnM+bQjPPseVeychBWXwzXh/zx2hKLz+gdA1NuTC52rPsQdF76lWbWGDGf+o wVug== 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=BzW+jAkZ9572se3AS6Hmig3CtiVBX+gzaJe+yfsdfTI=; b=m/iCaXm5YXBqvg9Rs1Xf413IMKsqn9rXC63kz0Go2PMPb1OlAXYnnqPZuJDWAJhk6m 5436Rwq9pQ276HRDDLmkp0sBxsAodCCCMycCcMkesEVUYtguEseQpTwjbHTR7wxWGXvC mdmu6wCP1cpUH3m7JZH6dDpVERdeOwb7d1PJBuPJhUx+g2rGEXX7qhGXt2oG/49Ywq+D FjaMCBGMw6Gxb54ILr/kb1MM+fo2TdPvgGUXJY7KuMZtqZDvkvpMrmZ5RJLoU8yJV61b TJsa6G1fqUdvcF9KDDoGfaYHPxbDQBjqXRtmbXh9b1y+gyWG46z8JAaaf1Mh1QEDkm1i jdvA== X-Gm-Message-State: AD7BkJK/YelCzyFpMyW+9JqZexTnRkqlaqgQbpl6Ih6k9NF4zP3K+xJANCWZmcXLjW5SYA== X-Received: by 10.50.132.39 with SMTP id or7mr790220igb.38.1459475579728; Thu, 31 Mar 2016 18:52:59 -0700 (PDT) Received: from localhost.localdomain (c-24-7-245-123.hsd1.mn.comcast.net. [24.7.245.123]) by smtp.gmail.com with ESMTPSA id oq8sm4904714igb.7.2016.03.31.18.52.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 18:52:59 -0700 (PDT) From: Eric Biggers To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH v2] vfs: constify arguments to utime family of system calls Date: Thu, 31 Mar 2016 20:51:12 -0500 Message-Id: <1459475472-13104-1-git-send-email-ebiggers3@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.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 | 4 ++-- 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, 32 insertions(+), 25 deletions(-) diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 6cc0816..20b4c85 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -952,7 +952,7 @@ struct itimerval32 }; static inline long -get_tv32(struct timeval *o, struct timeval32 __user *i) +get_tv32(struct timeval *o, const struct timeval32 __user *i) { return (!access_ok(VERIFY_READ, i, sizeof(*i)) || (__get_user(o->tv_sec, &i->tv_sec) | @@ -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 f964ef7..def595d 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -461,10 +461,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); @@ -485,9 +485,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 d795472..3b83e59 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, @@ -771,7 +771,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); @@ -784,7 +784,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 *);