Re: [Y2038] [PATCH v2 2/6] ipc: mqueue: Replace timespec with timespec64

2017-08-01 Thread Deepa Dinamani
> The audit bits look fine.  Deepa, I assume you are going to seek to
> have this go in through a tree other than audit?
>
> Acked-by: Paul Moore 

Yes, the proposal was to go through Al's tree since he already has a
few ipc patches queued up.

Thanks,
Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH v2 2/6] ipc: mqueue: Replace timespec with timespec64

2017-07-31 Thread Paul Moore
On Sun, Jul 30, 2017 at 6:30 PM, Deepa Dinamani  wrote:
> struct timespec is not y2038 safe. Replace
> all uses of timespec by y2038 safe struct timespec64.
>
> Even though timespec is used here to represent timeouts,
> replace these with timespec64 so that it facilitates
> in verification by creating a y2038 safe kernel image
> that is free of timespec.
>
> The syscall interfaces themselves are not changed as part
> of the patch. They will be part of a different series.
>
> Signed-off-by: Deepa Dinamani 
> Cc: Paul Moore 
> Cc: Richard Guy Briggs 
> Reviewed-by: Richard Guy Briggs 
> ---
>  include/linux/audit.h |  6 +++---
>  ipc/mqueue.c  | 28 ++--
>  kernel/audit.h|  2 +-
>  kernel/auditsc.c  | 12 ++--
>  4 files changed, 24 insertions(+), 24 deletions(-)

The audit bits look fine.  Deepa, I assume you are going to seek to
have this go in through a tree other than audit?

Acked-by: Paul Moore 

> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 2150bdccfbab..74d4d4e8e3db 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -351,7 +351,7 @@ extern int __audit_socketcall(int nargs, unsigned long 
> *args);
>  extern int __audit_sockaddr(int len, void *addr);
>  extern void __audit_fd_pair(int fd1, int fd2);
>  extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
> -extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
> msg_prio, const struct timespec *abs_timeout);
> +extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
> msg_prio, const struct timespec64 *abs_timeout);
>  extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent 
> *notification);
>  extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
>  extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
> @@ -412,7 +412,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
> struct mq_attr *attr)
> if (unlikely(!audit_dummy_context()))
> __audit_mq_open(oflag, mode, attr);
>  }
> -static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned 
> int msg_prio, const struct timespec *abs_timeout)
> +static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned 
> int msg_prio, const struct timespec64 *abs_timeout)
>  {
> if (unlikely(!audit_dummy_context()))
> __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
> @@ -549,7 +549,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
> struct mq_attr *attr)
>  { }
>  static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
>  unsigned int msg_prio,
> -const struct timespec *abs_timeout)
> +const struct timespec64 *abs_timeout)
>  { }
>  static inline void audit_mq_notify(mqd_t mqdes,
>const struct sigevent *notification)
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index c9ff943f19ab..5be1346a9167 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -668,11 +668,11 @@ static void __do_notify(struct mqueue_inode_info *info)
>  }
>
>  static int prepare_timeout(const struct timespec __user *u_abs_timeout,
> -  struct timespec *ts)
> +  struct timespec64 *ts)
>  {
> -   if (copy_from_user(ts, u_abs_timeout, sizeof(struct timespec)))
> +   if (get_timespec64(ts, u_abs_timeout))
> return -EFAULT;
> -   if (!timespec_valid(ts))
> +   if (!timespec64_valid(ts))
> return -EINVAL;
> return 0;
>  }
> @@ -962,7 +962,7 @@ static inline void pipelined_receive(struct wake_q_head 
> *wake_q,
>
>  static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
> size_t msg_len, unsigned int msg_prio,
> -   struct timespec *ts)
> +   struct timespec64 *ts)
>  {
> struct fd f;
> struct inode *inode;
> @@ -979,7 +979,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user 
> *u_msg_ptr,
> return -EINVAL;
>
> if (ts) {
> -   expires = timespec_to_ktime(*ts);
> +   expires = timespec64_to_ktime(*ts);
> timeout = &expires;
> }
>
> @@ -1080,7 +1080,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char 
> __user *u_msg_ptr,
>
>  static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
> size_t msg_len, unsigned int __user *u_msg_prio,
> -   struct timespec *ts)
> +   struct timespec64 *ts)
>  {
> ssize_t ret;
> struct msg_msg *msg_ptr;
> @@ -1092,7 +1092,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user 
> *u_msg_ptr,
> struct posix_msg_tree_node *new_leaf = NULL;
>
> if (ts) {
> -   expires = timespec_to_ktime(*ts);
> +   expires = ti

[Y2038] [PATCH v2 2/6] ipc: mqueue: Replace timespec with timespec64

2017-07-30 Thread Deepa Dinamani
struct timespec is not y2038 safe. Replace
all uses of timespec by y2038 safe struct timespec64.

Even though timespec is used here to represent timeouts,
replace these with timespec64 so that it facilitates
in verification by creating a y2038 safe kernel image
that is free of timespec.

The syscall interfaces themselves are not changed as part
of the patch. They will be part of a different series.

Signed-off-by: Deepa Dinamani 
Cc: Paul Moore 
Cc: Richard Guy Briggs 
Reviewed-by: Richard Guy Briggs 
---
 include/linux/audit.h |  6 +++---
 ipc/mqueue.c  | 28 ++--
 kernel/audit.h|  2 +-
 kernel/auditsc.c  | 12 ++--
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 2150bdccfbab..74d4d4e8e3db 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -351,7 +351,7 @@ extern int __audit_socketcall(int nargs, unsigned long 
*args);
 extern int __audit_sockaddr(int len, void *addr);
 extern void __audit_fd_pair(int fd1, int fd2);
 extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
-extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
msg_prio, const struct timespec *abs_timeout);
+extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
msg_prio, const struct timespec64 *abs_timeout);
 extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent 
