From patchwork Sat Aug 27 14:51:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 9302425 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 47B956077C for ; Sat, 27 Aug 2016 14:52:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 387522890C for ; Sat, 27 Aug 2016 14:52:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CA12289C8; Sat, 27 Aug 2016 14:52:00 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 940862890C for ; Sat, 27 Aug 2016 14:51:59 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 359BE7CA3; Sat, 27 Aug 2016 09:51:57 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay3.corp.sgi.com [198.149.34.15]) by oss.sgi.com (Postfix) with ESMTP id 7487A7CA2 for ; Sat, 27 Aug 2016 09:51:53 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay3.corp.sgi.com (Postfix) with ESMTP id D7E24AC002 for ; Sat, 27 Aug 2016 07:51:52 -0700 (PDT) X-ASG-Debug-ID: 1472309510-0bf81509b0267850001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id HKWrMKIL3WtV1ruT (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sat, 27 Aug 2016 07:51:51 -0700 (PDT) X-Barracuda-Envelope-From: zlang@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1C25CD247; Sat, 27 Aug 2016 14:51:50 +0000 (UTC) Received: from localhost (vpn1-5-239.pek2.redhat.com [10.72.5.239]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7REpn2I000908; Sat, 27 Aug 2016 10:51:50 -0400 From: Zorro Lang To: fstests@vger.kernel.org Subject: [PATCH] fstests: test xfs rw remount with unknown ro-compat features Date: Sat, 27 Aug 2016 22:51:37 +0800 X-ASG-Orig-Subj: [PATCH] fstests: test xfs rw remount with unknown ro-compat features Message-Id: <1472309497-11351-1-git-send-email-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 27 Aug 2016 14:51:50 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1472309511 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.157.11:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4303 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: Zorro Lang , xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Although ro-compat features cannot be mounted rw, a bug allows an ro->rw remount transition, and this will corrupt the filesystem if it contains ro-compat features unknown to the running kernel. This bug has been fix on linux kernel (d0a58e8 xfs: disallow rw remount on fs with unknown ro-compat features), this case is the regression testcase of that bug. Signed-off-by: Zorro Lang --- tests/xfs/263 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/263.out | 6 ++++ tests/xfs/group | 1 + 3 files changed, 106 insertions(+) create mode 100755 tests/xfs/263 create mode 100644 tests/xfs/263.out diff --git a/tests/xfs/263 b/tests/xfs/263 new file mode 100755 index 0000000..b934e9f --- /dev/null +++ b/tests/xfs/263 @@ -0,0 +1,99 @@ +#! /bin/bash +# FS QA Test 263 +# +# Test upstream d0a58e8: +# xfs: disallow rw remount on fs with unknown ro-compat features +# +#----------------------------------------------------------------------- +# Copyright (c) 2016 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + # Due to we've broken the superblock of SCRATCH_DEV by + # xfs_db, so clean bad superblock at the end + _scratch_unmount + _scratch_mkfs >/dev/null 2>&1 +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs xfs +_supported_os Linux +_require_scratch +_require_xfs_crc + +# Only V5 XFS disallow rw mount/remount with unknown ro-compat +# features +MKFS_OPTIONS="-m crc=1" +_scratch_mkfs_xfs >>$seqres.full 2>&1 + +# set the highest bit of features_ro_compat, use it as an unknown +# feature bit. If one day this bit become known feature, please +# change this case. +$XFS_DB_PROG -x -c "sb 0" \ + -c "write features_ro_compat $((2**31))" \ + $SCRATCH_DEV + +echo "rw mount test" +# Generally this mount failed as bad superblock +# But still keep testing this +MOUNT_OPTIONS="-o rw" +_scratch_mount 2>>$seqres.full +if [ $? -eq 0 ]; then + _fail "rw mount test failed" +fi + +echo "ro mount test" +MOUNT_OPTIONS="-o ro" +_scratch_mount +if [ $? -ne 0 ]; then + _fail "ro mount test failed" +else + # no hang/panic is fine + $FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 400 >>$seqres.full 2>&1 +fi + +dmesg -c >/dev/null +echo "rw remount test" +MOUNT_OPTIONS="-o rw,remount" +_scratch_mount 2>>$seqres.full +if [ $? -eq 0 ]; then + _fail "rw,remount test failed" +fi +dmesg -c | sed -n -e "s/.*XFS.*: \(ro->rw transition prohibited.*\)/\1/p" + +# success, all done +status=0 +exit diff --git a/tests/xfs/263.out b/tests/xfs/263.out new file mode 100644 index 0000000..974e02f --- /dev/null +++ b/tests/xfs/263.out @@ -0,0 +1,6 @@ +QA output created by 263 +features_ro_compat = 0x80000000 +rw mount test +ro mount test +rw remount test +mount: cannot remount LOOP_IMG read-write, is write-protected diff --git a/tests/xfs/group b/tests/xfs/group index 6905a62..ec3c022 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -260,6 +260,7 @@ 260 auto quick quota 261 auto quick quota 262 auto quick quota +263 auto quick mount 265 auto clone 266 dump ioctl auto quick 267 dump ioctl tape