* [PATCH v2 00/24] drivers, fs: y2038 updates
@ 2019-12-13 20:49 Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-13 20:49 UTC (permalink / raw)
To: y2038, linux-kernel
Cc: Arnd Bergmann, jdike, richard, jcmvbkbc, stefanr, l.stach,
linux+etnaviv, christian.gmeiner, airlied, daniel, robdclark,
sean, valdis.kletnieks, gregkh, ccaulfie, teigland, hirofumi,
jack, davem, fw, viro, rfontana, tglx, linux-um, linux1394-devel,
etnaviv, dri-devel, linux-arm-msm, freedreno, devel,
cluster-devel, linux-fsdevel, netdev, trond.myklebust,
anna.schumaker, linux-nfs, linux-xfs, darrick.wong, sparclinux
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. I will
add these to my y2038 branch [1] for linux-next, but can keep
rebasing for feedback and to remove any patches that get
picked up by a maintainer.
Changes since v1 [2]:
- Add Acks I received
- Rebase to v5.5-rc1, droping patches that got merged already
- Add NFS, XFS and the final three patches from another series
- Rewrite etnaviv patches
Arnd
[1] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=y2038
[2] https://lore.kernel.org/lkml/20191108213257.3097633-1-arnd@arndb.de/
Arnd Bergmann (24):
Input: input_event: fix struct padding on sparc64
fat: use prandom_u32() for i_generation
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
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: reject timeouts with tv_nsec >= NSEC_PER_SEC
drm/etnaviv: avoid deprecated timespec
sunrpc: convert to time64_t for expiry
nfs: use time64_t internally
nfs: fix timstamp debug prints
nfs: fscache: use timespec64 in inode auxdata
xfs: rename compat_time_t to old_time32_t
xfs: disallow broken ioctls without compat-32-bit-time
xfs: quota: move to time64_t interfaces
y2038: remove obsolete jiffies conversion functions
y2038: rename itimerval to __kernel_old_itimerval
y2038: sparc: remove use of struct timex
arch/sparc/kernel/sys_sparc_64.c | 29 +++++-----
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/gpu/drm/etnaviv/etnaviv_drv.c | 20 ++++---
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 11 ++--
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 4 +-
drivers/gpu/drm/etnaviv/etnaviv_gem.h | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 +-
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 5 +-
drivers/gpu/drm/msm/msm_drv.h | 3 +-
drivers/input/evdev.c | 14 ++---
drivers/input/misc/uinput.c | 14 +++--
fs/dlm/lowcomms.c | 6 +-
fs/fat/inode.c | 3 +-
fs/hfs/hfs_fs.h | 28 +++++++--
fs/hfs/inode.c | 4 +-
fs/hfsplus/hfsplus_fs.h | 28 +++++++--
fs/hfsplus/inode.c | 12 ++--
fs/hostfs/hostfs.h | 22 ++++---
fs/hostfs/hostfs_kern.c | 15 +++--
fs/nfs/fscache-index.c | 6 +-
fs/nfs/fscache.c | 18 ++++--
fs/nfs/fscache.h | 8 ++-
fs/nfs/nfs4xdr.c | 10 ++--
fs/quota/quotaio_v1.h | 6 +-
fs/xfs/xfs_dquot.c | 6 +-
fs/xfs/xfs_ioctl.c | 26 +++++++++
fs/xfs/xfs_ioctl32.c | 2 +-
fs/xfs/xfs_ioctl32.h | 2 +-
fs/xfs/xfs_qm.h | 6 +-
fs/xfs/xfs_quotaops.c | 6 +-
fs/xfs/xfs_trans_dquot.c | 8 ++-
include/linux/jiffies.h | 20 -------
include/linux/sunrpc/cache.h | 42 ++++++++------
include/linux/sunrpc/gss_api.h | 4 +-
include/linux/sunrpc/gss_krb5.h | 2 +-
include/linux/syscalls.h | 9 ++-
include/uapi/linux/acct.h | 2 +
include/uapi/linux/input.h | 1 +
include/uapi/linux/taskstats.h | 6 +-
include/uapi/linux/time_types.h | 5 ++
include/uapi/linux/timex.h | 2 +
kernel/acct.c | 4 +-
kernel/time/itimer.c | 18 +++---
kernel/time/time.c | 58 ++-----------------
kernel/tsacct.c | 9 ++-
net/packet/af_packet.c | 27 +++++----
net/sunrpc/auth_gss/gss_krb5_mech.c | 12 +++-
net/sunrpc/auth_gss/gss_krb5_seal.c | 8 +--
net/sunrpc/auth_gss/gss_krb5_unseal.c | 6 +-
net/sunrpc/auth_gss/gss_krb5_wrap.c | 16 ++---
net/sunrpc/auth_gss/gss_mech_switch.c | 2 +-
net/sunrpc/auth_gss/svcauth_gss.c | 6 +-
net/sunrpc/cache.c | 16 ++---
net/sunrpc/svcauth_unix.c | 10 ++--
59 files changed, 351 insertions(+), 290 deletions(-)
--
2.20.0
Cc: jdike@addtoit.com
Cc: richard@nod.at
Cc: jcmvbkbc@gmail.com
Cc: stefanr@s5r6.in-berlin.de
Cc: l.stach@pengutronix.de
Cc: linux+etnaviv@armlinux.org.uk
Cc: christian.gmeiner@gmail.com
Cc: airlied@linux.ie
Cc: daniel@ffwll.ch
Cc: robdclark@gmail.com
Cc: sean@poorly.run
Cc: valdis.kletnieks@vt.edu
Cc: gregkh@linuxfoundation.org
Cc: ccaulfie@redhat.com
Cc: teigland@redhat.com
Cc: hirofumi@mail.parknet.co.jp
Cc: jack@suse.com
Cc: davem@davemloft.net
Cc: fw@strlen.de
Cc: viro@zeniv.linux.org.uk
Cc: rfontana@redhat.com
Cc: tglx@linutronix.de
Cc: linux-um@lists.infradead.org
Cc: linux1394-devel@lists.sourceforge.net
Cc: etnaviv@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: devel@driverdev.osuosl.org
Cc: cluster-devel@redhat.com
Cc: linux-fsdevel@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: trond.myklebust@hammerspace.com
Cc: anna.schumaker@netapp.com
Cc: linux-nfs@vger.kernel.org
Cc: linux-xfs@vger.kernel.org
Cc: darrick.wong@oracle.com
Cc: sparclinux@vger.kernel.org
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t
2019-12-13 20:49 [PATCH v2 00/24] drivers, fs: y2038 updates Arnd Bergmann
@ 2019-12-13 20:53 ` Arnd Bergmann
2019-12-13 21:18 ` Darrick J. Wong
2019-12-13 20:53 ` [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Arnd Bergmann
2 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-13 20:53 UTC (permalink / raw)
To: y2038, linux-kernel, Darrick J. Wong, linux-xfs
Cc: Arnd Bergmann, Brian Foster, Eric Sandeen, Nick Bowler
The compat_time_t type has been removed everywhere else,
as most users rely on old_time32_t for both native and
compat mode handling of 32-bit time_t.
Remove the last one in xfs.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/xfs/xfs_ioctl32.c | 2 +-
fs/xfs/xfs_ioctl32.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index c4c4f09113d3..a49bd80b2c3b 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -107,7 +107,7 @@ xfs_ioctl32_bstime_copyin(
xfs_bstime_t *bstime,
compat_xfs_bstime_t __user *bstime32)
{
- compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */
+ old_time32_t sec32; /* tv_sec differs on 64 vs. 32 */
if (get_user(sec32, &bstime32->tv_sec) ||
get_user(bstime->tv_nsec, &bstime32->tv_nsec))
diff --git a/fs/xfs/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h
index 8c7743cd490e..053de7d894cd 100644
--- a/fs/xfs/xfs_ioctl32.h
+++ b/fs/xfs/xfs_ioctl32.h
@@ -32,7 +32,7 @@
#endif
typedef struct compat_xfs_bstime {
- compat_time_t tv_sec; /* seconds */
+ old_time32_t tv_sec; /* seconds */
__s32 tv_nsec; /* and nanoseconds */
} compat_xfs_bstime_t;
--
2.20.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time
2019-12-13 20:49 [PATCH v2 00/24] drivers, fs: y2038 updates Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann
@ 2019-12-13 20:53 ` Arnd Bergmann
2019-12-13 21:05 ` Darrick J. Wong
2019-12-13 20:53 ` [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Arnd Bergmann
2 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-13 20:53 UTC (permalink / raw)
To: y2038, linux-kernel, Darrick J. Wong, linux-xfs
Cc: Arnd Bergmann, Brian Foster, Dave Chinner, Allison Collins,
Jan Kara, Eric Sandeen
When building a kernel that disables support for 32-bit time_t
system calls, it also makes sense to disable the old xfs_bstat
ioctls completely, as they truncate the timestamps to 32-bit
values.
Any application using these needs to be updated to use the v5
interfaces.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/xfs/xfs_ioctl.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 7b35d62ede9f..a4a4eed8879c 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -36,6 +36,7 @@
#include "xfs_reflink.h"
#include "xfs_ioctl.h"
+#include <linux/compat.h>
#include <linux/mount.h>
#include <linux/namei.h>
@@ -617,6 +618,23 @@ xfs_fsinumbers_fmt(
return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp));
}
+/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */
+static bool xfs_have_compat_bstat_time32(unsigned int cmd)
+{
+ if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME))
+ return true;
+
+ if (IS_ENABLED(CONFIG_64BIT) && !in_compat_syscall())
+ return true;
+
+ if (cmd == XFS_IOC_FSBULKSTAT_SINGLE ||
+ cmd == XFS_IOC_FSBULKSTAT ||
+ cmd == XFS_IOC_SWAPEXT)
+ return false;
+
+ return true;
+}
+
STATIC int
xfs_ioc_fsbulkstat(
xfs_mount_t *mp,
@@ -637,6 +655,9 @@ xfs_ioc_fsbulkstat(
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ if (!xfs_have_compat_bstat_time32(cmd))
+ return -EINVAL;
+
if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
@@ -1815,6 +1836,11 @@ xfs_ioc_swapext(
struct fd f, tmp;
int error = 0;
+ if (xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) {
+ error = -EINVAL;
+ goto out;
+ }
+
/* Pull information for the target fd */
f = fdget((int)sxp->sx_fdtarget);
if (!f.file) {
--
2.20.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-13 20:49 [PATCH v2 00/24] drivers, fs: y2038 updates Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Arnd Bergmann
@ 2019-12-13 20:53 ` Arnd Bergmann
2019-12-13 21:17 ` Darrick J. Wong
2 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-13 20:53 UTC (permalink / raw)
To: y2038, linux-kernel, Darrick J. Wong, linux-xfs
Cc: Arnd Bergmann, Brian Foster, Carlos Maiolino, Pavel Reichl,
Eric Sandeen, Dave Chinner, Allison Collins, Jan Kara
As a preparation for removing the 32-bit time_t type and
all associated interfaces, change xfs to use time64_t and
ktime_get_real_seconds() for the quota housekeeping.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/xfs/xfs_dquot.c | 6 +++---
fs/xfs/xfs_qm.h | 6 +++---
fs/xfs/xfs_quotaops.c | 6 +++---
fs/xfs/xfs_trans_dquot.c | 8 +++++---
4 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 2bff21ca9d78..9cfd3209f52b 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers(
(d->d_blk_hardlimit &&
(be64_to_cpu(d->d_bcount) >
be64_to_cpu(d->d_blk_hardlimit)))) {
- d->d_btimer = cpu_to_be32(get_seconds() +
+ d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
mp->m_quotainfo->qi_btimelimit);
} else {
d->d_bwarns = 0;
@@ -160,7 +160,7 @@ xfs_qm_adjust_dqtimers(
(d->d_ino_hardlimit &&
(be64_to_cpu(d->d_icount) >
be64_to_cpu(d->d_ino_hardlimit)))) {
- d->d_itimer = cpu_to_be32(get_seconds() +
+ d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
mp->m_quotainfo->qi_itimelimit);
} else {
d->d_iwarns = 0;
@@ -183,7 +183,7 @@ xfs_qm_adjust_dqtimers(
(d->d_rtb_hardlimit &&
(be64_to_cpu(d->d_rtbcount) >
be64_to_cpu(d->d_rtb_hardlimit)))) {
- d->d_rtbtimer = cpu_to_be32(get_seconds() +
+ d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
mp->m_quotainfo->qi_rtbtimelimit);
} else {
d->d_rtbwarns = 0;
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
index 7823af39008b..4e57edca8bce 100644
--- a/fs/xfs/xfs_qm.h
+++ b/fs/xfs/xfs_qm.h
@@ -64,9 +64,9 @@ struct xfs_quotainfo {
struct xfs_inode *qi_pquotaip; /* project quota inode */
struct list_lru qi_lru;
int qi_dquots;
- time_t qi_btimelimit; /* limit for blks timer */
- time_t qi_itimelimit; /* limit for inodes timer */
- time_t qi_rtbtimelimit;/* limit for rt blks timer */
+ time64_t qi_btimelimit; /* limit for blks timer */
+ time64_t qi_itimelimit; /* limit for inodes timer */
+ time64_t qi_rtbtimelimit;/* limit for rt blks timer */
xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index c7de17deeae6..38669e827206 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -37,9 +37,9 @@ xfs_qm_fill_state(
tstate->flags |= QCI_SYSFILE;
tstate->blocks = ip->i_d.di_nblocks;
tstate->nextents = ip->i_d.di_nextents;
- tstate->spc_timelimit = q->qi_btimelimit;
- tstate->ino_timelimit = q->qi_itimelimit;
- tstate->rt_spc_timelimit = q->qi_rtbtimelimit;
+ tstate->spc_timelimit = (u32)q->qi_btimelimit;
+ tstate->ino_timelimit = (u32)q->qi_itimelimit;
+ tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit;
tstate->spc_warnlimit = q->qi_bwarnlimit;
tstate->ino_warnlimit = q->qi_iwarnlimit;
tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index a6fe2d8dc40f..d1b9869bc5fa 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -580,7 +580,7 @@ xfs_trans_dqresv(
{
xfs_qcnt_t hardlimit;
xfs_qcnt_t softlimit;
- time_t timer;
+ time64_t timer;
xfs_qwarncnt_t warns;
xfs_qwarncnt_t warnlimit;
xfs_qcnt_t total_count;
@@ -635,7 +635,8 @@ xfs_trans_dqresv(
goto error_return;
}
if (softlimit && total_count > softlimit) {
- if ((timer != 0 && get_seconds() > timer) ||
+ if ((timer != 0 &&
+ ktime_get_real_seconds() > timer) ||
(warns != 0 && warns >= warnlimit)) {
xfs_quota_warn(mp, dqp,
QUOTA_NL_BSOFTLONGWARN);
@@ -662,7 +663,8 @@ xfs_trans_dqresv(
goto error_return;
}
if (softlimit && total_count > softlimit) {
- if ((timer != 0 && get_seconds() > timer) ||
+ if ((timer != 0 &&
+ ktime_get_real_seconds() > timer) ||
(warns != 0 && warns >= warnlimit)) {
xfs_quota_warn(mp, dqp,
QUOTA_NL_ISOFTLONGWARN);
--
2.20.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time
2019-12-13 20:53 ` [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Arnd Bergmann
@ 2019-12-13 21:05 ` Darrick J. Wong
2019-12-16 16:45 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2019-12-13 21:05 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038, linux-kernel, linux-xfs, Brian Foster, Dave Chinner,
Allison Collins, Jan Kara, Eric Sandeen
On Fri, Dec 13, 2019 at 09:53:48PM +0100, Arnd Bergmann wrote:
> When building a kernel that disables support for 32-bit time_t
> system calls, it also makes sense to disable the old xfs_bstat
> ioctls completely, as they truncate the timestamps to 32-bit
> values.
Note that current xfs doesn't support > 32-bit timestamps at all, so for
now the old bulkstat/swapext ioctls will never overflow.
Granted, I melded everyone's suggestions into a more fully formed
'bigtime' feature patchset that I'll dump out soon as part of my usual
end of year carpetbombing of the mailing list, so we likely still need
most of this patch anyway...
> Any application using these needs to be updated to use the v5
> interfaces.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> fs/xfs/xfs_ioctl.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 7b35d62ede9f..a4a4eed8879c 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -36,6 +36,7 @@
> #include "xfs_reflink.h"
> #include "xfs_ioctl.h"
>
> +#include <linux/compat.h>
> #include <linux/mount.h>
> #include <linux/namei.h>
>
> @@ -617,6 +618,23 @@ xfs_fsinumbers_fmt(
> return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp));
> }
>
> +/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */
> +static bool xfs_have_compat_bstat_time32(unsigned int cmd)
The v5 bulkstat ioctls follow an entirely separate path through
xfs_ioctl.c, so I think you don't need the @cmd parameter.
> +{
> + if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME))
> + return true;
> +
> + if (IS_ENABLED(CONFIG_64BIT) && !in_compat_syscall())
> + return true;
> +
> + if (cmd == XFS_IOC_FSBULKSTAT_SINGLE ||
> + cmd == XFS_IOC_FSBULKSTAT ||
> + cmd == XFS_IOC_SWAPEXT)
> + return false;
> +
> + return true;
> +}
> +
> STATIC int
> xfs_ioc_fsbulkstat(
> xfs_mount_t *mp,
> @@ -637,6 +655,9 @@ xfs_ioc_fsbulkstat(
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
>
> + if (!xfs_have_compat_bstat_time32(cmd))
> + return -EINVAL;
> +
> if (XFS_FORCED_SHUTDOWN(mp))
> return -EIO;
>
> @@ -1815,6 +1836,11 @@ xfs_ioc_swapext(
> struct fd f, tmp;
> int error = 0;
>
> + if (xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) {
if (!xfs_have...()) ?
--D
> + error = -EINVAL;
> + goto out;
> + }
> +
> /* Pull information for the target fd */
> f = fdget((int)sxp->sx_fdtarget);
> if (!f.file) {
> --
> 2.20.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-13 20:53 ` [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Arnd Bergmann
@ 2019-12-13 21:17 ` Darrick J. Wong
2019-12-16 16:52 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2019-12-13 21:17 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038, linux-kernel, linux-xfs, Brian Foster, Carlos Maiolino,
Pavel Reichl, Eric Sandeen, Dave Chinner, Allison Collins,
Jan Kara
On Fri, Dec 13, 2019 at 09:53:49PM +0100, Arnd Bergmann wrote:
> As a preparation for removing the 32-bit time_t type and
> all associated interfaces, change xfs to use time64_t and
> ktime_get_real_seconds() for the quota housekeeping.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Looks mostly reasonable to me...
The bigtime series refactors the triplicated timer handling and whatnot,
but I don't think it would be difficult to rebase that series assuming
this lands first (which it probably will, I expect a new incompat ondisk
feature to take a /long/ time to get through review.)
> ---
> fs/xfs/xfs_dquot.c | 6 +++---
> fs/xfs/xfs_qm.h | 6 +++---
> fs/xfs/xfs_quotaops.c | 6 +++---
> fs/xfs/xfs_trans_dquot.c | 8 +++++---
> 4 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 2bff21ca9d78..9cfd3209f52b 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_blk_hardlimit &&
> (be64_to_cpu(d->d_bcount) >
> be64_to_cpu(d->d_blk_hardlimit)))) {
> - d->d_btimer = cpu_to_be32(get_seconds() +
> + d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
> mp->m_quotainfo->qi_btimelimit);
> } else {
> d->d_bwarns = 0;
> @@ -160,7 +160,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_ino_hardlimit &&
> (be64_to_cpu(d->d_icount) >
> be64_to_cpu(d->d_ino_hardlimit)))) {
> - d->d_itimer = cpu_to_be32(get_seconds() +
> + d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
> mp->m_quotainfo->qi_itimelimit);
> } else {
> d->d_iwarns = 0;
> @@ -183,7 +183,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_rtb_hardlimit &&
> (be64_to_cpu(d->d_rtbcount) >
> be64_to_cpu(d->d_rtb_hardlimit)))) {
> - d->d_rtbtimer = cpu_to_be32(get_seconds() +
> + d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
> mp->m_quotainfo->qi_rtbtimelimit);
Hmm, so one thing that I clean up on the way to bigtime is the total
lack of clamping here. If (for example) it's September 2105 and
rtbtimelimit is set to 1 year, this will cause an integer overflow. The
quota timer will be set to 1970 and expire immediately, rather than what
I'd consider the best effort of February 2106.
(I'll grant you the current code also behaves like this...)
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> } else {
> d->d_rtbwarns = 0;
> diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
> index 7823af39008b..4e57edca8bce 100644
> --- a/fs/xfs/xfs_qm.h
> +++ b/fs/xfs/xfs_qm.h
> @@ -64,9 +64,9 @@ struct xfs_quotainfo {
> struct xfs_inode *qi_pquotaip; /* project quota inode */
> struct list_lru qi_lru;
> int qi_dquots;
> - time_t qi_btimelimit; /* limit for blks timer */
> - time_t qi_itimelimit; /* limit for inodes timer */
> - time_t qi_rtbtimelimit;/* limit for rt blks timer */
> + time64_t qi_btimelimit; /* limit for blks timer */
> + time64_t qi_itimelimit; /* limit for inodes timer */
> + time64_t qi_rtbtimelimit;/* limit for rt blks timer */
> xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
> xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
> xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
> diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
> index c7de17deeae6..38669e827206 100644
> --- a/fs/xfs/xfs_quotaops.c
> +++ b/fs/xfs/xfs_quotaops.c
> @@ -37,9 +37,9 @@ xfs_qm_fill_state(
> tstate->flags |= QCI_SYSFILE;
> tstate->blocks = ip->i_d.di_nblocks;
> tstate->nextents = ip->i_d.di_nextents;
> - tstate->spc_timelimit = q->qi_btimelimit;
> - tstate->ino_timelimit = q->qi_itimelimit;
> - tstate->rt_spc_timelimit = q->qi_rtbtimelimit;
> + tstate->spc_timelimit = (u32)q->qi_btimelimit;
> + tstate->ino_timelimit = (u32)q->qi_itimelimit;
> + tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit;
> tstate->spc_warnlimit = q->qi_bwarnlimit;
> tstate->ino_warnlimit = q->qi_iwarnlimit;
> tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index a6fe2d8dc40f..d1b9869bc5fa 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -580,7 +580,7 @@ xfs_trans_dqresv(
> {
> xfs_qcnt_t hardlimit;
> xfs_qcnt_t softlimit;
> - time_t timer;
> + time64_t timer;
> xfs_qwarncnt_t warns;
> xfs_qwarncnt_t warnlimit;
> xfs_qcnt_t total_count;
> @@ -635,7 +635,8 @@ xfs_trans_dqresv(
> goto error_return;
> }
> if (softlimit && total_count > softlimit) {
> - if ((timer != 0 && get_seconds() > timer) ||
> + if ((timer != 0 &&
> + ktime_get_real_seconds() > timer) ||
> (warns != 0 && warns >= warnlimit)) {
> xfs_quota_warn(mp, dqp,
> QUOTA_NL_BSOFTLONGWARN);
> @@ -662,7 +663,8 @@ xfs_trans_dqresv(
> goto error_return;
> }
> if (softlimit && total_count > softlimit) {
> - if ((timer != 0 && get_seconds() > timer) ||
> + if ((timer != 0 &&
> + ktime_get_real_seconds() > timer) ||
> (warns != 0 && warns >= warnlimit)) {
> xfs_quota_warn(mp, dqp,
> QUOTA_NL_ISOFTLONGWARN);
> --
> 2.20.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t
2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann
@ 2019-12-13 21:18 ` Darrick J. Wong
2019-12-16 16:31 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2019-12-13 21:18 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038, linux-kernel, linux-xfs, Brian Foster, Eric Sandeen,
Nick Bowler
On Fri, Dec 13, 2019 at 09:53:47PM +0100, Arnd Bergmann wrote:
> The compat_time_t type has been removed everywhere else,
> as most users rely on old_time32_t for both native and
> compat mode handling of 32-bit time_t.
>
> Remove the last one in xfs.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Looks fine to me, assuming that compat_time_t -> old_time32_t.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_ioctl32.c | 2 +-
> fs/xfs/xfs_ioctl32.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> index c4c4f09113d3..a49bd80b2c3b 100644
> --- a/fs/xfs/xfs_ioctl32.c
> +++ b/fs/xfs/xfs_ioctl32.c
> @@ -107,7 +107,7 @@ xfs_ioctl32_bstime_copyin(
> xfs_bstime_t *bstime,
> compat_xfs_bstime_t __user *bstime32)
> {
> - compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */
> + old_time32_t sec32; /* tv_sec differs on 64 vs. 32 */
>
> if (get_user(sec32, &bstime32->tv_sec) ||
> get_user(bstime->tv_nsec, &bstime32->tv_nsec))
> diff --git a/fs/xfs/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h
> index 8c7743cd490e..053de7d894cd 100644
> --- a/fs/xfs/xfs_ioctl32.h
> +++ b/fs/xfs/xfs_ioctl32.h
> @@ -32,7 +32,7 @@
> #endif
>
> typedef struct compat_xfs_bstime {
> - compat_time_t tv_sec; /* seconds */
> + old_time32_t tv_sec; /* seconds */
> __s32 tv_nsec; /* and nanoseconds */
> } compat_xfs_bstime_t;
>
> --
> 2.20.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t
2019-12-13 21:18 ` Darrick J. Wong
@ 2019-12-16 16:31 ` Arnd Bergmann
0 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-16 16:31 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Eric Sandeen, Nick Bowler
On Fri, Dec 13, 2019 at 10:18 PM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
>
> On Fri, Dec 13, 2019 at 09:53:47PM +0100, Arnd Bergmann wrote:
> > The compat_time_t type has been removed everywhere else,
> > as most users rely on old_time32_t for both native and
> > compat mode handling of 32-bit time_t.
> >
> > Remove the last one in xfs.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Looks fine to me, assuming that compat_time_t -> old_time32_t.
Yes, that's the idea. Christoph asked for the global change last year
as a cleanup,
but I left out xfs and a few others at the time when I was missing
other patches.
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Thanks,
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time
2019-12-13 21:05 ` Darrick J. Wong
@ 2019-12-16 16:45 ` Arnd Bergmann
2019-12-16 16:52 ` Darrick J. Wong
0 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-16 16:45 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Dave Chinner, Allison Collins, Jan Kara,
Eric Sandeen
On Fri, Dec 13, 2019 at 10:05 PM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
>
> On Fri, Dec 13, 2019 at 09:53:48PM +0100, Arnd Bergmann wrote:
> > When building a kernel that disables support for 32-bit time_t
> > system calls, it also makes sense to disable the old xfs_bstat
> > ioctls completely, as they truncate the timestamps to 32-bit
> > values.
>
> Note that current xfs doesn't support > 32-bit timestamps at all, so for
> now the old bulkstat/swapext ioctls will never overflow.
Right, this patch originally came after my version of the 40-bit
timestamps that I dropped from the series now.
I've added "... once the extended times are supported." above now.
> Granted, I melded everyone's suggestions into a more fully formed
> 'bigtime' feature patchset that I'll dump out soon as part of my usual
> end of year carpetbombing of the mailing list, so we likely still need
> most of this patch anyway...
What is the timeline for that work now? I'm mainly interested in
getting the removal of 'time_t/timeval/timespec' and 'get_seconds()'
from the kernel done for v5.6, but it would be good to also have
this patch and the extended timestamps in the same version
just so we can claim that "all known y2038 issues" are addressed
in that release (I'm sure we will run into bugs we don't know yet).
> > @@ -617,6 +618,23 @@ xfs_fsinumbers_fmt(
> > return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp));
> > }
> >
> > +/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */
> > +static bool xfs_have_compat_bstat_time32(unsigned int cmd)
>
> The v5 bulkstat ioctls follow an entirely separate path through
> xfs_ioctl.c, so I think you don't need the @cmd parameter.
The check is there to not forbid XFS_IOC_FSINUMBERS at
the moment, since that is not affected.
> > @@ -1815,6 +1836,11 @@ xfs_ioc_swapext(
> > struct fd f, tmp;
> > int error = 0;
> >
> > + if (xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) {
>
> if (!xfs_have...()) ?
Right, fixed now.
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time
2019-12-16 16:45 ` Arnd Bergmann
@ 2019-12-16 16:52 ` Darrick J. Wong
2019-12-17 15:06 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2019-12-16 16:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Dave Chinner, Allison Collins, Jan Kara,
Eric Sandeen
On Mon, Dec 16, 2019 at 05:45:29PM +0100, Arnd Bergmann wrote:
> On Fri, Dec 13, 2019 at 10:05 PM Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
> >
> > On Fri, Dec 13, 2019 at 09:53:48PM +0100, Arnd Bergmann wrote:
> > > When building a kernel that disables support for 32-bit time_t
> > > system calls, it also makes sense to disable the old xfs_bstat
> > > ioctls completely, as they truncate the timestamps to 32-bit
> > > values.
> >
> > Note that current xfs doesn't support > 32-bit timestamps at all, so for
> > now the old bulkstat/swapext ioctls will never overflow.
>
> Right, this patch originally came after my version of the 40-bit
> timestamps that I dropped from the series now.
>
> I've added "... once the extended times are supported." above now.
>
> > Granted, I melded everyone's suggestions into a more fully formed
> > 'bigtime' feature patchset that I'll dump out soon as part of my usual
> > end of year carpetbombing of the mailing list, so we likely still need
> > most of this patch anyway...
>
> What is the timeline for that work now? I'm mainly interested in
> getting the removal of 'time_t/timeval/timespec' and 'get_seconds()'
> from the kernel done for v5.6, but it would be good to also have
> this patch and the extended timestamps in the same version
> just so we can claim that "all known y2038 issues" are addressed
> in that release (I'm sure we will run into bugs we don't know yet).
Personally, I think you should push this whenever it's ready. Are you
aiming to send all 24 patches as a treewide pull request directly to
Linus, or would you rather the 2-3 xfs patches go through the xfs tree?
The y2038 format changes are going to take a while to push through
review. If somehow it all gets through review for 5.6 I can always
apply both and fix the merge damage, but more likely y2038 timestamps is
a <cough> 5.8 EXPERIMENTAL thing.
Or later, given that Dave and I both have years worth of unreviewed
patch backlog. :(
> > > @@ -617,6 +618,23 @@ xfs_fsinumbers_fmt(
> > > return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp));
> > > }
> > >
> > > +/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */
> > > +static bool xfs_have_compat_bstat_time32(unsigned int cmd)
> >
> > The v5 bulkstat ioctls follow an entirely separate path through
> > xfs_ioctl.c, so I think you don't need the @cmd parameter.
>
> The check is there to not forbid XFS_IOC_FSINUMBERS at
> the moment, since that is not affected.
Aha.
> > > @@ -1815,6 +1836,11 @@ xfs_ioc_swapext(
> > > struct fd f, tmp;
> > > int error = 0;
> > >
> > > + if (xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) {
> >
> > if (!xfs_have...()) ?
>
> Right, fixed now.
<nod>
--D
> Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-13 21:17 ` Darrick J. Wong
@ 2019-12-16 16:52 ` Arnd Bergmann
2019-12-17 15:02 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-16 16:52 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Carlos Maiolino, Pavel Reichl, Eric Sandeen,
Dave Chinner, Allison Collins, Jan Kara
On Fri, Dec 13, 2019 at 10:17 PM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
>
> On Fri, Dec 13, 2019 at 09:53:49PM +0100, Arnd Bergmann wrote:
> > As a preparation for removing the 32-bit time_t type and
> > all associated interfaces, change xfs to use time64_t and
> > ktime_get_real_seconds() for the quota housekeeping.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Looks mostly reasonable to me...
>
> The bigtime series refactors the triplicated timer handling and whatnot,
> but I don't think it would be difficult to rebase that series assuming
> this lands first (which it probably will, I expect a new incompat ondisk
> feature to take a /long/ time to get through review.)
Could you just merge my three patches into your tree then once
you are happy with all the changes?
> > @@ -183,7 +183,7 @@ xfs_qm_adjust_dqtimers(
> > (d->d_rtb_hardlimit &&
> > (be64_to_cpu(d->d_rtbcount) >
> > be64_to_cpu(d->d_rtb_hardlimit)))) {
> > - d->d_rtbtimer = cpu_to_be32(get_seconds() +
> > + d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
> > mp->m_quotainfo->qi_rtbtimelimit);
>
> Hmm, so one thing that I clean up on the way to bigtime is the total
> lack of clamping here. If (for example) it's September 2105 and
> rtbtimelimit is set to 1 year, this will cause an integer overflow. The
> quota timer will be set to 1970 and expire immediately, rather than what
> I'd consider the best effort of February 2106.
I don't think clamping would be good here, that just replaces
one bug with another at the overflow time. If you would like to
have something better before this gets extended, I could try to
come up with a version that converts it to the nearest 64-bit
timestamp, similar to the way that time_before32() in the kernel
or the NTP protocol work.
If you think it can get extended properly soon, I'd just leave the
patch as it is today in order to remove the get_seconds()
interface for v5.6.
> (I'll grant you the current code also behaves like this...)
>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Thanks,
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-16 16:52 ` Arnd Bergmann
@ 2019-12-17 15:02 ` Arnd Bergmann
2019-12-17 22:15 ` Darrick J. Wong
0 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-17 15:02 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Carlos Maiolino, Pavel Reichl, Eric Sandeen,
Dave Chinner, Allison Collins, Jan Kara
On Mon, Dec 16, 2019 at 5:52 PM Arnd Bergmann <arnd@arndb.de> wrote:
> On Fri, Dec 13, 2019 at 10:17 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>>
>> Hmm, so one thing that I clean up on the way to bigtime is the total
>> lack of clamping here. If (for example) it's September 2105 and
>> rtbtimelimit is set to 1 year, this will cause an integer overflow. The
>> quota timer will be set to 1970 and expire immediately, rather than what
>> I'd consider the best effort of February 2106.
One more hing to note (I will add this to the changelog text) is that on
32-bit architectures, the limit here is y2038, while on 64-bit
architectures it's y2106:
int xfs_trans_dqresv(...)
{
time_t timer; /* signed 'long' */
timer = be32_to_cpu(dqp->q_core.d_btimer);
/* get_seconds() returns unsigned long */
if ((timer != 0 && get_seconds() > timer))
return -EDQUOT;
}
> I don't think clamping would be good here, that just replaces
> one bug with another at the overflow time. If you would like to
> have something better before this gets extended, I could try to
> come up with a version that converts it to the nearest 64-bit
> timestamp, similar to the way that time_before32() in the kernel
> or the NTP protocol work.
>
> If you think it can get extended properly soon, I'd just leave the
> patch as it is today in order to remove the get_seconds()
> interface for v5.6.
I've tried this now, and but this feels wrong: it adds lots of complexity
for corner cases and is still fragile, e.g. when the time is wrong
during boot before ntp runs. See that patch below for reference.
I also see that quotatool on xfs always uses the old xfs quota
interface, so it already overflows on the user space side. Fixing
this properly seems to be a bigger effort than I was planning for
(on an unpatched 64-bit kernel):
$ sudo quotatool -b -u -t 220month /mnt/tmp -r
$ rm file ; fallocate -l 11M file
$ sudo quotatool -d /mnt/tmp -u arnd
1000 /mnt/tmp 11264 10240 20480 570239975 2 0 00
$ sudo quotatool -b -u -t 222month /mnt/tmp -r
$ rm file ; fallocate -l 11M file
$ sudo quotatool -d /mnt/tmp -u arnd
1000 /mnt/tmp 11264 10240 20480 18446744069990008316 2 0 00
Arnd
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 9cfd3209f52b..6c9128bb607b 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -98,6 +98,23 @@ xfs_qm_adjust_dqlimits(
xfs_dquot_set_prealloc_limits(dq);
}
+static __be32 xfs_quota_timeout32(s64 limit)
+{
+ time64_t now = ktime_get_real_seconds();
+ u32 timeout;
+
+ /* avoid overflows in out-of-range limits */
+ if ((u64)limit > S32_MAX)
+ limit = S32_MAX;
+ timeout = now + limit;
+
+ /* avoid timeout of zero */
+ if (lower_32_bits(timeout) == 0)
+ return cpu_to_be32(1);
+
+ return cpu_to_be32(lower_32_bits(timeout));
+}
+
/*
* Check the limits and timers of a dquot and start or reset timers
* if necessary.
@@ -137,7 +154,7 @@ xfs_qm_adjust_dqtimers(
(d->d_blk_hardlimit &&
(be64_to_cpu(d->d_bcount) >
be64_to_cpu(d->d_blk_hardlimit)))) {
- d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
+ d->d_btimer = xfs_quota_timeout32(
mp->m_quotainfo->qi_btimelimit);
} else {
d->d_bwarns = 0;
@@ -160,7 +177,7 @@ xfs_qm_adjust_dqtimers(
(d->d_ino_hardlimit &&
(be64_to_cpu(d->d_icount) >
be64_to_cpu(d->d_ino_hardlimit)))) {
- d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
+ d->d_itimer = xfs_quota_timeout32(
mp->m_quotainfo->qi_itimelimit);
} else {
d->d_iwarns = 0;
@@ -183,7 +200,7 @@ xfs_qm_adjust_dqtimers(
(d->d_rtb_hardlimit &&
(be64_to_cpu(d->d_rtbcount) >
be64_to_cpu(d->d_rtb_hardlimit)))) {
- d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
+ d->d_rtbtimer = xfs_quota_timeout32(
mp->m_quotainfo->qi_rtbtimelimit);
} else {
d->d_rtbwarns = 0;
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 1ea82764bf89..2087626b4bee 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -601,6 +601,14 @@ xfs_qm_scall_setqlim(
return error;
}
+/* Assume timers are within +/- 68 years of current wall clock */
+static time64_t xfs_quota_time32_to_time64(time64_t now, __be32 timer)
+{
+ s32 diff = be32_to_cpu(timer) - lower_32_bits(now);
+
+ return now + diff;
+}
+
/* Fill out the quota context. */
static void
xfs_qm_scall_getquota_fill_qc(
@@ -609,6 +617,8 @@ xfs_qm_scall_getquota_fill_qc(
const struct xfs_dquot *dqp,
struct qc_dqblk *dst)
{
+ time64_t now = ktime_get_real_seconds();
+
memset(dst, 0, sizeof(*dst));
dst->d_spc_hardlimit =
XFS_FSB_TO_B(mp, be64_to_cpu(dqp->q_core.d_blk_hardlimit));
@@ -618,8 +628,8 @@ xfs_qm_scall_getquota_fill_qc(
dst->d_ino_softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
dst->d_space = XFS_FSB_TO_B(mp, dqp->q_res_bcount);
dst->d_ino_count = dqp->q_res_icount;
- dst->d_spc_timer = be32_to_cpu(dqp->q_core.d_btimer);
- dst->d_ino_timer = be32_to_cpu(dqp->q_core.d_itimer);
+ dst->d_spc_timer = xfs_quota_time32_to_time64(now,
dqp->q_core.d_btimer);
+ dst->d_ino_timer = xfs_quota_time32_to_time64(now,
dqp->q_core.d_itimer);
dst->d_ino_warns = be16_to_cpu(dqp->q_core.d_iwarns);
dst->d_spc_warns = be16_to_cpu(dqp->q_core.d_bwarns);
dst->d_rt_spc_hardlimit =
@@ -627,7 +637,7 @@ xfs_qm_scall_getquota_fill_qc(
dst->d_rt_spc_softlimit =
XFS_FSB_TO_B(mp, be64_to_cpu(dqp->q_core.d_rtb_softlimit));
dst->d_rt_space = XFS_FSB_TO_B(mp, dqp->q_res_rtbcount);
- dst->d_rt_spc_timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
+ dst->d_rt_spc_timer = xfs_quota_time32_to_time64(now,
dqp->q_core.d_rtbtimer);
dst->d_rt_spc_warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
/*
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index d1b9869bc5fa..c75887da6546 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -636,7 +636,8 @@ xfs_trans_dqresv(
}
if (softlimit && total_count > softlimit) {
if ((timer != 0 &&
- ktime_get_real_seconds() > timer) ||
+ time_after32(ktime_get_real_seconds(),
+ timer)) ||
(warns != 0 && warns >= warnlimit)) {
xfs_quota_warn(mp, dqp,
QUOTA_NL_BSOFTLONGWARN);
@@ -664,7 +665,8 @@ xfs_trans_dqresv(
}
if (softlimit && total_count > softlimit) {
if ((timer != 0 &&
- ktime_get_real_seconds() > timer) ||
+ time_after32(ktime_get_real_seconds(),
+ timer)) ||
(warns != 0 && warns >= warnlimit)) {
xfs_quota_warn(mp, dqp,
QUOTA_NL_ISOFTLONGWARN);
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time
2019-12-16 16:52 ` Darrick J. Wong
@ 2019-12-17 15:06 ` Arnd Bergmann
0 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-17 15:06 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Dave Chinner, Allison Collins, Jan Kara,
Eric Sandeen
On Mon, Dec 16, 2019 at 5:52 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> On Mon, Dec 16, 2019 at 05:45:29PM +0100, Arnd Bergmann wrote:
> > On Fri, Dec 13, 2019 at 10:05 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> > What is the timeline for that work now? I'm mainly interested in
> > getting the removal of 'time_t/timeval/timespec' and 'get_seconds()'
> > from the kernel done for v5.6, but it would be good to also have
> > this patch and the extended timestamps in the same version
> > just so we can claim that "all known y2038 issues" are addressed
> > in that release (I'm sure we will run into bugs we don't know yet).
>
> Personally, I think you should push this whenever it's ready. Are you
> aiming to send all 24 patches as a treewide pull request directly to
> Linus, or would you rather the 2-3 xfs patches go through the xfs tree?
My plan is get as much of the remaining 60 patches into maintainer
trees for v5.6 and then send a pull request for whatever remains that
has not been picked up by anyone.
The 24 patches are the ones that didn't seem worth splitting into a
separate series, aside from these I also have v4l2, alsa and nfsd
pending, plus a final cleanup that removes the then-unused
interfaces.
So if you can pick up the xfs patches, that would help me.
> The y2038 format changes are going to take a while to push through
> review. If somehow it all gets through review for 5.6 I can always
> apply both and fix the merge damage, but more likely y2038 timestamps is
> a <cough> 5.8 EXPERIMENTAL thing.
>
> Or later, given that Dave and I both have years worth of unreviewed
> patch backlog. :(
Ok, I see.
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-17 15:02 ` Arnd Bergmann
@ 2019-12-17 22:15 ` Darrick J. Wong
2019-12-18 16:44 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2019-12-17 22:15 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Carlos Maiolino, Pavel Reichl, Eric Sandeen,
Dave Chinner, Allison Collins, Jan Kara
On Tue, Dec 17, 2019 at 04:02:47PM +0100, Arnd Bergmann wrote:
> On Mon, Dec 16, 2019 at 5:52 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > On Fri, Dec 13, 2019 at 10:17 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> >>
> >> Hmm, so one thing that I clean up on the way to bigtime is the total
> >> lack of clamping here. If (for example) it's September 2105 and
> >> rtbtimelimit is set to 1 year, this will cause an integer overflow. The
> >> quota timer will be set to 1970 and expire immediately, rather than what
> >> I'd consider the best effort of February 2106.
>
> One more hing to note (I will add this to the changelog text) is that on
Ok, I'll look for it in the next revision you send out.
By the way, would you mind cc'ing the xfs list on all 24 patches? They
probably aren't directly relevant to xfs, but it does make it a lot
easier for us to look at the other 21 patches and think "Oh, ok, so
there isn't some core infrastructure change that we're not seeing".
> 32-bit architectures, the limit here is y2038, while on 64-bit
> architectures it's y2106:
Yikes. I probably just need to send the bigtime series and see what you
all think about the mess I created^W^W^Wway I dealt with all that.
> int xfs_trans_dqresv(...)
> {
> time_t timer; /* signed 'long' */
> timer = be32_to_cpu(dqp->q_core.d_btimer);
> /* get_seconds() returns unsigned long */
> if ((timer != 0 && get_seconds() > timer))
> return -EDQUOT;
> }
>
> > I don't think clamping would be good here, that just replaces
> > one bug with another at the overflow time. If you would like to
> > have something better before this gets extended, I could try to
> > come up with a version that converts it to the nearest 64-bit
> > timestamp, similar to the way that time_before32() in the kernel
> > or the NTP protocol work.
> >
> > If you think it can get extended properly soon, I'd just leave the
> > patch as it is today in order to remove the get_seconds()
> > interface for v5.6.
>
> I've tried this now, and but this feels wrong: it adds lots of complexity
> for corner cases and is still fragile, e.g. when the time is wrong
> during boot before ntp runs. See that patch below for reference.
Yeah, that is pretty weird to glue the upper 32 bits of the timestamp
onto the expiration timer...
--D
> I also see that quotatool on xfs always uses the old xfs quota
> interface, so it already overflows on the user space side. Fixing
> this properly seems to be a bigger effort than I was planning for
> (on an unpatched 64-bit kernel):
>
> $ sudo quotatool -b -u -t 220month /mnt/tmp -r
> $ rm file ; fallocate -l 11M file
> $ sudo quotatool -d /mnt/tmp -u arnd
> 1000 /mnt/tmp 11264 10240 20480 570239975 2 0 00
> $ sudo quotatool -b -u -t 222month /mnt/tmp -r
> $ rm file ; fallocate -l 11M file
> $ sudo quotatool -d /mnt/tmp -u arnd
> 1000 /mnt/tmp 11264 10240 20480 18446744069990008316 2 0 00
>
> Arnd
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 9cfd3209f52b..6c9128bb607b 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -98,6 +98,23 @@ xfs_qm_adjust_dqlimits(
> xfs_dquot_set_prealloc_limits(dq);
> }
>
> +static __be32 xfs_quota_timeout32(s64 limit)
> +{
> + time64_t now = ktime_get_real_seconds();
> + u32 timeout;
> +
> + /* avoid overflows in out-of-range limits */
> + if ((u64)limit > S32_MAX)
> + limit = S32_MAX;
> + timeout = now + limit;
> +
> + /* avoid timeout of zero */
> + if (lower_32_bits(timeout) == 0)
> + return cpu_to_be32(1);
> +
> + return cpu_to_be32(lower_32_bits(timeout));
> +}
> +
> /*
> * Check the limits and timers of a dquot and start or reset timers
> * if necessary.
> @@ -137,7 +154,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_blk_hardlimit &&
> (be64_to_cpu(d->d_bcount) >
> be64_to_cpu(d->d_blk_hardlimit)))) {
> - d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
> + d->d_btimer = xfs_quota_timeout32(
> mp->m_quotainfo->qi_btimelimit);
> } else {
> d->d_bwarns = 0;
> @@ -160,7 +177,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_ino_hardlimit &&
> (be64_to_cpu(d->d_icount) >
> be64_to_cpu(d->d_ino_hardlimit)))) {
> - d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
> + d->d_itimer = xfs_quota_timeout32(
> mp->m_quotainfo->qi_itimelimit);
> } else {
> d->d_iwarns = 0;
> @@ -183,7 +200,7 @@ xfs_qm_adjust_dqtimers(
> (d->d_rtb_hardlimit &&
> (be64_to_cpu(d->d_rtbcount) >
> be64_to_cpu(d->d_rtb_hardlimit)))) {
> - d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
> + d->d_rtbtimer = xfs_quota_timeout32(
> mp->m_quotainfo->qi_rtbtimelimit);
> } else {
> d->d_rtbwarns = 0;
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index 1ea82764bf89..2087626b4bee 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -601,6 +601,14 @@ xfs_qm_scall_setqlim(
> return error;
> }
>
> +/* Assume timers are within +/- 68 years of current wall clock */
> +static time64_t xfs_quota_time32_to_time64(time64_t now, __be32 timer)
> +{
> + s32 diff = be32_to_cpu(timer) - lower_32_bits(now);
> +
> + return now + diff;
> +}
> +
> /* Fill out the quota context. */
> static void
> xfs_qm_scall_getquota_fill_qc(
> @@ -609,6 +617,8 @@ xfs_qm_scall_getquota_fill_qc(
> const struct xfs_dquot *dqp,
> struct qc_dqblk *dst)
> {
> + time64_t now = ktime_get_real_seconds();
> +
> memset(dst, 0, sizeof(*dst));
> dst->d_spc_hardlimit =
> XFS_FSB_TO_B(mp, be64_to_cpu(dqp->q_core.d_blk_hardlimit));
> @@ -618,8 +628,8 @@ xfs_qm_scall_getquota_fill_qc(
> dst->d_ino_softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
> dst->d_space = XFS_FSB_TO_B(mp, dqp->q_res_bcount);
> dst->d_ino_count = dqp->q_res_icount;
> - dst->d_spc_timer = be32_to_cpu(dqp->q_core.d_btimer);
> - dst->d_ino_timer = be32_to_cpu(dqp->q_core.d_itimer);
> + dst->d_spc_timer = xfs_quota_time32_to_time64(now,
> dqp->q_core.d_btimer);
> + dst->d_ino_timer = xfs_quota_time32_to_time64(now,
> dqp->q_core.d_itimer);
> dst->d_ino_warns = be16_to_cpu(dqp->q_core.d_iwarns);
> dst->d_spc_warns = be16_to_cpu(dqp->q_core.d_bwarns);
> dst->d_rt_spc_hardlimit =
> @@ -627,7 +637,7 @@ xfs_qm_scall_getquota_fill_qc(
> dst->d_rt_spc_softlimit =
> XFS_FSB_TO_B(mp, be64_to_cpu(dqp->q_core.d_rtb_softlimit));
> dst->d_rt_space = XFS_FSB_TO_B(mp, dqp->q_res_rtbcount);
> - dst->d_rt_spc_timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
> + dst->d_rt_spc_timer = xfs_quota_time32_to_time64(now,
> dqp->q_core.d_rtbtimer);
> dst->d_rt_spc_warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
>
> /*
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index d1b9869bc5fa..c75887da6546 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -636,7 +636,8 @@ xfs_trans_dqresv(
> }
> if (softlimit && total_count > softlimit) {
> if ((timer != 0 &&
> - ktime_get_real_seconds() > timer) ||
> + time_after32(ktime_get_real_seconds(),
> + timer)) ||
> (warns != 0 && warns >= warnlimit)) {
> xfs_quota_warn(mp, dqp,
> QUOTA_NL_BSOFTLONGWARN);
> @@ -664,7 +665,8 @@ xfs_trans_dqresv(
> }
> if (softlimit && total_count > softlimit) {
> if ((timer != 0 &&
> - ktime_get_real_seconds() > timer) ||
> + time_after32(ktime_get_real_seconds(),
> + timer)) ||
> (warns != 0 && warns >= warnlimit)) {
> xfs_quota_warn(mp, dqp,
> QUOTA_NL_ISOFTLONGWARN);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces
2019-12-17 22:15 ` Darrick J. Wong
@ 2019-12-18 16:44 ` Arnd Bergmann
0 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2019-12-18 16:44 UTC (permalink / raw)
To: Darrick J. Wong
Cc: y2038 Mailman List, linux-kernel@vger.kernel.org, linux-xfs,
Brian Foster, Carlos Maiolino, Pavel Reichl, Eric Sandeen,
Dave Chinner, Allison Collins, Jan Kara
On Tue, Dec 17, 2019 at 11:18 PM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
> On Tue, Dec 17, 2019 at 04:02:47PM +0100, Arnd Bergmann wrote:
> > On Mon, Dec 16, 2019 at 5:52 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Fri, Dec 13, 2019 at 10:17 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> > >>
> > >> Hmm, so one thing that I clean up on the way to bigtime is the total
> > >> lack of clamping here. If (for example) it's September 2105 and
> > >> rtbtimelimit is set to 1 year, this will cause an integer overflow. The
> > >> quota timer will be set to 1970 and expire immediately, rather than what
> > >> I'd consider the best effort of February 2106.
> >
> > One more hing to note (I will add this to the changelog text) is that on
>
> Ok, I'll look for it in the next revision you send out.
>
> By the way, would you mind cc'ing the xfs list on all 24 patches? They
> probably aren't directly relevant to xfs, but it does make it a lot
> easier for us to look at the other 21 patches and think "Oh, ok, so
> there isn't some core infrastructure change that we're not seeing".
I wasn't planning on sending the full series once more, as there were very
few comments now. I've sent the three XFS patches again by themselves
now. If you can pick these up, I'll put the rest into linux-next to give them
some more testing, and hopefully have others pick up a couple more
before I send a pull request.
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-12-18 16:45 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-13 20:49 [PATCH v2 00/24] drivers, fs: y2038 updates Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann
2019-12-13 21:18 ` Darrick J. Wong
2019-12-16 16:31 ` Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Arnd Bergmann
2019-12-13 21:05 ` Darrick J. Wong
2019-12-16 16:45 ` Arnd Bergmann
2019-12-16 16:52 ` Darrick J. Wong
2019-12-17 15:06 ` Arnd Bergmann
2019-12-13 20:53 ` [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Arnd Bergmann
2019-12-13 21:17 ` Darrick J. Wong
2019-12-16 16:52 ` Arnd Bergmann
2019-12-17 15:02 ` Arnd Bergmann
2019-12-17 22:15 ` Darrick J. Wong
2019-12-18 16:44 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox