mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.13.y-ckt 07/19] userns: Document what the invariant required for safe unprivileged mappings.
Date: Thu, 15 Jan 2015 14:09:43 -0800	[thread overview]
Message-ID: <1421359795-11155-8-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1421359795-11155-1-git-send-email-kamal@canonical.com>

3.13.11-ckt14 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 0542f17bf2c1f2430d368f44c8fcf2f82ec9e53e upstream.

The rule is simple.  Don't allow anything that wouldn't be allowed
without unprivileged mappings.

It was previously overlooked that establishing gid mappings would
allow dropping groups and potentially gaining permission to files and
directories that had lesser permissions for a specific group than for
all other users.

This is the rule needed to fix CVE-2014-8989 and prevent any other
security issues with new_idmap_permitted.

The reason for this rule is that the unix permission model is old and
there are programs out there somewhere that take advantage of every
little corner of it.  So allowing a uid or gid mapping to be
established without privielge that would allow anything that would not
be allowed without that mapping will result in expectations from some
code somewhere being violated.  Violated expectations about the
behavior of the OS is a long way to say a security issue.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 kernel/user_namespace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 8bdb421..1ae8d2c 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -804,7 +804,9 @@ static bool new_idmap_permitted(const struct file *file,
 				struct user_namespace *ns, int cap_setid,
 				struct uid_gid_map *new_map)
 {
-	/* Allow mapping to your own filesystem ids */
+	/* Don't allow mappings that would allow anything that wouldn't
+	 * be allowed without the establishment of unprivileged mappings.
+	 */
 	if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) {
 		u32 id = new_map->extent[0].lower_first;
 		if (cap_setid == CAP_SETUID) {
-- 
1.9.1


  parent reply	other threads:[~2015-01-15 22:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15 22:09 [3.13.y-ckt stable] Linux 3.13.11-ckt14 stable review Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 01/19] [3.13-stable only] ipv6: fix swapped ipv4/ipv6 mtu_reduced callbacks Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 02/19] e1000e: Fix no connectivity when driver loaded with cable out Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 03/19] usb: gadget: at91_udc: move prepare clk into process context Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 04/19] [3.13-stable only] KVM: x86: Fix far-jump to non-canonical check Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 05/19] x86/tls: Validate TLS entries to protect espfix Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 06/19] userns: Check euid no fsuid when establishing an unprivileged uid mapping Kamal Mostafa
2015-01-15 22:09 ` Kamal Mostafa [this message]
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 08/19] userns: Only allow the creator of the userns unprivileged mappings Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 09/19] x86_64, switch_to(): Load TLS descriptors before switching DS and ES Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 10/19] isofs: Fix infinite looping over CE entries Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 11/19] batman-adv: Calculate extra tail size based on queued fragments Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 12/19] KEYS: close race between key lookup and freeing Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 13/19] isofs: Fix unchecked printing of ER records Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 14/19] x86_64, vdso: Fix the vdso address randomization algorithm Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 15/19] groups: Consolidate the setgroups permission checks Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 16/19] userns: Don't allow setgroups until a gid mapping has been setablished Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 17/19] userns: Don't allow unprivileged creation of gid mappings Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 18/19] move d_rcu from overlapping d_child to overlapping d_alias Kamal Mostafa
2015-01-15 22:09 ` [PATCH 3.13.y-ckt 19/19] deal with deadlock in d_walk() Kamal Mostafa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421359795-11155-8-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=ebiederm@xmission.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®