From 79b689fefa608bf2da9865de5842a595ce841f33 Mon Sep 17 00:00:00 2001 From: Salvatore Bonaccorso Date: Fri, 23 Aug 2019 17:56:42 +0200 Subject: [PATCH] xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails due to EDQUOT --- debian/changelog | 6 ++ ...ILOCK-unlock-when-xfs_setattr_nonsiz.patch | 62 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 69 insertions(+) create mode 100644 debian/patches/bugfix/all/xfs-fix-missing-ILOCK-unlock-when-xfs_setattr_nonsiz.patch diff --git a/debian/changelog b/debian/changelog index 8ca273b487e7..4547a1ff7c52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +linux (5.2.9-3) UNRELEASED; urgency=medium + + * xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails due to EDQUOT + + -- Salvatore Bonaccorso Fri, 23 Aug 2019 17:57:27 +0200 + linux (5.2.9-2) unstable; urgency=medium [ Ben Hutchings ] diff --git a/debian/patches/bugfix/all/xfs-fix-missing-ILOCK-unlock-when-xfs_setattr_nonsiz.patch b/debian/patches/bugfix/all/xfs-fix-missing-ILOCK-unlock-when-xfs_setattr_nonsiz.patch new file mode 100644 index 000000000000..dc3c866df5f7 --- /dev/null +++ b/debian/patches/bugfix/all/xfs-fix-missing-ILOCK-unlock-when-xfs_setattr_nonsiz.patch @@ -0,0 +1,62 @@ +From: "Darrick J. Wong" +Date: Thu, 22 Aug 2019 20:55:28 -0700 +Subject: xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails due to EDQUOT +Origin: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/commit/?h=xfs-5.3-fixes-6&id=1fb254aa983bf190cfd685d40c64a480a9bafaee + +Benjamin Moody reported to Debian that XFS partially wedges when a chgrp +fails on account of being out of disk quota. I ran his reproducer +script: + +# adduser dummy +# adduser dummy plugdev + +# dd if=/dev/zero bs=1M count=100 of=test.img +# mkfs.xfs test.img +# mount -t xfs -o gquota test.img /mnt +# mkdir -p /mnt/dummy +# chown -c dummy /mnt/dummy +# xfs_quota -xc 'limit -g bsoft=100k bhard=100k plugdev' /mnt + +(and then as user dummy) + +$ dd if=/dev/urandom bs=1M count=50 of=/mnt/dummy/foo +$ chgrp plugdev /mnt/dummy/foo + +and saw: + +================================================ +WARNING: lock held when returning to user space! +5.3.0-rc5 #rc5 Tainted: G W +------------------------------------------------ +chgrp/47006 is leaving the kernel with locks still held! +1 lock held by chgrp/47006: + #0: 000000006664ea2d (&xfs_nondir_ilock_class){++++}, at: xfs_ilock+0xd2/0x290 [xfs] + +...which is clearly caused by xfs_setattr_nonsize failing to unlock the +ILOCK after the xfs_qm_vop_chown_reserve call fails. Add the missing +unlock. + +Reported-by: benjamin.moody@gmail.com +Fixes: 253f4911f297 ("xfs: better xfs_trans_alloc interface") +Signed-off-by: Darrick J. Wong +Reviewed-by: Dave Chinner +Tested-by: Salvatore Bonaccorso +--- + fs/xfs/xfs_iops.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c +index ff3c1fae5357..fe285d123d69 100644 +--- a/fs/xfs/xfs_iops.c ++++ b/fs/xfs/xfs_iops.c +@@ -793,6 +793,7 @@ xfs_setattr_nonsize( + + out_cancel: + xfs_trans_cancel(tp); ++ xfs_iunlock(ip, XFS_ILOCK_EXCL); + out_dqrele: + xfs_qm_dqrele(udqp); + xfs_qm_dqrele(gdqp); +-- +2.23.0 + diff --git a/debian/patches/series b/debian/patches/series index 906ae53db0ba..c99ce1cd1425 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -88,6 +88,7 @@ bugfix/all/fs-add-module_softdep-declarations-for-hard-coded-cr.patch bugfix/all/partially-revert-usb-kconfig-using-select-for-usb_co.patch debian/revert-objtool-fix-config_stack_validation-y-warning.patch bugfix/all/partially-revert-net-socket-implement-64-bit-timestamps.patch +bugfix/all/xfs-fix-missing-ILOCK-unlock-when-xfs_setattr_nonsiz.patch # Miscellaneous features