|
|
3604df |
From 2481925ea7fcbac7cc60f511379157afdcbca9c7 Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Date: Fri, 23 Sep 2016 21:06:37 +0530
|
|
|
3604df |
Subject: [PATCH 109/141] storage/posix: Fix race in posix_pstat
|
|
|
3604df |
|
|
|
3604df |
Problem:
|
|
|
3604df |
When one thread is in the process of creating a file/directory
|
|
|
3604df |
and the other thread is doing readdirp, there is a chance that
|
|
|
3604df |
posix_pstat, creation fops race in the following manner which
|
|
|
3604df |
will lead to wrong stat values to be read by parent xlators
|
|
|
3604df |
like posix-acl.
|
|
|
3604df |
|
|
|
3604df |
Creation fops posix_pstat() as part of readdirp
|
|
|
3604df |
1) file is created with uid/gid 0/0 1) does stat of the path that
|
|
|
3604df |
is created just now.
|
|
|
3604df |
2) Does chown to set the correct
|
|
|
3604df |
uid/gid
|
|
|
3604df |
3) Sets the acl/user/internal xattrs
|
|
|
3604df |
4) Sets the gfid on the entry and
|
|
|
3604df |
completes the creation of the file/dir
|
|
|
3604df |
2) fills the gfid in the iatt
|
|
|
3604df |
|
|
|
3604df |
If unwind of readdirp hits server xlator before creation fop, then
|
|
|
3604df |
posix-acl remembers uid/gid of the file to be root/root and fails
|
|
|
3604df |
fops like open etc on it.
|
|
|
3604df |
|
|
|
3604df |
Fix:
|
|
|
3604df |
Reverse the order of filling gfid and filling lstat() values in
|
|
|
3604df |
posix_pstat() so that if there is gfid in iatt buffer uid/gid
|
|
|
3604df |
are valid.
|
|
|
3604df |
|
|
|
3604df |
>Change-Id: I46caa7f6da7abfa40a0b1d70e35b88de9c64959c
|
|
|
3604df |
>Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
>Reviewed-on: http://review.gluster.org/15564
|
|
|
3604df |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
|
|
|
3604df |
|
|
|
3604df |
BUG: 1339765
|
|
|
3604df |
Change-Id: Id14a37eb5b71d9d8eb28ae83079047c23ab6f51f
|
|
|
3604df |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/87555
|
|
|
3604df |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
xlators/storage/posix/src/posix-helpers.c | 10 +++++-----
|
|
|
3604df |
1 files changed, 5 insertions(+), 5 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
3604df |
index 86c3339..2912896 100644
|
|
|
3604df |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
3604df |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
3604df |
@@ -640,6 +640,11 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
|
|
|
3604df |
|
|
|
3604df |
priv = this->private;
|
|
|
3604df |
|
|
|
3604df |
+ if (gfid && !gf_uuid_is_null (gfid))
|
|
|
3604df |
+ gf_uuid_copy (stbuf.ia_gfid, gfid);
|
|
|
3604df |
+ else
|
|
|
3604df |
+ posix_fill_gfid_path (this, path, &stbuf);
|
|
|
3604df |
+
|
|
|
3604df |
ret = sys_lstat (path, &lstatbuf);
|
|
|
3604df |
|
|
|
3604df |
if (ret != 0) {
|
|
|
3604df |
@@ -672,11 +677,6 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
|
|
|
3604df |
|
|
|
3604df |
iatt_from_stat (&stbuf, &lstatbuf);
|
|
|
3604df |
|
|
|
3604df |
- if (gfid && !gf_uuid_is_null (gfid))
|
|
|
3604df |
- gf_uuid_copy (stbuf.ia_gfid, gfid);
|
|
|
3604df |
- else
|
|
|
3604df |
- posix_fill_gfid_path (this, path, &stbuf);
|
|
|
3604df |
-
|
|
|
3604df |
posix_fill_ino_from_gfid (this, &stbuf);
|
|
|
3604df |
|
|
|
3604df |
if (buf_p)
|
|
|
3604df |
--
|
|
|
3604df |
1.7.1
|
|
|
3604df |
|