All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: tglx@linutronix.de, viro@zeniv.linux.org.uk,
	gregkh@linuxfoundation.org, andreas.dilger@intel.com,
	arnd@arndb.de, bfields@fieldses.org, clm@fb.com,
	davem@davemloft.net, dsterba@suse.com, dushistov@mail.ru,
	eparis@redhat.com, jaegeuk@kernel.org, jbacik@fb.com,
	jlayton@poochiereds.net, john.stultz@linaro.org,
	jsimmons@infradead.org, mingo@redhat.com, oleg.drokin@intel.com,
	paul@paul-moore.com, rostedt@goodmis.org, yuchao0@huawei.com,
	ceph-devel@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-audit@redhat.com, linux-btrfs@vger.kernel.org,
	linux-cifs@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-security-module@vger.kernel.org,
	lustre-devel@lists.lustre.org, netdev@vger.kernel.org,
	samba-technical@lists.samba.org, y2038@lists.linaro.org
Subject: [PATCH 06/12] audit: Use timespec64 to represent audit timestamps
Date: Fri,  7 Apr 2017 17:57:04 -0700	[thread overview]
Message-ID: <1491613030-11599-7-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1491613030-11599-1-git-send-email-deepa.kernel@gmail.com>

struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c        | 10 +++++-----
 kernel/audit.h        |  2 +-
 kernel/auditsc.c      |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 6fdfefc..f830508 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
 				/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial);
+			      struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -511,7 +511,7 @@ static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial)
+			      struct timespec64 *t, unsigned int *serial)
 {
 	return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 2f4964c..fcbf377 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1625,10 +1625,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-				   struct timespec *t, unsigned int *serial)
+				   struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-		*t = CURRENT_TIME;
+		ktime_get_real_ts64(t);
 		*serial = audit_serial();
 	}
 }
@@ -1652,7 +1652,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 				     int type)
 {
 	struct audit_buffer *ab;
-	struct timespec t;
+	struct timespec64 t;
 	unsigned int uninitialized_var(serial);
 
 	if (audit_initialized != AUDIT_INITIALIZED)
@@ -1705,8 +1705,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 	}
 
 	audit_get_stamp(ab->ctx, &t, &serial);
-	audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-			 t.tv_sec, t.tv_nsec/1000000, serial);
+	audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+			 (unsigned long long)t.tv_sec, t.tv_nsec/1000000, serial);
 
 	return ab;
 }
diff --git a/kernel/audit.h b/kernel/audit.h
index 0f1cf6d..cdf96f4 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
 	enum audit_state    state, current_state;
 	unsigned int	    serial;     /* serial number for record */
 	int		    major;      /* syscall number */
-	struct timespec	    ctime;      /* time of syscall entry */
+	struct timespec64   ctime;      /* time of syscall entry */
 	unsigned long	    argv[4];    /* syscall arguments */
 	long		    return_code;/* syscall return code */
 	u64		    prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e59ffc7..a2d9217 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1532,7 +1532,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,
 		return;
 
 	context->serial     = 0;
-	context->ctime      = CURRENT_TIME;
+	ktime_get_real_ts64(&context->ctime);
 	context->in_syscall = 1;
 	context->current_state  = state;
 	context->ppid       = 0;
@@ -1941,13 +1941,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-		       struct timespec *t, unsigned int *serial)
+		       struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx->in_syscall)
 		return 0;
-- 
2.7.4


WARNING: multiple messages have this Message-ID (diff)
From: Deepa Dinamani <deepa.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Cc: yuchao0-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org,
	clm-b10kYP2dOMg@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	dushistov-JGs/UdohzUI@public.gmane.org,
	jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org,
	tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org,
	y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	arnd-r2nGTMty4D4@public.gmane.org,
	rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org,
	oleg.drokin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
	dsterba-IBi9RG/b67k@public.gmane.org,
	jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jbacik-b10kYP2dOMg@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org,
	eparis-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-f2fs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	linux-btrfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	lustre-devel-aLEFhgZF4x6X6Mz3xDxJMA@public.gmane.org
Subject: [PATCH 06/12] audit: Use timespec64 to represent audit timestamps
Date: Fri,  7 Apr 2017 17:57:04 -0700	[thread overview]
Message-ID: <1491613030-11599-7-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1491613030-11599-1-git-send-email-deepa.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Acked-by: Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org>
Acked-by: Richard Guy Briggs <rgb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c        | 10 +++++-----
 kernel/audit.h        |  2 +-
 kernel/auditsc.c      |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 6fdfefc..f830508 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
 				/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial);
+			      struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -511,7 +511,7 @@ static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial)
+			      struct timespec64 *t, unsigned int *serial)
 {
 	return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 2f4964c..fcbf377 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1625,10 +1625,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-				   struct timespec *t, unsigned int *serial)
+				   struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-		*t = CURRENT_TIME;
+		ktime_get_real_ts64(t);
 		*serial = audit_serial();
 	}
 }
@@ -1652,7 +1652,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 				     int type)
 {
 	struct audit_buffer *ab;
-	struct timespec t;
+	struct timespec64 t;
 	unsigned int uninitialized_var(serial);
 
 	if (audit_initialized != AUDIT_INITIALIZED)
@@ -1705,8 +1705,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 	}
 
 	audit_get_stamp(ab->ctx, &t, &serial);
-	audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-			 t.tv_sec, t.tv_nsec/1000000, serial);
+	audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+			 (unsigned long long)t.tv_sec, t.tv_nsec/1000000, serial);
 
 	return ab;
 }
diff --git a/kernel/audit.h b/kernel/audit.h
index 0f1cf6d..cdf96f4 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
 	enum audit_state    state, current_state;
 	unsigned int	    serial;     /* serial number for record */
 	int		    major;      /* syscall number */
-	struct timespec	    ctime;      /* time of syscall entry */
+	struct timespec64   ctime;      /* time of syscall entry */
 	unsigned long	    argv[4];    /* syscall arguments */
 	long		    return_code;/* syscall return code */
 	u64		    prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e59ffc7..a2d9217 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1532,7 +1532,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,
 		return;
 
 	context->serial     = 0;
-	context->ctime      = CURRENT_TIME;
+	ktime_get_real_ts64(&context->ctime);
 	context->in_syscall = 1;
 	context->current_state  = state;
 	context->ppid       = 0;
@@ -1941,13 +1941,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-		       struct timespec *t, unsigned int *serial)
+		       struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx->in_syscall)
 		return 0;
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: deepa.kernel@gmail.com (Deepa Dinamani)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 06/12] audit: Use timespec64 to represent audit timestamps
Date: Fri,  7 Apr 2017 17:57:04 -0700	[thread overview]
Message-ID: <1491613030-11599-7-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1491613030-11599-1-git-send-email-deepa.kernel@gmail.com>

struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c        | 10 +++++-----
 kernel/audit.h        |  2 +-
 kernel/auditsc.c      |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 6fdfefc..f830508 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
 				/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial);
+			      struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -511,7 +511,7 @@ static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial)
+			      struct timespec64 *t, unsigned int *serial)
 {
 	return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 2f4964c..fcbf377 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1625,10 +1625,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-				   struct timespec *t, unsigned int *serial)
+				   struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-		*t = CURRENT_TIME;
+		ktime_get_real_ts64(t);
 		*serial = audit_serial();
 	}
 }
@@ -1652,7 +1652,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 				     int type)
 {
 	struct audit_buffer *ab;
-	struct timespec t;
+	struct timespec64 t;
 	unsigned int uninitialized_var(serial);
 
 	if (audit_initialized != AUDIT_INITIALIZED)
@@ -1705,8 +1705,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 	}
 
 	audit_get_stamp(ab->ctx, &t, &serial);
-	audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-			 t.tv_sec, t.tv_nsec/1000000, serial);
+	audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+			 (unsigned long long)t.tv_sec, t.tv_nsec/1000000, serial);
 
 	return ab;
 }
diff --git a/kernel/audit.h b/kernel/audit.h
index 0f1cf6d..cdf96f4 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
 	enum audit_state    state, current_state;
 	unsigned int	    serial;     /* serial number for record */
 	int		    major;      /* syscall number */
