These are updates to devidce drivers and file systems that for some
reason or another were not included in the kernel in the previous
y2038 series.
I've gone through all users of time_t again to make sure the
kernel is in a long-term maintainable state.
Posting these as a series for better organization, but each change
here is applicable standalone.
Please merge, review, ack/nack etc as you see fit. My plan is to
include any patches that don't get a reply this time around in
a future pull request, probably for linux-5.6.
As mentioned before, the full series of 90 patches is available at
https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=…
Arnd
Arnd Bergmann (16):
staging: exfat: use prandom_u32() for i_generation
fat: use prandom_u32() for i_generation
net: sock: use __kernel_old_timespec instead of timespec
dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD
xtensa: ISS: avoid struct timeval
um: ubd: use 64-bit time_t where possible
acct: stop using get_seconds()
tsacct: add 64-bit btime field
netfilter: nft_meta: use 64-bit time arithmetic
packet: clarify timestamp overflow
quota: avoid time_t in v1_disk_dqblk definition
hostfs: pass 64-bit timestamps to/from user space
hfs/hfsplus: use 64-bit inode timestamps
drm/msm: avoid using 'timespec'
drm/etnaviv: use ktime_t for timeouts
firewire: ohci: stop using get_seconds() for BUS_TIME
arch/um/drivers/cow.h | 2 +-
arch/um/drivers/cow_user.c | 7 +++--
arch/um/drivers/ubd_kern.c | 10 +++----
arch/um/include/shared/os.h | 2 +-
arch/um/os-Linux/file.c | 2 +-
.../platforms/iss/include/platform/simcall.h | 4 +--
drivers/firewire/ohci.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 19 ++++++-------
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 21 ++++++--------
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 5 ++--
drivers/gpu/drm/etnaviv/etnaviv_gem.h | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 4 +--
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 +--
drivers/gpu/drm/msm/msm_drv.h | 3 +-
drivers/staging/exfat/exfat_super.c | 4 +--
fs/dlm/lowcomms.c | 6 ++--
fs/fat/inode.c | 3 +-
fs/hfs/hfs_fs.h | 26 +++++++++++++----
fs/hfs/inode.c | 4 +--
fs/hfsplus/hfsplus_fs.h | 26 +++++++++++++----
fs/hfsplus/inode.c | 12 ++++----
fs/hostfs/hostfs.h | 22 +++++++++------
fs/hostfs/hostfs_kern.c | 15 ++++++----
fs/quota/quotaio_v1.h | 6 ++--
include/linux/skbuff.h | 7 +++--
include/uapi/linux/acct.h | 2 ++
include/uapi/linux/taskstats.h | 6 +++-
kernel/acct.c | 4 ++-
kernel/tsacct.c | 9 ++++--
net/compat.c | 2 +-
net/ipv4/tcp.c | 28 +++++++++++--------
net/netfilter/nft_meta.c | 10 +++----
net/packet/af_packet.c | 27 +++++++++++-------
net/socket.c | 2 +-
34 files changed, 184 insertions(+), 124 deletions(-)
--
2.20.0
Cc: jdike(a)addtoit.com
Cc: richard(a)nod.at
Cc: jcmvbkbc(a)gmail.com
Cc: stefanr(a)s5r6.in-berlin.de
Cc: l.stach(a)pengutronix.de
Cc: linux+etnaviv(a)armlinux.org.uk
Cc: christian.gmeiner(a)gmail.com
Cc: airlied(a)linux.ie
Cc: daniel(a)ffwll.ch
Cc: robdclark(a)gmail.com
Cc: sean(a)poorly.run
Cc: valdis.kletnieks(a)vt.edu
Cc: gregkh(a)linuxfoundation.org
Cc: ccaulfie(a)redhat.com
Cc: teigland(a)redhat.com
Cc: hirofumi(a)mail.parknet.co.jp
Cc: jack(a)suse.com
Cc: davem(a)davemloft.net
Cc: edumazet(a)google.com
Cc: pablo(a)netfilter.org
Cc: kadlec(a)netfilter.org
Cc: fw(a)strlen.de
Cc: willemb(a)google.com
Cc: viro(a)zeniv.linux.org.uk
Cc: rfontana(a)redhat.com
Cc: tglx(a)linutronix.de
Cc: linux-um(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Cc: linux1394-devel(a)lists.sourceforge.net
Cc: etnaviv(a)lists.freedesktop.org
Cc: dri-devel(a)lists.freedesktop.org>
Cc: linux-arm-msm(a)vger.kernel.org>
Cc: freedreno(a)lists.freedesktop.org>
Cc: devel(a)driverdev.osuosl.org>
Cc: cluster-devel(a)redhat.com>
Cc: linux-fsdevel(a)vger.kernel.org>
Cc: netdev(a)vger.kernel.org>
Cc: netfilter-devel(a)vger.kernel.org>
Cc: coreteam(a)netfilter.org>
This is a series I worked on with Baolin in 2017 and 2018, but we
never quite managed to finish up the last pieces. During the
ALSA developer meetup at ELC-E 2018 in Edinburgh, a decision was
made to go with this approach for keeping best compatibility
with existing source code, and then I failed to follow up by
resending the patches.
Now I have patches for all remaining time_t uses in the kernel,
so it's absolutely time to revisit them. I have done more
review of the patches myself and found a couple of minor issues
that I have fixed up, otherwise the series is still the same as
before.
Conceptually, the idea of these patches is:
- 64-bit applications should see no changes at all, neither
compile-time nor run-time.
- 32-bit code compiled with a 64-bit time_t currently
does not work with ALSA, and requires kernel changes and/or
sound/asound.h changes
- Most 32-bit code using these interfaces will work correctly
on a modified kernel, with or without the uapi header changes.
- 32-bit code using SNDRV_TIMER_IOCTL_TREAD requires the
updated header file for 64-bit time_t support
- 32-bit i386 user space with 64-bit time_t is broken for
SNDRV_PCM_IOCTL_STATUS, SNDRV_RAWMIDI_IOCTL_STATUS and
SNDRV_PCM_IOCTL_SYNC_PTR because of i386 alignment. This is also
addressed by the updated uapi header.
- PCM mmap is currently supported on native x86 kernels
(both 32-bit and 64-bit) but not for compat mode. This series breaks
the 32-bit native mmap support for 32-bit time_t, but instead allows
it for 64-bit time_t on both native and compat kernels. This seems to
be the best trade-off, as mmap support is optional already, and most
32-bit code runs in compat mode anyway.
- I've tried to avoid breaking compilation of 32-bit code
as much as possible. Anything that does break however is likely code
that is already broken on 64-bit time_t and needs source changes to
fix them.
I would like to propose merging this into the alsa tree after
the v5.5 merge window for inclusion into v5.6, to allow a good
amount of testing, in particular for the header changes that
may cause problems for user space applications.
A git branch with the same contents is available for testing at [1].
Please review and test!
Arnd
[1] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-alsa
[2] https://lore.kernel.org/lkml/CAK8P3a2Os66+iwQYf97qh05W2JP8rmWao8zmKoHiXqVHv…
Changes since v5 (Arnd):
- Rebased to linux-5.4-rc4
- Updated to completely remove timespec and time_t references from alsa
- found and fixed a few bugs
Changes since v4 (Baolin):
- Add patch 5 to change trigger_tstamp member of struct snd_pcm_runtime.
- Add patch 8 to change internal timespec.
- Add more explanation in commit message.
- Use ktime_get_real_ts64() in patch 6.
- Split common code out into a separate function in patch 6.
- Fix tu->tread bug in patch 6 and remove #if __BITS_PER_LONG == 64 macro.
Changes since v3:
- Move struct snd_pcm_status32 to pcm.h file.
- Modify comments and commit message.
- Add new patch2 ~ patch6.
Changes since v2:
- Renamed all structures to make clear.
- Remove CONFIG_X86_X32 macro and introduced new compat_snd_pcm_status64_x86_32.
Changes since v1:
- Add one macro for struct snd_pcm_status_32 which only active in 32bits kernel.
- Convert pcm_compat.c to use struct snd_pcm_status_64.
- Convert pcm_native.c to use struct snd_pcm_status_64.
---
Arnd Bergmann (2):
ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
Baolin Wang (6):
ALSA: Replace timespec with timespec64
ALSA: Avoid using timespec for struct snd_timer_status
ALSA: Avoid using timespec for struct snd_ctl_elem_value
ALSA: Avoid using timespec for struct snd_pcm_status
ALSA: Avoid using timespec for struct snd_rawmidi_status
ALSA: Avoid using timespec for struct snd_timer_tread
include/sound/pcm.h | 74 ++++++--
include/sound/timer.h | 4 +-
include/uapi/sound/asound.h | 132 ++++++++++++--
sound/core/pcm.c | 12 +-
sound/core/pcm_compat.c | 282 ++++++++----------------------
sound/core/pcm_lib.c | 38 ++--
sound/core/pcm_native.c | 226 +++++++++++++++++++++---
sound/core/rawmidi.c | 132 +++++++++++---
sound/core/rawmidi_compat.c | 87 +++------
sound/core/timer.c | 229 ++++++++++++++++++------
sound/core/timer_compat.c | 62 +------
sound/pci/hda/hda_controller.c | 10 +-
sound/soc/intel/skylake/skl-pcm.c | 4 +-
13 files changed, 804 insertions(+), 488 deletions(-)
--
2.20.0
This is part of a longer set of changes to clean up the last remaining
bits for the y2038 conversion. In XFS, three distinct problems need to
be addressed:
1. The use of time_t in kernel sources -- I'm in the process
of removing all of them so we can remove the definition itself,
making it harder to write new y2038-unsafe code. This part is
trivially done as a side-effect of the other two.
2. The use of time_t in a user API header for ioctls. When
building against a new 32-bit libc with 64-bit time_t, the structures
no longer match and we get incorrect data from ioctls. Unfortunately,
there is no good way to fix XFS_IOC_FSBULKSTAT, I considered different
approaches and in the end came up with three variants that are all
part of this series. The idea is to pick just one of course.
3. On-disk timestamps hitting the y2038 limit. This applies to both
inode timestamps and quota data. Both are extended to 40 bits,
with the minimum timestamp still being year 1902, and the maximum
getting extended from 2038 to 36744.
Please review and let me know which of ioctl API changes makes the
most sense. I have not done any actual runtime testing on the patches,
so this is clearly too late for the next merge window, but I hope to
get it all merged for v5.6.
Arnd
Arnd Bergmann (5):
xfs: [variant A] avoid time_t in user api
xfs: [variant B] add time64 version of xfs_bstat
xfs: [variant C] avoid i386-misaligned xfs_bstat
xfs: extend inode format for 40-bit timestamps
xfs: use 40-bit quota time limits
fs/xfs/libxfs/xfs_dquot_buf.c | 6 +-
fs/xfs/libxfs/xfs_format.h | 11 +-
fs/xfs/libxfs/xfs_fs.h | 37 +++++-
fs/xfs/libxfs/xfs_inode_buf.c | 28 +++--
fs/xfs/libxfs/xfs_inode_buf.h | 1 +
fs/xfs/libxfs/xfs_log_format.h | 6 +-
fs/xfs/libxfs/xfs_trans_inode.c | 3 +-
fs/xfs/xfs_dquot.c | 29 +++--
fs/xfs/xfs_inode.c | 3 +-
fs/xfs/xfs_inode_item.c | 10 +-
fs/xfs/xfs_ioctl.c | 195 +++++++++++++++++++++++++++++++-
fs/xfs/xfs_ioctl.h | 12 ++
fs/xfs/xfs_ioctl32.c | 160 +++++---------------------
fs/xfs/xfs_ioctl32.h | 26 ++---
fs/xfs/xfs_iops.c | 3 +-
fs/xfs/xfs_itable.c | 2 +-
fs/xfs/xfs_qm.c | 18 ++-
fs/xfs/xfs_qm.h | 6 +-
fs/xfs/xfs_qm_syscalls.c | 16 ++-
fs/xfs/xfs_quotaops.c | 6 +-
fs/xfs/xfs_super.c | 2 +-
fs/xfs/xfs_trans_dquot.c | 17 ++-
22 files changed, 387 insertions(+), 210 deletions(-)
--
2.20.0
Most kernel interfaces that take a timespec require normalized
representation with tv_nsec between 0 and NSEC_PER_SEC.
Passing values larger than 0x100000000ull further behaves differently
on 32-bit and 64-bit kernels, and can cause the latter to spend a long
time counting seconds in timespec64_sub()/set_normalized_timespec64().
Reject those large values at the user interface to enforce sane and
portable behavior.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 1f9c01be40d7..95d72dc00280 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -297,6 +297,9 @@ static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
if (args->op & ~(ETNA_PREP_READ | ETNA_PREP_WRITE | ETNA_PREP_NOSYNC))
return -EINVAL;
+ if (args->timeout.tv_nsec > NSEC_PER_SEC)
+ return -EINVAL;
+
obj = drm_gem_object_lookup(file, args->handle);
if (!obj)
return -ENOENT;
@@ -360,6 +363,9 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data,
if (args->flags & ~(ETNA_WAIT_NONBLOCK))
return -EINVAL;
+ if (args->timeout.tv_nsec > NSEC_PER_SEC)
+ return -EINVAL;
+
if (args->pipe >= ETNA_MAX_PIPES)
return -EINVAL;
@@ -411,6 +417,9 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,
if (args->flags & ~(ETNA_WAIT_NONBLOCK))
return -EINVAL;
+ if (args->timeout.tv_nsec > NSEC_PER_SEC)
+ return -EINVAL;
+
if (args->pipe >= ETNA_MAX_PIPES)
return -EINVAL;
--
2.20.0
I'm in the process of finishing up the last bits on y2038-unsafe
code in the kernel, this series is for v4l2, which has no problem
with overflow, but has multiple ioctls that break with user space
built against a new 32-bit libc.
I posted similar patches as part of a series back in 2015, the
new version was rewritten from scratch and I double-checked with
the old version to make sure I did not miss anything I had already
taken care of before.
Hans Verkuil worked on a different patch set in 2017, but this
also did not get to the point of being merged.
My new version contains compat-ioctl support, which the old one
did not and should be complete, but given its size likely contains
bugs. I did randconfig build tests, but no runtime test, so
careful review as well as testing would be much appreciated.
With this version, the newly added code takes care of the existing
ABI, while the existing code got moved to the 64-bit time_t
interface and is used internally. This means that testing with
existing binaries should exercise most of the modifications
and if that works and doesn't get shot down in review, we can
probably live without testing the new ABI explicitly.
I'm not entirely happy with the compat-ioctl implementation that
adds quite a bit of code duplication, but I hope this is
acceptable anyway, as a better implementation would likely
require a larger refactoring of the compat-ioctl file, while
my approach simply adds support for the additional data structure
variants.
The patches apply cleanly on either v5.4-rc4 or the media-tree
master branch. I uploaded a copy to [2] for easier testing.
Arnd
[1] https://lwn.net/Articles/657754/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=…
Arnd Bergmann (8):
media: documentation: fix video_event description
media: v4l2: abstract timeval handling in v4l2_buffer
media: v4l2-core: ignore native command codes
media: v4l2-core: split out data copy from video_usercopy
media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI
media: v4l2-core: fix v4l2_buffer handling for time64 ABI
media: v4l2-core: fix compat VIDIOC_DQEVENT for time64 ABI
media: v4l2-core: fix compat v4l2_buffer handling for time64 ABI
.../media/uapi/dvb/video-get-event.rst | 2 +-
Documentation/media/uapi/dvb/video_types.rst | 2 +-
.../media/common/videobuf2/videobuf2-v4l2.c | 4 +-
drivers/media/pci/meye/meye.c | 4 +-
drivers/media/usb/cpia2/cpia2_v4l.c | 4 +-
drivers/media/usb/stkwebcam/stk-webcam.c | 2 +-
drivers/media/usb/usbvision/usbvision-video.c | 4 +-
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 464 +++++++++++++++---
drivers/media/v4l2-core/v4l2-event.c | 5 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 186 +++++--
drivers/media/v4l2-core/v4l2-subdev.c | 20 +-
drivers/media/v4l2-core/videobuf-core.c | 4 +-
include/linux/videodev2.h | 17 +-
include/trace/events/v4l2.h | 2 +-
include/uapi/linux/videodev2.h | 72 +++
15 files changed, 660 insertions(+), 132 deletions(-)
--
2.20.0
Hi Vinvenzo,
I'm looking through some of the remaining y2038 work, and noticed
that arch/arm64 has the new generic vdso implementation, but arch/arm
does.
Do you patches for using the same code on arch/arm?
Arnd
All system calls use struct __kernel_timespec instead of the old struct
timespec, but this one was just added with the old-style ABI. Change it
now to enforce the use of __kernel_timespec, avoiding ABI confusion and
the need for compat handlers on 32-bit architectures.
Any user space caller will have to use __kernel_timespec now, but this
is unambiguous and works for any C library regardless of the time_t
definition. A nicer way to specify the timeout would have been a less
ambiguous 64-bit nanosecond value, but I suppose it's too late now to
change that as this would impact both 32-bit and 64-bit users.
Fixes: 5262f567987d ("io_uring: IORING_OP_TIMEOUT support")
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
fs/io_uring.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index aa8ac557493c..8a0381f1a43b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1892,15 +1892,15 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe)
unsigned count, req_dist, tail_index;
struct io_ring_ctx *ctx = req->ctx;
struct list_head *entry;
- struct timespec ts;
+ struct timespec64 ts;
if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->flags || sqe->ioprio || sqe->buf_index || sqe->timeout_flags ||
sqe->len != 1)
return -EINVAL;
- if (copy_from_user(&ts, (void __user *) (unsigned long) sqe->addr,
- sizeof(ts)))
+
+ if (get_timespec64(&ts, u64_to_user_ptr(sqe->addr)))
return -EFAULT;
/*
@@ -1934,7 +1934,7 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe)
hrtimer_init(&req->timeout.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
req->timeout.timer.function = io_timeout_fn;
- hrtimer_start(&req->timeout.timer, timespec_to_ktime(ts),
+ hrtimer_start(&req->timeout.timer, timespec64_to_ktime(ts),
HRTIMER_MODE_REL);
return 0;
}
--
2.20.0