Bug #65043
openUnable to set timestamp to value > UINT32_MAX
0%
Description
I have been testing the samba integration with cephfs at the backend using smbtorture - a tool provided by Samba to test for protocol correctness. The test in question is
smb2.timestamps
This sets mtime, btime and atime on a file to various times and then checks the return values for consistency. I noticed that the problem arises when the timestamp sets the number of seconds either in a negative range or to values > UINT32_MAX.
It was bought to my notice that CephFS uses u32 for the tv_sec element for time_t and this explains the issue we see
https://github.com/ceph/ceph/blob/main/src/include/utime.h#L51
To demonstrate the problem, I have attached a reproducer which sets the atime/ctime to UINT32_MAX, UINT32_MAX+1 and UINT32_MAX+2 for a file opened on a cephfs filesystem and for a file opened in the cwd of the directory from which the test is run. The timestamps on the local filesystem are set correctly while those on the cephfs system fail for values > UINT32_MAX.
- gcc -o test -D_FILE_OFFSET_BITS=64 -lcephfs test.c
- ./test
Ceph: Create a new file
cephfs: Get time: 1711023453
local: Create a new file
local: Get time: 1711023453
Set time to UINT32_MAX
cephfs: Set time: 4294967295
cephfs: Get time: 4294967295
local: Set time: 4294967295
local: Get time: 4294967295
Set time to UINT32_MAX+1
cephfs: Set time: 4294967296
cephfs: Get time: 0
local: Set time: 4294967296
local: Get time: 4294967296
Set time to UINT32_MAX+2
cephfs: Set time: 4294967297
cephfs: Get time: 1
local: Set time: 4294967297
local: Get time: 4294967297
Is there any chance that we will see 64 bit values used in the future?
Files