From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Meng Xu <mengxu.gatech@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: potential data race on ext_inode_hdr(inode)->eh_depth, ext_inode_hdr(inode)->eh_max between a creat and unlink syscall
Date: Thu, 28 Nov 2019 18:19:47 -0500 [thread overview]
Message-ID: <20191128231947.GH22921@mit.edu> (raw)
In-Reply-To: <CAAwBoOLoHTZGWFw5y_3MoMgZDQ3gCUQrsAO8Z=U4RwV9KyA_fA@mail.gmail.com>
On Thu, Nov 28, 2019 at 12:03:04PM -0500, Meng Xu wrote:
> I notice a potential data race on ext_inode_hdr(inode)->eh_depth,
> ext_inode_hdr(inode)->eh_max between a create and unlink syscall.
> Following is the trace:
>
> [Setup]
> mkdir("foo", 511) = 0;
> open("foo", 65536, 511) = 3;
> create("bar", 511) = 4;
> symlink("foo", "sym_foo") = 0;
> open("sym_foo", 65536, 511) = 5;
>
> [Thread 1]
> create("bar", 438);
>
> __do_sys_creat
> ksys_open
> do_filp_open
> path_openat
> do_last
> handle_truncate
> do_truncate
> notify_change
> ext4_setattr
> ext4_truncate
> ext4_ext_truncate
> ext4_ext _remove_space
> [WRITE, 2 bytes] ext_inode_hdr(inode)->eh_depth = 0;
> [WRITE, 2 bytes] ext_inode_hdr(inode)->eh_max
> = cpu_to_le16(ext4_ext_space_root(inode, 0));
>
> [Thread 2]
> unlink("sym_foo");
>
> __do_sys_unlink
> do_unlinkat
> iput
> iput_final
> evict
> ext4_evict_inode
> ext4_orphan_del
> ext4_mark_iloc_dirty
> ext4_do_update_inode
> [READ, 4 bytes] raw_inode->i_block[block] = ei->i_data[block];
>
>
> I could observe that the order between the READ and WRITE is not
> deterministic and I was curious what will happen if the READ takes
> place in the middle of the two WRITES? Does it cause any damages or
> violations?
This makes no sense. The inodes corresponding to "sym_foo" and "bar"
are completely differenth. So why would there be a data race?
How are you concluding that that there is, in fact, a data race?
- Ted
next prev parent reply other threads:[~2019-11-28 23:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-28 17:03 potential data race on ext_inode_hdr(inode)->eh_depth, ext_inode_hdr(inode)->eh_max between a creat and unlink syscall Meng Xu
2019-11-28 23:19 ` Theodore Y. Ts'o [this message]
2019-11-29 4:43 ` Meng Xu
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=20191128231947.GH22921@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=mengxu.gatech@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).