Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3522724ybc; Mon, 18 Nov 2019 16:53:12 -0800 (PST) X-Google-Smtp-Source: APXvYqyo3t6URxZOg07rJqBIr77KSNFS6HVHHTqXCZt9rYOLB2iF7IBH2jJqETM/yLsFehLSc+f/ X-Received: by 2002:a17:906:4dd5:: with SMTP id f21mr30413258ejw.203.1574124791963; Mon, 18 Nov 2019 16:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574124791; cv=none; d=google.com; s=arc-20160816; b=UVavB6R/P2F0euNhvY4396kO2ZGV3UJqNxjGY6tARHtJpAP1ufhqYQ7+hzyKYntVyG D1nOY12KANJzmwSJwDlSecpL/5Kpk2uCSFhsLh4qHegd59iAAybEHhFxO9PApn7G0Ftn NfaI8w32ChkFseaXoDtv5jLguAgymhEwDFup3yVLCtIk2FYVuGWrlzmYQYTGMANQoOZP cuLcgePOTKMqHpGZih39JHQrobJWMVB2vGWvBbxuomzBZ0Mjs+EzB/X1u5CBc1wSfgdv 32K/ssjRglTPsJXRlRIQHzb6P1M1sfvSmeNJX4tOtQndalTD9GJOfJQjiVqtvdbqmEeQ amIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:to:references :subject:reply-to:dkim-signature; bh=1YpNQImsbOY2XvuXHptOUdXQSplh3oG1AGe2pyP9gNU=; b=golbYm4heu9uKUyMd6A7mw3zB4MAv9HBkDSTYkawhm6B70ZPFrfgH/spqTMViBxEYe Jw8QYMHRVvD5+uJY6lyGfE4jIaLdwBa8vOayMkOGh84XFKKiaeRHyyCAu2xN4l2SF+rS 0x4C0xXw7nxsvGfIw2aEQCeJ6C3xxtW//vNxa7nqBTgxZszE4H1wKjFlCVfGTHbOV3P1 JIvkUN6zEpwELXDV/mOdMIZTaNVHh+KggmpEQFe/giUQX/udHMt3p0q8nPzEO+b36RCP fAGNauLxaFEn6fBaYj44tiz6fFMTcii9XEqyUOjX+oC+v/IQADlkQYHe/Oo4Eyt1gimI wtVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=QjE+xGiI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24si13441892edb.328.2019.11.18.16.52.33; Mon, 18 Nov 2019 16:53:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=QjE+xGiI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbfKSAtI (ORCPT + 99 others); Mon, 18 Nov 2019 19:49:08 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46922 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbfKSAtI (ORCPT ); Mon, 18 Nov 2019 19:49:08 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAJ0htno109073; Tue, 19 Nov 2019 00:48:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=reply-to : subject : references : to : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=1YpNQImsbOY2XvuXHptOUdXQSplh3oG1AGe2pyP9gNU=; b=QjE+xGiItWVREUg96rzbIILSkWZjn6IuaPtImcl6XeHJBOGvCt/UvC3rKySCmz6JEmql hphWm3+SG6u/iu5rCUSLt30BzACcm0ObIJpLWzLt5jNHQNf68GyDXmffz52WA2irl7DO XD/8EijyXGrmjqdwhKIkfiDpnaC33Wx7HjF52Q8S39kl3pZD8Q0EpVBmra1tP5ld3Gcf c9MGS42IgfIVQhaoliZg7t0I+YqxPt7vS0VZDd9bvEoK548VPbaqRZNHIhP8cGWVqHPm Cda/Uwm1bJSieTg0L0gq6ZedCTJxckLitq2zkhSApH2vEI9mTyXP9y9ZRVXzbiKI4Yjb Iw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2wa9rqbn08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Nov 2019 00:48:36 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAJ0lrEe020048; Tue, 19 Nov 2019 00:48:36 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2wc0affd4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Nov 2019 00:48:36 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAJ0mYhr032125; Tue, 19 Nov 2019 00:48:34 GMT Received: from [10.132.95.199] (/10.132.95.199) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 16:48:33 -0800 Reply-To: prakash.sangappa@oracle.com Subject: Re: [RESEND RFC PATCH 1/1] Selectively allow CAP_SYS_NICE capability inside user namespaces References: <1574096478-11520-1-git-send-email-prakash.sangappa@oracle.com> <1574096478-11520-2-git-send-email-prakash.sangappa@oracle.com> To: Jann Horn Cc: kernel list , Linux API , "Eric W. Biederman" , Thomas Gleixner , Peter Zijlstra , "Serge E. Hallyn" , Christian Brauner From: "prakash.sangappa" Message-ID: <9b2dd6f5-5b0b-9c9b-e853-5795c352e092@oracle.com> Date: Mon, 18 Nov 2019 16:46:08 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9445 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911190004 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9445 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911190003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/18/2019 11:30 AM, Jann Horn wrote: > On Mon, Nov 18, 2019 at 6:04 PM Prakash Sangappa > wrote: >> Allow CAP_SYS_NICE to take effect for processes having effective uid of a >> root user from init namespace. > [...] >> @@ -4548,6 +4548,8 @@ int can_nice(const struct task_struct *p, const int nice) >> int nice_rlim = nice_to_rlimit(nice); >> >> return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) || >> + (ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE) && >> + uid_eq(current_euid(), GLOBAL_ROOT_UID)) || >> capable(CAP_SYS_NICE)); > I very strongly dislike tying such a feature to GLOBAL_ROOT_UID. > Wouldn't it be better to control this through procfs, similar to > uid_map and gid_map? If you really need an escape hatch to become > privileged outside a user namespace, then I'd much prefer a file > "cap_map" that lets someone with appropriate capabilities in the outer > namespace write a bitmask of capabilities that should have effect > outside the container, or something like that. And limit that to bits > where that's sane, like CAP_SYS_NICE. Sounds reasonable. Adding a 'cap_map' file to user namespace, would give more control. We could allow the capability in 'cap_map' to take effect only if corresponding capability is enabled for the user inside the user namespace Ex uid 0. Start with support for CAP_SYS_NICE? > > If we tie features like this to GLOBAL_ROOT_UID, more people are going > to run their containers with GLOBAL_ROOT_UID. Which is a terrible, > terrible idea. GLOBAL_ROOT_UID gives you privilege over all sorts of > files that you shouldn't be able to access, and only things like mount > namespaces and possibly LSMs prevent you from exercising that > privilege. GLOBAL_ROOT_UID should only ever be given to processes that > you trust completely. Agreed.