I noticed that the mic driver passes a 'struct timespec64' as part of
a message into an attached device, where it is used to set the current
system time.
This won't actually work if one of the two sides runs a 32-bit kernel and
the other runs a 64-bit kernel, since the structure layout is different
between the two.
I found this while replacing calls to the deprecated do_settimeofday64()
interface with the modern ktime_get_real_ts() variant, but it seems
appropriate to address both at the same time here.
To make sure we have a sane structure, let's define our own structure
using the layout of the 64-bit kernel.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
drivers/misc/mic/cosm/cosm_main.h | 5 ++++-
drivers/misc/mic/cosm/cosm_scif_server.c | 6 +++++-
drivers/misc/mic/cosm_client/cosm_scif_client.c | 6 +++++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/mic/cosm/cosm_main.h b/drivers/misc/mic/cosm/cosm_main.h
index f01156fca881..aa78cdf25e40 100644
--- a/drivers/misc/mic/cosm/cosm_main.h
+++ b/drivers/misc/mic/cosm/cosm_main.h
@@ -45,7 +45,10 @@ struct cosm_msg {
u64 id;
union {
u64 shutdown_status;
- struct timespec64 timespec;
+ struct {
+ u64 tv_sec;
+ u64 tv_nsec;
+ } timespec;
};
};
diff --git a/drivers/misc/mic/cosm/cosm_scif_server.c b/drivers/misc/mic/cosm/cosm_scif_server.c
index 05a63286741c..e94b7eac4a06 100644
--- a/drivers/misc/mic/cosm/cosm_scif_server.c
+++ b/drivers/misc/mic/cosm/cosm_scif_server.c
@@ -179,9 +179,13 @@ static void cosm_set_crashed(struct cosm_device *cdev)
static void cosm_send_time(struct cosm_device *cdev)
{
struct cosm_msg msg = { .id = COSM_MSG_SYNC_TIME };
+ struct timespec64 ts;
int rc;
- getnstimeofday64(&msg.timespec);
+ ktime_get_real_ts64(&ts);
+ msg.timespec.tv_sec = ts.tv_sec;
+ msg.timespec.tv_nsec = ts.tv_nsec;
+
rc = scif_send(cdev->epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
if (rc < 0)
dev_err(&cdev->dev, "%s %d scif_send failed rc %d\n",
diff --git a/drivers/misc/mic/cosm_client/cosm_scif_client.c b/drivers/misc/mic/cosm_client/cosm_scif_client.c
index beafc0da4027..225078cb51fd 100644
--- a/drivers/misc/mic/cosm_client/cosm_scif_client.c
+++ b/drivers/misc/mic/cosm_client/cosm_scif_client.c
@@ -63,7 +63,11 @@ static struct notifier_block cosm_reboot = {
/* Set system time from timespec value received from the host */
static void cosm_set_time(struct cosm_msg *msg)
{
- int rc = do_settimeofday64(&msg->timespec);
+ struct timespec64 ts = {
+ .tv_sec = msg->timespec.tv_sec,
+ .tv_nsec = msg->timespec.tv_nsec,
+ };
+ int rc = do_settimeofday64(&ts);
if (rc)
dev_err(&client_spdev->dev, "%s: %d settimeofday rc %d\n",
--
2.9.0
getnstimeofday64() is just a wrapper around the ktime accessor, so
we should use that directly.
I considered using ktime_get_boottime_ts64() (to avoid leap second
problems) or ktime_get_real_seconds() (to simplify the calculation,
but in the end concluded that the existing interface is probably
the most appropriate in this case.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
drivers/rtc/class.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index d37588f08055..7fa32c922617 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -68,7 +68,7 @@ static int rtc_suspend(struct device *dev)
return 0;
}
- getnstimeofday64(&old_system);
+ ktime_get_real_ts64(&old_system);
old_rtc.tv_sec = rtc_tm_to_time64(&tm);
@@ -110,7 +110,7 @@ static int rtc_resume(struct device *dev)
return 0;
/* snapshot the current rtc and system time at resume */
- getnstimeofday64(&new_system);
+ ktime_get_real_ts64(&new_system);
err = rtc_read_time(rtc, &tm);
if (err < 0) {
pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev));
--
2.9.0
Commit b5793b0d92c9 ("posix-timers: Make compat syscalls depend on
CONFIG_COMPAT_32BIT_TIME") added support for building the nanosleep
compat system call on 32-bit architectures, but missed one change
in nanosleep_copyout(), which would trigger a BUG() as soon as we
switch any architecture over to use it.
This makes sure the TT_COMPAT handler is available when we need it.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
kernel/time/hrtimer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 055a4a728c00..3e93c54bd3a1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
{
switch(restart->nanosleep.type) {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
case TT_COMPAT:
if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp))
return -EFAULT;
--
2.9.0
The machine check timestamp uses get_seconds(), which returns an 'unsigned long'
number that might overflow on 32-bit architectures (in the distant future)
and is therefore deprecated.
The normal replacement would be ktime_get_real_seconds(), but that needs to
use a sequence lock that might cause a deadlock if the mce happens at just
the wrong moment. The __ktime_get_real_seconds() skips that lock and is
safer here, but has a miniscule risk of returning the wrong time when we read
it on a 32-bit architecture at the same time as updating the epoch, i.e.
from before y2106 overflow time to after, or vice versa.
This seems to be an acceptable risk in this particular case, and is the
same thing we do in kdb.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
arch/x86/kernel/cpu/mcheck/mce.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index e4cf6ff1c2e1..b887415652ed 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -123,8 +123,8 @@ void mce_setup(struct mce *m)
{
memset(m, 0, sizeof(struct mce));
m->cpu = m->extcpu = smp_processor_id();
- /* We hope get_seconds stays lockless */
- m->time = get_seconds();
+ /* need the internal __ version to avoid deadlocks */
+ m->time = __ktime_get_real_seconds();
m->cpuvendor = boot_cpu_data.x86_vendor;
m->cpuid = cpuid_eax(1);
m->socketid = cpu_data(m->extcpu).phys_proc_id;
--
2.9.0
time_t and get_seconds() are deprecated because they will overflow on
32-bit architectures in the future. This is not a problem on 64-bit s390,
but we should use proper interfaces anyway.
Besides moving to the time64_t based interface, the CLOCK_MONOTONIC
based ktime_get_seconds() is preferred for kernel internal timekeeping
because it does not behave in unexpected ways during leap second changes
or settimeofday() calls.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
arch/s390/hypfs/inode.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 06b513d192b9..c681329fdeec 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -36,7 +36,7 @@ struct hypfs_sb_info {
kuid_t uid; /* uid used for files and dirs */
kgid_t gid; /* gid used for files and dirs */
struct dentry *update_file; /* file to trigger update */
- time_t last_update; /* last update time in secs since 1970 */
+ time64_t last_update; /* last update, CLOCK_MONOTONIC time */
struct mutex lock; /* lock to protect update process */
};
@@ -52,7 +52,7 @@ static void hypfs_update_update(struct super_block *sb)
struct hypfs_sb_info *sb_info = sb->s_fs_info;
struct inode *inode = d_inode(sb_info->update_file);
- sb_info->last_update = get_seconds();
+ sb_info->last_update = ktime_get_seconds();
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
}
@@ -179,7 +179,7 @@ static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
* to restart data collection in this case.
*/
mutex_lock(&fs_info->lock);
- if (fs_info->last_update == get_seconds()) {
+ if (fs_info->last_update == ktime_get_seconds()) {
rc = -EBUSY;
goto out;
}
--
2.9.0
The series aims at adding a new y2038-safe struct __kernel_itimerspec.
This is intended to replace the struct itimerspec at ABI level.
The series is a continuation of efforts to convert all syscalls with
time_t or time_t-derived structures to be y2038-safe.
Arnd, maybe this series can go along with the rest of syscalls that you
have in your y2038 tree?
Deepa Dinamani (3):
time: Introduce struct __kernel_itimerspec
time: Enable get/put_compat_itimerspec64 always
time: Change types to new y2038 safe __kernel_itimerspec
fs/timerfd.c | 8 ++++----
include/linux/compat.h | 9 ---------
include/linux/compat_time.h | 9 +++++++++
include/linux/syscalls.h | 10 +++++-----
include/linux/time.h | 4 ++--
include/linux/time64.h | 1 +
include/uapi/linux/time.h | 7 +++++++
kernel/compat.c | 29 -----------------------------
kernel/time/posix-timers.c | 12 +++++++-----
kernel/time/time.c | 25 +++++++++++++++++++++++--
10 files changed, 58 insertions(+), 56 deletions(-)
base-commit: 4b373f94fee5acf2ff4c1efbb3f702060379df1f
--
2.17.1
The following changes since commit 93b7f7ad2018d2037559b1d0892417864c78b371:
skip LAYOUTRETURN if layout is invalid (2018-06-12 08:48:04 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git
tags/vfs-timespec64
for you to fetch changes up to e264abeaf9daa3cde9aed8013a6f82b0370425e5:
pstore: Remove bogus format string definition (2018-06-14 14:57:24 +0200)
----------------------------------------------------------------
vfs/y2038: inode timestamps conversion to timespec64
This is a late set of changes from Deepa Dinamani doing an automated
treewide conversion of the inode and iattr structures from 'timespec'
to 'timespec64', to push the conversion from the VFS layer into the
individual file systems.
There were no conflicts between this and the contents of linux-next
until just before the merge window, when we saw multiple problems:
- A minor conflict with my own y2038 fixes, which I could address
by adding another patch on top here.
- One semantic conflict with late changes to the NFS tree. I addressed
this by merging Deepa's original branch on top of the changes that
now got merged into mainline and making sure the merge commit includes
the necessary changes as produced by coccinelle.
- A trivial conflict against the removal of staging/lustre.
- Multiple conflicts against the VFS changes in the overlayfs tree.
These are still part of linux-next, but apparently this is no longer
intended for 4.18 [1], so I am ignoring that part.
As Deepa writes:
The series aims to switch vfs timestamps to use struct timespec64.
Currently vfs uses struct timespec, which is not y2038 safe.
The series involves the following:
1. Add vfs helper functions for supporting struct timepec64 timestamps.
2. Cast prints of vfs timestamps to avoid warnings after the switch.
3. Simplify code using vfs timestamps so that the actual
replacement becomes easy.
4. Convert vfs timestamps to use struct timespec64 using a script.
This is a flag day patch.
Next steps:
1. Convert APIs that can handle timespec64, instead of converting
timestamps at the boundaries.
2. Update internal data structures to avoid timestamp conversions.
Thomas Gleixner adds:
I think there is no point to drag that out for the next merge window.
The whole thing needs to be done in one go for the core changes which
means that you're going to play that catchup game forever. Let's get
over with it towards the end of the merge window.
[1] https://www.spinics.net/lists/linux-fsdevel/msg128294.html
----------------------------------------------------------------
Note: since the conflicting overlayfs changes are still part of linux-next,
the linux-next build will fail after this gets merged, unless the overlayfs
tree gets dropped or updated to reflect the changes.
Arnd Bergmann (2):
Merge branch 'vfs_timespec64' of
https://github.com/deepa-hub/vfs into vfs-timespec64
pstore: Remove bogus format string definition
Deepa Dinamani (6):
fs: add timespec64_truncate()
lustre: Use long long type to print inode time
ceph: make inode time prints to be long long
fs: nfs: get rid of memcpys for inode times
udf: Simplify calls to udf_disk_stamp_to_time
vfs: change inode times to use struct timespec64
Kees Cook (1):
pstore: Convert internal records to timespec64
drivers/firmware/efi/efi-pstore.c | 27 ++++----
drivers/staging/lustre/lustre/llite/llite_lib.c | 12 ++--
drivers/staging/lustre/lustre/llite/namei.c | 5 +-
drivers/staging/lustre/lustre/lmv/lmv_obd.c | 7 +-
drivers/staging/lustre/lustre/mdc/mdc_reint.c | 6 +-
drivers/staging/lustre/lustre/obdclass/obdo.c | 6 +-
drivers/tty/tty_io.c | 15 ++++-
drivers/usb/gadget/function/f_fs.c | 2 +-
fs/adfs/inode.c | 7 +-
fs/afs/fsclient.c | 2 +-
fs/attr.c | 14 ++--
fs/bad_inode.c | 2 +-
fs/btrfs/file.c | 6 +-
fs/btrfs/inode.c | 8 +--
fs/btrfs/ioctl.c | 4 +-
fs/btrfs/root-tree.c | 4 +-
fs/btrfs/transaction.c | 2 +-
fs/ceph/addr.c | 12 ++--
fs/ceph/cache.c | 4 +-
fs/ceph/caps.c | 6 +-
fs/ceph/file.c | 6 +-
fs/ceph/inode.c | 86 +++++++++++++------------
fs/ceph/mds_client.c | 7 +-
fs/ceph/snap.c | 6 +-
fs/cifs/cache.c | 4 +-
fs/cifs/fscache.c | 8 +--
fs/cifs/inode.c | 26 ++++----
fs/coda/coda_linux.c | 12 ++--
fs/configfs/inode.c | 12 ++--
fs/cramfs/inode.c | 2 +-
fs/ext4/ext4.h | 34 ++++++----
fs/ext4/ialloc.c | 4 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/f2fs.h | 10 ++-
fs/f2fs/file.c | 12 ++--
fs/f2fs/inode.c | 12 ++--
fs/f2fs/namei.c | 4 +-
fs/fat/inode.c | 20 ++++--
fs/fat/namei_msdos.c | 21 +++---
fs/fat/namei_vfat.c | 22 ++++---
fs/fuse/inode.c | 2 +-
fs/gfs2/dir.c | 6 +-
fs/gfs2/glops.c | 4 +-
fs/hfs/inode.c | 4 +-
fs/hfsplus/inode.c | 12 ++--
fs/hostfs/hostfs_kern.c | 12 ++--
fs/inode.c | 58 ++++++++++++-----
fs/jffs2/dir.c | 18 +++---
fs/jffs2/file.c | 2 +-
fs/jffs2/fs.c | 12 ++--
fs/kernfs/dir.c | 4 +-
fs/kernfs/inode.c | 8 +--
fs/locks.c | 2 +-
fs/nfs/callback_proc.c | 4 +-
fs/nfs/fscache-index.c | 4 +-
fs/nfs/fscache.c | 12 ++--
fs/nfs/inode.c | 49 ++++++++------
fs/nfs/nfs2xdr.c | 25 ++++---
fs/nfs/nfs3xdr.c | 8 ++-
fs/nfs/nfs4xdr.c | 7 +-
fs/nfsd/blocklayout.c | 8 ++-
fs/nfsd/nfs3xdr.c | 14 ++--
fs/nfsd/nfs4xdr.c | 7 +-
fs/nfsd/nfsxdr.c | 2 +-
fs/ntfs/inode.c | 30 ++++-----
fs/ocfs2/dlmglue.c | 20 ++++--
fs/ocfs2/file.c | 6 +-
fs/orangefs/inode.c | 2 +-
fs/orangefs/orangefs-kernel.h | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/proc/uptime.c | 2 +-
fs/pstore/platform.c | 2 +-
fs/pstore/ram.c | 18 +++---
fs/reiserfs/namei.c | 2 +-
fs/reiserfs/xattr.c | 4 +-
fs/ubifs/dir.c | 4 +-
fs/ubifs/file.c | 23 +++----
fs/ubifs/ubifs.h | 2 +-
fs/udf/ialloc.c | 4 +-
fs/udf/inode.c | 59 +++++++++--------
fs/udf/super.c | 17 +++--
fs/udf/udfdecl.h | 4 +-
fs/udf/udftime.c | 9 +--
fs/xfs/xfs_inode.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
fs/xfs/xfs_trans_inode.c | 2 +-
include/linux/fs.h | 24 +++----
include/linux/pstore.h | 2 +-
include/linux/stat.h | 8 +--
90 files changed, 559 insertions(+), 440 deletions(-)
Dear Recipent ,
This email address has won Three Million Pounds on the o2 mobile sweepstakes.Please Contact Payment Cordinator Mat on email : mrwest(a)o2loto.co.uk for explanation and payment processing .
Yours Faithfully
Debbie Spence
Cordinator O2 Mobile Promotional Sweepstakes.