[Devel,RHEL7,COMMIT] ms/overlayfs: fix dentry reference leak

Submitted by Konstantin Khorenko on Aug. 9, 2016, 8:20 a.m.


Message ID 201608090820.u798K7KU015403@finist_cl7.x64_64.work.ct
State New
Series "overlayfs: fix dentry reference leak"
Headers show

Commit Message

Konstantin Khorenko Aug. 9, 2016, 8:20 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.22.2.vz7.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.22.2.vz7.16.3
commit 2e9f0d0c9a8d55eaac3b2c9307b9dc4d72e1537f
Author: Maxim Patlasov <mpatlasov@virtuozzo.com>
Date:   Tue Aug 9 12:20:07 2016 +0400

    ms/overlayfs: fix dentry reference leak
    Without this patch it is easy to crash node by fiddling
    with overlayfs dirs. Backport commit ab79efab0 from ms:
    From: David Howells <dhowells@redhat.com>
    In ovl_copy_up_locked(), newdentry is leaked if the function exits through
    out_cleanup as this just to out after calling ovl_cleanup() - which doesn't
    actually release the ref on newdentry.
    The out_cleanup segment should instead exit through out2 as certainly
    newdentry leaks - and possibly upper does also, though this isn't caught
    given the catch of newdentry.
    Without this fix, something like the following is seen:
        BUG: Dentry ffff880023e9eb20{i=f861,n=#ffff880023e82d90} still in use (1) [unmount of tmpfs tmpfs]
        BUG: Dentry ffff880023ece640{i=0,n=bigfile}  still in use (1) [unmount of tmpfs tmpfs]
    when unmounting the upper layer after an error occurred in copyup.
    An error can be induced by creating a big file in a lower layer with
    something like:
        dd if=/dev/zero of=/lower/a/bigfile bs=65536 count=1 seek=$((0xf000))
    to create a large file (4.1G).  Overlay an upper layer that is too small
    (on tmpfs might do) and then induce a copy up by opening it writably.
    Reported-by: Ulrich Obergfell <uobergfe@redhat.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
    Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
 fs/overlayfs/copy_up.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 3f3d1b0..afed35c 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -299,7 +299,7 @@  out:
 	ovl_cleanup(wdir, newdentry);
-	goto out;
+	goto out2;