From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out03.mta.xmission.com ([166.70.13.233]:49176 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764200AbdAKQWN (ORCPT ); Wed, 11 Jan 2017 11:22:13 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Andrei Vagin , Ram Pai References: <20161231061729.GX1555@ZenIV.linux.org.uk> <874m1hdkyv.fsf@xmission.com> <20170103014806.GA1555@ZenIV.linux.org.uk> <87ful07ryd.fsf@xmission.com> <20170103040052.GB1555@ZenIV.linux.org.uk> <87y3yr32ig.fsf@xmission.com> <87shoz32g8.fsf_-_@xmission.com> <87a8b6r0z5.fsf_-_@xmission.com> <20170107050644.GA12074@ZenIV.linux.org.uk> <87fukqh2we.fsf@xmission.com> <20170111041140.GQ1555@ZenIV.linux.org.uk> <87inplinxd.fsf@xmission.com> Date: Thu, 12 Jan 2017 05:18:12 +1300 In-Reply-To: <87inplinxd.fsf@xmission.com> (Eric W. Biederman's message of "Thu, 12 Jan 2017 05:03:42 +1300") Message-ID: <87inplh8or.fsf_-_@xmission.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [REVIEW][PATCH 1/2] mnt: Fix propagate_mount_busy to notice all cases of busy mounts. Sender: linux-fsdevel-owner@vger.kernel.org List-ID: When I look at what propagate_mount_busy is trying to do and I look at the code closely I discover there is a great disconnect between the two. In the ordinary non-propagation case propagate_mount_busy has been verifying that there are no submounts and that there are no extraneous references on the mount. For mounts that the unmount would propagate to propagate_mount_busy has been verifying that there are no extraneous references only if there are no submounts. Which is nonsense. Thefore rework the logic in propgate_mount_busy so that for each mount it examines it considers that mount busy if that mount has children or if there are extraneous references to that mount. While this check was incorrect we could leak mounts instead of simply failing umount. Cc: stable@vger.kernel.org Fixes: a05964f3917c ("[PATCH] shared mounts handling: umount") Signed-off-by: "Eric W. Biederman" --- If you don't figure this fix is worth it after all of this time please let me know. This feels like the proper thing to do, and I don't expect it will break anyone to fix this. fs/pnode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/pnode.c b/fs/pnode.c index 06a793f4ae38..12fafa711114 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -344,7 +344,6 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) { struct mount *m, *child; struct mount *parent = mnt->mnt_parent; - int ret = 0; if (mnt == parent) return do_refcount_check(mnt, refcnt); @@ -360,11 +359,13 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) for (m = propagation_next(parent, parent); m; m = propagation_next(m, parent)) { child = __lookup_mnt_last(&m->mnt, mnt->mnt_mountpoint); - if (child && list_empty(&child->mnt_mounts) && - (ret = do_refcount_check(child, 1))) - break; + if (!child) + continue; + if (!list_empty(&child->mnt_mounts) || + do_refcount_check(child, 1)) + return 1; } - return ret; + return 0; } /* -- 2.10.1