Message ID | 1447778351-118699-3-git-send-email-seth.forshee@canonical.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show
Return-Path: <selinux-bounces@tycho.nsa.gov> 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 B62B9BF90C for <patchwork-selinux@patchwork.kernel.org>; Tue, 17 Nov 2015 17:22:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D095204E4 for <patchwork-selinux@patchwork.kernel.org>; Tue, 17 Nov 2015 17:22:35 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (emvm-gh1-uea08.nsa.gov [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DC982049E for <patchwork-selinux@patchwork.kernel.org>; Tue, 17 Nov 2015 17:22:34 +0000 (UTC) X-TM-IMSS-Message-ID: <325665cc00055509@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([63.239.67.9]) with ESMTP (TREND IMSS SMTP Service 7.1) id 325665cc00055509 ; Tue, 17 Nov 2015 12:20:37 -0500 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 tAHHKWdO010080; Tue, 17 Nov 2015 12:20:34 -0500 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 tAHGeIEw018621 for <selinux@prometheus.infosec.tycho.ncsc.mil>; Tue, 17 Nov 2015 11:40:18 -0500 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 tAHGeCpm005521 for <selinux@tycho.nsa.gov>; Tue, 17 Nov 2015 11:40:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1AvBQCOVktW/6zVVdFeGQEBAQEPAQEBAYMLgUK8R4QNhg8CgVBMAQEBAQEBhUABAQEDEi4BATcBD1E0AQUBHAYBEiKIDAWeCIExPjGKV4VUAQWLTwEBAQEBAQEDAgEaBgqEOoIQiSaFEY4WiDiPBocyhh+ERYcHNoEXY4IEDR0WgV9TAYM/Ah4HgSMBAQE X-IPAS-Result: A1AvBQCOVktW/6zVVdFeGQEBAQEPAQEBAYMLgUK8R4QNhg8CgVBMAQEBAQEBhUABAQEDEi4BATcBD1E0AQUBHAYBEiKIDAWeCIExPjGKV4VUAQWLTwEBAQEBAQEDAgEaBgqEOoIQiSaFEY4WiDiPBocyhh+ERYcHNoEXY4IEDR0WgV9TAYM/Ah4HgSMBAQE X-IronPort-AV: E=Sophos;i="5.20,308,1444708800"; d="scan'208";a="4940865" Received: from emvm-gh1-uea08.nsa.gov ([63.239.67.9]) by goalie.tycho.ncsc.mil with ESMTP; 17 Nov 2015 11:40:06 -0500 X-TM-IMSS-Message-ID: <32314292000547b3@nsa.gov> Received: from mail-ig0-f172.google.com (mail-ig0-f172.google.com [209.85.213.172]) by nsa.gov ([63.239.67.9]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 32314292000547b3 ; Tue, 17 Nov 2015 11:40:03 -0500 Received: by igl9 with SMTP id 9so82932205igl.0 for <selinux@tycho.nsa.gov>; Tue, 17 Nov 2015 08:40:05 -0800 (PST) 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=82307GhF4DfEulDFlEN5o0F3tZyKr/GCBK6KOIrNfu0=; b=zVM6u1pq2AXxM/14EVK4XFXSc/qsLT3rCXKsJfbR1XJiohq6LHd/2JIopsnQi+RZZz zvgyc5KnKVwwHn0H1kRdwRtwvwFq4768+d8iz5VCXnrLnVt1NmPyj8k/9roYKBOjXqNj K6SX33tk4QVoIcs5291R6GFukAZVjjc9PMePvngomshMazzuYBiXhrJOCnBblx+aihtC aoV7JWFXY39XdFGJBquWjwDPSf7CDlqtTYLPKHoSYpKmWdTxYm+947r+LG30GYoQ5p8n EJU2Ci4J+vJQgv/TRnpP4noSAMsPvOVHGeyFZS4MaEoGdAcWQDBhPZKtlNAxxWcCnw8b 0y8w== 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=82307GhF4DfEulDFlEN5o0F3tZyKr/GCBK6KOIrNfu0=; b=BPUUYvW2zc1+ij439sulh2OkabTmc/EoZJQiNL2kc0ocwCsHZ5zfLLB5iuf+zRPyvg Jt+yI5OnNHvqICx1SZUxH6qJoo6M7GOVmecrKaTzcQQLOOE2LGONcAUKw7fJbKm9zNTr alhL4NyxIjx9JkTtsUcHs0FTVnbYvbEMEeJHwfXa0tDCVufuvenuMhNibd2vVvACzjIt xFMBxL7XcRXCh0amSy2pX9qINtTzdW0b3d/JsJY5nN9k91d9ZkRL4wlHdByVrtbWKAo4 aqVjDolnYGhD2CZROTVqjDEX/p7TVhbSHVHnAiny4dfLyyCelGtABwuY8QoASETfb/Kn eAnQ== X-Gm-Message-State: ALoCoQlnBDBR3gj9Mt4yeiSzEJzSVALg7FLOdPZpBQBN0OmD3/Y7uYIe4XbmLuJI5Tm3vbN+Dap5 X-Received: by 10.50.78.194 with SMTP id d2mr2742488igx.72.1447778404956; Tue, 17 Nov 2015 08:40:04 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id 81sm13239047iot.17.2015.11.17.08.40.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 08:40:04 -0800 (PST) From: Seth Forshee <seth.forshee@canonical.com> To: "Eric W. Biederman" <ebiederm@xmission.com>, Alexander Viro <viro@zeniv.linux.org.uk> Subject: [PATCH v3 2/7] block_dev: Check permissions towards block device inode when mounting Date: Tue, 17 Nov 2015 10:39:05 -0600 Message-Id: <1447778351-118699-3-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447778351-118699-1-git-send-email-seth.forshee@canonical.com> References: <1447778351-118699-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Tue, 17 Nov 2015 12:08:00 -0500 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" <selinux.tycho.nsa.gov> List-Post: <mailto:selinux@tycho.nsa.gov> List-Help: <mailto:selinux-request@tycho.nsa.gov?subject=help> Cc: Serge Hallyn <serge.hallyn@canonical.com>, dm-devel@redhat.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski <luto@amacapital.net>, linux-raid@vger.kernel.org, Seth Forshee <seth.forshee@canonical.com>, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, selinux@tycho.nsa.gov, linux-fsdevel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" <selinux-bounces@tycho.nsa.gov> X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 |
diff --git a/fs/block_dev.c b/fs/block_dev.c index f1f0aa7214a3..54d94cd64577 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1394,9 +1394,14 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, void *holder) { struct block_device *bdev; + int perm = 0; int err; - bdev = lookup_bdev(path, 0); + if (mode & FMODE_READ) + perm |= MAY_READ; + if (mode & FMODE_WRITE) + perm |= MAY_WRITE; + bdev = lookup_bdev(path, perm); if (IS_ERR(bdev)) return bdev;
Unprivileged users should not be able to mount block devices when they lack sufficient privileges towards the block device inode. Update blkdev_get_by_path() to validate that the user has the required access to the inode at the specified path. The check will be skipped for CAP_SYS_ADMIN, so privileged mounts will continue working as before. Signed-off-by: Seth Forshee <seth.forshee@canonical.com> --- fs/block_dev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)