From patchwork Fri Apr 22 15:38:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 613736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qs0FJ1HpCz9t5C for ; Sat, 23 Apr 2016 01:40:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=My9u187n; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdAx-0001nu-DF; Fri, 22 Apr 2016 15:39:23 +0000 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdAs-0001bA-BN for linux-mtd@lists.infradead.org; Fri, 22 Apr 2016 15:39:18 +0000 Received: by mail-oi0-x22f.google.com with SMTP id x201so120326281oif.3 for ; Fri, 22 Apr 2016 08:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dHB8Wekis2WgTmOMNGGsndp9g3UUaHukS7BmOV9fQcM=; b=My9u187nq7/8Ff9L28m2Qni41fEt+4SMvdrkfOqOW0htRJrmUZTrpSQZNKjyusXBBa BfNfXIxiAVKJyiz/T2nji8LnesMTwwjRjkwQGUQHPfOalYMgEC8JorEgpt0ib+7b8o5Y D5BtkZJ8yowzXyag255AcKnZPyxhKXKiVi/7Ibp8eNwl8ylZgSnqyzS4R9iq21A058v0 nHSr/x/IrC7/gAHWAx8UmD7G3Xi6/OE6wzdOVlKUgZ6uYYn6iPaYYCSKM08cDN1p46QW GEQePvRgmdECWEw8vfr9yjBygd/iR7BKrqchRFBWSIWZi/5K8wU0FrrMoparljm2d35k PCTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dHB8Wekis2WgTmOMNGGsndp9g3UUaHukS7BmOV9fQcM=; b=jQMgvHn7dQz9xPg6Rfbod2nryExV5xJW2DAZNqQMd5RCZNyReBpF4SjKnbhUxYdweX 4+GLW9+3dHGn+OAM1+ck7WOgDswh7ryc7fXRlNHE2MQI/6fQY5wwVEpYV91rBG8AGeNn b5k4g52rxZnDmdcvWO87T8+gCUCAI+1PIF4DPZdDrlT9q9bflbc+A3a9r3XTAvHanoVc ZK25oZgbt3cgOrp0qwNi41ftbKxObHyasfmfsOcjV4aMmKv5HUDtcPw30A12TIcGsi9z +uPVBpERiQDtMaDzqdxLY9KRz2mJm7MoZC4qeqZlpxOFpUP1+xKySciSSaD/+SaCW6qR vDOg== X-Gm-Message-State: AOPr4FVmE8N/JVMZHbQl4hdCZHeG5JWuGqLsV04fTt8YbIz5f3D35QgPWVUtl8v0u69Q71gm X-Received: by 10.157.46.196 with SMTP id w62mr9592014ota.7.1461339537348; Fri, 22 Apr 2016 08:38:57 -0700 (PDT) Received: from localhost ([2605:a601:aab:f920:ad1c:41df:dcb1:a4a0]) by smtp.gmail.com with ESMTPSA id lf2sm2119259obb.16.2016.04.22.08.38.56 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 22 Apr 2016 08:38:56 -0700 (PDT) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH v3 01/21] fs: fix a posible leak of allocated superblock Date: Fri, 22 Apr 2016 10:38:18 -0500 Message-Id: <1461339521-123191-2-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> References: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160422_083918_464731_CC0E75AF X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4003:c06:0:0:0:22f listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-bcache@vger.kernel.org, Serge Hallyn , Seth Forshee , dm-devel@redhat.com, Miklos Szeredi , Richard Weinberger , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, fuse-devel@lists.sourceforge.net, Austin S Hemmelgarn , linux-mtd@lists.infradead.org, selinux@tycho.nsa.gov, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, Pavel Tikhomirov MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Pavel Tikhomirov We probably need to fix superblock leak in patch (v4 "fs: Add user namesapace member to struct super_block"): Imagine posible code path in sget_userns: we iterate through type->fs_supers and do not find suitable sb, we drop sb_lock to allocate s and go to retry. After we dropped sb_lock some other task from different userns takes sb_lock, it is already in retry stage and has s allocated, so it puts its s in type->fs_supers list. So in retry we will find these sb in list and check it has a different userns, and finally we will return without freeing s. Signed-off-by: Pavel Tikhomirov Acked-by: Seth Forshee --- fs/super.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/super.c b/fs/super.c index 829841e0ae7e..092a7828442e 100644 --- a/fs/super.c +++ b/fs/super.c @@ -474,6 +474,10 @@ retry: continue; if (user_ns != old->s_user_ns) { spin_unlock(&sb_lock); + if (s) { + up_write(&s->s_umount); + destroy_super(s); + } return ERR_PTR(-EBUSY); } if (!grab_super(old))