[Bug 205571] New: potential data race on ext4_setattr around inode->i_mtime with ftruncate and readv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.kernel.org/show_bug.cgi?id=205571

            Bug ID: 205571
           Summary: potential data race on ext4_setattr around
                    inode->i_mtime with ftruncate and readv
           Product: File System
           Version: 2.5
    Kernel Version: 5.4-rc5
          Hardware: All
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: ext4
          Assignee: fs_ext4@xxxxxxxxxxxxxxxxxxxx
          Reporter: mengxu.gatech@xxxxxxxxx
        Regression: No

I am bringing up the visibility of a potential data race on ext4_setattr around
inode->i_mtime when one thread is doing ftruncate and the other readv.

[Setup]
creat(file_bar, 0777, ) = 4;
dup2(4, 198) = 198;
link(file_bar, link_bar) = 0;
open(link_bar, 0x2, 0777) = 6;
dup2(6, 196) = 196;


[Thread 1] ftruncate(198, 21009);
[Thread 2] readv(196, [{iov_base=0x0x7fa652a1fa07, iov_len=1641}, ,..], 6);

The function call trace is shown below:

[Thread 1: SYS_ftruncate]
__do_sys_ftruncate
  do_sys_ftruncate
    do_truncate
      ext4_setattr
        [WRITE] inode->i_mtime = current_time(inode);

[Thread 2: SYS_readv]
__do_sys_readv
  do_readv
    vfs_readv
      do_iter_read
        do_iter_readv_writev
          call_read_iter
            ext4_file_read_iter
              generic_file_read_iter
                generic_file_buffered_read
                  file_accessed
                    atime_needs_update
                      relatime_need_update
                        [READ] if (timespec64_compare(&inode->i_mtime,
&inode->i_atime) >= 0)


I could confirm that the WRITE may happen before and after the READ operation
by controlling the timing of the two threads, i.e., by setting breakpoints
before the WRITE statement.

However, I am not very sure about the implication of such a data race (e.g.,
causing violations of assumptions). I would appreciate if you could help check
on this potential bug and advise whether this is a harmful data race or it
is intended. Thank you!

-- 
You are receiving this mail because:
You are watching the assignee of the bug.



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux