Skip to contentSkip to conversation

overlay: disallow overlayfs as upperdir

PATCH Superseded Xiong Zhou 3 participants 18 messages Feb 16, 2017 – Feb 17, 2017

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Xiong Zhou

author
#0 lore raw

PATCH 1/8 overlay: disallow overlayfs as upperdir

Using overlayfs dir as upperdir to mount another overlayfs should fail.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/022     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/022.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/overlay/022
 create mode 100644 tests/overlay/022.out
tests/overlay/022 new file +80 -0
new file mode 100755
index 0000000..b09a924
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test 022
+#
+# Regression test for kernel commit:
+#     76bc8e2 ovl: disallow overlayfs as upperdir
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+mkdir -p $upperdir/upper
+mkdir -p $upperdir/work
+# mount overlay with dirs in upper
+_scratch_mount
+
+mkdir -p $tmp/{lower,mnt}
+# mount overlay using upper from another overlay upper
+# should fail
+_overlay_mount_dirs $tmp/lower $SCRATCH_MNT/upper \
+  $SCRATCH_MNT/work overlay $tmp/mnt > /dev/null 2>&1
+if [ $? -ne 0 ] ; then
+	echo "Silence is golden"
+else
+	echo "Test Fail"
+	$UMOUNT_PROG $tmp/mnt
+fi
+
+# success, all done
+status=0
+exit
tests/overlay/022.out new file +2 -0
new file mode 100644
index 0000000..394c6a7
@@ -0,0 +1,2 @@
+QA output created by 022
+Silence is golden
tests/overlay/group +1 -0
index 5bcc25e..45768f5 100644
@@ -24,3 +24,4 @@
 019 auto stress
 020 auto quick copyup perms
 021 auto quick copyup
+022 auto quick
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 2/8 overlay: work dir in overlay inherits no ACLs

They should be cleaned while mounting overlayfs.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/023     | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/023.out |  8 +++++
 tests/overlay/group   |  1 +
 3 files changed, 90 insertions(+)
 create mode 100755 tests/overlay/023
 create mode 100644 tests/overlay/023.out
tests/overlay/023 new file +81 -0
new file mode 100755
index 0000000..9f4ace5
@@ -0,0 +1,81 @@
+#! /bin/bash
+# FS QA Test 023
+#
+# The "work" directory in an overlyfs workdir should not inherit
+# ACL attrs from workdir.
+# Kernel commits below fix it.
+#   c11b9fdd6a61 ovl: remove posix_acl_default from workdir
+#   e1ff3dd1ae52 ovl: fix workdir creation
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_acls
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# setting acls before mount
+wkdir=$SCRATCH_DEV/$OVERLAY_WORK_DIR
+mkdir -p $wkdir
+setfacl -d -m o::rwx $wkdir
+
+_scratch_mount
+
+# getting acls and doing a non-common filter,
+# since getfacl will remove leading / from absolute
+# path names.
+getfacl $wkdir/work 2>&1 | \
+	sed -e "s,${wkdir#/},wkdir,g" \
+	    -e "/Removing leading/ d"
+
+# success, all done
+status=0
+exit
tests/overlay/023.out new file +8 -0
new file mode 100644
index 0000000..3bdaca4
@@ -0,0 +1,8 @@
+QA output created by 023
+# file: wkdir/work
+# owner: root
+# group: root
+user::---
+group::---
+other::---
+
tests/overlay/group +1 -0
index 45768f5..09da1be 100644
@@ -25,3 +25,4 @@
 020 auto quick copyup perms
 021 auto quick copyup
 022 auto quick
+023 auto quick attr
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 3/8 overlay: test workdir cleanup in mounting

In reply to Xiong Zhou

"work" directory in workdir should be cleaned up and recreated while overlayfs mounting. Or overlayfs will be mounted read-only.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/024     | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/024.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 78 insertions(+)
 create mode 100755 tests/overlay/024
 create mode 100644 tests/overlay/024.out
tests/overlay/024 new file +75 -0
new file mode 100755
index 0000000..a1d306e
@@ -0,0 +1,75 @@
+#! /bin/bash
+# FS QA Test 024
+#
+# "work" directory under workdir should be cleaned up
+# well on overlayfs startup, or overlayfs will be mounted
+# read-only.
+# Kernel commit below fixes it.
+# eea2fb4851e9 ovl: proper cleanup of workdir
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# making workdir
+wkdir=$SCRATCH_DEV/$OVERLAY_WORK_DIR
+mkdir -p $wkdir/work/foo
+
+_scratch_mount
+
+# try writing to mountpoint
+touch $SCRATCH_MNT/bar
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/024.out new file +2 -0
new file mode 100644
index 0000000..fd6fbb1
@@ -0,0 +1,2 @@
+QA output created by 024
+Silence is golden
tests/overlay/group +1 -0
index 09da1be..0563a04 100644
@@ -26,3 +26,4 @@
 021 auto quick copyup
 022 auto quick
 023 auto quick attr
+024 auto quick
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH 3/8] overlay: test workdir cleanup in mounting

Quoted 81 lines · Xiong Zhou

"work" directory in workdir should be cleaned up and recreated while overlayfs mounting. Or overlayfs will be mounted read-only.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/024     | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/024.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 78 insertions(+)
 create mode 100755 tests/overlay/024
 create mode 100644 tests/overlay/024.out
tests/overlay/024 new file +61 -0
new file mode 100755
index 0000000..a1d306e
@@ -0,0 +1,75 @@
+#! /bin/bash
+# FS QA Test 024
+#
+# "work" directory under workdir should be cleaned up
+# well on overlayfs startup, or overlayfs will be mounted
+# read-only.
+# Kernel commit below fixes it.
+# eea2fb4851e9 ovl: proper cleanup of workdir
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs

tests/overlay/024 line 71

Quoted 10 lines
tests/overlay/024 new file +10 -0
+
+# making workdir
+wkdir=$SCRATCH_DEV/$OVERLAY_WORK_DIR
+mkdir -p $wkdir/work/foo
+
+_scratch_mount
+
+# try writing to mountpoint
+touch $SCRATCH_MNT/bar
+

This doesn't really prove that workdir was cleaned, only that overlay mount did not error.

Maybe also check that $wkdir/work/foo was really removed?

Quoted 28 lines
tests/overlay/024 new file +4 -0
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/024.out new file +2 -0
new file mode 100644
index 0000000..fd6fbb1
@@ -0,0 +1,2 @@
+QA output created by 024
+Silence is golden
tests/overlay/group +1 -1
index 09da1be..0563a04 100644
@@ -26,3 +26,4 @@
 021 auto quick copyup
 022 auto quick
 023 auto quick attr
+024 auto quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#4 lore raw

PATCH 4/8 overlay: permission check with cached acls in tmpfs

In reply to Xiong Zhou

tmpfs does not implement ->get_acl method, overlayfs need to get its cached acls in permission check when lower or upper fs is tmpfs.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/025     | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/025.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 88 insertions(+)
 create mode 100755 tests/overlay/025
 create mode 100644 tests/overlay/025.out
tests/overlay/025 new file +85 -0
new file mode 100755
index 0000000..2e24c70
@@ -0,0 +1,85 @@
+#! /bin/bash
+# FS QA Test 025
+#
+# Overlayfs failed to get posix acls if lower or upper
+# fs is tmpfs.
+# Kernel commit below fixed it.
+# 5201dc449e4b ovl: use cached acl on underlying layer
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_user
+
+# create a tmpfs under $tmp
+mkdir -p $tmp/tmpfs
+$MOUNT_PROG -t tmpfs tmpfs $tmp/tmpfs || \
+  _notrun "this test requires a valid tmpfs"
+
+pushd $tmp/tmpfs > /dev/null 2>&1
+
+mkdir -p lower upper work mnt
+mkdir -p -m 0 upper/testd
+# grant perssion for $qa_user
+setfacl -m u:$qa_user:rx upper/testd
+
+# mount overlay using dirs in tmpfs
+_overlay_mount_dirs lower upper work overlay mnt
+
+popd > /dev/null 2>&1
+
+# user accessing test dir, should be Okay
+_user_do "ls $tmp/tmpfs/mnt/testd"
+
+$UMOUNT_PROG $tmp/tmpfs/mnt
+$UMOUNT_PROG $tmp/tmpfs
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/025.out new file +2 -0
new file mode 100644
index 0000000..3d70951
@@ -0,0 +1,2 @@
+QA output created by 025
+Silence is golden
tests/overlay/group +1 -0
index 0563a04..82fe69e 100644
@@ -27,3 +27,4 @@
 022 auto quick
 023 auto quick attr
 024 auto quick
+025 auto quick attr
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [PATCH 4/8] overlay: permission check with cached acls in tmpfs

Quoted 78 lines · Xiong Zhou

tmpfs does not implement ->get_acl method, overlayfs need to get its cached acls in permission check when lower or upper fs is tmpfs.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/025     | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/025.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 88 insertions(+)
 create mode 100755 tests/overlay/025
 create mode 100644 tests/overlay/025.out
tests/overlay/025 new file +58 -0
new file mode 100755
index 0000000..2e24c70
@@ -0,0 +1,85 @@
+#! /bin/bash
+# FS QA Test 025
+#
+# Overlayfs failed to get posix acls if lower or upper
+# fs is tmpfs.
+# Kernel commit below fixed it.
+# 5201dc449e4b ovl: use cached acl on underlying layer
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_user
+

tests/overlay/025 line 68

Quoted 10 lines
tests/overlay/025 new file +10 -0
+# create a tmpfs under $tmp
+mkdir -p $tmp/tmpfs
+$MOUNT_PROG -t tmpfs tmpfs $tmp/tmpfs || \
+  _notrun "this test requires a valid tmpfs"
+
+pushd $tmp/tmpfs > /dev/null 2>&1
+
+mkdir -p lower upper work mnt
+mkdir -p -m 0 upper/testd
+# grant perssion for $qa_user

typo (perssion)

tests/overlay/025 line 81

Quoted 13 lines
tests/overlay/025 new file +13 -0
+setfacl -m u:$qa_user:rx upper/testd
+
+# mount overlay using dirs in tmpfs
+_overlay_mount_dirs lower upper work overlay mnt
+
+popd > /dev/null 2>&1
+
+# user accessing test dir, should be Okay
+_user_do "ls $tmp/tmpfs/mnt/testd"
+
+$UMOUNT_PROG $tmp/tmpfs/mnt
+$UMOUNT_PROG $tmp/tmpfs
+

Clean those mounts and $tmp/tmpfs itself in cleanup()

Quoted 28 lines
tests/overlay/025 new file +4 -0
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/025.out new file +2 -0
new file mode 100644
index 0000000..3d70951
@@ -0,0 +1,2 @@
+QA output created by 025
+Silence is golden
tests/overlay/group +1 -1
index 0563a04..82fe69e 100644
@@ -27,3 +27,4 @@
 022 auto quick
 023 auto quick attr
 024 auto quick
+025 auto quick attr
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#6 lore raw

PATCH 5/8 overlay: filter out xattr starts with "trusted.overlay."

In reply to Xiong Zhou

Not "trusted.overlay".
"trusted.overlayxxx" is allowed.
"trusted.overlay.xxx" is not allowed.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/026     | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/026.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 91 insertions(+)
 create mode 100755 tests/overlay/026
 create mode 100644 tests/overlay/026.out
tests/overlay/026 new file +88 -0
new file mode 100755
index 0000000..d409286
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test 026
+#
+# Overlayfs should only filter out xattr starting with
+# "trusted.overlay.", not "trusted.overlay".
+# Setting acls like "trusted.overlay.xxx" is not allowed.
+# Setting acls like "trusted.overlayxxx" is allowed.
+#
+# Kernel commit below fixed it.
+# fe2b75952347 ovl: Fix OVL_XATTR_PREFIX
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/attr
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Mounting overlay
+_scratch_mount
+touch $SCRATCH_MNT/testf0
+touch $SCRATCH_MNT/testf1
+
+# The first setfattr should pass silently
+$SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
+  $SCRATCH_MNT/testf0
+
+# The second setfattr should fail, the reason not using
+# filter SCRATCH here is errno returned varies between
+# kernel versions, "not supported" vs "not permitted".
+$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 > /dev/null 2>&1
+if [ $? -eq 0 ] ; then
+	echo "Test Fail"
+else
+	echo "Silence is golden"
+fi
+# success, all done
+status=0
+exit
tests/overlay/026.out new file +2 -0
new file mode 100644
index 0000000..e45c6a3
@@ -0,0 +1,2 @@
+QA output created by 026
+Silence is golden
tests/overlay/group +1 -0
index 82fe69e..92afa8d 100644
@@ -28,3 +28,4 @@
 023 auto quick attr
 024 auto quick
 025 auto quick attr
+026 auto attr quick
Signature · 1 line
1.8.3.1
#7 lore raw

Re: [PATCH 5/8] overlay: filter out xattr starts with "trusted.overlay."

Quoted 20 lines · Xiong Zhou

Not "trusted.overlay".
"trusted.overlayxxx" is allowed.
"trusted.overlay.xxx" is not allowed.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/026     | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/026.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 91 insertions(+)
 create mode 100755 tests/overlay/026
 create mode 100644 tests/overlay/026.out
tests/overlay/026 new file +0 -0
new file mode 100755
index 0000000..d409286

tests/overlay/026 line 7

Quoted 7 lines
tests/overlay/026 new file +7 -0
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test 026
+#
+# Overlayfs should only filter out xattr starting with
+# "trusted.overlay.", not "trusted.overlay".
+# Setting acls like "trusted.overlay.xxx" is not allowed.
+# Setting acls like "trusted.overlayxxx" is allowed.

Those are not acls. they are xattr.

tests/overlay/026 line 11

Quoted 4 lines
tests/overlay/026 new file +4 -0
+#
+# Kernel commit below fixed it.
+# fe2b75952347 ovl: Fix OVL_XATTR_PREFIX
+#

That commit also changes the behavior of getxattr, so maybe check that as well is this test.

Quoted 54 lines
tests/overlay/026 new file +54 -0
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/attr
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+# Remove all files from previous tests
+_scratch_mkfs

tests/overlay/026 line 75

Quoted 10 lines
tests/overlay/026 new file +10 -0
+
+# Mounting overlay
+_scratch_mount
+touch $SCRATCH_MNT/testf0
+touch $SCRATCH_MNT/testf1
+
+# The first setfattr should pass silently
+$SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
+  $SCRATCH_MNT/testf0
+

Suggesting to add:
$GETFATTR_PROG -n "trusted.overlayxxx" \
$SCRATCH_MNT/testf0 2>&1 | grep "No such attribute" | _filter_scratch

and expect "No such attribute" in output.
either "not supported" or "not permitted" will fail to match the output.

tests/overlay/026 line 85

Quoted 10 lines
tests/overlay/026 new file +10 -0
+# The second setfattr should fail, the reason not using
+# filter SCRATCH here is errno returned varies between
+# kernel versions, "not supported" vs "not permitted".
+$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 > /dev/null 2>&1
+if [ $? -eq 0 ] ; then
+       echo "Test Fail"
+else
+       echo "Silence is golden"
+fi

For $GETFATTR_PROG -n "trusted.overlay.xxx"
you can also grep for "No such attribute" and expect no output.

Quoted 27 lines
tests/overlay/026 new file +3 -0
+# success, all done
+status=0
+exit
tests/overlay/026.out new file +2 -0
new file mode 100644
index 0000000..e45c6a3
@@ -0,0 +1,2 @@
+QA output created by 026
+Silence is golden
tests/overlay/group +1 -1
index 82fe69e..92afa8d 100644
@@ -28,3 +28,4 @@
 023 auto quick attr
 024 auto quick
 025 auto quick attr
+026 auto attr quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#8 lore raw

Re: [PATCH 5/8] overlay: filter out xattr starts with "trusted.overlay."

Quoted 15 lines · Amir Goldstein
Quoted 14 lines · Xiong Zhou

Not "trusted.overlay".
"trusted.overlayxxx" is allowed.
"trusted.overlay.xxx" is not allowed.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/026     | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/026.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 91 insertions(+)
 create mode 100755 tests/overlay/026
 create mode 100644 tests/overlay/026.out
Quoted 15 lines

tests/overlay/026 line 7

Quoted 13 lines
tests/overlay/026 new file +7 -0
new file mode 100755
index 0000000..d409286
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test 026
+#
+# Overlayfs should only filter out xattr starting with
+# "trusted.overlay.", not "trusted.overlay".
+# Setting acls like "trusted.overlay.xxx" is not allowed.
+# Setting acls like "trusted.overlayxxx" is allowed.

Those are not acls. they are xattr.

Ya! /cry

Quoted 81 lines

tests/overlay/026 line 11

Quoted 5 lines
tests/overlay/026 new file +4 -0
+#
+# Kernel commit below fixed it.
+# fe2b75952347 ovl: Fix OVL_XATTR_PREFIX
+#

That commit also changes the behavior of getxattr, so maybe check that as well is this test.

Quoted 54 lines
tests/overlay/026 new file +54 -0
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/attr
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+# Remove all files from previous tests
+_scratch_mkfs

tests/overlay/026 line 75

Quoted 10 lines
tests/overlay/026 new file +10 -0
+
+# Mounting overlay
+_scratch_mount
+touch $SCRATCH_MNT/testf0
+touch $SCRATCH_MNT/testf1
+
+# The first setfattr should pass silently
+$SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
+  $SCRATCH_MNT/testf0
+

Suggesting to add:
$GETFATTR_PROG -n "trusted.overlayxxx" \
$SCRATCH_MNT/testf0 2>&1 | grep "No such attribute" | _filter_scratch

and expect "No such attribute" in output.
either "not supported" or "not permitted" will fail to match the output.

Quoted 13 lines

tests/overlay/026 line 85

Quoted 10 lines
tests/overlay/026 new file +10 -0
+# The second setfattr should fail, the reason not using
+# filter SCRATCH here is errno returned varies between
+# kernel versions, "not supported" vs "not permitted".
+$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 > /dev/null 2>&1
+if [ $? -eq 0 ] ; then
+       echo "Test Fail"
+else
+       echo "Silence is golden"
+fi

For $GETFATTR_PROG -n "trusted.overlay.xxx"
you can also grep for "No such attribute" and expect no output.

Yes, testing getfattr here together is a good idea!

Thanks all for the comments. I'm sending v2 based on them and my test results on RHEL/upstream kernels.

--
Xiong

Quoted 28 lines
Quoted 28 lines
tests/overlay/026 new file +3 -0
+# success, all done
+status=0
+exit
tests/overlay/026.out new file +2 -0
new file mode 100644
index 0000000..e45c6a3
@@ -0,0 +1,2 @@
+QA output created by 026
+Silence is golden
tests/overlay/group +1 -1
index 82fe69e..92afa8d 100644
@@ -28,3 +28,4 @@
 023 auto quick attr
 024 auto quick
 025 auto quick attr
+026 auto attr quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH 5/8] overlay: filter out xattr starts with "trusted.overlay."

Quoted 9 lines · Xiong Zhou
Quoted 8 lines · Amir Goldstein
Quoted 7 lines · Xiong Zhou

Not "trusted.overlay".
"trusted.overlayxxx" is allowed.
"trusted.overlay.xxx" is not allowed.

CC Miklos Szeredi <[email protected]>

---

...

Quoted 4 lines

Thanks all for the comments. I'm sending v2 based on them and my test results on RHEL/upstream kernels.

You're welcome. Those are some good tests!

I suggest that you CC linux-unionfs next time
I don't know how many subscribers it has that are not on fstests, but that's the official overlayfs mailing list, so it seems in order.

Cheers,
Amir.

author
#10 lore raw

PATCH 6/8 overlay: can not change underlying immutable file

In reply to Xiong Zhou

Even timestamp change by touch.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/027     | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/027.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 81 insertions(+)
 create mode 100755 tests/overlay/027
 create mode 100644 tests/overlay/027.out
tests/overlay/027 new file +78 -0
new file mode 100755
index 0000000..b3a97b8
@@ -0,0 +1,78 @@
+#! /bin/bash
+# FS QA Test 027
+#
+# If underlying upper file is immutable, it should stays
+# untouchable in the overlayfs mount.
+#
+# Kernel commit below fixed it.
+# f2b20f6ee842 vfs: move permission checking into ...
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_chattr
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Preparing immutable file
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+mkdir -p $upperdir
+touch $upperdir/foo
+$CHATTR_PROG +i $upperdir/foo
+
+# Mounting overlay
+_scratch_mount
+
+# Touching immutable file in overlay, should fail
+touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/overlay/027.out new file +2 -0
new file mode 100644
index 0000000..3f19c46
@@ -0,0 +1,2 @@
+QA output created by 027
+touch: setting times of 'SCRATCH_MNT/foo': Operation not permitted
tests/overlay/group +1 -0
index 92afa8d..4db6751 100644
@@ -29,3 +29,4 @@
 024 auto quick
 025 auto quick attr
 026 auto attr quick
+027 auto quick perms
Signature · 1 line
1.8.3.1
#11 lore raw

Re: [PATCH 6/8] overlay: can not change underlying immutable file

Quoted 76 lines · Xiong Zhou

Even timestamp change by touch.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/027     | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/027.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 81 insertions(+)
 create mode 100755 tests/overlay/027
 create mode 100644 tests/overlay/027.out
tests/overlay/027 new file +58 -0
new file mode 100755
index 0000000..b3a97b8
@@ -0,0 +1,78 @@
+#! /bin/bash
+# FS QA Test 027
+#
+# If underlying upper file is immutable, it should stays
+# untouchable in the overlayfs mount.
+#
+# Kernel commit below fixed it.
+# f2b20f6ee842 vfs: move permission checking into ...
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch

tests/overlay/027 line 68

Quoted 10 lines
tests/overlay/027 new file +10 -0
+_require_chattr
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Preparing immutable file
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+mkdir -p $upperdir
+touch $upperdir/foo
+$CHATTR_PROG +i $upperdir/foo

Need to remove immutable attribute after test, otherwise this file will never be removed in overlayfs testing.

Thanks,
Eryu

Quoted 34 lines
tests/overlay/027 new file +10 -0
+
+# Mounting overlay
+_scratch_mount
+
+# Touching immutable file in overlay, should fail
+touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/overlay/027.out new file +2 -0
new file mode 100644
index 0000000..3f19c46
@@ -0,0 +1,2 @@
+QA output created by 027
+touch: setting times of 'SCRATCH_MNT/foo': Operation not permitted
tests/overlay/group +1 -0
index 92afa8d..4db6751 100644
@@ -29,3 +29,4 @@
 024 auto quick
 025 auto quick attr
 026 auto attr quick
