]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ecryptfs: Set s_time_gran to get correct time granularity
authorFrank Hsiao 蕭法宣 <frankhsiao@qnap.com>
Fri, 17 May 2024 10:09:55 +0000 (10:09 +0000)
committerTyler Hicks <code@tyhicks.com>
Thu, 26 Mar 2026 03:35:49 +0000 (22:35 -0500)
commit7d9ebf33d85317f3f258c627de51701e2bf7642d
treeb5a0a472595ed1cfe31684f788e81f2c6e30f207
parentc369299895a591d96745d6492d4888259b004a9e
ecryptfs: Set s_time_gran to get correct time granularity

Set the eCryptfs superblock time granularity, using the lower
filesystem's s_time_gran value, to prevent unnecessary inode timestamp
truncation to the granularity of a full second.

The use of utimensat(2) to set a timestamp with nanosecond precision
would trigger this bug. That occurred when using the following utilities
to update timestamps of a file:
  * cp -p: copy a file and preserve its atime and mtime
  * touch -r: touch a file and use a reference file's timestamps

Closes: https://bugs.launchpad.net/ecryptfs/+bug/1890486
Signed-off-by: Frank Hsiao 蕭法宣 <frankhsiao@qnap.com>
[tyhicks: Partially rewrite the commit message]
Signed-off-by: Tyler Hicks <code@tyhicks.com>
fs/ecryptfs/main.c