All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <guaneryu@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Icenowy Zheng <icenowy@aosc.io>,
	Chengguang Xu <cgxu519@mykernel.net>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v2 5/5] overlay: Regression test for deadlock on directory ioctl
Date: Wed, 10 Feb 2021 21:03:34 +0200	[thread overview]
Message-ID: <20210210190334.1212210-6-amir73il@gmail.com> (raw)
In-Reply-To: <20210210190334.1212210-1-amir73il@gmail.com>

Overlayfs added the ability to set inode flags (e.g. chattr +i) in
kernel 5.10 by commit 61536bed2149 ("ovl: support [S|G]ETFLAGS and
FS[S|G]ETXATTR ioctls for directories").
Icenowy Zheng reported [1] a regression in that commit that causes
a deadlock when setting inode flags on lower dir.

The regression was fixed by commit b854cc659dcb ("ovl: avoid deadlock
on directory ioctl") and applied to kernel 5.10.15.

[1] https://lore.kernel.org/linux-unionfs/20210101201230.768653-1-icenowy@aosc.io/

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/overlay/076     | 66 +++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/076.out |  2 ++
 tests/overlay/group   |  1 +
 3 files changed, 69 insertions(+)
 create mode 100644 tests/overlay/076
 create mode 100644 tests/overlay/076.out

diff --git a/tests/overlay/076 b/tests/overlay/076
new file mode 100644
index 00000000..07827c0b
--- /dev/null
+++ b/tests/overlay/076
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 076
+#
+# Support for chattr on overlayfs directories was added in kernel v5.10
+# by commit 61536bed2149 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR
+# ioctls for directories").  That commit introduced a deadlock.
+#
+# This is a regression test for the fix commit b854cc659dcb ("ovl: avoid
+# deadlock on directory ioctl")
+#
+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 /
+        $CHATTR_PROG -i $lowerdir/foo > /dev/null 2>&1
+        $CHATTR_PROG -i $upperdir/foo > /dev/null 2>&1
+        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
+_require_scratch
+_require_chattr i
+
+# remove all files from previous runs
+_scratch_mkfs
+
+# prepare lower test file
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
+mkdir -p $lowerdir
+mkdir $lowerdir/foo
+
+# mounting overlay
+_scratch_mount
+
+# Try to add the immutable attributes, it will invoke ioctl() on the directory
+# The ioctl will fail on kernel < 5.10, succeed on kernel >= 5.10.15 and hang
+# on kernel v5.10..v5.10.14.  Anything but hang is considered a test success.
+$CHATTR_PROG +i $SCRATCH_MNT/foo > /dev/null 2>&1
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/076.out b/tests/overlay/076.out
new file mode 100644
index 00000000..248e095d
--- /dev/null
+++ b/tests/overlay/076.out
@@ -0,0 +1,2 @@
+QA output created by 076
+Silence is golden
diff --git a/tests/overlay/group b/tests/overlay/group
index cfc75bb1..ddc355e5 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -78,6 +78,7 @@
 073 auto quick whiteout
 074 auto quick exportfs dangerous
 075 auto quick perms
+076 auto quick perms dangerous
 100 auto quick union samefs
 101 auto quick union nonsamefs
 102 auto quick union nonsamefs xino
-- 
2.25.1


      parent reply	other threads:[~2021-02-10 19:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 19:03 [PATCH v2 0/5] Tests for overlayfs immutable/append-only files Amir Goldstein
2021-02-10 19:03 ` [PATCH v2 1/5] overlay/030: Update comment w.r.t upstream kernel Amir Goldstein
2021-02-10 19:03 ` [PATCH v2 2/5] src/t_immutable: factor out some helpers Amir Goldstein
2021-02-10 19:03 ` [PATCH v2 3/5] src/t_immutable: Allow setting flags on existing files Amir Goldstein
2021-02-10 19:03 ` [PATCH v2 4/5] overlay: Test lost immutable/append-only flags on copy-up Amir Goldstein
2021-02-10 19:03 ` Amir Goldstein [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210210190334.1212210-6-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=cgxu519@mykernel.net \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=icenowy@aosc.io \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.