|
|
d1681e |
From cb681aeb67fbca52e8e0aab04a909e4bf8a62174 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd@samba.org>
|
|
|
d1681e |
Date: Mon, 9 Oct 2017 18:02:25 +0200
|
|
|
d1681e |
Subject: [PATCH 130/139] md-cache: avoid checking the xattr value buffer with
|
|
|
d1681e |
string functions.
|
|
|
d1681e |
MIME-Version: 1.0
|
|
|
d1681e |
Content-Type: text/plain; charset=UTF-8
|
|
|
d1681e |
Content-Transfer-Encoding: 8bit
|
|
|
d1681e |
|
|
|
d1681e |
xattrs may very well contain binary, non-text data with leading 0
|
|
|
d1681e |
values. Using strcmp for checking empty values is not the appropriate
|
|
|
d1681e |
thing to do: In the best case, it might treat a binary xattr value
|
|
|
d1681e |
starting with 0 from being cached (and hence also from being reported
|
|
|
d1681e |
back with xattr). In the worst case, we might read beyond the end
|
|
|
d1681e |
of a data blob that does contain any zero byte.
|
|
|
d1681e |
|
|
|
d1681e |
We fix this by checking the length of the data blob and checking
|
|
|
d1681e |
the first byte against 0 if the length is one.
|
|
|
d1681e |
|
|
|
d1681e |
> Signed-off-by: Guenther Deschner <gd@samba.org>
|
|
|
d1681e |
> Pair-Programmed-With: Michael Adam <obnox@samba.org>
|
|
|
d1681e |
> Change-Id: If723c465a630b8a37b6be58782a2724df7ac6b11
|
|
|
d1681e |
> BUG: 1476324
|
|
|
d1681e |
> Reviewed-on: https://review.gluster.org/17910
|
|
|
d1681e |
> Reviewed-by: Michael Adam <obnox@samba.org>
|
|
|
d1681e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
d1681e |
> Reviewed-by: Poornima G <pgurusid@redhat.com>
|
|
|
d1681e |
> Tested-by: Poornima G <pgurusid@redhat.com>
|
|
|
d1681e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
d1681e |
> (cherry picked from commit ab4ffdac9dec1867f2d9b33242179cf2b347319d)
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: If723c465a630b8a37b6be58782a2724df7ac6b11
|
|
|
d1681e |
BUG: 1446125
|
|
|
d1681e |
Signed-off-by: Günther Deschner <gd@samba.org>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/128478
|
|
|
d1681e |
Tested-by: Poornima Gurusiddaiah <pgurusid@redhat.com>
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
tests/bugs/md-cache/bug-1476324.t | 27 +++++++++++++++++++++++++++
|
|
|
d1681e |
xlators/performance/md-cache/src/md-cache.c | 2 +-
|
|
|
d1681e |
2 files changed, 28 insertions(+), 1 deletion(-)
|
|
|
d1681e |
create mode 100644 tests/bugs/md-cache/bug-1476324.t
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/tests/bugs/md-cache/bug-1476324.t b/tests/bugs/md-cache/bug-1476324.t
|
|
|
d1681e |
new file mode 100644
|
|
|
d1681e |
index 0000000..c34f412
|
|
|
d1681e |
--- /dev/null
|
|
|
d1681e |
+++ b/tests/bugs/md-cache/bug-1476324.t
|
|
|
d1681e |
@@ -0,0 +1,27 @@
|
|
|
d1681e |
+#!/bin/bash
|
|
|
d1681e |
+
|
|
|
d1681e |
+. $(dirname $0)/../../include.rc
|
|
|
d1681e |
+. $(dirname $0)/../../volume.rc
|
|
|
d1681e |
+
|
|
|
d1681e |
+cleanup;
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterd;
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3};
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST $CLI volume start $V0
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST $CLI volume set $V0 performance.md-cache-timeout 600
|
|
|
d1681e |
+TEST $CLI volume set $V0 performance.cache-samba-metadata on
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST touch $M0/file1
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST "setfattr -n user.DOSATTRIB -v 0sAAOW $M0/file1"
|
|
|
d1681e |
+TEST "getfattr -n user.DOSATTRIB $M0/file1 -e base64 | grep -q 0sAAOW"
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST "setfattr -n user.DOSATTRIB -v 0x00ff $M0/file1"
|
|
|
d1681e |
+TEST "getfattr -n user.DOSATTRIB $M0/file1 -e hex | grep -q 0x00ff"
|
|
|
d1681e |
+
|
|
|
d1681e |
+cleanup;
|
|
|
d1681e |
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
|
|
|
d1681e |
index d21a6a7..1ca7727 100644
|
|
|
d1681e |
--- a/xlators/performance/md-cache/src/md-cache.c
|
|
|
d1681e |
+++ b/xlators/performance/md-cache/src/md-cache.c
|
|
|
d1681e |
@@ -633,7 +633,7 @@ updatefn(dict_t *dict, char *key, data_t *value, void *data)
|
|
|
d1681e |
* not update their cache if the value of a xattr is a 0 byte
|
|
|
d1681e |
* data (i.e. "").
|
|
|
d1681e |
*/
|
|
|
d1681e |
- if (!strcmp (value->data, ""))
|
|
|
d1681e |
+ if (value->len == 1 && value->data[0] == '\0')
|
|
|
d1681e |
continue;
|
|
|
d1681e |
|
|
|
d1681e |
if (dict_set(u->dict, key, value) < 0) {
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|