summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-08-09 13:00:01 +0530
committerjiffin tony Thottan <jthottan@redhat.com>2018-09-06 15:54:16 +0000
commit8356b9f169f73cfdfaf6e96fcd0af618efc3a649 (patch)
treebd3cb64ce91c33a7c4a857ba248ba4df04cb2443
parente1461a27e98980dde85c1a506eef514d8cefda4b (diff)
server-protocol: don't allow '../' path in 'name'
This will prevent any arbitrary file creation through glusterfs by modifying the client bits. Also check for the similar flaw inside posix too, so we prevent any changes in layers in-between. BUG: 1625664 Signed-off-by: Amar Tumballi <amarts@redhat.com> Change-Id: Id9fe0ef6e86459e8ed85ab947d977f058c5ae06e
-rw-r--r--xlators/protocol/server/src/server-resolve.c12
-rw-r--r--xlators/storage/posix/src/posix-handle.h6
2 files changed, 18 insertions, 0 deletions
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index d0126aa..aa35685 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -294,6 +294,18 @@ resolve_entry_simple (call_frame_t *frame)
/* expected @parent was found from the inode cache */
gf_uuid_copy (state->loc_now->pargfid, resolve->pargfid);
state->loc_now->parent = inode_ref (parent);
+
+ if (strstr (resolve->bname, "../")) {
+ /* Resolving outside the parent's tree is not allowed */
+ gf_msg (this->name, GF_LOG_ERROR, EPERM,
+ PS_MSG_GFID_RESOLVE_FAILED,
+ "%s: path sent by client not allowed",
+ resolve->bname);
+ resolve->op_ret = -1;
+ resolve->op_errno = EPERM;
+ ret = 1;
+ goto out;
+ }
state->loc_now->name = resolve->bname;
inode = inode_grep (state->itable, parent, resolve->bname);
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index 21525c6..fcbc35d 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -223,6 +223,12 @@
break; \
} \
\
+ if (strstr (loc->name, "../")) { \
+ gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ENTRY_HANDLE_CREATE, \
+ "'../' in name not allowed: (%s)", loc->name); \
+ op_ret = -1; \
+ break; \
+ } \
if (LOC_HAS_ABSPATH (loc)) { \
MAKE_REAL_PATH (entp, this, loc->path); \
__parp = strdupa (entp); \