From: Neil Horman <nhorman@redhat.com>
To: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Neil Horman <nhorman@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [Patch] vfs: increase scope of critical locked path in fget_light to avoid race
Date: Fri, 20 May 2005 11:25:50 -0400 [thread overview]
Message-ID: <20050520152550.GF19229@hmsendeavour.rdu.redhat.com> (raw)
In-Reply-To: <20050520134046.GQ29811@parcelfarce.linux.theplanet.co.uk>
On Fri, May 20, 2005 at 02:40:46PM +0100, Al Viro wrote:
> On Fri, May 20, 2005 at 02:33:38PM +0100, Al Viro wrote:
> > Er... If we get 1, we *KNOW* who holds the only reference - that's us.
> > And to change refcount of files_struct you need to hold a reference to
> or contents
I don't have the complete race scenario, just a stack that suggests that
files->fd was corrupted. This problem isn't recreatable at will (yet), so this
is really based on a thought experiment more than anything else. The conditions
that I was envisioning was a multithreaded application in which two threads
modified the same file descriptor at the same time. Its my understanding, from
the way I read the code that the ref count on a file_struct will still be one
for a multithreaded application, and as such it would be possible, using the
fget_light routine for one thread to be be preforming an operation on an
descriptor in the fd array, while another thread preformed another operation on
it (say close). The result potentially would be (if the two operations were on
the same fd index), that the routine operating in fget_light would retrieve a
corrupted fd value from the files->fd array, since it was being modified at the
same time by another execution context. Given the above, I suppose it might be
more appropriate to increment the reference count on thread creation as well as
process creation, but I wasn't certain of the potential side effects of doing
so. Also, every other location in the vfs that calls fcheck_files to retrieve a
value out of file_structs fd array, do so under the protection of the
file_structs file_lock, so this really seemed like a candidate for race badness
to me.
Regards
Neil
--
/***************************************************
*Neil Horman
*Software Engineer
*Red Hat, Inc.
*nhorman@redhat.com
*gpg keyid: 1024D / 0x92A74FA1
*http://pgp.mit.edu
***************************************************/
next prev parent reply other threads:[~2005-05-20 15:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-20 13:23 [Patch] vfs: increase scope of critical locked path in fget_light to avoid race Neil Horman
2005-05-20 13:33 ` Al Viro
2005-05-20 13:40 ` Al Viro
2005-05-20 15:25 ` Neil Horman [this message]
2005-05-20 21:28 ` Al Viro
2005-05-21 13:14 ` Neil Horman
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=20050520152550.GF19229@hmsendeavour.rdu.redhat.com \
--to=nhorman@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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.