From: Meng Xu <mengxu.gatech@gmail.com>
To: linux-fsdevel@vger.kernel.org
Subject: Potential data race on the file->f_pos field between getdents and sendfile
Date: Wed, 27 Nov 2019 21:56:46 -0500 [thread overview]
Message-ID: <CAAwBoOLikLrR4bCGcOj0BQzKxf90C-OUpXk4Hi-0jJf-mL3HpA@mail.gmail.com> (raw)
Hi VFS developers,
I am posting here a potential data race on the file->f_pos field
between getdents and sendfile. Following is the trace:
[Setup]
mkdir("foo", 511) = 0;
open("foo", 65536, 511) = 3;
dup2(3, 199) = 199;
create("bar", 511) = 4;
dup2(4, 198) = 198;
[Thread 1]
getdents(199, [some buffer], 3874);
__do_sys_getdents
iterate_dir
[WRITE] file->f_pos = ctx->pos;
[Thread 2]
sendfile(198, 199, NULL, 2163);
__do_sys_sendfile64
do_sendfile
[READ] pos = in.file->f_pos;
This may be a false data race, i.e., the behavior could be allowed by
POSIX as user might want to sendfile to a dirfd while the dirfd is
being iterated (although there is no obvious reason for doing so). I
am posting this here for more visibility and feel free to comment.
Best Regards,
Meng
reply other threads:[~2019-11-28 3:03 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=CAAwBoOLikLrR4bCGcOj0BQzKxf90C-OUpXk4Hi-0jJf-mL3HpA@mail.gmail.com \
--to=mengxu.gatech@gmail.com \
--cc=linux-fsdevel@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 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).