diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2017-11-07 16:09:37 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2017-11-09 17:26:19 +0000 |
commit | 8b57378e5596f287a7b9d106dd6fb56a624b42ee (patch) | |
tree | 37f699e4d24e38d8ce3a6d840383ccc630317d47 /xlators/mount/fuse/src/fuse-bridge.c | |
parent | 52add0a289b8433547c5443b0dfd76e157275b10 (diff) |
mount/fuse: use fstat in getattr implementation if any opened fd is available
The restriction of using fds opened by the same Pid means fds cannot
be shared across threads of multithreaded application. Note that fops
from kernel have different Pid for different threads. Imagine
following sequence of operations:
* Turn off performance.open-behind
* Thread t1 opens an fd - fd1 - on file "file". Let's assume nodeid of
"file" is "nodeid-file".
* Thread t2 does RENAME ("newfile", "file"). Let's assume nodeid of
"newfile" as "nodeid-newfile".
* t2 proceeds to do fstat (fd1)
The above set of operations can sometimes result in ESTALE/ENOENT
errors. RENAME overwrites "file" with "newfile" changing its nodeid
from "nodeid-file" to "nodeid-newfile" and post RENAME, "nodeid-file" is
removed from the backend. If fstat carries nodeid-file as argument,
which can happen if lookup has not refreshed the nodeid of "file" and
since t2 doesn't have an fd opened, fuse_getattr_resume uses STAT
which will fail as "nodeid-file" no longer exists.
Since the above set of operations and sharing of fds across
multiple threads are valid, this is a bug.
The fix is to use any fd opened on the inode. In this specific example
fuse_getattr_resume will find fd1 and winds down the call as fstat
(fd1) which won't fail.
Cross-checked with "Miklos Szeredi" <mszeredi.at.redhat.dot.com> for
any security issues with this solution and he approves the solution.
Thanks to "Miklos Szeredi" <mszeredi.at.redhat.dot.com> for all the
pointers and discussions.
Change-Id: I88dd29b3607cd2594eee9d72a1637b5346c8d49c
BUG: 1510401
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/mount/fuse/src/fuse-bridge.c')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 50ac9931a5a..4e075904936 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -905,7 +905,7 @@ fuse_getattr_resume (fuse_state_t *state) } if (!IA_ISDIR (state->loc.inode->ia_type)) { - state->fd = fd_lookup (state->loc.inode, state->finh->pid); + state->fd = fd_lookup (state->loc.inode, 0); } if (!state->fd) { |