*notification);
 extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
 extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
@@ -412,7 +412,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
struct mq_attr *attr)
if (unlikely(!audit_dummy_context()))
__audit_mq_open(oflag, mode, attr);
 }
-static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
msg_prio, const struct timespec *abs_timeout)
+static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
msg_prio, const struct timespec64 *abs_timeout)
 {
if (unlikely(!audit_dummy_context()))
__audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
@@ -549,7 +549,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
struct mq_attr *attr)
 { }
 static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
 unsigned int msg_prio,
-const struct timespec *abs_timeout)
+const struct timespec64 *abs_timeout)
 { }
 static inline void audit_mq_notify(mqd_t mqdes,
   const struct sigevent *notification)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index c9ff943f19ab..5be1346a9167 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -668,11 +668,11 @@ static void __do_notify(struct mqueue_inode_info *info)
 }
 
 static int prepare_timeout(const struct timespec __user *u_abs_timeout,
-  struct timespec *ts)
+  struct timespec64 *ts)
 {
-   if (copy_from_user(ts, u_abs_timeout, sizeof(struct timespec)))
+   if (get_timespec64(ts, u_abs_timeout))
return -EFAULT;
-   if (!timespec_valid(ts))
+   if (!timespec64_valid(ts))
return -EINVAL;
return 0;
 }
@@ -962,7 +962,7 @@ static inline void pipelined_receive(struct wake_q_head 
*wake_q,
 
 static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
size_t msg_len, unsigned int msg_prio,
-   struct timespec *ts)
+   struct timespec64 *ts)
 {
struct fd f;
struct inode *inode;
@@ -979,7 +979,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user 
*u_msg_ptr,
return -EINVAL;
 
if (ts) {
-   expires = timespec_to_ktime(*ts);
+   expires = timespec64_to_ktime(*ts);
timeout = &expires;
}
 
@@ -1080,7 +1080,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user 
*u_msg_ptr,
 
 static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
size_t msg_len, unsigned int __user *u_msg_prio,
-   struct timespec *ts)
+   struct timespec64 *ts)
 {
ssize_t ret;
struct msg_msg *msg_ptr;
@@ -1092,7 +1092,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user 
*u_msg_ptr,
struct posix_msg_tree_node *new_leaf = NULL;
 
if (ts) {
-   expires = timespec_to_ktime(*ts);
+   expires = timespec64_to_ktime(*ts);
timeout = &expires;
}
 
@@ -1184,7 +1184,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char 
__user *, u_msg_ptr,
size_t, msg_len, unsigned int, msg_prio,
const struct timespec __user *, u_abs_timeout)
 {
-   struct timespec ts, *p = NULL;
+   struct timespec64 ts, *p = NULL;
if (u_abs_timeout) {