The following changes since commit e42617b825f8073569da76dc4510bfa019b1c35a:
Linux 5.5-rc1 (2019-12-08 14:57:55 -0800)
are available in the Git repository at:
git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground.git tags/block-ioctl-cleanup-5.6
for you to fetch changes up to 3462d5c19dac7c062c5a2db727775116e6d2b28e:
Documentation: document ioctl interfaces better (2019-12-17 22:45:18 +0100)
----------------------------------------------------------------
block, scsi: final compat_ioctl cleanup
This series concludes the work I did for linux-5.5 on the compat_ioctl()
cleanup, killing off fs/compat_ioctl.c and block/compat_ioctl.c by moving
everything into drivers.
Overall this would be a reduction both in complexity and line count, but
as I'm also adding documentation the overall number of lines increases
in the end.
My plan was originally to keep the SCSI and block parts separate.
This did not work easily because of interdependencies: I cannot
do the final SCSI cleanup in a good way without first addressing the
CDROM ioctls, so this is one series that I hope could be merged through
either the block or the scsi git trees, or possibly both if you can
pull in the same branch.
The series comes in these steps:
1. clean up the sg v3 interface as suggested by Linus. I have
talked about this with Doug Gilbert as well, and he would
rebase his sg v4 patches on top of "compat: scsi: sg: fix v3
compat read/write interface"
2. Actually moving handlers out of block/compat_ioctl.c and
block/scsi_ioctl.c into drivers, mixed in with cleanup
patches
3. Document how to do this right. I keep getting asked about this,
and it helps to point to some documentation file.
The branch is based on another one that fixes a couple of bugs found
during the creation of this series.
Changes since the original version [1]:
- move out the bugfixes into a branch for itself
- clean up scsi sg driver further as suggested by Christoph Hellwig
- avoid some ifdefs by moving compat_ptr() out of asm/compat.h
- split out the blkdev_compat_ptr_ioctl function; bug spotted by
Ben Hutchings
- Improve formatting of documentation
[1] https://lore.kernel.org/linux-block/20191211204306.1207817-1-arnd@arndb.de/…
----------------------------------------------------------------
Arnd Bergmann (22): (plus five from the first pull request)
compat: ARM64: always include asm-generic/compat.h
compat: provide compat_ptr() on all architectures
compat: scsi: sg: fix v3 compat read/write interface
compat_ioctl: block: add blkdev_compat_ptr_ioctl
compat_ioctl: ubd, aoe: use blkdev_compat_ptr_ioctl
compat_ioctl: move CDROM_SEND_PACKET handling into scsi
compat_ioctl: move CDROMREADADIO to cdrom.c
compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN
compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers
compat_ioctl: add scsi_compat_ioctl
compat_ioctl: bsg: add handler
compat_ioctl: ide: floppy: add handler
compat_ioctl: scsi: move ioctl handling into drivers
compat_ioctl: move sys_compat_ioctl() to ioctl.c
compat_ioctl: simplify the implementation
compat_ioctl: move cdrom commands into cdrom.c
compat_ioctl: scsi: handle HDIO commands from drivers
compat_ioctl: move HDIO ioctl handling into drivers/ide
compat_ioctl: block: move blkdev_compat_ioctl() into ioctl.c
compat_ioctl: block: simplify compat_blkpg_ioctl()
compat_ioctl: simplify up block/ioctl.c
Documentation: document ioctl interfaces better
Documentation/core-api/index.rst | 1 +
Documentation/core-api/ioctl.rst | 248 +++++++++++++++
arch/arm64/include/asm/compat.h | 22 +-
arch/mips/include/asm/compat.h | 18 --
arch/parisc/include/asm/compat.h | 17 -
arch/powerpc/include/asm/compat.h | 17 -
arch/powerpc/oprofile/backtrace.c | 2 +-
arch/s390/include/asm/compat.h | 6 +-
arch/sparc/include/asm/compat.h | 17 -
arch/um/drivers/ubd_kern.c | 1 +
arch/x86/include/asm/compat.h | 17 -
block/Makefile | 1 -
block/bsg.c | 1 +
block/compat_ioctl.c | 411 -------------------------
block/ioctl.c | 319 +++++++++++++++----
block/scsi_ioctl.c | 214 ++++++++-----
drivers/ata/libata-scsi.c | 9 +
drivers/block/aoe/aoeblk.c | 1 +
drivers/block/floppy.c | 3 +
drivers/block/paride/pcd.c | 3 +
drivers/block/paride/pd.c | 1 +
drivers/block/paride/pf.c | 1 +
drivers/block/pktcdvd.c | 26 +-
drivers/block/sunvdc.c | 1 +
drivers/block/virtio_blk.c | 3 +
drivers/block/xen-blkfront.c | 1 +
drivers/cdrom/cdrom.c | 35 ++-
drivers/cdrom/gdrom.c | 3 +
drivers/ide/ide-cd.c | 37 +++
drivers/ide/ide-disk.c | 1 +
drivers/ide/ide-floppy.c | 4 +
drivers/ide/ide-floppy.h | 2 +
drivers/ide/ide-floppy_ioctl.c | 35 +++
drivers/ide/ide-gd.c | 14 +
drivers/ide/ide-ioctls.c | 44 ++-
drivers/ide/ide-tape.c | 11 +
drivers/scsi/aic94xx/aic94xx_init.c | 3 +
drivers/scsi/ch.c | 9 +-
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 +
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 +
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +
drivers/scsi/ipr.c | 3 +
drivers/scsi/isci/init.c | 3 +
drivers/scsi/mvsas/mv_init.c | 3 +
drivers/scsi/pm8001/pm8001_init.c | 3 +
drivers/scsi/scsi_ioctl.c | 54 +++-
drivers/scsi/sd.c | 50 ++-
drivers/scsi/sg.c | 170 +++++-----
drivers/scsi/sr.c | 53 +++-
drivers/scsi/st.c | 51 +--
fs/Makefile | 2 +-
fs/compat_ioctl.c | 261 ----------------
fs/internal.h | 6 -
fs/ioctl.c | 131 +++++---
include/linux/blkdev.h | 7 +
include/linux/compat.h | 18 ++
include/linux/falloc.h | 2 -
include/linux/fs.h | 4 -
include/linux/ide.h | 2 +
include/linux/libata.h | 6 +
include/scsi/scsi_ioctl.h | 1 +
include/scsi/sg.h | 30 ++
62 files changed, 1257 insertions(+), 1171 deletions(-)
create mode 100644 Documentation/core-api/ioctl.rst
delete mode 100644 block/compat_ioctl.c
delete mode 100644 fs/compat_ioctl.c
--
2.20.0
Hi Jens, James and Martin,
This series concludes the work I did for linux-5.5 on the compat_ioctl()
cleanup, killing off fs/compat_ioctl.c and block/compat_ioctl.c by moving
everything into drivers.
Overall this would be a reduction both in complexity and line count, but
as I'm also adding documentation the overall number of lines increases
in the end.
My plan was originally to keep the SCSI and block parts separate.
This did not work easily because of interdependencies: I cannot
do the final SCSI cleanup in a good way without first addressing the
CDROM ioctls, so this is one series that I hope could be merged through
either the block or the scsi git trees, or possibly both if you can
pull in the same branch.
The series comes in these steps:
1. clean up the sg v3 interface as suggested by Linus. I have
talked about this with Doug Gilbert as well, and he would
rebase his sg v4 patches on top of "compat: scsi: sg: fix v3
compat read/write interface"
2. Four patches for missing block compat_ioctl handlers, to be
backported into stable kernels. Separate patches because they
are needed in different stable versions.
3. Actually moving handlers out of block/compat_ioctl.c and
block/scsi_ioctl.c into drivers, mixed in with cleanup
patches
4. Document how to do this right. I keep getting asked about this,
and it helps to point to some documentation file.
The series is avaialable for testing at [1].
Arnd
[1] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=…
Arnd Bergmann (24):
compat: ARM64: always include asm-generic/compat.h
compat: scsi: sg: fix v3 compat read/write interface
compat_ioctl: block: handle BLKREPORTZONE/BLKRESETZONE
compat_ioctl: block: handle BLKGETZONESZ/BLKGETNRZONES
compat_ioctl: block: handle add zone open, close and finish ioctl
compat_ioctl: block: handle Persistent Reservations
compaT_ioctl: ubd, aoe: use blkdev_compat_ptr_ioctl
compat_ioctl: move CDROM_SEND_PACKET handling into scsi
compat_ioctl: move CDROMREADADIO to cdrom.c
compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN
compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers
compat_ioctl: add scsi_compat_ioctl
compat_ioctl: bsg: add handler
compat_ioctl: ide: floppy: add handler
compat_ioctl: scsi: move ioctl handling into drivers
compat_ioctl: move sys_compat_ioctl() to ioctl.c
compat_ioctl: simplify the implementation
compat_ioctl: move cdrom commands into cdrom.c
compat_ioctl: scsi: handle HDIO commands from drivers
compat_ioctl: move HDIO ioctl handling into drivers/ide
compat_ioctl: block: move blkdev_compat_ioctl() into ioctl.c
compat_ioctl: block: simplify compat_blkpg_ioctl()
compat_ioctl: simplify up block/ioctl.c
Documentation: document ioctl interfaces better
Documentation/core-api/index.rst | 1 +
Documentation/core-api/ioctl.rst | 250 +++++++++++++++
arch/arm64/include/asm/compat.h | 5 +-
arch/um/drivers/ubd_kern.c | 1 +
block/Makefile | 1 -
block/bsg.c | 1 +
block/compat_ioctl.c | 411 -------------------------
block/ioctl.c | 319 +++++++++++++++----
block/scsi_ioctl.c | 214 ++++++++-----
drivers/ata/libata-scsi.c | 9 +
drivers/block/aoe/aoeblk.c | 1 +
drivers/block/floppy.c | 3 +
drivers/block/paride/pcd.c | 3 +
drivers/block/paride/pd.c | 1 +
drivers/block/paride/pf.c | 1 +
drivers/block/pktcdvd.c | 26 +-
drivers/block/sunvdc.c | 1 +
drivers/block/virtio_blk.c | 3 +
drivers/block/xen-blkfront.c | 1 +
drivers/cdrom/cdrom.c | 35 ++-
drivers/cdrom/gdrom.c | 3 +
drivers/ide/ide-cd.c | 40 +++
drivers/ide/ide-disk.c | 3 +
drivers/ide/ide-floppy.c | 4 +
drivers/ide/ide-floppy.h | 2 +
drivers/ide/ide-floppy_ioctl.c | 35 +++
drivers/ide/ide-gd.c | 14 +
drivers/ide/ide-ioctls.c | 47 ++-
drivers/ide/ide-tape.c | 14 +
drivers/scsi/aic94xx/aic94xx_init.c | 3 +
drivers/scsi/ch.c | 9 +-
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 +
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 +
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +
drivers/scsi/ipr.c | 3 +
drivers/scsi/isci/init.c | 3 +
drivers/scsi/mvsas/mv_init.c | 3 +
drivers/scsi/pm8001/pm8001_init.c | 3 +
drivers/scsi/scsi_ioctl.c | 54 +++-
drivers/scsi/sd.c | 50 ++-
drivers/scsi/sg.c | 169 +++++-----
drivers/scsi/sr.c | 53 +++-
drivers/scsi/st.c | 51 +--
fs/Makefile | 2 +-
fs/compat_ioctl.c | 261 ----------------
fs/internal.h | 6 -
fs/ioctl.c | 131 +++++---
include/linux/blkdev.h | 7 +
include/linux/falloc.h | 2 -
include/linux/fs.h | 4 -
include/linux/ide.h | 2 +
include/linux/libata.h | 6 +
include/scsi/scsi_ioctl.h | 1 +
include/scsi/sg.h | 30 ++
54 files changed, 1249 insertions(+), 1062 deletions(-)
create mode 100644 Documentation/core-api/ioctl.rst
delete mode 100644 block/compat_ioctl.c
delete mode 100644 fs/compat_ioctl.c
--
2.20.0
Cc: corbet(a)lwn.net
Cc: catalin.marinas(a)arm.com
Cc: will(a)kernel.org
Cc: jdike(a)addtoit.com
Cc: richard(a)nod.at
Cc: anton.ivanov(a)cambridgegreys.com
Cc: fujita.tomonori(a)lab.ntt.co.jp
Cc: justin(a)coraid.com
Cc: efremov(a)linux.com
Cc: tim(a)cyberelk.net
Cc: mst(a)redhat.com
Cc: jasowang(a)redhat.com
Cc: pbonzini(a)redhat.com
Cc: stefanha(a)redhat.com
Cc: boris.ostrovsky(a)oracle.com
Cc: jgross(a)suse.com
Cc: sstabellini(a)kernel.org
Cc: konrad.wilk(a)oracle.com
Cc: roger.pau(a)citrix.com
Cc: bp(a)alien8.de
Cc: davem(a)davemloft.net
Cc: john.garry(a)huawei.com
Cc: brking(a)us.ibm.com
Cc: intel-linux-scu(a)intel.com
Cc: artur.paszkiewicz(a)intel.com
Cc: jinpu.wang(a)cloud.ionos.com
Cc: dgilbert(a)interlog.com
Cc: Kai.Makisara(a)kolumbus.fi
Cc: arnd(a)arndb.de
Cc: damien.lemoal(a)hgst.com
Cc: hare(a)suse.com
Cc: linux-doc(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
Cc: linux-block(a)vger.kernel.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-um(a)lists.infradead.org
Cc: linux-scsi(a)vger.kernel.org
Cc: linux-ide(a)vger.kernel.org
Cc: virtualization(a)lists.linux-foundation.org
Cc: xen-devel(a)lists.xenproject.org
Cc: linux-fsdevel(a)vger.kernel.org
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.
I uploaded git branch on top of the v4l2/dvb branch to [2].
Arnd
Changes since v5:
- Fix all bugs that Hans found during testing
- Add a comment about x32 still being broken
Changes since v4:
- Move non-public contents out of uapi header
- split out __kernel_v4l2_timeval into separate struct
- use compound initializers for v4l2_event_time32 and
v4l2_buffer_time32 conversion
- add comment for v4l2_buffer_get_timestamp()
Changes since v3:
- This is a minor update compared to version 3 of this series,
with bugfixes for small mistakes that I found or that were
reported by automated build bots.
[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: compat: 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 | 477 +++++++++++++++---
drivers/media/v4l2-core/v4l2-event.c | 5 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 211 ++++++--
drivers/media/v4l2-core/v4l2-subdev.c | 26 +-
drivers/media/v4l2-core/videobuf-core.c | 5 +-
include/media/v4l2-common.h | 21 +
include/media/v4l2-ioctl.h | 55 ++
include/trace/events/v4l2.h | 2 +-
include/uapi/linux/videodev2.h | 29 ++
16 files changed, 718 insertions(+), 135 deletions(-)
--
2.20.0
Push clamping timestamps down the call stack into notify_change(), so
in-kernel callers like nfsd and overlayfs will get similar timestamp
set behavior as utimes.
Suggested-by: Miklos Szeredi <mszeredi(a)redhat.com>
Fixes: 42e729b9ddbb ("utimes: Clamp the timestamps before update")
Cc: stable(a)vger.kernel.org # v5.4
Cc: Deepa Dinamani <deepa.kernel(a)gmail.com>
Cc: Jeff Layton <jlayton(a)kernel.org>
Signed-off-by: Amir Goldstein <amir73il(a)gmail.com>
---
Arnd,
This fixes xfstest generic/402 when run with -overlay setup.
Note that running the test requires latest xfstests with:
acb2ba78 - overlay: support timestamp range check
I had previously posted a fix specific for overlayfs [1],
but Miklos suggested this more generic fix, which should also
serve nfsd and other in-kernel users.
I tested this change with test generic/402 on ext4/xfs/btrfs
and overlayfs, but not with nfsd.
Jeff, could you ack this change is good for nfsd as well?
Thanks,
Amir.
[1] https://lore.kernel.org/linux-fsdevel/20191111073000.2957-1-amir73il@gmail.…
fs/attr.c | 5 +++++
fs/utimes.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/attr.c b/fs/attr.c
index df28035aa23e..e8de5e636e66 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -268,8 +268,13 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
attr->ia_ctime = now;
if (!(ia_valid & ATTR_ATIME_SET))
attr->ia_atime = now;
+ else
+ attr->ia_atime = timestamp_truncate(attr->ia_atime, inode);
if (!(ia_valid & ATTR_MTIME_SET))
attr->ia_mtime = now;
+ else
+ attr->ia_mtime = timestamp_truncate(attr->ia_mtime, inode);
+
if (ia_valid & ATTR_KILL_PRIV) {
error = security_inode_need_killpriv(dentry);
if (error < 0)
diff --git a/fs/utimes.c b/fs/utimes.c
index 1ba3f7883870..090739322463 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -36,14 +36,14 @@ static int utimes_common(const struct path *path, struct timespec64 *times)
if (times[0].tv_nsec == UTIME_OMIT)
newattrs.ia_valid &= ~ATTR_ATIME;
else if (times[0].tv_nsec != UTIME_NOW) {
- newattrs.ia_atime = timestamp_truncate(times[0], inode);
+ newattrs.ia_atime = times[0];
newattrs.ia_valid |= ATTR_ATIME_SET;
}
if (times[1].tv_nsec == UTIME_OMIT)
newattrs.ia_valid &= ~ATTR_MTIME;
else if (times[1].tv_nsec != UTIME_NOW) {
- newattrs.ia_mtime = timestamp_truncate(times[1], inode);
+ newattrs.ia_mtime = times[1];
newattrs.ia_valid |= ATTR_MTIME_SET;
}
/*
--
2.17.1
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.
This is a minor update compared to version 3 of this series,
with bugfixes for small mistakes that I found or that were
reported by automated build bots. I updated the tree at [2]
to this version now.
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: compat: 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 | 470 +++++++++++++++---
drivers/media/v4l2-core/v4l2-event.c | 5 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 188 +++++--
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 | 77 +++
15 files changed, 669 insertions(+), 136 deletions(-)
--
2.20.0
See below for the changes compared to v3:
|diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
|index a13e4849df0c..3bbf47d950e0 100644
|--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
|+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
|@@ -500,7 +500,7 @@ struct v4l2_buffer32_time32 {
| __u32 bytesused;
| __u32 flags;
| __u32 field; /* enum v4l2_field */
|- struct compat_timeval timestamp;
|+ struct old_timeval32 timestamp;
| struct v4l2_timecode timecode;
| __u32 sequence;
|
|@@ -1290,7 +1290,7 @@ struct v4l2_event32_time32 {
| } u;
| __u32 pending;
| __u32 sequence;
|- struct compat_timespec timestamp;
|+ struct old_timespec32 timestamp;
| __u32 id;
| __u32 reserved[8];
| };
|@@ -1482,8 +1482,8 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
| case VIDIOC_S_EXT_CTRLS32: ncmd = VIDIOC_S_EXT_CTRLS; break;
| case VIDIOC_TRY_EXT_CTRLS32: ncmd = VIDIOC_TRY_EXT_CTRLS; break;
| #ifdef CONFIG_X86_64
|- case VIDIOC_DQEVENT32: cmd = VIDIOC_DQEVENT; break;
|- case VIDIOC_DQEVENT32_TIME32: cmd = VIDIOC_DQEVENT_TIME32; break;
|+ case VIDIOC_DQEVENT32: ncmd = VIDIOC_DQEVENT; break;
|+ case VIDIOC_DQEVENT32_TIME32: ncmd = VIDIOC_DQEVENT_TIME32; break;
| #endif
| case VIDIOC_OVERLAY32: ncmd = VIDIOC_OVERLAY; break;
| case VIDIOC_STREAMON32: ncmd = VIDIOC_STREAMON; break;
|diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
|index cd9a80960289..ad125cd4eb41 100644
|--- a/drivers/media/v4l2-core/v4l2-ioctl.c
|+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
|@@ -474,7 +474,7 @@ static void v4l_print_buffer(const void *arg, bool write_only)
| const struct v4l2_plane *plane;
| int i;
|
|- pr_cont("%02ld:%02d:%02d.%09ld index=%d, type=%s, request_fd=%d, flags=0x%08x, field=%s, sequence=%d, memory=%s",
|+ pr_cont("%02d:%02d:%02d.%09ld index=%d, type=%s, request_fd=%d, flags=0x%08x, field=%s, sequence=%d, memory=%s",
| (int)p->timestamp.tv_sec / 3600,
| ((int)p->timestamp.tv_sec / 60) % 60,
| ((int)p->timestamp.tv_sec % 60),
|@@ -821,7 +821,7 @@ static void v4l_print_event(const void *arg, bool write_only)
| const struct v4l2_event *p = arg;
| const struct v4l2_event_ctrl *c;
|
|- pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, timestamp=%lu.%9.9lu\n",
|+ pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, timestamp=%llu.%9.9llu\n",
| p->type, p->pending, p->sequence, p->id,
| p->timestamp.tv_sec, p->timestamp.tv_nsec);
| switch (p->type) {
|diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
|index 481ee3013b50..4086036e37d5 100644
|--- a/include/linux/videodev2.h
|+++ b/include/linux/videodev2.h
|@@ -62,7 +62,7 @@
| static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
| {
| return buf->timestamp.tv_sec * NSEC_PER_SEC +
|- buf->timestamp.tv_usec * NSEC_PER_USEC;
|+ (u32)buf->timestamp.tv_usec * NSEC_PER_USEC;
| }
|
| static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf,
|diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
|index 4275d6e92dae..ca10828328a5 100644
|--- a/include/uapi/linux/videodev2.h
|+++ b/include/uapi/linux/videodev2.h
|@@ -1001,7 +1001,12 @@ struct v4l2_buffer {
| /* match glibc timeval64 format */
| struct {
| long long tv_sec;
|+# if defined(__sparc__) && defined(__arch64__)
|+ int tv_usec;
|+ int __pad;
|+# else
| long long tv_usec;
|+# endif
| } timestamp;
| #else
| struct timeval timestamp;
|
I've gone through the remaining uses of time_t etc and come up with a
set of 90 patches of varying complexity and importance, to the point
of being able to remove the old time_t/timeval/timespec from the kernel
headers completely.
This set includes the eight patches that I think should be merged
right away and backported into stable kernels if possible.
Please apply individual patches to the respective maintainer trees
for either v5.4 or v5.5 as appropriate.
For reference, the full series of 90 patches can be found at
https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=…
Arnd
Arnd Bergmann (8):
y2038: timex: remove incorrect time_t truncation
timekeeping: optimize ns_to_timespec64
powerpc: fix vdso32 for ppc64le
ipmi: kill off 'timespec' usage again
netfilter: xt_time: use time64_t
lp: fix sparc64 LPSETTIMEOUT ioctl
ppdev: fix PPGETTIME/PPSETTIME ioctls
Input: input_event: fix struct padding on sparc64
arch/powerpc/kernel/vdso32/gettimeofday.S | 2 +-
drivers/char/ipmi/ipmi_si_intf.c | 40 ++++++++---------------
drivers/char/lp.c | 4 +++
drivers/char/ppdev.c | 16 ++++++---
drivers/input/evdev.c | 3 ++
drivers/input/misc/uinput.c | 3 ++
include/uapi/linux/input.h | 1 +
kernel/time/ntp.c | 2 +-
kernel/time/time.c | 21 +++++++-----
net/netfilter/xt_time.c | 19 ++++++-----
10 files changed, 61 insertions(+), 50 deletions(-)
Cc: Benjamin Herrenschmidt <benh(a)kernel.crashing.org>
Cc: Paul Mackerras <paulus(a)samba.org>
Cc: Michael Ellerman <mpe(a)ellerman.id.au>
Cc: Corey Minyard <minyard(a)acm.org>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Sudip Mukherjee <sudipm.mukherjee(a)gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov(a)gmail.com>
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Stephen Boyd <sboyd(a)kernel.org>
Cc: Pablo Neira Ayuso <pablo(a)netfilter.org>
Cc: Jozsef Kadlecsik <kadlec(a)netfilter.org>
Cc: Florian Westphal <fw(a)strlen.de>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: linuxppc-dev(a)lists.ozlabs.org
Cc: linux-kernel(a)vger.kernel.org
Cc: openipmi-developer(a)lists.sourceforge.net
Cc: linux-input(a)vger.kernel.org
Cc: netfilter-devel(a)vger.kernel.org
Cc: coreteam(a)netfilter.org
Cc: netdev(a)vger.kernel.org
Cc: sparclinux(a)vger.kernel.org
--
2.20.0
On compat interfaces, the high order bits of nanoseconds should
be zeroed out. This is because the application code or the libc
do not guarantee zeroing of these. If used without zeroing,
kernel might be at risk of using timespec values incorrectly.
Originally it was handled correctly, but lost during is_compat_syscall()
cleanup. Revert the condition back to check CONFIG_64BIT.
Reported-by: Ben Hutchings <ben.hutchings(a)codethink.co.uk>
Fixes: 98f76206b335 ("compat: Cleanup in_compat_syscall() callers")
Cc: Arnd Bergmann <arnd(a)arndb.de>
Cc: Ben Hutchings <ben.hutchings(a)codethink.co.uk>
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Stephen Boyd <sboyd(a)kernel.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: y2038(a)lists.linaro.org
Cc: stable(a)vger.kernel.org # v4.20+
Signed-off-by: Dmitry Safonov <dima(a)arista.com>
---
kernel/time/time.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 5c54ca632d08..1cb045c5c97e 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -881,7 +881,7 @@ int get_timespec64(struct timespec64 *ts,
ts->tv_sec = kts.tv_sec;
/* Zero out the padding for 32 bit systems or in compat mode */
- if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
+ if (IS_ENABLED(CONFIG_64BIT_TIME) && (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()))
kts.tv_nsec &= 0xFFFFFFFFUL;
ts->tv_nsec = kts.tv_nsec;
--
2.24.0