aboutsummaryrefslogtreecommitdiff
path: root/fs/devpts
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-12-13 18:06:40 -0800
committerEric W. Biederman <ebiederm@xmission.com>2012-12-14 13:50:32 -0800
commit520d9eabce18edfef76a60b7b839d54facafe1f9 (patch)
tree69aed7689a6467f88aad8ea43790d5cf2f30ec7c /fs/devpts
parent98f842e675f96ffac96e6c50315790912b2812be (diff)
Fix cap_capable to only allow owners in the parent user namespace to have caps.
Andy Lutomirski pointed out that the current behavior of allowing the owner of a user namespace to have all caps when that owner is not in a parent user namespace is wrong. Add a test to ensure the owner of a user namespace is in the parent of the user namespace to fix this bug. Thankfully this bug did not apply to the initial user namespace, keeping the mischief that can be caused by this bug quite small. This is bug was introduced in v3.5 by commit 783291e6900 "Simplify the user_namespace by making userns->creator a kuid." But did not matter until the permisions required to create a user namespace were relaxed allowing a user namespace to be created inside of a user namespace. The bug made it possible for the owner of a user namespace to be present in a child user namespace. Since the owner of a user nameapce is granted all capabilities it became possible for users in a grandchild user namespace to have all privilges over their parent user namspace. Reorder the checks in cap_capable. This should make the common case faster and make it clear that nothing magic happens in the initial user namespace. The reordering is safe because cred->user_ns can only be in targ_ns or targ_ns->parent but not both. Add a comment a the top of the loop to make the logic of the code clear. Add a distinct variable ns that changes as we walk up the user namespace hierarchy to make it clear which variable is changing. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/devpts')
0 files changed, 0 insertions, 0 deletions