+027 auto quick perms
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#12 lore raw

PATCH 7/8 overlay: test flock after copied up

In reply to Xiong Zhou

Locks of file in lower dir should working after it's been copied up.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/028     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/028.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/overlay/028
 create mode 100644 tests/overlay/028.out
tests/overlay/028 new file +80 -0
new file mode 100755
index 0000000..2e0995e
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test 028
+#
+# When file in lower dir is locked and it's been copied up,
+# make sure the lock is working in overlayfs.
+#
+# Kernel commit below fixed it.
+# c568d68341be locks: fix file locking on overlayfs
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR
+mkdir -p $lowerdir
+touch $lowerdir/foo
+
+# Mounting overlay
+_scratch_mount
+
+# Testing copyup and flock
+flock $SCRATCH_MNT/foo sleep 5 &
+# flock in subshell should fail with no output
+(sleep 1; echo bar > $SCRATCH_MNT/foo; \
+  flock -n $SCRATCH_MNT/foo echo LOCKED)
+
+wait
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/028.out new file +2 -0
new file mode 100644
index 0000000..2615f73
@@ -0,0 +1,2 @@
+QA output created by 028
+Silence is golden
tests/overlay/group +1 -0
index 4db6751..cf058fc 100644
@@ -30,3 +30,4 @@
 025 auto quick attr
 026 auto attr quick
 027 auto quick perms
+028 auto copyup quick
Signature · 1 line
1.8.3.1
#13 lore raw

Re: [PATCH 7/8] overlay: test flock after copied up

Quoted 84 lines · Xiong Zhou

Locks of file in lower dir should working after it's been copied up.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/028     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/028.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/overlay/028
 create mode 100644 tests/overlay/028.out
tests/overlay/028 new file +65 -0
new file mode 100755
index 0000000..2e0995e
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test 028
+#
+# When file in lower dir is locked and it's been copied up,
+# make sure the lock is working in overlayfs.
+#
+# Kernel commit below fixed it.
+# c568d68341be locks: fix file locking on overlayfs
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR
+mkdir -p $lowerdir
+touch $lowerdir/foo

tests/overlay/028 line 75

Quoted 10 lines
tests/overlay/028 new file +10 -0
+
+# Mounting overlay
+_scratch_mount
+
+# Testing copyup and flock
+flock $SCRATCH_MNT/foo sleep 5 &
+# flock in subshell should fail with no output
+(sleep 1; echo bar > $SCRATCH_MNT/foo; \
+  flock -n $SCRATCH_MNT/foo echo LOCKED)
+

I think this echo is meant to say NOTLOCKED ;-)

Quoted 29 lines
tests/overlay/028 new file +5 -0
+wait
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/overlay/028.out new file +2 -0
new file mode 100644
index 0000000..2615f73
@@ -0,0 +1,2 @@
+QA output created by 028
+Silence is golden
tests/overlay/group +1 -1
index 4db6751..cf058fc 100644
@@ -30,3 +30,4 @@
 025 auto quick attr
 026 auto attr quick
 027 auto quick perms
+028 auto copyup quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#14 lore raw

PATCH 8/8 overlay: accessing stacked overlayfs files

In reply to Xiong Zhou

Lower dir comes from another overlayfs dir, then accessing files in it should work.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/029     | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/029.out |  3 ++
 tests/overlay/group   |  1 +
 3 files changed, 96 insertions(+)
 create mode 100755 tests/overlay/029
 create mode 100644 tests/overlay/029.out
tests/overlay/029 new file +92 -0
new file mode 100755
index 0000000..aedd141
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test 029
+#
+# There are dirs/files in lower dir and upper dir before
+# mounting overlayfs. After mounting, use dir in overlayfs
+# mountpoint as lowerdir to mount another overlayfs, then
+# access old files through the second overlayfs. It was
+# not working, kernel commit below fixed it.
+#
+# c4fcfc1619ea ovl: fix d_real() for stacked fs
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Preparing files
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR
+mkdir -p $upperdir/up
+echo foo > $upperdir/up/foo
+mkdir -p $lowerdir/low
+echo bar > $lowerdir/low/bar
+
+# mount overlay in SCRATCH_MNT
+_scratch_mount
+
+mkdir -p $tmp/{upper,mnt,work}
+# mount overlay again using lower dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/up $tmp/{upper,work} \
+  overlay $tmp/mnt
+# accessing file in the second mount
+cat $tmp/mnt/foo
+$UMOUNT_PROG $tmp/mnt
+
+# mount overlay again using upper dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/low $tmp/{upper,work} \
+  overlay $tmp/mnt
+cat $tmp/mnt/bar
+$UMOUNT_PROG $tmp/mnt
+
+# success, all done
+status=0
+exit
tests/overlay/029.out new file +3 -0
new file mode 100644
index 0000000..870fcd9
@@ -0,0 +1,3 @@
+QA output created by 029
+foo
+bar
tests/overlay/group +1 -0
index cf058fc..7e72a30 100644
@@ -31,3 +31,4 @@
 026 auto attr quick
 027 auto quick perms
 028 auto copyup quick
+029 auto quick
Signature · 1 line
1.8.3.1
#15 lore raw

Re: [PATCH 8/8] overlay: accessing stacked overlayfs files

Quoted 87 lines · Xiong Zhou

Lower dir comes from another overlayfs dir, then
accessing files in it should work.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/029     | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/029.out |  3 ++
 tests/overlay/group   |  1 +
 3 files changed, 96 insertions(+)
 create mode 100755 tests/overlay/029
 create mode 100644 tests/overlay/029.out
tests/overlay/029 new file +68 -0
new file mode 100755
index 0000000..aedd141
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test 029
+#
+# There are dirs/files in lower dir and upper dir before
+# mounting overlayfs. After mounting, use dir in overlayfs
+# mountpoint as lowerdir to mount another overlayfs, then
+# access old files through the second overlayfs. It was
+# not working, kernel commit below fixed it.
+#
+# c4fcfc1619ea ovl: fix d_real() for stacked fs
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Preparing files
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR
+mkdir -p $upperdir/up

tests/overlay/029 line 78

Quoted 10 lines
tests/overlay/029 new file +10 -0
+echo foo > $upperdir/up/foo
+mkdir -p $lowerdir/low
+echo bar > $lowerdir/low/bar
+
+# mount overlay in SCRATCH_MNT
+_scratch_mount
+
+mkdir -p $tmp/{upper,mnt,work}
+# mount overlay again using lower dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/up $tmp/{upper,work} \

comment and code mismatch lower vs. up

tests/overlay/029 line 83

Quoted 5 lines
tests/overlay/029 new file +5 -0
+  overlay $tmp/mnt
+# accessing file in the second mount
+cat $tmp/mnt/foo
+$UMOUNT_PROG $tmp/mnt
+

cleanup mount and $tmp/mnt on cleanup()

tests/overlay/029 line 85

Quoted 2 lines
tests/overlay/029 new file +2 -0
+# mount overlay again using upper dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/low $tmp/{upper,work} \

comment and code mismatch upper vs. low

tests/overlay/029 line 89

Quoted 4 lines
tests/overlay/029 new file +4 -0
+  overlay $tmp/mnt
+cat $tmp/mnt/bar
+$UMOUNT_PROG $tmp/mnt
+

Suggesting to add:
_overlay_mount_dirs $SCRATCH_MNT/ $tmp/{upper,work} \
overlay $tmp/mnt
cat $tmp/mnt/up/foo
cat $tmp/mnt/low/bar

This differs from the 2 tests above in 2 ways:
1. $SCRATCH_MNT/ is an overlay root
2. $SCRATCH_MNT/ is a merge dir

You may want to further split these 2 cases by creating up and low under a common 'ovl' base dir and testing both on $SCRATCH_MNT/ and $SCRATCH_MNT/ovl - not critical IMO.

Quoted 28 lines
tests/overlay/029 new file +3 -0
+# success, all done
+status=0
+exit
tests/overlay/029.out new file +3 -0
new file mode 100644
index 0000000..870fcd9
@@ -0,0 +1,3 @@
+QA output created by 029
+foo
+bar
tests/overlay/group +1 -1
index cf058fc..7e72a30 100644
@@ -31,3 +31,4 @@
 026 auto attr quick
 027 auto quick perms
 028 auto copyup quick
+029 auto quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#16 lore raw

Re: [PATCH 8/8] overlay: accessing stacked overlayfs files

Quoted 101 lines · Amir Goldstein
Quoted 87 lines · Xiong Zhou

Lower dir comes from another overlayfs dir, then
accessing files in it should work.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/029     | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/029.out |  3 ++
 tests/overlay/group   |  1 +
 3 files changed, 96 insertions(+)
 create mode 100755 tests/overlay/029
 create mode 100644 tests/overlay/029.out
tests/overlay/029 new file +68 -0
new file mode 100755
index 0000000..aedd141
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test 029
+#
+# There are dirs/files in lower dir and upper dir before
+# mounting overlayfs. After mounting, use dir in overlayfs
+# mountpoint as lowerdir to mount another overlayfs, then
+# access old files through the second overlayfs. It was
+# not working, kernel commit below fixed it.
+#
+# c4fcfc1619ea ovl: fix d_real() for stacked fs
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Preparing files
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR
+mkdir -p $upperdir/up

