From patchwork Fri Dec 28 23:59:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Vagin X-Patchwork-Id: 10744701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20BD86C5 for ; Fri, 28 Dec 2018 23:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECE7526BE9 for ; Fri, 28 Dec 2018 23:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7BCF22376; Fri, 28 Dec 2018 23:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F68C22376 for ; Fri, 28 Dec 2018 23:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbeL1X7E (ORCPT ); Fri, 28 Dec 2018 18:59:04 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37652 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbeL1X7E (ORCPT ); Fri, 28 Dec 2018 18:59:04 -0500 Received: by mail-pg1-f193.google.com with SMTP id c25so10602743pgb.4; Fri, 28 Dec 2018 15:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=nAK+/a92BOHvHKAusVY+pJNj7+mpVXimZ9xkQIgWuSM=; b=FYJIjKJOIw+AYziCMMpvdMw7juTQerMff1EwqGECzvlXrrPzWayvkPyPyste2fzIND /U63X2Wu4kstR0qlUMxArXxxu3XBPgvq8wPtVuLyBok0MHKIGWGRkJ5pHQJSMjaTpK99 ork7OT2F84t0w/9+Lo7F61CrqFmYPUnBwzyBKv/3C+ersD3JayOfIBlveTAceOzLbre9 Rs8YrI03VnsD5NjpCdXBwSBCfwzCfQwH7JNkLaQ+lLVX/TRwci1nDCedIISsPIA5+QYG qAKLaXPZ3EPcfmTJpWukRwBjNB893Q5cYMEkfbyIMGi68Q+ykRtSt0mxCMRbXwjCocNa zTyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nAK+/a92BOHvHKAusVY+pJNj7+mpVXimZ9xkQIgWuSM=; b=idSckH4U5svAkyf5fd9thXLotDzZp0sA/qTTDLQJSv0Hr574pmbW4ZzOadGA3HxV5Z 8y4KjJCGJIJ8daCPy55TILJhfhIzb+/Avq+kHBFf7gLJYUEHJF9JoIdf3NM2ODjXlpZV CFdX/HxMzwk1TzYxSIWBiw6Xj0P0ZIBJ0uh3wb8l03y1wRQLPj0lqPDy4l8KDuGTqK5t 1kMW1zikn/OwBlwN3iU+juTNhmgsJJmgcpUnsyAJuznke1cvxHKl955Z7hDsjeamPk7h IG0X9KWMHWIwXhmDuaUqWkARTSds2OA4iWjXxFseB4TSZN6Wl6Kv2UPV0y2RjavsiEdE hqVg== X-Gm-Message-State: AA+aEWaAbqIkynN0FspeaDbixT2rsKlAz/tG/zXY4uaHmiD/kN8+UPFi rvSjl7xYYRGGNfR9OerovFw= X-Google-Smtp-Source: AFSGD/WTIVxXN6kq8aa1CVZZTemnZ5HwzP2uEc3j9WYu5eKezupg6XdAedT7pzL63xMbrb52u7jl+Q== X-Received: by 2002:aa7:824f:: with SMTP id e15mr29289750pfn.192.1546041543567; Fri, 28 Dec 2018 15:59:03 -0800 (PST) Received: from localhost.localdomain ([2620:0:1008:fd00:78b4:3a07:980a:287b]) by smtp.gmail.com with ESMTPSA id e65sm76794196pfc.74.2018.12.28.15.59.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Dec 2018 15:59:02 -0800 (PST) From: Andrei Vagin To: Alexander Viro , David Howells Cc: linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, Andrei Vagin , Li Zefan Subject: [PATCH] cgroup: fix top cgroup refcnt leak Date: Fri, 28 Dec 2018 15:59:00 -0800 Message-Id: <20181228235900.21468-1-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It looks like the c6b3d5bcd67c ("cgroup: fix top cgroup refcnt leak") commit was reverted by mistake. $ mkdir /tmp/cgroup $ mkdir /tmp/cgroup2 $ mount -t cgroup -o none,name=test test /tmp/cgroup $ mount -t cgroup -o none,name=test test /tmp/cgroup2 $ umount /tmp/cgroup $ umount /tmp/cgroup2 $ cat /proc/self/cgroup | grep test 12:name=test:/ You can see the test cgroup was not freed. Cc: Li Zefan Fixes: aea3f2676c83 ("kernfs, sysfs, cgroup, intel_rdt: Support fs_context") Signed-off-by: Andrei Vagin --- kernel/cgroup/cgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index fb0717696895..dbb8805bf66c 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2045,8 +2045,11 @@ int cgroup_do_get_tree(struct fs_context *fc) } ret = 0; - if (ctx->kfc.new_sb_created) + if (ctx->kfc.new_sb_created) { goto out_cgrp; + } else { + cgroup_put(&ctx->root->cgrp); + } apply_cgroup_root_flags(ctx->flags); return 0;