glusterfs: fix CVE-2018-10911
PATCH 1/7 glusterfs: fix CVE-2018-10911
Backport patch to fix the following CVE.
CVE: CVE-2018-10911
--- ...-negative-key-value-length-while-unserial.patch | 39 ++++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 40 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patch
recipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 428ee988df7d6cbe6e18becffcee5cdfb0fa9d17 Mon Sep 17 00:00:00 2001 +From: Amar Tumballi <[email protected]> +Date: Tue, 24 Jul 2018 13:25:12 +0530 +Subject: [PATCH 1/7] dict: handle negative key/value length while unserialize + +Fixes: bz#1625089 +Change-Id: Ie56df0da46c242846a1ba51ccb9e011af118b119 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10911 + +Signed-off-by: Chen Qi <[email protected]> +--- + libglusterfs/src/dict.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c +index 839b426..ac0a677 100644 +--- a/libglusterfs/src/dict.c ++++ b/libglusterfs/src/dict.c +@@ -2751,6 +2751,13 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + vallen = ntoh32 (hostord); + buf += DICT_DATA_HDR_VAL_LEN; + ++ if ((keylen < 0) || (vallen < 0)) { ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, ++ "undersized length passed " ++ "key:%d val:%d", keylen, vallen); ++ goto out; ++ } + if ((buf + keylen) > (orig_buf + size)) { + gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, + LG_MSG_UNDERSIZED_BUF, +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -23,6 +23,7 @@ SRC_URI += "file://glusterd.init \ file://0001-shared-storage-Prevent-mounting-shared-storage-from-.patch \ file://0002-server-auth-add-option-for-strict-authentication.patch \ file://0003-glusterfs-access-trusted-peer-group-via-remote-host-.patch \ + file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 2/7 glusterfs: fix CVE-2018-10923
Backport patch to fix the following CVE.
CVE: CVE-2018-10923
--- ...-disable-open-read-write-on-special-files.patch | 93 ++++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 94 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0002-posix-disable-open-read-write-on-special-files.patch
recipes-extended/glusterfs/files/0002-posix-disable-open-read-write-on-special-files.patch new file +93 -0
@@ -0,0 +1,93 @@ +From 08dc006aac79ee1d1f6a5b7044fc973df7f00ed6 Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Tue, 25 Sep 2018 14:02:01 +0800 +Subject: [PATCH 2/7] posix: disable open/read/write on special files + +In the file system, the responsibility w.r.to the block and char device +files is related to only support for 'creating' them (using mknod(2)). + +Once the device files are created, the read/write syscalls for the specific +devices are handled by the device driver registered for the specific major +number, and depending on the minor number, it knows where to read from. +Hence, we are at risk of reading contents from devices which are handled +by the host kernel on server nodes. + +By disabling open/read/write on the device file, we would be safe with +the bypass one can achieve from client side (using gfapi) + +Fixes: bz#1625096 + +Change-Id: I48c776b0af1cbd2a5240862826d3d8918601e47f +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10923 +Modified to suite the old version of glusterfs. + +Signed-off-by: Chen Qi <[email protected]> +--- + xlators/storage/posix/src/posix.c | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index b1a529b..506ae91 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -3091,6 +3091,17 @@ posix_open (call_frame_t *frame, xlator_t *this, + priv = this->private; + VALIDATE_OR_GOTO (priv, out); + ++ if (loc->inode && ++ ((loc->inode->ia_type == IA_IFBLK) || ++ (loc->inode->ia_type == IA_IFCHR))) { ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_INVALID_ARGUMENT, ++ "open received on a block/char file (%s)", ++ uuid_utoa (loc->inode->gfid)); ++ op_errno = EINVAL; ++ goto out; ++ } ++ + MAKE_INODE_HANDLE (real_path, this, loc, &stbuf); + if (!real_path) { + op_ret = -1; +@@ -3180,6 +3191,17 @@ posix_readv (call_frame_t *frame, xlator_t *this, + priv = this->private; + VALIDATE_OR_GOTO (priv, out); + ++ if (fd->inode && ++ ((fd->inode->ia_type == IA_IFBLK) || ++ (fd->inode->ia_type == IA_IFCHR))) { ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_INVALID_ARGUMENT, ++ "readv received on a block/char file (%s)", ++ uuid_utoa (fd->inode->gfid)); ++ op_errno = EINVAL; ++ goto out; ++ } ++ + ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno); + if (ret < 0) { + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, +@@ -3415,6 +3437,17 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + + VALIDATE_OR_GOTO (priv, out); + ++ if (fd->inode && ++ ((fd->inode->ia_type == IA_IFBLK) || ++ (fd->inode->ia_type == IA_IFCHR))) { ++ gf_msg (this->name, GF_LOG_ERROR, EINVAL, ++ P_MSG_INVALID_ARGUMENT, ++ "writev received on a block/char file (%s)", ++ uuid_utoa (fd->inode->gfid)); ++ op_errno = EINVAL; ++ goto out; ++ } ++ + ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno); + if (ret < 0) { + gf_msg (this->name, GF_LOG_WARNING, ret, P_MSG_PFD_NULL, +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -24,6 +24,7 @@ SRC_URI += "file://glusterd.init \ file://0002-server-auth-add-option-for-strict-authentication.patch \ file://0003-glusterfs-access-trusted-peer-group-via-remote-host-.patch \ file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ + file://0002-posix-disable-open-read-write-on-special-files.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 3/7 glusterfs: backport patch to fix a few CVEs
In reply to Chen QiBackport a patch to fix the following CVEs.
CVE: CVE-2018-10926
CVE: CVE-2018-10927
CVE: CVE-2018-10928
CVE: CVE-2018-10929
CVE: CVE-2018-10930
--- ...erver-protocol-don-t-allow-.-path-in-name.patch | 73 ++++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 74 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0003-server-protocol-don-t-allow-.-path-in-name.patch
recipes-extended/glusterfs/files/0003-server-protocol-don-t-allow-.-path-in-name.patch new file +73 -0
@@ -0,0 +1,73 @@ +From b89658672d137ef56bd0694457b9125bf7d45ba4 Mon Sep 17 00:00:00 2001 +From: Amar Tumballi <[email protected]> +Date: Thu, 9 Aug 2018 13:00:01 +0530 +Subject: [PATCH 3/7] 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. + +Fixes: bz#1625095 + +Signed-off-by: Amar Tumballi <[email protected]> +Change-Id: Id9fe0ef6e86459e8ed85ab947d977f058c5ae06e + +Upstream-Status: Backport + +Fix CVE-2018-10926 +Fix CVE-2018-10927 +Fix CVE-2018-10928 +Fix CVE-2018-10929 +Fix CVE-2018-10930 + +Signed-off-by: Chen Qi <[email protected]> +--- + xlators/protocol/server/src/server-resolve.c | 12 ++++++++++++ + xlators/storage/posix/src/posix-handle.h | 6 ++++++ + 2 files changed, 18 insertions(+) + +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 9af6a7a..6e7a8d2 100644 +--- a/xlators/storage/posix/src/posix-handle.h ++++ b/xlators/storage/posix/src/posix-handle.h +@@ -217,6 +217,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); \ +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -25,6 +25,7 @@ SRC_URI += "file://glusterd.init \ file://0003-glusterfs-access-trusted-peer-group-via-remote-host-.patch \ file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ file://0002-posix-disable-open-read-write-on-special-files.patch \ + file://0003-server-protocol-don-t-allow-.-path-in-name.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 4/7 glusterfs: fix CVE-2018-10904
In reply to Chen QiBackport patch to fix the following CVE.
CVE: CVE-2018-10904
--- ...ats-dump-io-stats-info-in-var-run-gluster.patch | 153 +++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 154 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch
recipes-extended/glusterfs/files/0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch new file +153 -0
@@ -0,0 +1,153 @@ +From 0f9c26d5e3a0d0480ff31a800ca8f31966da10ff Mon Sep 17 00:00:00 2001 +From: Amar Tumballi <[email protected]> +Date: Tue, 24 Jul 2018 15:42:28 +0530 +Subject: [PATCH 4/7] io-stats: dump io-stats info in /var/run/gluster + +It wouldn't make sense to allow iostats file to be written in +*any* directory. While the formating makes sure we try to append +io-stats-name for the file, so overwriting existing file is slim, +but in any case it makes sense to restrict dumping to one directory. + +Below are the sample commands, and files created for the corresponding +values: + + $ setfattr -n trusted.io-stats-dump -v file-for-dump $M0 + +In this case, the file would be in /var/run/gluster/file-for-dump + + $ setfattr -n trusted.io-stats-dump -v /dir1/dir2/file-for-dump $M0 + +In this case, then the dump file is in /var/run/gluster/dir1-dir2-file-for-dump + +Note that the value passed for this virtual xattr would be treated as a +file, and even if the value has '/' in it, it would be changed to '-' +for sanity. + +Fixes: bz#1625106 + +Change-Id: Id9ae6a40a190b8937c51662e6e1c2a0f6c86a0e0 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10904 + +Signed-off-by: Chen Qi <[email protected]> +--- + tests/bugs/core/io-stats-1322825.t | 12 ++++++------ + xlators/debug/io-stats/src/io-stats.c | 34 +++++++++++++++++++++++++--------- + 2 files changed, 31 insertions(+), 15 deletions(-) + +diff --git a/tests/bugs/core/io-stats-1322825.t b/tests/bugs/core/io-stats-1322825.t +index d232ecb..53f2d04 100755 +--- a/tests/bugs/core/io-stats-1322825.t ++++ b/tests/bugs/core/io-stats-1322825.t +@@ -23,7 +23,7 @@ TEST $CLI volume profile $V0 start + TEST mkdir $M0/dir1 + + # Generate the stat dump across the io-stat instances +-TEST setfattr -n trusted.io-stats-dump -v /tmp/io-stats-1322825 $M0 ++TEST setfattr -n trusted.io-stats-dump -v io-stats-1322825 $M0 + + # Check if $M0 is clean w.r.t xattr information + # TODO: if there are better ways to check we really get no attr error, please +@@ -42,12 +42,12 @@ ret=$(echo $?) + EXPECT 0 echo $ret + + # Check if we have 5 io-stat files in /tmp +-EXPECT 5 ls -1 /tmp/io-stats-1322825* ++EXPECT 5 ls -1 /var/run/gluster/io-stats-1322825* + # Cleanup the 5 generated files +-rm -f /tmp/io-stats-1322825* ++rm -f /var/run/gluster/io-stats-1322825* + + # Rinse and repeat above for a directory +-TEST setfattr -n trusted.io-stats-dump -v /tmp/io-stats-1322825 $M0/dir1 ++TEST setfattr -n trusted.io-stats-dump -v io-stats-1322825 $M0/dir1 + getfattr -n trusted.io-stats-dump $B0/${V0}1/dir1 2>&1 | grep -qi "no such attribute" + ret=$(echo $?) + EXPECT 0 echo $ret +@@ -61,7 +61,7 @@ getfattr -n trusted.io-stats-dump $B0/${V0}4/dir1 2>&1 | grep -qi "no such attri + ret=$(echo $?) + EXPECT 0 echo $ret + +-EXPECT 5 ls -1 /tmp/io-stats-1322825* +-rm -f /tmp/io-stats-1322825* ++EXPECT 5 ls -1 /var/run/gluster/io-stats-1322825* ++rm -f /var/run/gluster/io-stats-1322825* + + cleanup; +diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c +index d9d1e1d..72fa39c 100644 +--- a/xlators/debug/io-stats/src/io-stats.c ++++ b/xlators/debug/io-stats/src/io-stats.c +@@ -45,6 +45,8 @@ + #define DEFAULT_GRP_BUF_SZ 16384 + #define IOS_BLOCK_COUNT_SIZE 32 + ++#define IOS_STATS_DUMP_DIR DEFAULT_VAR_RUN_DIRECTORY ++ + typedef enum { + IOS_STATS_TYPE_NONE, + IOS_STATS_TYPE_OPEN, +@@ -2999,7 +3001,6 @@ io_stats_fsync (call_frame_t *frame, xlator_t *this, + return 0; + } + +- + int + conditional_dump (dict_t *dict, char *key, data_t *value, void *data) + { +@@ -3012,9 +3013,10 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data) + char *filename = NULL; + FILE *logfp = NULL; + struct ios_dump_args args = {0}; +- int pid, namelen; ++ int pid, namelen, dirlen; + char dump_key[100]; + char *slash_ptr = NULL; ++ char *path_in_value = NULL; + + stub = data; + this = stub->this; +@@ -3023,16 +3025,30 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data) + name as well. This helps when there is more than a single io-stats + instance in the graph, or the client and server processes are running + on the same node */ +- /* hmmm... no check for this */ +- /* name format: <passed in path/filename>.<xlator name slashes to -> */ +- namelen = value->len + strlen (this->name) + 2; /* '.' and '\0' */ ++ /* For the sanity of where the file should be located, we should make ++ sure file is written only inside RUNDIR (ie, /var/run/gluster) */ ++ /* TODO: provide an option to dump it to different directory of ++ choice, based on options */ ++ /* name format: /var/run/gluster/<passed in path/filename>.<xlator name slashes to -> */ ++ ++ path_in_value = data_to_str (value); ++ ++ if (strstr (path_in_value, "../")) { ++ gf_log (this->name, GF_LOG_ERROR, ++ "%s: no \"../\" allowed in path", path_in_value); ++ return -1; ++ } ++ dirlen = strlen (IOS_STATS_DUMP_DIR); ++ namelen = (dirlen + value->len + strlen (this->name) + 3); ++ /* +3 for '/', '.' and '\0' added in snprintf below*/ ++ + filename = alloca0 (namelen); +- memcpy (filename, data_to_str (value), value->len); +- memcpy (filename + value->len, ".", 1); +- memcpy (filename + value->len + 1, this->name, strlen(this->name)); ++ ++ snprintf (filename, namelen, "%s/%s.%s", IOS_STATS_DUMP_DIR, ++ path_in_value, this->name); + + /* convert any slashes to '-' so that fopen works correctly */ +- slash_ptr = strchr (filename + value->len + 1, '/'); ++ slash_ptr = strchr (filename + dirlen + 1, '/'); + while (slash_ptr) { + *slash_ptr = '-'; + slash_ptr = strchr (slash_ptr, '/'); +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -26,6 +26,7 @@ SRC_URI += "file://glusterd.init \ file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ file://0002-posix-disable-open-read-write-on-special-files.patch \ file://0003-server-protocol-don-t-allow-.-path-in-name.patch \ + file://0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 5/7 glusterfs: fix CVE-2018-10924
In reply to Chen QiBackport patch to fix the following CVE.
CVE: CVE-2018-10924
--- .../0005-cluster-afr-Fix-dict-leak-in-pre-op.patch | 135 +++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 136 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0005-cluster-afr-Fix-dict-leak-in-pre-op.patch
recipes-extended/glusterfs/files/0005-cluster-afr-Fix-dict-leak-in-pre-op.patch new file +135 -0
@@ -0,0 +1,135 @@ +From f4dddd7727988b8077b2da577e195621d5bac9c7 Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Tue, 25 Sep 2018 15:23:10 +0800 +Subject: [PATCH 5/7] cluster/afr: Fix dict-leak in pre-op + +At the time of pre-op, pre_op_xdata is populted with the xattrs we get from the +disk and at the time of post-op it gets over-written without unreffing the +previous value stored leading to a leak. +This is a regression we missed in +https://review.gluster.org/#/q/ba149bac92d169ae2256dbc75202dc9e5d06538e + +BUG: 1550078 +Change-Id: I0456f9ad6f77ce6248b747964a037193af3a3da7 +Signed-off-by: Pranith Kumar K <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10924 + +Modified for this old glusterfs version. + +Signed-off-by: Chen Qi <[email protected]> +--- + xlators/cluster/afr/src/afr-common.c | 14 +++++++------- + xlators/cluster/afr/src/afr-transaction.c | 20 ++++++++++---------- + xlators/cluster/afr/src/afr.h | 4 ++-- + 3 files changed, 19 insertions(+), 19 deletions(-) + +diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c +index 0643204..85150a0 100644 +--- a/xlators/cluster/afr/src/afr-common.c ++++ b/xlators/cluster/afr/src/afr-common.c +@@ -1673,13 +1673,13 @@ afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this) + GF_FREE (local->transaction.pre_op); + + GF_FREE (local->transaction.pre_op_sources); +- if (local->transaction.pre_op_xdata) { ++ if (local->transaction.changelog_xdata) { + for (i = 0; i < priv->child_count; i++) { +- if (!local->transaction.pre_op_xdata[i]) ++ if (!local->transaction.changelog_xdata[i]) + continue; +- dict_unref (local->transaction.pre_op_xdata[i]); ++ dict_unref (local->transaction.changelog_xdata[i]); + } +- GF_FREE (local->transaction.pre_op_xdata); ++ GF_FREE (local->transaction.changelog_xdata); + } + + GF_FREE (local->transaction.eager_lock); +@@ -5396,10 +5396,10 @@ afr_transaction_local_init (afr_local_t *local, xlator_t *this) + goto out; + + if (priv->arbiter_count == 1) { +- local->transaction.pre_op_xdata = +- GF_CALLOC (sizeof (*local->transaction.pre_op_xdata), ++ local->transaction.changelog_xdata = ++ GF_CALLOC (sizeof (*local->transaction.changelog_xdata), + priv->child_count, gf_afr_mt_dict_t); +- if (!local->transaction.pre_op_xdata) ++ if (!local->transaction.changelog_xdata) + goto out; + + local->transaction.pre_op_sources = +diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c +index 35621d9..c9a4474 100644 +--- a/xlators/cluster/afr/src/afr-transaction.c ++++ b/xlators/cluster/afr/src/afr-transaction.c +@@ -276,9 +276,9 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this) + matrix = ALLOC_MATRIX (priv->child_count, int); + + for (i = 0; i < priv->child_count; i++) { +- if (!local->transaction.pre_op_xdata[i]) ++ if (!local->transaction.changelog_xdata[i]) + continue; +- xdata = local->transaction.pre_op_xdata[i]; ++ xdata = local->transaction.changelog_xdata[i]; + afr_selfheal_fill_matrix (this, matrix, i, idx, xdata); + } + +@@ -295,13 +295,6 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this) + for (j = 0; j < priv->child_count; j++) + if (matrix[i][j] != 0) + local->transaction.pre_op_sources[j] = 0; +- +- /*We don't need the xattrs any more. */ +- for (i = 0; i < priv->child_count; i++) +- if (local->transaction.pre_op_xdata[i]) { +- dict_unref (local->transaction.pre_op_xdata[i]); +- local->transaction.pre_op_xdata[i] = NULL; +- } + } + + gf_boolean_t +@@ -1175,7 +1168,7 @@ afr_changelog_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + + if (priv->arbiter_count == 1 && !op_ret) { + if (xattr) +- local->transaction.pre_op_xdata[child_index] = ++ local->transaction.changelog_xdata[child_index] = + dict_ref (xattr); + } + +@@ -1608,6 +1601,13 @@ afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr, + local = frame->local; + priv = this->private; + ++ for (i = 0; i < priv->child_count; i++) { ++ if (local->transaction.changelog_xdata[i]) { ++ dict_unref (local->transaction.changelog_xdata[i]); ++ local->transaction.changelog_xdata[i] = NULL; ++ } ++ } ++ + ret = afr_changelog_prepare (this, frame, &call_count, changelog_resume, + op, &xdata, &newloc_xdata); + +diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h +index cf736ed..2854153 100644 +--- a/xlators/cluster/afr/src/afr.h ++++ b/xlators/cluster/afr/src/afr.h +@@ -737,8 +737,8 @@ typedef struct _afr_local { + + unsigned char *pre_op; + +- /* For arbiter configuration only. */ +- dict_t **pre_op_xdata; ++ /* Changelog xattr dict for [f]xattrop*/ ++ dict_t **changelog_xdata; + unsigned char *pre_op_sources; + + /* @failed_subvols: subvolumes on which a pre-op or a +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -27,6 +27,7 @@ SRC_URI += "file://glusterd.init \ file://0002-posix-disable-open-read-write-on-special-files.patch \ file://0003-server-protocol-don-t-allow-.-path-in-name.patch \ file://0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch \ + file://0005-cluster-afr-Fix-dict-leak-in-pre-op.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 6/7 glusterfs: fix Fix CVE-2018-10913 and CVE-2018-10914
In reply to Chen QiBackport a patch to fix the following two CVEs.
CVE: CVE-2018-10913
CVE: CVE-2018-10914
--- ...osix-remove-not-supported-get-set-content.patch | 297 +++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 298 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0006-posix-remove-not-supported-get-set-content.patch
recipes-extended/glusterfs/files/0006-posix-remove-not-supported-get-set-content.patch new file +297 -0
@@ -0,0 +1,297 @@ +From 76ee41dcb37d3c864d9cb70f957034c246de43ab Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Tue, 25 Sep 2018 16:31:14 +0800 +Subject: [PATCH 6/7] posix: remove not supported get/set content + +getting and setting a file's content using extended +attribute worked great as a GET/PUT alternative when +an object storage is supported on top of Gluster. But +it needs application changes, and also, it skips some +caching layers. It is not used over years, and not +supported any more. Remove the dead code. + +Fixes: bz#1625102 + +Change-Id: Ide3b3f1f644f6ca58558bbe45561f346f96b95b7 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10913 +Fix CVE-2018-10914 + +Modified to suite this old version. + +Signed-off-by: Chen Qi <[email protected]> +--- + libglusterfs/src/glusterfs.h | 6 -- + xlators/storage/posix/src/posix-helpers.c | 166 +----------------------------- + xlators/storage/posix/src/posix.c | 14 --- + xlators/storage/posix/src/posix.h | 4 - + 4 files changed, 1 insertion(+), 189 deletions(-) + +diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h +index 9047373..77cafcb 100644 +--- a/libglusterfs/src/glusterfs.h ++++ b/libglusterfs/src/glusterfs.h +@@ -152,9 +152,6 @@ + #define GLUSTERFS_INTERNAL_FOP_KEY "glusterfs-internal-fop" + #define DHT_CHANGELOG_RENAME_OP_KEY "changelog.rename-op" + +-#define ZR_FILE_CONTENT_STR "glusterfs.file." +-#define ZR_FILE_CONTENT_STRLEN 15 +- + #define GLUSTERFS_WRITE_IS_APPEND "glusterfs.write-is-append" + #define GLUSTERFS_WRITE_UPDATE_ATOMIC "glusterfs.write-update-atomic" + #define GLUSTERFS_OPEN_FD_COUNT "glusterfs.open-fd-count" +@@ -220,9 +217,6 @@ + + #define STARTING_EVENT_THREADS 1 + +-#define ZR_FILE_CONTENT_REQUEST(key) (!strncmp(key, ZR_FILE_CONTENT_STR, \ +- ZR_FILE_CONTENT_STRLEN)) +- + #define DEFAULT_VAR_RUN_DIRECTORY DATADIR "/run/gluster" + #define DEFAULT_GLUSTERFSD_MISC_DIRETORY DATADIR "/lib/misc/glusterfsd" + #ifdef GF_LINUX_HOST_OS +diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c +index 69f61bf..f849845 100644 +--- a/xlators/storage/posix/src/posix-helpers.c ++++ b/xlators/storage/posix/src/posix-helpers.c +@@ -890,166 +890,6 @@ out: + return ret; + } + +- +-int +-posix_set_file_contents (xlator_t *this, const char *path, char *keyp, +- data_t *value, int flags) +-{ +- char * key = NULL; +- char real_path[PATH_MAX]; +- int32_t file_fd = -1; +- int op_ret = 0; +- int ret = -1; +- +- +- /* XXX: does not handle assigning GFID to created files */ +- return -1; +- +- key = &(keyp[15]); +- sprintf (real_path, "%s/%s", path, key); +- +- if (flags & XATTR_REPLACE) { +- /* if file exists, replace it +- * else, error out */ +- file_fd = open (real_path, O_TRUNC|O_WRONLY); +- +- if (file_fd == -1) { +- goto create; +- } +- +- if (value->len) { +- ret = sys_write (file_fd, value->data, value->len); +- if (ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, +- P_MSG_SET_FILE_CONTENTS, "write failed" +- "while doing setxattr for key %s on" +- "path%s", key, real_path); +- goto out; +- } +- +- ret = sys_close (file_fd); +- if (ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, +- P_MSG_SET_FILE_CONTENTS, +- "close failed on %s", +- real_path); +- goto out; +- } +- } +- +- create: /* we know file doesn't exist, create it */ +- +- file_fd = open (real_path, O_CREAT|O_WRONLY, 0644); +- +- if (file_fd == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, +- P_MSG_SET_FILE_CONTENTS, "failed to open file" +- "%s with O_CREAT", key); +- goto out; +- } +- +- ret = sys_write (file_fd, value->data, value->len); +- if (ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, +- P_MSG_SET_FILE_CONTENTS, "write failed on %s" +- "while setxattr with key %s", real_path, key); +- goto out; +- } +- +- ret = sys_close (file_fd); +- if (ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, +- P_MSG_SET_FILE_CONTENTS, "close failed on" +- " %s while setxattr with key %s", +- real_path, key); +- goto out; +- } +- } +- +-out: +- return op_ret; +-} +- +- +-int +-posix_get_file_contents (xlator_t *this, uuid_t pargfid, +- const char *name, char **contents) +-{ +- char *real_path = NULL; +- int32_t file_fd = -1; +- struct iatt stbuf = {0,}; +- int op_ret = 0; +- int ret = -1; +- +- +- MAKE_HANDLE_PATH (real_path, this, pargfid, name); +- if (!real_path) { +- op_ret = -ESTALE; +- gf_msg (this->name, GF_LOG_ERROR, ESTALE, +- P_MSG_XDATA_GETXATTR, +- "Failed to create handle path for %s/%s", +- uuid_utoa (pargfid), name); +- goto out; +- } +- +- op_ret = posix_istat (this, pargfid, name, &stbuf); +- if (op_ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, +- "lstat failed on %s", real_path); +- goto out; +- } +- +- file_fd = open (real_path, O_RDONLY); +- +- if (file_fd == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, +- "open failed on %s", real_path); +- goto out; +- } +- +- *contents = GF_CALLOC (stbuf.ia_size + 1, sizeof(char), +- gf_posix_mt_char); +- if (! *contents) { +- op_ret = -errno; +- goto out; +- } +- +- ret = sys_read (file_fd, *contents, stbuf.ia_size); +- if (ret <= 0) { +- op_ret = -1; +- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, +- "read on %s failed", real_path); +- goto out; +- } +- +- *contents[stbuf.ia_size] = '\0'; +- +- op_ret = sys_close (file_fd); +- file_fd = -1; +- if (op_ret == -1) { +- op_ret = -errno; +- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, +- "close on %s failed", real_path); +- goto out; +- } +- +-out: +- if (op_ret < 0) { +- GF_FREE (*contents); +- if (file_fd != -1) +- sys_close (file_fd); +- } +- +- return op_ret; +-} +- + #ifdef HAVE_SYS_ACL_H + int + posix_pacl_set (const char *path, const char *key, const char *acl_s) +@@ -1154,9 +994,6 @@ posix_handle_pair (xlator_t *this, const char *real_path, + if (XATTR_IS_PATHINFO (key)) { + ret = -EACCES; + goto out; +- } else if (ZR_FILE_CONTENT_REQUEST(key)) { +- ret = posix_set_file_contents (this, real_path, key, value, +- flags); + } else if (GF_POSIX_ACL_REQUEST (key)) { + if (stbuf && IS_DHT_LINKFILE_MODE (stbuf)) + goto out; +@@ -1609,8 +1446,7 @@ _handle_entry_create_keyvalue_pair (dict_t *d, char *k, data_t *v, + !strcmp ("gfid-req", k) || + !strcmp (POSIX_ACL_DEFAULT_XATTR, k) || + !strcmp (POSIX_ACL_ACCESS_XATTR, k) || +- posix_xattr_ignorable (k) || +- ZR_FILE_CONTENT_REQUEST(k)) { ++ posix_xattr_ignorable (k)) { + return 0; + } + +diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c +index 506ae91..a69e8f6 100644 +--- a/xlators/storage/posix/src/posix.c ++++ b/xlators/storage/posix/src/posix.c +@@ -4427,7 +4427,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + char *value = NULL; + char *real_path = NULL; + dict_t *dict = NULL; +- char *file_contents = NULL; + int ret = -1; + char *path = NULL; + char *rpath = NULL; +@@ -4458,19 +4457,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, + goto out; + } + +- if (loc->inode && IA_ISDIR(loc->inode->ia_type) && name && +- ZR_FILE_CONTENT_REQUEST(name)) { +- ret = posix_get_file_contents (this, loc->gfid, &name[15], +- &file_contents); +- if (ret < 0) { +- op_errno = -ret; +- gf_msg (this->name, GF_LOG_ERROR, op_errno, +- P_MSG_FILE_FAILED, "getting file contents" +- "failed"); +- goto out; +- } +- } +- + dict = dict_new (); + if (!dict) { + op_errno = ENOMEM; +diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h +index febd432..3d2566b 100644 +--- a/xlators/storage/posix/src/posix.h ++++ b/xlators/storage/posix/src/posix.h +@@ -250,10 +250,6 @@ int posix_handle_pair (xlator_t *this, const char *real_path, char *key, + int posix_fhandle_pair (xlator_t *this, int fd, char *key, data_t *value, + int flags, struct iatt *stbuf); + void posix_spawn_janitor_thread (xlator_t *this); +-int posix_get_file_contents (xlator_t *this, uuid_t pargfid, +- const char *name, char **contents); +-int posix_set_file_contents (xlator_t *this, const char *path, char *key, +- data_t *value, int flags); + int posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req); + int posix_gfid_heal (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req); + int posix_entry_create_xattr_set (xlator_t *this, const char *path, +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -28,6 +28,7 @@ SRC_URI += "file://glusterd.init \ file://0003-server-protocol-don-t-allow-.-path-in-name.patch \ file://0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch \ file://0005-cluster-afr-Fix-dict-leak-in-pre-op.patch \ + file://0006-posix-remove-not-supported-get-set-content.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
PATCH 7/7 glusterfs: fix CVE-2018-10907
In reply to Chen QiBackport a patch to fix the following CVE.
CVE: CVE-2018-10907
--- .../files/0007-protocol-don-t-use-alloca.patch | 400 +++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 401 insertions(+) create mode 100644 recipes-extended/glusterfs/files/0007-protocol-don-t-use-alloca.patch
recipes-extended/glusterfs/files/0007-protocol-don-t-use-alloca.patch new file +400 -0
@@ -0,0 +1,400 @@ +From 7d8d9bd27f245739a6f297e4ecfc87b90c783987 Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Wed, 26 Sep 2018 09:47:28 +0800 +Subject: [PATCH 7/7] protocol: don't use alloca + +current implementation of alloca can cause issues when strings larger +than the allocated buffer is passed to the xdr. Hence it makes sense +to allow XDR decode functions to deal with memory allocations, which +we can free later. + +Fixes: bz#1625097 + +Change-Id: I3a05553f5702de9575c244649ca0e5ac9abaac94 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10907 + +Signed-off-by: Chen Qi <[email protected]> +--- + xlators/protocol/server/src/server-rpc-fops.c | 73 +++++++++++---------------- + 1 file changed, 30 insertions(+), 43 deletions(-) + +diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c +index 0ba4ffa..d3a44fc 100644 +--- a/xlators/protocol/server/src/server-rpc-fops.c ++++ b/xlators/protocol/server/src/server-rpc-fops.c +@@ -3983,8 +3983,6 @@ server3_3_create (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_create_req); + if (ret < 0) { +@@ -4034,6 +4032,7 @@ server3_3_create (rpcsvc_request_t *req) + out: + /* memory allocated by libc, don't use GF_FREE */ + free (args.xdata.xdata_val); ++ free (args.bname); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -4693,8 +4692,6 @@ server3_3_unlink (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_unlink_req); + if (ret < 0) { +@@ -4734,6 +4731,7 @@ server3_3_unlink (rpcsvc_request_t *req) + resolve_and_resume (frame, server_unlink_resume); + out: + free (args.xdata.xdata_val); ++ free (args.bname); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -4755,8 +4753,6 @@ server3_3_setxattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.dict.dict_val = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_setxattr_req); + if (ret < 0) { +@@ -4809,6 +4805,7 @@ server3_3_setxattr (rpcsvc_request_t *req) + + out: + free (args.xdata.xdata_val); ++ free (args.dict.dict_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -4834,7 +4831,6 @@ server3_3_fsetxattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.dict.dict_val = alloca (req->msg[0].iov_len); + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fsetxattr_req); + if (ret < 0) { +@@ -4885,6 +4881,7 @@ server3_3_fsetxattr (rpcsvc_request_t *req) + + out: + free (args.xdata.xdata_val); ++ free (args.dict.dict_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -4910,7 +4907,6 @@ server3_3_fxattrop (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.dict.dict_val = alloca (req->msg[0].iov_len); + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fxattrop_req); + if (ret < 0) { +@@ -4961,6 +4957,7 @@ server3_3_fxattrop (rpcsvc_request_t *req) + + out: + free (args.xdata.xdata_val); ++ free (args.dict.dict_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -4986,8 +4983,6 @@ server3_3_xattrop (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.dict.dict_val = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_xattrop_req); + if (ret < 0) { +@@ -5037,6 +5032,7 @@ server3_3_xattrop (rpcsvc_request_t *req) + + out: + free (args.xdata.xdata_val); ++ free (args.dict.dict_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5060,8 +5056,6 @@ server3_3_getxattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.name = alloca (256); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_getxattr_req); + if (ret < 0) { +@@ -5104,6 +5098,7 @@ server3_3_getxattr (rpcsvc_request_t *req) + resolve_and_resume (frame, server_getxattr_resume); + out: + free (args.xdata.xdata_val); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5124,7 +5119,6 @@ server3_3_fgetxattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.name = alloca (256); + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fgetxattr_req); + if (ret < 0) { +@@ -5165,6 +5159,7 @@ server3_3_fgetxattr (rpcsvc_request_t *req) + resolve_and_resume (frame, server_fgetxattr_resume); + out: + free (args.xdata.xdata_val); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5186,8 +5181,6 @@ server3_3_removexattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.name = alloca (256); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_removexattr_req); + if (ret < 0) { +@@ -5225,6 +5218,7 @@ server3_3_removexattr (rpcsvc_request_t *req) + resolve_and_resume (frame, server_removexattr_resume); + out: + free (args.xdata.xdata_val); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5244,8 +5238,6 @@ server3_3_fremovexattr (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.name = alloca (4096); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fremovexattr_req); + if (ret < 0) { +@@ -5284,6 +5276,7 @@ server3_3_fremovexattr (rpcsvc_request_t *req) + resolve_and_resume (frame, server_fremovexattr_resume); + out: + free (args.xdata.xdata_val); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5561,8 +5554,6 @@ server3_3_mknod (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_mknod_req); + if (ret < 0) { +@@ -5609,6 +5600,7 @@ out: + + /* memory allocated by libc, don't use GF_FREE */ + free (args.xdata.xdata_val); ++ free (args.bname); + + return ret; + +@@ -5627,8 +5619,6 @@ server3_3_mkdir (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_mkdir_req); + if (ret < 0) { +@@ -5674,6 +5664,7 @@ out: + SERVER_REQ_SET_ERROR (req, ret); + + free (args.xdata.xdata_val); ++ free (args.bname); + + return ret; + } +@@ -5691,8 +5682,6 @@ server3_3_rmdir (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_rmdir_req); + if (ret < 0) { +@@ -5732,6 +5721,7 @@ server3_3_rmdir (rpcsvc_request_t *req) + resolve_and_resume (frame, server_rmdir_resume); + out: + free (args.xdata.xdata_val); ++ free (args.bname); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5754,8 +5744,6 @@ server3_3_inodelk (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.volume = alloca (256); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_inodelk_req); + if (ret < 0) { +@@ -5822,6 +5810,7 @@ server3_3_inodelk (rpcsvc_request_t *req) + resolve_and_resume (frame, server_inodelk_resume); + out: + free (args.xdata.xdata_val); ++ free (args.volume); + + free (args.flock.lk_owner.lk_owner_val); + +@@ -5843,7 +5832,6 @@ server3_3_finodelk (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.volume = alloca (256); + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_finodelk_req); + if (ret < 0) { +@@ -5911,6 +5899,7 @@ server3_3_finodelk (rpcsvc_request_t *req) + resolve_and_resume (frame, server_finodelk_resume); + out: + free (args.xdata.xdata_val); ++ free (args.volume); + + free (args.flock.lk_owner.lk_owner_val); + +@@ -5933,9 +5922,6 @@ server3_3_entrylk (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.volume = alloca (256); +- args.name = alloca (256); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_entrylk_req); + if (ret < 0) { +@@ -5979,6 +5965,8 @@ server3_3_entrylk (rpcsvc_request_t *req) + resolve_and_resume (frame, server_entrylk_resume); + out: + free (args.xdata.xdata_val); ++ free (args.volume); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -5998,9 +5986,6 @@ server3_3_fentrylk (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.name = alloca (256); +- args.volume = alloca (256); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fentrylk_req); + if (ret < 0) { +@@ -6044,6 +6029,8 @@ server3_3_fentrylk (rpcsvc_request_t *req) + resolve_and_resume (frame, server_fentrylk_resume); + out: + free (args.xdata.xdata_val); ++ free (args.volume); ++ free (args.name); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -6121,9 +6108,6 @@ server3_3_symlink (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.bname = alloca (req->msg[0].iov_len); +- args.linkname = alloca (4096); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_symlink_req); + if (ret < 0) { +@@ -6168,6 +6152,8 @@ out: + + /* memory allocated by libc, don't use GF_FREE */ + free (args.xdata.xdata_val); ++ free (args.linkname); ++ free (args.bname); + + return ret; + } +@@ -6186,8 +6172,6 @@ server3_3_link (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.newbname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_link_req); + if (ret < 0) { + //failed to decode msg; +@@ -6227,6 +6211,7 @@ server3_3_link (rpcsvc_request_t *req) + resolve_and_resume (frame, server_link_resume); + out: + free (args.xdata.xdata_val); ++ free (args.newbname); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -6247,9 +6232,6 @@ server3_3_rename (rpcsvc_request_t *req) + if (!req) + return ret; + +- args.oldbname = alloca (req->msg[0].iov_len); +- args.newbname = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_rename_req); + if (ret < 0) { +@@ -6291,6 +6273,8 @@ server3_3_rename (rpcsvc_request_t *req) + resolve_and_resume (frame, server_rename_resume); + out: + free (args.xdata.xdata_val); ++ free (args.newbname); ++ free (args.oldbname); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); +@@ -6537,9 +6521,6 @@ server3_3_lookup (rpcsvc_request_t *req) + + GF_VALIDATE_OR_GOTO ("server", req, err); + +- args.bname = alloca (req->msg[0].iov_len); +- args.xdata.xdata_val = alloca (req->msg[0].iov_len); +- + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_lookup_req); + if (ret < 0) { +@@ -6585,8 +6566,14 @@ server3_3_lookup (rpcsvc_request_t *req) + ret = 0; + resolve_and_resume (frame, server_lookup_resume); + ++ free (args.bname); ++ free (args.xdata.xdata_val); ++ + return ret; + out: ++ free (args.bname); ++ free (args.xdata.xdata_val); ++ + server_lookup_cbk (frame, NULL, frame->this, -1, EINVAL, NULL, NULL, + NULL, NULL); + ret = 0; +-- +2.7.4 +
recipes-extended/glusterfs/glusterfs.inc +1 -0
@@ -29,6 +29,7 @@ SRC_URI += "file://glusterd.init \ file://0004-io-stats-dump-io-stats-info-in-var-run-gluster.patch \ file://0005-cluster-afr-Fix-dict-leak-in-pre-op.patch \ file://0006-posix-remove-not-supported-get-set-content.patch \ + file://0007-protocol-don-t-use-alloca.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
Signature · 1 line
2.7.4
ping
Quoted 68 lines · Chen Qi
Backport patch to fix the following CVE.
CVE: CVE-2018-10911
Signed-off-by Chen Qi <[email protected]>--- ...-negative-key-value-length-while-unserial.patch | 39 ++++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 40 insertions(+)create mode 100644
recipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patchrecipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patch new file +39
-0@@ -0,0 +1,39 @@ +From 428ee988df7d6cbe6e18becffcee5cdfb0fa9d17 Mon Sep 17 00:00:00 2001 +From: Amar Tumballi <[email protected]> +Date: Tue, 24 Jul 2018 13:25:12 +0530 +Subject: [PATCH 1/7] dict: handle negative key/value length while unserialize + +Fixes: bz#1625089 +Change-Id: Ie56df0da46c242846a1ba51ccb9e011af118b119 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10911 + +Signed-off-by: Chen Qi <[email protected]> +--- + libglusterfs/src/dict.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c +index 839b426..ac0a677 100644 +--- a/libglusterfs/src/dict.c ++++ b/libglusterfs/src/dict.c +@@ -2751,6 +2751,13 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + vallen = ntoh32 (hostord); + buf += DICT_DATA_HDR_VAL_LEN; + ++ if ((keylen < 0) || (vallen < 0)) { ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, ++ "undersized length passed " ++ "key:%d val:%d", keylen, vallen); ++ goto out; ++ } + if ((buf + keylen) > (orig_buf + size)) { + gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, + LG_MSG_UNDERSIZED_BUF, +-- +2.7.4 +recipes-extended/glusterfs/glusterfs.inc +1
-0@@ -23,6 +23,7 @@ SRC_URI += "file://glusterd.init \ file://0001-shared-storage-Prevent-mounting-shared-storage-from-.patch \ file://0002-server-auth-add-option-for-strict-authentication.patch \ file://0003-glusterfs-access-trusted-peer-group-via-remote-host-.patch \ + file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"
I almost always let patches sit for 3 or more days to allow people time to comment.
This is now merged.
Bruce
Quoted 79 lines · ChenQi
ping
Quoted 61 lines · Chen Qi
Backport patch to fix the following CVE.
CVE: CVE-2018-10911
Signed-off-by Chen Qi <[email protected]>--- ...-negative-key-value-length-while-unserial.patch | 39 ++++++++++++++++++++++ recipes-extended/glusterfs/glusterfs.inc | 1 + 2 files changed, 40 insertions(+)create mode 100644
recipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patchrecipes-extended/glusterfs/files/0001-dict-handle-negative-key-value-length-while-unserial.patch new file +39
-0@@ -0,0 +1,39 @@ +From 428ee988df7d6cbe6e18becffcee5cdfb0fa9d17 Mon Sep 17 00:00:00 2001 +From: Amar Tumballi <[email protected]> +Date: Tue, 24 Jul 2018 13:25:12 +0530 +Subject: [PATCH 1/7] dict: handle negative key/value length while unserialize + +Fixes: bz#1625089 +Change-Id: Ie56df0da46c242846a1ba51ccb9e011af118b119 +Signed-off-by: Amar Tumballi <[email protected]> + +Upstream-Status: Backport + +Fix CVE-2018-10911 + +Signed-off-by: Chen Qi <[email protected]> +--- + libglusterfs/src/dict.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c +index 839b426..ac0a677 100644 +--- a/libglusterfs/src/dict.c ++++ b/libglusterfs/src/dict.c +@@ -2751,6 +2751,13 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill) + vallen = ntoh32 (hostord); + buf += DICT_DATA_HDR_VAL_LEN; + ++ if ((keylen < 0) || (vallen < 0)) { ++ gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, ++ LG_MSG_UNDERSIZED_BUF, ++ "undersized length passed " ++ "key:%d val:%d", keylen, vallen); ++ goto out; ++ } + if ((buf + keylen) > (orig_buf + size)) { + gf_msg_callingfn ("dict", GF_LOG_ERROR, 0, + LG_MSG_UNDERSIZED_BUF, +-- +2.7.4 +recipes-extended/glusterfs/glusterfs.inc +0
-0recipes-extended/glusterfs/glusterfs.inc SRC_URI += "file://glusterd.init \ · line 29
Quoted 7 lines
recipes-extended/glusterfs/glusterfs.inc +1
-0@@ -23,6 +23,7 @@ SRC_URI += "file://glusterd.init \ file://0001-shared-storage-Prevent-mounting-shared-storage-from-.patch \ file://0002-server-auth-add-option-for-strict-authentication.patch \ file://0003-glusterfs-access-trusted-peer-group-via-remote-host-.patch \ + file://0001-dict-handle-negative-key-value-length-while-unserial.patch \ " LICENSE = "(LGPLv3+ | GPLv2) & GPLv3+ & LGPLv3+ & GPLv2+ & LGPLv2+ & LGPLv2.1+ & Apache-2.0"--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"