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: 8913301 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 733F1BF29F for ; Fri, 22 Apr 2016 15:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B783E20121 for ; Fri, 22 Apr 2016 15:46:32 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (smtp.nsa.gov [8.44.101.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C234B200CF for ; Fri, 22 Apr 2016 15:46:31 +0000 (UTC) X-TM-IMSS-Message-ID: Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id ad99364c00000826 ; Fri, 22 Apr 2016 11:44:00 -0400 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u3MFeGw6005118; Fri, 22 Apr 2016 11:41:20 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u3MFd6FJ105257 for ; Fri, 22 Apr 2016 11:39:06 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u3MFd2vl004295 for ; Fri, 22 Apr 2016 11:39:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CpBAA7RBpX/yUp0ApeHAGCcIF7t3eEEIYOAoF0AQEBAQEBZieEQgEBAQMSFRkBATIFAQ8gMTQBBQEcBgESIogIAaBpgTE+MYpPhSgBBIxdAQEBAQEFAgEXBgqEDYIKjmABjkuJSIFVjEGJKYVljXEwgQ5igXiCEU4BiHoBAQE X-IPAS-Result: A0CpBAA7RBpX/yUp0ApeHAGCcIF7t3eEEIYOAoF0AQEBAQEBZieEQgEBAQMSFRkBATIFAQ8gMTQBBQEcBgESIogIAaBpgTE+MYpPhSgBBIxdAQEBAQEFAgEXBgqEDYIKjmABjkuJSIFVjEGJKYVljXEwgQ5igXiCEU4BiHoBAQE X-IronPort-AV: E=Sophos;i="5.24,517,1454994000"; d="scan'208";a="5402605" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 22 Apr 2016 11:38:59 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A9YLThBcM80KCEPVl7P1MdeyAlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc+5Zh7h7PlgxGXEQZ/co6odzbGG4+a/ASdQvd6oizMrTt9lb1c9k8?= =?us-ascii?q?IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9?= =?us-ascii?q?HOnpAIma153xjLDivcKLKFUUzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRu?= =?us-ascii?q?JN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqL?= =?us-ascii?q?cQzarFYGU25erVwAKQnI4BzgW573+GOuu+B81SWXJ8jeXbU1Qi+j6KEtQxjt3m?= =?us-ascii?q?NPHjo04GjRhsFqxJxauhXp8wJ+2Yn8coyTNeQ4eqLbYMNcQnBOGNtSAX9vGIS5?= =?us-ascii?q?OrACE+pJE+FCtInwqhNathaiBU+iA/n0yjJFrnT/26o80u8oFUfN2wl2TIFGi2?= =?us-ascii?q?jdsNigbPRaauuy1qSdiGybN/4=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A1EiAQCfQhpXjyraVdFeHAGCcIF7t3eEE?= =?us-ascii?q?IINhAECgXQBAQEBAQECAg8BAQEBBwsLCSGCXH1bPQEBAQMSFRkBATIFAQ8gMTQ?= =?us-ascii?q?BBQEcBgESIogIAaBsgTE+MYpPhSgBBIxdAQEBAQEFAgEXBgqEDYIKjmCOTIlIg?= =?us-ascii?q?VWMQYkphWWNcTCBDoJaHoFzTgGIegEBAQ?= X-IPAS-Result: =?us-ascii?q?A1EiAQCfQhpXjyraVdFeHAGCcIF7t3eEEIINhAECgXQBAQE?= =?us-ascii?q?BAQECAg8BAQEBBwsLCSGCXH1bPQEBAQMSFRkBATIFAQ8gMTQBBQEcBgESIogIA?= =?us-ascii?q?aBsgTE+MYpPhSgBBIxdAQEBAQEFAgEXBgqEDYIKjmCOTIlIgVWMQYkphWWNcTC?= =?us-ascii?q?BDoJaHoFzTgGIegEBAQ?= X-IronPort-AV: E=Sophos;i="5.24,517,1454976000"; d="scan'208";a="15532456" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by emsm-gh1-uea11.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Apr 2016 15:38:58 +0000 X-TM-IMSS-Message-ID: <61b5cd400000052d@nsa.gov> Received: from mail-oi0-f42.google.com (mail-oi0-f42.google.com [209.85.218.42]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 61b5cd400000052d ; Fri, 22 Apr 2016 11:38:19 -0400 Received: by mail-oi0-f42.google.com with SMTP id k142so120563301oib.1 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=cHMfPSxcA2oKV2CM8OwaxizzVZ7VwwwUcEhD785um0BI51TKSBMAS4DDyAyucQGGGk 2fZV5/VERF/I9LYbXBEwnIoLZtmDO0A/1Q3CUnAAb3ugWshzP9oB9owy5QprBOTwElXl e0gdJzMI/F67Yr0JfjA1a7r6Cu64hqdzidecB0JRWPWvkb2NKEwIWW+93H0wXcvhGJh7 wal5jJyVzSmHqnSi2M1pUnEkH+OCVKBaQcwQEE8Ah6mXU/Dm3gcN92ShmjtytWIarR6k sV0O0alYX2EY/D1p2BeFzA35NWJz9Gto+onvZ0gf2M3SDRLLFi8UoTkkx+/rhxYmz/Hu NV2Q== X-Gm-Message-State: AOPr4FVgIPITQOdx1OoupsHpCbmZfvQ5IEshtp7emr4MfhvhuApy+mPKRxFiVWPVwrcbheNJ 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-TM-AS-MML: disable X-Mailman-Approved-At: Fri, 22 Apr 2016 11:40:16 -0400 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: 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 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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))