From patchwork Tue May 1 15:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10374111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0591601C7 for ; Tue, 1 May 2018 15:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEE3B28707 for ; Tue, 1 May 2018 15:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B378B2872F; Tue, 1 May 2018 15:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B38D28710 for ; Tue, 1 May 2018 15:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750787AbeEAPkC (ORCPT ); Tue, 1 May 2018 11:40:02 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33718 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755402AbeEAPkB (ORCPT ); Tue, 1 May 2018 11:40:01 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w41FZes9060002; Tue, 1 May 2018 15:39:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=WaeNUZNfLNWGCsP9Es2DLAzIACi/oArcR2V3TquimYA=; b=rSThyS51fq92KKefed5JapgHprV6oOWBmjLRPPAcliPTLaECZYzU80usp/7+ZMK2I7Sx ULwzqGJdwWPCe7ysJmPUebf1RqGzw+Qe/Kbq1DP/hiErlpmoZLIc2gWExDiq1vUqhygy Yc7NZbSlmaItdYr3PrmFYHzwtjWM5euu9JVQ6s81JEzZYf0FKZuVZMo76vpamELGBgJ5 01icWunYlJAeaw4CF8WyGkqjPkXjd4VURG2+BFF5PGGfKHNcrfQacIxjVLtJdm+j2XXt F9UX0tcLYYVYPXjAFah+PI2qGg2t39ORSUaERDDS+Kj31Qao5ho45lR7EPrupJGM1Fnk mA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2hmhmfg5u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 May 2018 15:39:59 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w41Fdwde028665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 May 2018 15:39:59 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w41Fdws5001433; Tue, 1 May 2018 15:39:58 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 01 May 2018 08:39:58 -0700 Subject: [PATCH 6/9] generic/453: test creation of malicious directory entries From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 01 May 2018 08:39:57 -0700 Message-ID: <152518919767.23023.15585535417009112941.stgit@magnolia> In-Reply-To: <152518916007.23023.4793255395982876953.stgit@magnolia> References: <152518916007.23023.4793255395982876953.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8880 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=826 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805010154 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 --- tests/generic/453 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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