-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Problem description: When mounting an NTFS filesystem in read-only (ro) mode using the mount command, accessing a file still updates its access time.
Why is this a problem? Other filesystems (such as ext4) do not modify file access times when mounted read-only.
I feel it worth mentioning that when using "ntfs-3g -o ro /dev/device mount-point" to mount NTFS,file access times are not updated. File access times are only updated when mounting the NTFS volume using "mount -o ro /dev/device mount-point".
Steps to reproduce:
dd if=/dev/zero of=ntfs.img count=102400
mkfs.ntfs --force ntfs.img
mkdir disk
mount.ntfs-3g ntfs.img disk
cp somefile.txt disk/
umount disk
mount -o ro ntfs.img disk
stat disk/somefile.txt
(shows access time)
sleep 60
cat disk/somefile.txt
stat disk/somefile.txt
(shows updated access time)
Note: When mounting ntfs.img using "ntfs-3g -o ro ntfs.img disk" the file access times are not changed.
When this same test is doen with ext4, file access times do not change.
Test system: Debian 11, running kernel 5.10
Running mount.ntfs-3g --version gives the following information:
"ntfs-3g 2017.3.23AR.3 integrated FUSE 28"
Additional discussion on this issue is happening in this Reddit thread: https://old.reddit.com/r/linux/comments/vhpdp3/mount_o_ro_does_not_writeprotect_last_access/
Activity
unsound commentedon Jun 22, 2022
I haven't analyzed this issue very thoroughly but in general the 'remount' functionality in FUSE AFAIK has no callback in libfuse, but is purely implemented in the kernel with no real calls to libfuse.
This means that the FUSE daemon doesn't know that it has been remounted as read-only, and proceeds to update access times as if it was a read-write mount.
I will check if there's any new callback to support remount functionality in libfuse. If not, then the FUSE 'remount' feature is inherently flawed.
slicer69 commentedon Jun 22, 2022
I don't think this is just a remount issue. This problem seems to crop up even when the volume is umounted and then mounted again later in read-only mode.
jpandre commentedon Jun 22, 2022
Strange. When mounting read-only, there are three barriers preventing from actually write to device : the device is opened read-only, a read-only flag prevents from writing to the device and another read-only flags prevents from writing to the volume.
I suspect an update taking place in the cache, I would be suprised if it actually makes it to the device. Several cache issues are known with fuse which apparently cannot be solved. Anyway this has to be checked.
I rewrote your tests as :
Note the added "sleep" around umounts, often useful because they are asynchronous, otherwise we end up with multiple mounts.
This is what I get :
This is on a recent version of ntfs-3g, but I do not remember of a significant change in mountings since 2017.3.23AR.3
What do you have in your syslog ? you may have some specific configuration. I get three times what follows :
jpandre commentedon Jun 22, 2022
@unsound : your comment apparently belongs to issue #42
unsound commentedon Jun 22, 2022
Ah, I missed that one. It seems that this issue should be merged with #42 as it's essentially the same problem.
jpandre commentedon Jun 22, 2022
I do no think #42 and #43 are related. #42 is related to an explicit remount option with a single effective mounting. #43 may be caused by an asynchronous umount not taking place before the next mount, which means the device remains mounted as rw. I need the syslog to be sure.
slicer69 commentedon Jun 23, 2022
I tried doing the mount a few times, both in rw mode and ro mode. It looks like a syslog entry only gets added when I do the first mount (or an umount, new mount). It doesn't add a new syslog entry if I remount.
Anyway, here are my two most recent syslog entries, the first from when I mounted the NTFS volume in read-write mode and the second where I did a fresh umount/mount in read-only mode.
jpandre commentedon Jun 23, 2022
This is expected (first mount, or after effective umount). Please show both a modified access time condition and the corresponding syslog. If the umount is late, the second mount is rejected and not seen in the syslog.
This is also expected, but there is no remount in your original sequence, only successive mounts.
mirh commentedon Jan 12, 2023
Some food for thought
https://dfir.ru/2018/07/25/a-live-forensic-distribution-writing-to-a-suspect-drive/