Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1975562

Summary: Backported time64 syscalls fail with large values
Product: Red Hat Enterprise Linux 8 Reporter: Michael Halstead <mhalstead>
Component: kernelAssignee: Phil Auld <pauld>
kernel sub component: Kernel-Core QA Contact: Qiao Zhao <qzhao>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: medium    
Priority: unspecified CC: kcarcia, pauld
Version: 8.4Flags: pm-rhel: mirror+
Target Milestone: beta   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-08 14:04:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael Halstead 2021-06-23 22:51:37 UTC
Description of problem: 

Recently backported time64 syscalls fail with large values. Discovered when attempting to set file times.

> utimensat_time64(AT_FDCWD, "../install/usr/local/lib/cmake/assimp-4.1/assimp-config.cmake",
> [{tv_sec=1622966723, tv_nsec=6319439026193432576}, {tv_sec=1622966579, tv_nsec=17840053692309438464}], 0) = -1
> EINVAL (Invalid argument)

tv_nsec may be being clamped to LONG_MAX of 4 bytes but should be 
a LONG_LONG_MAX of 8 bytes on a 32 bit since the field is a 64 bit long.

Version-Release number of selected component (if applicable):

Problem began after upgrading from 4.18.0-240.15.1.el8_3.x86_64 to 4.18.0-305.3.1.el8.x86_64. 


Steps to Reproduce:

quick test bit of code (which makes assumptions about 32 bit):

#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

struct timespec64 {
    long long           tv_sec;                 /* seconds */
    long long           tv_nsec;                /* nanoseconds */
};

int main() {
  int fd = open("foo", O_RDWR | O_CREAT, 0644);
  write(fd, "foo", 3);
  struct timespec64 times[2] = {};
  times[0].tv_sec = 1622966723;
  times[0].tv_nsec = 631943;
  times[1].tv_sec = 1622966579;
  times[1].tv_nsec = 178400;
  int rc = syscall(SYS_utimensat_time64, fd, NULL, &times[0], 0);
  printf("rc=%d\n", rc);
  close(fd);
  return rc;
}

built with "gcc -m32 test-syscall.c -o test" and run with "strace ./test".
This works on all the systems I tried it in. As does:


  times[0].tv_sec = 1;
  times[0].tv_nsec = 2;
  times[1].tv_sec = 3;
  times[1].tv_nsec = 4;

however if you set (and ignore the compiler warning):

  times[0].tv_sec = 1622966723;
  times[0].tv_nsec = 6319439026193432576;
  times[1].tv_sec = 1622966579;
  times[1].tv_nsec = 17840053692309438464;

then you see EINVAL on the latest kernel (tested with 4.18.0-305 and 4.18.0-310).

Comment 1 Michael Halstead 2021-07-02 20:27:25 UTC
This problem is resolved in the 4.18.0-315.el8.x86_64 kernel on CentOS 8 Stream.

Comment 2 Qiao Zhao 2021-08-09 02:14:59 UTC
Thanks Michael reported this issue.

Retest this issue with the recent RHEL8 kernel (-325), everything looks good.

[]
openat(AT_FDCWD, "foo", O_RDWR|O_CREAT, 0644) = 3
write(3, "foo", 3)                      = 3
utimensat_time64(3, NULL, [{tv_sec=1622966723, tv_nsec=6319439026193432576}, {tv_sec=1622966579, tv_nsec=17840053692309438464}], 0) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
[/]