diff --git a/quota-4.06-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch b/quota-4.06-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch new file mode 100644 index 0000000..62a37e9 --- /dev/null +++ b/quota-4.06-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch @@ -0,0 +1,72 @@ +From 43b6e31f39edbe7de4f4feeef4d0cf6be093e021 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Nov 2020 17:12:27 +0100 +Subject: [PATCH] quotaio_xfs: Warn when large kernel timestamps cannot be + handled +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When time_t is 32-bit, warn if the kernel returns anything that cannot +fit in these time stamps. This also fixes a compilation warning that +shift exceeds data type size. Similarly when converting data to pass to +kernel, just avoid the pointless shift (generating compiler warning) +when time_t is 32-bit. + +Reported-by: "Dmitry V. Levin" +Signed-off-by: Jan Kara +Signed-off-by: Petr Písař +--- + configure.ac | 2 ++ + quotaio_xfs.c | 9 +++++++++ + 2 files changed, 11 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 2239b49..296b77a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -82,6 +82,8 @@ AS_IF([test x"$enable_werror" != "xno"], [ + ]) + AC_SUBST([WARN_CFLAGS]) + ++AC_CHECK_SIZEOF([time_t], [], [#include ]) ++ + # ========= + # Find ldap + # ========= +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index 2db1c0c..5abb2c2 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -45,8 +45,13 @@ report: xfs_report + static inline time_t xfs_kern2utildqblk_ts(const struct xfs_kern_dqblk *k, + __s32 timer, __s8 timer_hi) + { ++#if SIZEOF_TIME_T > 4 + if (k->d_fieldmask & FS_DQ_BIGTIME) + return (__u32)timer | (__s64)timer_hi << 32; ++#else ++ if (k->d_fieldmask & FS_DQ_BIGTIME && timer_hi != 0) ++ errstr(_("Truncating kernel returned time stamp.")); ++#endif + return timer; + } + +@@ -54,10 +59,14 @@ static inline void xfs_util2kerndqblk_ts(const struct xfs_kern_dqblk *k, + __s32 *timer_lo, __s8 *timer_hi, time_t timer) + { + *timer_lo = timer; ++#if SIZEOF_TIME_T > 4 + if (k->d_fieldmask & FS_DQ_BIGTIME) + *timer_hi = timer >> 32; + else + *timer_hi = 0; ++#else ++ *timer_hi = 0; ++#endif + } + + static inline int want_bigtime(time_t timer) +-- +2.26.2 + diff --git a/quota.spec b/quota.spec index b5bd006..537a9ab 100644 --- a/quota.spec +++ b/quota.spec @@ -64,6 +64,9 @@ Patch1: quota-4.03-Validate-upper-bound-of-RPC-port.patch Patch2: quota-4.06-quotacheck-Remove-a-dead-code-from-process_file.patch # Fix a compilation warning in quotaops.c, in upstream after 4.06 Patch3: quota-4.06-quotaops-fix-compilation-warning.patch +# Warn when kernel XFS large time stamp does fit into (32-bit) user-space +# time_t, in upstream after 4.06 +Patch4: quota-4.06-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: bash @@ -188,6 +191,7 @@ Linux/UNIX environment. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 # Regenerate build scripts autoreconf -f -i @@ -340,6 +344,8 @@ make check * Mon Dec 14 2020 Petr Pisar - 1:4.06-2 - Remove a dead code from process_file() (upstream bug #54) - Fix a compilation warning in quotaops.c +- Warn when kernel XFS large time stamp does fit into (32-bit) user-space + time_t * Tue Nov 10 2020 Petr Pisar - 1:4.06-1 - 4.06 bump