From patchwork Wed Apr 5 10:47:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9663753 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 73C47602B5 for ; Wed, 5 Apr 2017 10:50:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EAE42859A for ; Wed, 5 Apr 2017 10:50:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73448285A4; Wed, 5 Apr 2017 10:50:44 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 E6D742859A for ; Wed, 5 Apr 2017 10:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932949AbdDEKse (ORCPT ); Wed, 5 Apr 2017 06:48:34 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34719 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933446AbdDEKru (ORCPT ); Wed, 5 Apr 2017 06:47:50 -0400 Received: by mail-wr0-f196.google.com with SMTP id w43so1507063wrb.1; Wed, 05 Apr 2017 03:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PAfk04nLqwj9lmeEuJROwUTkB1fVtt95beceEa3mpew=; b=TpMFomXA4q0vmYo8BZMEbn07+0duC1zYNUFKwzEIq2tpGT4e0pEl7IR2FYAODZy6LK DLAxERkVg+/9sZDGg5WPinxxJbXqA6cflcDFE8HoLGo/1VYb2k8mWQPLNvVi1NUOh7AM TzN/ECQahvb4vBJo9fOQpO9adnqqNk5eWcbTKpd52OhGcX68QCLQKy5LNYt9rULJOHYp ct5Lc3ilXEdAUTcsYG15KdnnjrnJkQ6Yi+AsFHyJ+l2/TM4pPLtiOaSt5/q1BeZrAPwV lOq+P2Ee6LbPBMd3h/FIhnucAjxIsQ9IUGP2siyUIvDmX7BPuqEdrqzXNdnZHhc0L2fA /JDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PAfk04nLqwj9lmeEuJROwUTkB1fVtt95beceEa3mpew=; b=EjNgqwj7RWKoIbj+15g0PQ4uwMj9QWUjhOh4CpK9BUIJL7v1IPg0fpalXVRsQnr/2F eNwMAgKjrwhQGDJD8qeVUq3+oQ/LwIwBRIfEdgyGU+u7kr3ipuo2nbiee+ZjEpOtQrvH J/ZTulUXJzGfw3yS6cdtndaYZEHQdnUw0kQv5nSbsGIFIsOaTSRc9jEdzAuMseZ9sDx3 /DOuUzWzC0kwaGMYGWdi/IyWqP+SU+hkJufQpS2UvYvjpQHomRhjJ8z4xIBG5cyxF9oy m4unUPKmSO9OaTIEiiDxhlXnyougkNhxLPXDOXw3WlJtHQFsuypBueUc43Pws4UP14S/ 7dqA== X-Gm-Message-State: AFeK/H2PrXmRWZ29LpVI+DhHeL2DQQiGCqzy5HUJgCwYMM68RD2DEdSL1G+tj4vygwdnvA== X-Received: by 10.28.7.144 with SMTP id 138mr19265219wmh.125.1491389268530; Wed, 05 Apr 2017 03:47:48 -0700 (PDT) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id v7sm13610512wrd.0.2017.04.05.03.47.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 03:47:47 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Xiong Zhou , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/2] overlay/030: test immutable and append-only upper files Date: Wed, 5 Apr 2017 13:47:51 +0300 Message-Id: <1491389271-24726-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491389271-24726-1-git-send-email-amir73il@gmail.com> References: <1491389271-24726-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Run the t_immutable test program for immutable/append-only files and directories in an overlayfs upper directory. This test is similar and was derived from generic/079, but the original test is _notrun on overlay mount because FS_IOC_GETFLAGS FS_IOC_SETFLAGS ioctls fail on overlay directory inodes. Signed-off-by: Amir Goldstein --- tests/overlay/030 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/030.out | 5 ++++ tests/overlay/group | 1 + 3 files changed, 80 insertions(+) create mode 100755 tests/overlay/030 create mode 100644 tests/overlay/030.out Eryu, Xiong, While looking at overlay/027 and comparing it to generic/079, I realized that overlay/027 wasn't testing quite enough. There are many tests from t_immutable where overlayfs fails, because: - either overlay directory inodes don't inherit the upper flags - or vfs checks the flags on overlay inode (e.g. IS_APPEND() on ftruncate) This test fails on kernel v4.10 as follows: open(SCRATCH_MNT/t_immutable/append-only.f, O_RDWR) did not fail open(SCRATCH_MNT/t_immutable/append-only.f, O_WRONLY) did not fail open(SCRATCH_MNT/t_immutable/append-only.f, O_RDWR|O_TRUNC) did not fail open(SCRATCH_MNT/t_immutable/append-only.f, O_WRONLY|O_TRUNC) did not fail open(SCRATCH_MNT/t_immutable/append-only.f, O_RDWR|O_APPEND|O_TRUNC) did not fail open(SCRATCH_MNT/t_immutable/append-only.f, O_WRONLY|O_APPEND|O_TRUNC) did not fail truncate(SCRATCH_MNT/t_immutable/append-only.f, 0) did not fail testing immutable...PASS. testing append-only...FAILED! (7 tests failed) But actually, I think t_immutable stops too early as there are other (directory tests) that should also be failing, but at least overlay does not allow setting attr flags on directories so this is a lesser concern. Miklos, Do you think we should propagate the S_IMMUTABLE/S_APPEND flags to overlay inodes? We could also implement the FS_IOC_GETFLAGS/FS_IOC_SETFLAGS ioctls for overlay directory inodes if you think this is useful to have. Amir. diff --git a/tests/overlay/030 b/tests/overlay/030 new file mode 100755 index 0000000..d51189a --- /dev/null +++ b/tests/overlay/030 @@ -0,0 +1,74 @@ +#! /bin/bash +# FS QA Test No. 030 +# +# Run the t_immutable test program for immutable/append-only files +# and directories in an overlayfs upper directory. +# +# This test is similar and was derived from generic/079, but +# the original test is _notrun on overlay mount because FS_IOC_GETFLAGS +# FS_IOC_SETFLAGS ioctls fail on overlay directory inodes. +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# 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` +timmutable=$here/src/t_immutable +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + $timmutable -r $upperdir/t_immutable &> /dev/null + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +_supported_fs generic +_supported_os Linux + +_require_chattr ia +_require_scratch + +[ -x $timmutable ] || _notrun "t_immutable was not built for this platform" + +_scratch_mkfs + +# Preparing immutable files in uppper dir +mkdir -p $upperdir +$timmutable -C $upperdir/t_immutable >$tmp.out 2>&1 +if grep -q -e 'Operation not supported' -e "Inappropriate ioctl" $tmp.out; then + _notrun "Setting immutable/append flag not supported" +fi + +_scratch_mount + +# Test immutability of files in overlay +$timmutable $SCRATCH_MNT/t_immutable 2>&1 | _filter_scratch +status=$? +exit diff --git a/tests/overlay/030.out b/tests/overlay/030.out new file mode 100644 index 0000000..57ba0cd --- /dev/null +++ b/tests/overlay/030.out @@ -0,0 +1,5 @@ +QA output created by 030 +testing immutable...PASS. +testing append-only...PASS. +testing immutable as non-root...PASS. +testing append-only as non-root...PASS. diff --git a/tests/overlay/group b/tests/overlay/group index 7e72a30..c5048c4 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -32,3 +32,4 @@ 027 auto quick perms 028 auto copyup quick 029 auto quick +030 auto quick perms