tests/overlay/029 line 78

Quoted 10 lines
tests/overlay/029 new file +10 -0
+echo foo > $upperdir/up/foo
+mkdir -p $lowerdir/low
+echo bar > $lowerdir/low/bar
+
+# mount overlay in SCRATCH_MNT
+_scratch_mount
+
+mkdir -p $tmp/{upper,mnt,work}
+# mount overlay again using lower dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/up $tmp/{upper,work} \

comment and code mismatch lower vs. up

Quoted 7 lines

tests/overlay/029 line 83

Quoted 5 lines
tests/overlay/029 new file +5 -0
+  overlay $tmp/mnt
+# accessing file in the second mount
+cat $tmp/mnt/foo
+$UMOUNT_PROG $tmp/mnt
+

cleanup mount and $tmp/mnt on cleanup()

mounting again shortly..

Quoted 18 lines

tests/overlay/029 line 85

Quoted 3 lines
tests/overlay/029 new file +2 -0
+# mount overlay again using upper dir from SCRATCH_MNT dir
+_overlay_mount_dirs $SCRATCH_MNT/low $tmp/{upper,work} \

comment and code mismatch upper vs. low

tests/overlay/029 line 89

Quoted 4 lines
tests/overlay/029 new file +4 -0
+  overlay $tmp/mnt
+cat $tmp/mnt/bar
+$UMOUNT_PROG $tmp/mnt
+

Suggesting to add:
_overlay_mount_dirs $SCRATCH_MNT/ $tmp/{upper,work} \
overlay $tmp/mnt
cat $tmp/mnt/up/foo
cat $tmp/mnt/low/bar

Quoted 3 lines

This differs from the 2 tests above in 2 ways:
1. $SCRATCH_MNT/ is an overlay root
2. $SCRATCH_MNT/ is a merge dir

Good point! Thanks!

Quoted 35 lines

You may want to further split these 2 cases by creating up and low under a common 'ovl' base dir and testing both on $SCRATCH_MNT/ and $SCRATCH_MNT/ovl - not critical IMO.

Quoted 28 lines
tests/overlay/029 new file +3 -0
+# success, all done
+status=0
+exit
tests/overlay/029.out new file +3 -0
new file mode 100644
index 0000000..870fcd9
@@ -0,0 +1,3 @@
+QA output created by 029
+foo
+bar
tests/overlay/group +1 -1
index cf058fc..7e72a30 100644
@@ -31,3 +31,4 @@
 026 auto attr quick
 027 auto quick perms
 028 auto copyup quick
+029 auto quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#17 lore raw
In reply to Xiong Zhou
Quoted 84 lines · Xiong Zhou

Using overlayfs dir as upperdir to mount another
overlayfs should fail.

CC Miklos Szeredi <[email protected]>
---
 tests/overlay/022     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/022.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/overlay/022
 create mode 100644 tests/overlay/022.out
tests/overlay/022 new file +65 -0
new file mode 100755
index 0000000..b09a924
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test 022
+#
+# Regression test for kernel commit:
+#     76bc8e2 ovl: disallow overlayfs as upperdir
+#
+# This reproducer was originally written by
+#     Miklos Szeredi <[email protected]>
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 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.*
+}
+
+# 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
+
+# Modify as appropriate.
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
+mkdir -p $upperdir/upper
+mkdir -p $upperdir/work
+# mount overlay with dirs in upper
+_scratch_mount
+

tests/overlay/022 line 75

Quoted 10 lines
tests/overlay/022 new file +10 -0
+mkdir -p $tmp/{lower,mnt}
+# mount overlay using upper from another overlay upper
+# should fail
+_overlay_mount_dirs $tmp/lower $SCRATCH_MNT/upper \
+  $SCRATCH_MNT/work overlay $tmp/mnt > /dev/null 2>&1
+if [ $? -ne 0 ] ; then
+       echo "Silence is golden"
+else
+       echo "Test Fail"
+       $UMOUNT_PROG $tmp/mnt

Clean this mount and $tmp/mnt itself in cleanup()

Quoted 29 lines
tests/overlay/022 new file +5 -0
+fi
+
+# success, all done
+status=0
+exit
tests/overlay/022.out new file +2 -0
new file mode 100644
index 0000000..394c6a7
@@ -0,0 +1,2 @@
+QA output created by 022
+Silence is golden
tests/overlay/group +1 -1
index 5bcc25e..45768f5 100644
@@ -24,3 +24,4 @@
 019 auto stress
 020 auto quick copyup perms
 021 auto quick copyup
+022 auto quick
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html