All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH 6/9] generic/453: test creation of malicious directory entries
Date: Tue, 01 May 2018 08:39:57 -0700	[thread overview]
Message-ID: <152518919767.23023.15585535417009112941.stgit@magnolia> (raw)
In-Reply-To: <152518916007.23023.4793255395982876953.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Create malicious . and .. entries (you didn't see the zero-width
joiners at the end, did you?) in a directory to see if scrub will pick
them up.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/453 |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)


diff --git a/tests/generic/453 b/tests/generic/453
index 91d163ca..8841f581 100755
--- a/tests/generic/453
+++ b/tests/generic/453
@@ -62,6 +62,15 @@ setf() {
 	echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
 }
 
+setd() {
+	key="$(echo -e "$1")"
+	value="$2"
+
+	mkdir -p "${testdir}/${key}"
+	echo "${value}" > "${testdir}/${key}/value"
+	echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
+}
+
 testf() {
 	key="$(echo -e "$1")"
 	value="$2"
@@ -80,6 +89,24 @@ testf() {
 	fi
 }
 
+testd() {
+	key="$(echo -e "$1")"
+	value="$2"
+	fname="${testdir}/${key}/value"
+
+	echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
+
+	if [ ! -e "${fname}" ]; then
+		echo "Key ${key} does not exist for ${value} test??"
+		return
+	fi
+
+	actual_value="$(cat "${fname}")"
+	if [ "${actual_value}" != "${value}" ]; then
+		echo "Key ${key} has value ${value}, expected ${actual_value}."
+	fi
+}
+
 filter_scrub() {
 	grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
 }
@@ -143,6 +170,10 @@ setf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
 
+# fake dotdot entry
+setd ".\xe2\x80\x8d" "zero width joiners in dot entry"
+setd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
+
 ls -la $testdir >> $seqres.full
 
 echo "Test files"
@@ -190,6 +221,9 @@ testf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
 
+testd ".\xe2\x80\x8d" "zero width joiners in dot entry"
+testd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
+
 echo "Uniqueness of inodes?"
 stat -c '%i' "${testdir}/"* | sort | uniq -c | while read nr inum; do
 	if [ "${nr}" -gt 1 ]; then


  parent reply	other threads:[~2018-05-01 15:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01 15:39 [PATCH 0/9] misc. fstests changes Darrick J. Wong
2018-05-01 15:39 ` [PATCH 1/9] generic: test XATTR_REPLACE doesn't take the fs down Darrick J. Wong
2018-05-02  7:33   ` Eryu Guan
2018-05-02 14:50     ` Darrick J. Wong
2018-05-01 15:39 ` [PATCH 2/9] xfs/439: repair corrupted filesystem afterwards Darrick J. Wong
2018-05-02  7:51   ` Eryu Guan
2018-05-02 14:54     ` Darrick J. Wong
2018-05-03  1:15       ` Eryu Guan
2018-05-01 15:39 ` [PATCH 3/9] generic/45[34]: add unicode directional override checks Darrick J. Wong
2018-05-01 15:39 ` [PATCH 4/9] generic/45[34]: check unicode names only if xfs_scrub linked against libicu Darrick J. Wong
2018-05-01 15:39 ` [PATCH 5/9] generic/45[34]: test unicode confusables Darrick J. Wong
2018-05-01 15:39 ` Darrick J. Wong [this message]
2018-05-01 15:40 ` [PATCH 7/9] xfs/422: add fsstress to the freeze-and-rmap-repair race test Darrick J. Wong
2018-05-02  8:44   ` Eryu Guan
2018-05-02 14:55     ` Darrick J. Wong
2018-05-01 15:40 ` [PATCH 8/9] xfs: checkbashisms in all script files Darrick J. Wong
2018-05-02  8:55   ` Eryu Guan
2018-05-02  9:13     ` Jan Tulak
2018-05-02 14:59     ` Darrick J. Wong
2018-05-02 15:03   ` [PATCH v2 " Darrick J. Wong
2018-05-01 15:40 ` [PATCH 9/9] xfs: fix blocktrash fuzzers Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152518919767.23023.15585535417009112941.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.