public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] overlay: create directory over deleted whiteout
@ 2018-11-12  9:48 Miklos Szeredi
  2018-11-18 13:53 ` Eryu Guan
  0 siblings, 1 reply; 2+ messages in thread
From: Miklos Szeredi @ 2018-11-12  9:48 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Amir Goldstein, fstests, linux-unionfs

There's a bug in the overlayfs implementation starting from the very first
merged version that may cause an Oops of various forms if a directory is
created over a whiteout dentry, but the actual whiteout on the upper layer
was removed to the directory creation.

Reported by: kaixuxia <xiakaixu1987@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 tests/overlay/063     | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/063.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 69 insertions(+)
 create mode 100644 tests/overlay/063
 create mode 100644 tests/overlay/063.out

diff --git a/tests/overlay/063 b/tests/overlay/063
new file mode 100644
index 000000000000..0b62c2ca9a9d
--- /dev/null
+++ b/tests/overlay/063
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test 063
+#
+# Create dir over cached negative dentry, but whiteout removed from upper
+#
+# The following kernel commit fixed the kernel crash: 5e1275808630 ("ovl: check
+# whiteout in ovl_create_over_whiteout()")
+#
+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
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create test file
+lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
+upperdir=${OVL_BASE_SCRATCH_MNT}/${OVL_UPPER}
+mkdir -p $lowerdir
+touch ${lowerdir}/file
+
+_scratch_mount
+
+# Create whiteout and populate dcache with negative dentry
+
+rm ${SCRATCH_MNT}/file
+ls -l ${SCRATCH_MNT}/file > /dev/null 2>&1
+
+# Remove whiteout and try to create dir over negative dentry
+
+rm ${upperdir}/file
+mkdir ${SCRATCH_MNT}/file > /dev/null 2>&1
+
+# unmount overlayfs
+$UMOUNT_PROG $SCRATCH_MNT
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
diff --git a/tests/overlay/063.out b/tests/overlay/063.out
new file mode 100644
index 000000000000..de35fc52cfc4
--- /dev/null
+++ b/tests/overlay/063.out
@@ -0,0 +1,2 @@
+QA output created by 063
+Silence is golden
diff --git a/tests/overlay/group b/tests/overlay/group
index 165f002d96ae..1c4acd640a30 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -65,3 +65,4 @@
 060 auto quick metacopy
 061 auto quick copyup
 062 auto quick exportfs
+063 auto quick whiteout
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] overlay: create directory over deleted whiteout
  2018-11-12  9:48 [PATCH v2] overlay: create directory over deleted whiteout Miklos Szeredi
@ 2018-11-18 13:53 ` Eryu Guan
  0 siblings, 0 replies; 2+ messages in thread
From: Eryu Guan @ 2018-11-18 13:53 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Amir Goldstein, fstests, linux-unionfs

On Mon, Nov 12, 2018 at 10:48:18AM +0100, Miklos Szeredi wrote:
> There's a bug in the overlayfs implementation starting from the very first
> merged version that may cause an Oops of various forms if a directory is
> created over a whiteout dentry, but the actual whiteout on the upper layer
> was removed to the directory creation.
> 
> Reported by: kaixuxia <xiakaixu1987@gmail.com>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

Thanks for the resending and fix-up! Thanks to Amir for reviewing as
well :)

Eryu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-19  0:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-12  9:48 [PATCH v2] overlay: create directory over deleted whiteout Miklos Szeredi
2018-11-18 13:53 ` Eryu Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox