From: bugzilla-daemon@bugzilla.kernel.org
To: linux-ext4@vger.kernel.org
Subject: [Bug 205571] New: potential data race on ext4_setattr around inode->i_mtime with ftruncate and readv
Date: Mon, 18 Nov 2019 22:23:08 +0000 [thread overview]
Message-ID: <bug-205571-13602@https.bugzilla.kernel.org/> (raw)
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@kernel-bugs.osdl.org
Reporter: mengxu.gatech@gmail.com
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.
reply other threads:[~2019-11-18 22:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-205571-13602@https.bugzilla.kernel.org/ \
--to=bugzilla-daemon@bugzilla.kernel.org \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.