-	struct timespec	    ctime;      /* time of syscall entry */
+	struct timespec64   ctime;      /* time of syscall entry */
 	unsigned long	    argv[4];    /* syscall arguments */
 	long		    return_code;/* syscall return code */
 	u64		    prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e59ffc7..a2d9217 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1532,7 +1532,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,
 		return;
 
 	context->serial     = 0;
-	context->ctime      = CURRENT_TIME;
+	ktime_get_real_ts64(&context->ctime);
 	context->in_syscall = 1;
 	context->current_state  = state;
 	context->ppid       = 0;
@@ -1941,13 +1941,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-		       struct timespec *t, unsigned int *serial)
+		       struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx->in_syscall)
 		return 0;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Cc: yuchao0-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org,
	clm-b10kYP2dOMg@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	dushistov-JGs/UdohzUI@public.gmane.org,
	jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org,
	tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org,
	y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	arnd-r2nGTMty4D4@public.gmane.org,
	rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org,
	oleg.drokin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
	dsterba-IBi9RG/b67k@public.gmane.org,
	jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jbacik-b10kYP2dOMg@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org,
	eparis-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-f2fs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	linux-btrfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	lustre-devel-aLEFhgZF4x6X6Mz3xDxJMA@public.gmane.org
Subject: [lustre-devel] [PATCH 06/12] audit: Use timespec64 to represent audit timestamps
Date: Fri,  7 Apr 2017 17:57:04 -0700	[thread overview]
Message-ID: <1491613030-11599-7-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1491613030-11599-1-git-send-email-deepa.kernel@gmail.com>

struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c        | 10 +++++-----
 kernel/audit.h        |  2 +-
 kernel/auditsc.c      |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 6fdfefc..f830508 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
 				/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial);
+			      struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -511,7 +511,7 @@ static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
-			      struct timespec *t, unsigned int *serial)
+			      struct timespec64 *t, unsigned int *serial)
 {
 	return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 2f4964c..fcbf377 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1625,10 +1625,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-				   struct timespec *t, unsigned int *serial)
+				   struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-		*t = CURRENT_TIME;
+		ktime_get_real_ts64(t);
 		*serial = audit_serial();
 	}
 }
@@ -1652,7 +1652,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 				     int type)
 {
 	struct audit_buffer *ab;
-	struct timespec t;
+	struct timespec64 t;
 	unsigned int uninitialized_var(serial);
 
 	if (audit_initialized != AUDIT_INITIALIZED)
@@ -1705,8 +1705,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 	}
 
 	audit_get_stamp(ab->ctx, &t, &serial);
-	audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-			 t.tv_sec, t.tv_nsec/1000000, serial);
+	audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+			 (unsigned long long)t.tv_sec, t.tv_nsec/1000000, serial);
 
 	return ab;
 }
diff --git a/kernel/audit.h b/kernel/audit.h
index 0f1cf6d..cdf96f4 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
 	enum audit_state    state, current_state;
 	unsigned int	    serial;     /* serial number for record */
 	int		    major;      /* syscall number */
-	struct timespec	    ctime;      /* time of syscall entry */
+	struct timespec64   ctime;      /* time of syscall entry */
 	unsigned long	    argv[4];    /* syscall arguments */
 	long		    return_code;/* syscall return code */
 	u64		    prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e59ffc7..a2d9217 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1532,7 +1532,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,
 		return;
 
 	context->serial     = 0;
-	context->ctime      = CURRENT_TIME;
+	ktime_get_real_ts64(&context->ctime);
 	context->in_syscall = 1;
 	context->current_state  = state;
 	context->ppid       = 0;
@@ -1941,13 +1941,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-		       struct timespec *t, unsigned int *serial)
+		       struct timespec64 *t, unsigned int *serial)
 {
 	if (!ctx->in_syscall)
 		return 0;
-- 
2.7.4

  parent reply	other threads:[~2017-04-08  0:58 UTC|newest]

Thread overview: 166+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08  0:56 [PATCH 00/12] Delete CURRENT_TIME, CURRENT_TIME_SEC and current_fs_time Deepa Dinamani
2017-04-08  0:56 ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:56 ` Deepa Dinamani
2017-04-08  0:56 ` Deepa Dinamani
2017-04-08  0:56 ` [PATCH 01/12] fs: f2fs: Use ktime_get_real_seconds for sit_info times Deepa Dinamani
2017-04-08  0:56   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:56   ` Deepa Dinamani
2017-04-08  0:56   ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 02/12] trace: Make trace_hwlat timestamp y2038 safe Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  1:30   ` Steven Rostedt
2017-04-08  1:30     ` Steven Rostedt
2017-04-08  1:30     ` Steven Rostedt
2017-04-08  2:16     ` Deepa Dinamani
2017-04-08  2:16       ` [lustre-devel] " Deepa Dinamani
2017-04-08  2:16       ` Deepa Dinamani
2017-04-08  2:16       ` Deepa Dinamani
2017-04-08  2:16       ` Deepa Dinamani
2017-04-08  2:16       ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 03/12] fs: cifs: Replace CURRENT_TIME by other appropriate apis Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts() Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-06-01  9:56   ` Yan, Zheng
2017-06-01  9:56     ` Yan, Zheng
2017-06-01  9:56     ` Yan, Zheng
2017-06-01 10:22     ` Arnd Bergmann
2017-06-01 10:22       ` [lustre-devel] " Arnd Bergmann
2017-06-01 10:22       ` Arnd Bergmann
2017-06-01 10:22       ` Arnd Bergmann
2017-06-01 10:22       ` Arnd Bergmann
2017-06-01 10:22       ` Arnd Bergmann
2017-06-02  0:26       ` Yan, Zheng
2017-06-02  0:26         ` Yan, Zheng
2017-06-02  0:26         ` Yan, Zheng
2017-06-02  0:26         ` Yan, Zheng
2017-06-02  0:26         ` Yan, Zheng
2017-06-02  0:36         ` John Stultz
2017-06-02  0:36           ` John Stultz
2017-06-02  0:36           ` John Stultz
2017-06-02  0:36           ` John Stultz
2017-06-02  0:36           ` John Stultz
2017-06-02  0:36           ` John Stultz
2017-06-02  0:57           ` Deepa Dinamani
2017-06-02  0:57             ` [lustre-devel] " Deepa Dinamani
2017-06-02  0:57             ` Deepa Dinamani
2017-06-02  0:57             ` Deepa Dinamani
2017-06-02  0:57             ` Deepa Dinamani
2017-06-02  0:57             ` Deepa Dinamani
2017-06-02  2:09             ` Yan, Zheng
2017-06-02  2:09               ` Yan, Zheng
2017-06-02  2:09               ` Yan, Zheng
2017-06-02  2:09               ` Yan, Zheng
2017-06-02  9:45               ` Arnd Bergmann
2017-06-02  9:45                 ` [lustre-devel] " Arnd Bergmann
2017-06-02  9:45                 ` Arnd Bergmann
2017-06-02  9:45                 ` Arnd Bergmann
2017-06-02  9:45                 ` Arnd Bergmann
2017-06-02  9:45                 ` Arnd Bergmann
2017-06-02 10:10                 ` Yan, Zheng
2017-06-02 10:10                   ` Yan, Zheng
2017-06-02 10:10                   ` Yan, Zheng
2017-06-02 10:10                   ` Yan, Zheng
2017-06-02 10:10                   ` Yan, Zheng
2017-06-02 10:51                   ` Arnd Bergmann
2017-06-02 10:51                     ` [lustre-devel] " Arnd Bergmann
2017-06-02 10:51                     ` Arnd Bergmann
2017-06-02 10:51                     ` Arnd Bergmann
2017-06-02 10:51                     ` Arnd Bergmann
2017-06-02 10:51                     ` Arnd Bergmann
2017-06-02 11:18                     ` Yan, Zheng
2017-06-02 11:18                       ` Yan, Zheng
2017-06-02 11:18                       ` Yan, Zheng
2017-06-02 11:18                       ` Yan, Zheng
2017-06-02 11:18                       ` Yan, Zheng
2017-06-02 11:33                       ` Arnd Bergmann
2017-06-02 11:33                         ` [lustre-devel] " Arnd Bergmann
2017-06-02 11:33                         ` Arnd Bergmann
2017-06-02 11:33                         ` Arnd Bergmann
2017-06-02 11:33                         ` Arnd Bergmann
2017-06-02 11:33                         ` Arnd Bergmann
2017-06-02 12:18                         ` Yan, Zheng
2017-06-02 12:18                           ` Yan, Zheng
2017-06-02 12:18                           ` Yan, Zheng
2017-06-02 12:18                           ` Yan, Zheng
2017-06-02 12:18                           ` Yan, Zheng
2017-06-02 14:18                           ` Arnd Bergmann
2017-06-02 14:18                             ` [lustre-devel] " Arnd Bergmann
2017-06-02 14:18                             ` Arnd Bergmann
2017-06-02 14:18                             ` Arnd Bergmann
2017-06-02 14:18                             ` Arnd Bergmann
2017-06-02 14:18                             ` Arnd Bergmann
2017-06-04  7:54                             ` Yan, Zheng
2017-06-04  7:54                               ` Yan, Zheng
2017-06-04  7:54                               ` Yan, Zheng
2017-06-04  7:54                               ` Yan, Zheng
2017-06-04  7:54                               ` Yan, Zheng
2017-06-02  0:35       ` Yan, Zheng
2017-06-02  0:35         ` Yan, Zheng
2017-06-02  0:35         ` Yan, Zheng
2017-06-02  0:35         ` Yan, Zheng
2017-06-02  0:35         ` Yan, Zheng
2017-04-08  0:57 ` [PATCH 05/12] fs: ufs: Use ktime_get_real_ts64() for birthtime Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57 ` Deepa Dinamani [this message]
2017-04-08  0:57   ` [lustre-devel] [PATCH 06/12] audit: Use timespec64 to represent audit timestamps Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08 12:40   ` Paul Moore
2017-04-08 12:40     ` Paul Moore
2017-04-08 12:40     ` Paul Moore
2017-04-08 17:58     ` Deepa Dinamani
2017-04-08 17:58       ` [lustre-devel] " Deepa Dinamani
2017-04-08 17:58       ` Deepa Dinamani
2017-04-08 17:58       ` Deepa Dinamani
2017-04-08 17:58       ` Deepa Dinamani
2017-04-08 17:58       ` Deepa Dinamani
2017-04-11 20:12       ` Paul Moore
2017-04-11 20:12         ` Paul Moore
2017-04-11 20:12         ` Paul Moore
2017-04-11 20:12         ` Paul Moore
2017-04-11 20:12         ` Paul Moore
2017-04-15 10:29       ` Arnd Bergmann
2017-04-15 10:29         ` [lustre-devel] " Arnd Bergmann
2017-04-15 10:29         ` Arnd Bergmann
2017-04-15 10:29         ` Arnd Bergmann
2017-04-15 10:29         ` Arnd Bergmann
2017-04-08  0:57 ` [PATCH 07/12] fs: btrfs: Use ktime_get_real_ts for root ctime Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-12 13:42   ` David Sterba
2017-04-12 13:42     ` [lustre-devel] " David Sterba
2017-04-12 13:42     ` David Sterba
2017-04-12 13:42     ` David Sterba
2017-04-08  0:57 ` [PATCH 08/12] fs: ubifs: Replace CURRENT_TIME_SEC with current_time Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 09/12] lustre: Replace CURRENT_TIME macro Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 10/12] apparmorfs: Replace CURRENT_TIME with current_time() Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-06-02  7:29   ` John Johansen
2017-06-02  7:29     ` John Johansen
2017-06-02  7:29     ` John Johansen
2017-04-08  0:57 ` [PATCH 11/12] time: Delete CURRENT_TIME_SEC and CURRENT_TIME Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57 ` [PATCH 12/12] time: Delete current_fs_time() function Deepa Dinamani
2017-04-08  0:57   ` [lustre-devel] " Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani
2017-04-08  0:57   ` Deepa Dinamani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491613030-11599-7-git-send-email-deepa.kernel@gmail.com \
    --to=deepa.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas.dilger@intel.com \
    --cc=arnd@arndb.de \
    --cc=bfields@fieldses.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=clm@fb.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=dsterba@suse.com \
    --cc=dushistov@mail.ru \
    --cc=eparis@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jaegeuk@kernel.org \
    --cc=jbacik@fb.com \
    --cc=jlayton@poochiereds.net \
    --cc=john.stultz@linaro.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-audit@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=paul@paul-moore.com \
    --cc=rostedt@goodmis.org \
    --cc=samba-technical@lists.samba.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.