* [PATCH][V2] xfstest: overlay: File capabilities should not be lost over copy-up
@ 2019-01-11 18:39 Vivek Goyal
2019-01-15 3:57 ` Dave Chinner
0 siblings, 1 reply; 2+ messages in thread
From: Vivek Goyal @ 2019-01-11 18:39 UTC (permalink / raw)
To: fstests, linux-unionfs; +Cc: guaneryu, Amir Goldstein, Miklos Szeredi
Make sure file capabilities are not lost over copy-up when file is
opened for WRITE but nothing is actually written to it.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
tests/overlay/064 | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/overlay/064.out | 2 +
tests/overlay/group | 1
3 files changed, 74 insertions(+)
Index: xfstests-dev/tests/overlay/064
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xfstests-dev/tests/overlay/064 2019-01-11 13:18:16.900461223 -0500
@@ -0,0 +1,71 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
+#
+# FS QA Test 064
+#
+# Make sure CAP_SETUID is not cleared over file copy up.
+#
+# Following commit introduced regression where if a lower file with
+# CAP_SETUID is opened for writing, and capability is cleared over copy up.
+#
+# bd64e57586d3 ("ovl: During copy up, first copy up metadata and then data")
+#
+# A later kernel patch will fix it. This test will help avoid introducing
+# such regressions again.
+#
+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
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_command "$SETCAP_PROG" setcap
+_require_command "$GETCAP_PROG" getcap
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create test file
+lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
+echo "This is lower" >> ${lowerdir}/file
+
+# set setuid bit
+$SETCAP_PROG cap_setuid+ep ${lowerdir}/file
+
+_scratch_mount
+
+# Trigger file copy up without actually writing anything to file. This
+# requires opening file with WRITE and xfs_io seems to open it with
+# O_RDWR by default.
+$XFS_IO_PROG -c "quit" ${SCRATCH_MNT}/file >>$seqres.full
+
+# Make sure cap_setuid is still there
+$GETCAP_PROG ${SCRATCH_MNT}/file | _filter_scratch
+
+# unmount overlayfs
+$UMOUNT_PROG $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
Index: xfstests-dev/tests/overlay/064.out
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xfstests-dev/tests/overlay/064.out 2019-01-11 13:18:22.652461223 -0500
@@ -0,0 +1,2 @@
+QA output created by 064
+SCRATCH_MNT/file = cap_setuid+ep
Index: xfstests-dev/tests/overlay/group
===================================================================
--- xfstests-dev.orig/tests/overlay/group 2018-12-19 11:47:04.443031019 -0500
+++ xfstests-dev/tests/overlay/group 2019-01-10 15:43:28.053079686 -0500
@@ -66,3 +66,4 @@
061 auto quick copyup
062 auto quick exportfs
063 auto quick whiteout
+064 auto quick copyup
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][V2] xfstest: overlay: File capabilities should not be lost over copy-up
2019-01-11 18:39 [PATCH][V2] xfstest: overlay: File capabilities should not be lost over copy-up Vivek Goyal
@ 2019-01-15 3:57 ` Dave Chinner
0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2019-01-15 3:57 UTC (permalink / raw)
To: Vivek Goyal
Cc: fstests, linux-unionfs, guaneryu, Amir Goldstein, Miklos Szeredi
On Fri, Jan 11, 2019 at 01:39:25PM -0500, Vivek Goyal wrote:
> Make sure file capabilities are not lost over copy-up when file is
> opened for WRITE but nothing is actually written to it.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> tests/overlay/064 | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/overlay/064.out | 2 +
> tests/overlay/group | 1
> 3 files changed, 74 insertions(+)
>
> Index: xfstests-dev/tests/overlay/064
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ xfstests-dev/tests/overlay/064 2019-01-11 13:18:16.900461223 -0500
> @@ -0,0 +1,71 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
2019 now.
> +# Make sure CAP_SETUID is not cleared over file copy up.
That's the test description.
> +#
> +# Following commit introduced regression where if a lower file with
> +# CAP_SETUID is opened for writing, and capability is cleared over copy up.
> +#
> +# bd64e57586d3 ("ovl: During copy up, first copy up metadata and then data")
> +#
> +# A later kernel patch will fix it. This test will help avoid introducing
> +# such regressions again.
This all belongs in the commit message, not the test description.
> +
> +# Trigger file copy up without actually writing anything to file. This
> +# requires opening file with WRITE and xfs_io seems to open it with
> +# O_RDWR by default.
There's no "seems to" about it. xfs_io will open the file O_RDWR
unless you tell it to open it read only.
> +$XFS_IO_PROG -c "quit" ${SCRATCH_MNT}/file >>$seqres.full
Probably better to use the -c "stat" command to dump the file
metadata into the debug file than to just quit.
> +# Make sure cap_setuid is still there
> +$GETCAP_PROG ${SCRATCH_MNT}/file | _filter_scratch
> +# unmount overlayfs
> +$UMOUNT_PROG $SCRATCH_MNT
No need to do that, the test harness will unmount for you...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-15 3:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-11 18:39 [PATCH][V2] xfstest: overlay: File capabilities should not be lost over copy-up Vivek Goyal
2019-01-15 3:57 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox