From patchwork Fri Jun 12 07:37:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 49787 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D5F62228DB for ; Fri, 12 Jun 2015 07:39:11 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf7584152lbb.0 for ; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=uSVoFTMMFhA5NoR54/YsArXZaeeaR7/lCPdaY0T+X+g=; b=Ycho8/RhN7ixa0ikobTlizEDf8QX2q8MOx2rPEOIk+cuxPCBuXO5R/c6J1CjcdtF/+ zLiwkruD3kom1IeakwYxaqQCYXJfKMULfUuGKpl3oaeMt9bdmCWYf9I5d++DSy6r1Gbq irQ15SFzojYPheuUjzfkh9JoeI6Mw/FxW3rYwfivXErQvW+Iqdi7eiUilgl6ce/Kvmhv Il119YrnF6trJcKWO6JheHgertzn3wqnrbNtoBApExFgcLRqoUYAJKHfSdjHJ/6oNTV8 e1WyrDr+Xw88q+aHdPJmHK3hKbUdB7rs3XcrlesF8eul/F7qlQicD9+/CbXhruNMCvEv JDLA== X-Gm-Message-State: ALoCoQmNZvMNjimhrTvwYlnO3TKoDfGelsgZgJlhrOC5Rxprx82rXmRdglKQIA2WpGRMtE/0fLAo X-Received: by 10.112.219.200 with SMTP id pq8mr12870593lbc.7.1434094750693; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.169 with SMTP id r9ls500216laj.86.gmail; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) X-Received: by 10.112.72.2 with SMTP id z2mr13609374lbu.39.1434094750515; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id wm10si2691995lbb.149.2015.06.12.00.39.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2015 00:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbcmx3 with SMTP id mx3so15249184lbc.1 for ; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr13617184lak.29.1434094750356; Fri, 12 Jun 2015 00:39:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp350386lbb; Fri, 12 Jun 2015 00:39:09 -0700 (PDT) X-Received: by 10.69.25.41 with SMTP id in9mr20952415pbd.80.1434094748554; Fri, 12 Jun 2015 00:39:08 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hu6si4206426pac.153.2015.06.12.00.39.07; Fri, 12 Jun 2015 00:39:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbbFLHjA (ORCPT + 29 others); Fri, 12 Jun 2015 03:39:00 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36507 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbbFLHi5 (ORCPT ); Fri, 12 Jun 2015 03:38:57 -0400 Received: by pabqy3 with SMTP id qy3so17952549pab.3 for ; Fri, 12 Jun 2015 00:38:57 -0700 (PDT) X-Received: by 10.69.10.196 with SMTP id ec4mr21262602pbd.69.1434094737182; Fri, 12 Jun 2015 00:38:57 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id jt2sm2703303pbc.21.2015.06.12.00.38.52 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 00:38:56 -0700 (PDT) From: Baolin Wang To: serge.hallyn@canonical.com Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, james.l.morris@oracle.com, serge@hallyn.com, paul@paul-moore.com, john.johansen@canonical.com, sds@tycho.nsa.gov, casey@schaufler-ca.com, penguin-kernel@I-love.SAKURA.ne.jp, neilb@suse.de, edumazet@google.com, jlayton@primarydata.com, linux-security-module@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v5 03/24] security: Introduce security_settime64() Date: Fri, 12 Jun 2015 15:37:42 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Due to the security_settime() with timespec type is not year 2038 safe on 32bit systems. Introduce the security_settime64() function with timespec64 type. Change the settime() callback of security_list_options structure argument with timespec64 type as a helper function wrapped by security_settime64(). The cap_settime() as a helper function is only called by security_settime64() and security_settime() functions, and it need change the argument with timespec64 type. Signed-off-by: Baolin Wang --- include/linux/lsm_hooks.h | 5 +++-- include/linux/security.h | 20 +++++++++++++++++--- security/commoncap.c | 2 +- security/security.c | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 9429f05..d791f35 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -1191,7 +1191,8 @@ * Return 0 if permission is granted. * @settime: * Check permission to change the system time. - * struct timespec and timezone are defined in include/linux/time.h + * struct timespec64 is defined in include/linux/time64.h and timezone + * is defined in include/linux/time.h * @ts contains new time * @tz contains new timezone * Return 0 if permission is granted. @@ -1324,7 +1325,7 @@ union security_list_options { int (*quotactl)(int cmds, int type, int id, struct super_block *sb); int (*quota_on)(struct dentry *dentry); int (*syslog)(int type); - int (*settime)(const struct timespec *ts, const struct timezone *tz); + int (*settime)(const struct timespec64 *ts, const struct timezone *tz); int (*vm_enough_memory)(struct mm_struct *mm, long pages); int (*bprm_set_creds)(struct linux_binprm *bprm); diff --git a/include/linux/security.h b/include/linux/security.h index 79d85dd..520f903 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -69,7 +69,7 @@ struct timezone; /* These functions are in security/commoncap.c */ extern int cap_capable(const struct cred *cred, struct user_namespace *ns, int cap, int audit); -extern int cap_settime(const struct timespec *ts, const struct timezone *tz); +extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz); extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); extern int cap_ptrace_traceme(struct task_struct *parent); extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); @@ -206,7 +206,13 @@ int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns, int security_quotactl(int cmds, int type, int id, struct super_block *sb); int security_quota_on(struct dentry *dentry); int security_syslog(int type); -int security_settime(const struct timespec *ts, const struct timezone *tz); +int security_settime64(const struct timespec64 *ts, const struct timezone *tz); +static int security_settime(const struct timespec *ts, const struct timezone *tz) +{ + struct timespec64 ts64 = timespec_to_timespec64(*ts); + + return security_settime64(&ts64, tz); +} int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); int security_bprm_set_creds(struct linux_binprm *bprm); int security_bprm_check(struct linux_binprm *bprm); @@ -457,10 +463,18 @@ static inline int security_syslog(int type) return 0; } +static inline int security_settime64(const struct timespec64 *ts, + const struct timezone *tz) +{ + return cap_settime(ts, tz); +} + static inline int security_settime(const struct timespec *ts, const struct timezone *tz) { - return cap_settime(ts, tz); + struct timsepc64 ts64 = timespec_to_timespec64(*ts); + + return cap_settime(&ts64, tz); } static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) diff --git a/security/commoncap.c b/security/commoncap.c index d103f5a4..17b1f79 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -111,7 +111,7 @@ int cap_capable(const struct cred *cred, struct user_namespace *targ_ns, * Determine whether the current process may set the system clock and timezone * information, returning 0 if permission granted, -ve if denied. */ -int cap_settime(const struct timespec *ts, const struct timezone *tz) +int cap_settime(const struct timespec64 *ts, const struct timezone *tz) { if (!capable(CAP_SYS_TIME)) return -EPERM; diff --git a/security/security.c b/security/security.c index 595fffa..8d0dbd6 100644 --- a/security/security.c +++ b/security/security.c @@ -213,7 +213,7 @@ int security_syslog(int type) return call_int_hook(syslog, 0, type); } -int security_settime(const struct timespec *ts, const struct timezone *tz) +int security_settime64(const struct timespec64 *ts, const struct timezone *tz) { return call_int_hook(settime, 0, ts, tz); }