Re: [PATCH] ecryptfs: set s_time_gran to get correct time granularity
Tyler Hicks <[email protected]> Thu, 26 Mar 2026 00:10:46 -0500
| Newsgroups | org.kernel.vger.ecryptfs |
|---|---|
| Message-ID | <acS_1gS8HmnUFZ4A@yaupon> |
On 2024-05-17 10:09:55, Frank Hsiao 蕭法宣 wrote: > related to: https://bugs.launchpad.net/ecryptfs/+bug/1890486 > > This bug happens in the two following situations: > cp -p: copy a file and preserve its atime and mtime > touch -r: touch a file and use a ref file's time instead of current time > > In fs/attr.c notify_change(), atime and mtime is truncated by timestamp_truncate(), > ecryptfs gets wrong s_time_gran (10^9 instead of original fs time granularity) and > truncates a/mtime to whole second. Setting s_time_gran when mounting ecryptfs > solves the issue. Thank you! This has been applied to the next branch of the tyhicks/ecryptfs.git tree. I apologize that this fix was forgotten for so long. Thanks to Bert for raising it back up to my attention. Given the long delay since you've sent this patch, I went ahead and slightly modified the commit message to make it follow the guidelines documented in the Documentation/process/submitting-patches.rst file. Let me know if you have any objections: === 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 蕭法宣 <[email protected]> [tyhicks: Partially rewrite the commit message] Signed-off-by: Tyler Hicks <[email protected]> === You can find a direct link below but please be aware that the commit hash is unstable and, therefore, the URL may not be valid in the future. [1/1] ecryptfs: Set s_time_gran to get correct time granularity https://git.kernel.org/tyhicks/ecryptfs/c/7d9ebf33d85317f3f258c627de51701e2bf7642d Tyler