Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753403AbcLHFQ7 convert rfc822-to-8bit (ORCPT ); Thu, 8 Dec 2016 00:16:59 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:51256 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbcLHFQ6 (ORCPT ); Thu, 8 Dec 2016 00:16:58 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: "Serge E. Hallyn" Cc: Seth Forshee , lkml , linux-api@vger.kernel.org References: <20161119151739.GA16398@mail.hallyn.com> <87inqvav4y.fsf@xmission.com> <20161208045640.GA433@mail.hallyn.com> Date: Thu, 08 Dec 2016 18:13:54 +1300 In-Reply-To: <20161208045640.GA433@mail.hallyn.com> (Serge E. Hallyn's message of "Wed, 7 Dec 2016 22:56:40 -0600") Message-ID: <87fulz3svh.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1cEr4c-00007R-7e;;;mid=<87fulz3svh.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=101.100.131.98;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19KUBKREpYXuykXK4vR8yaVNsbVDqFfjpY= X-SA-Exim-Connect-IP: 101.100.131.98 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4994] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XM_H_SpoofStaff3 XMission Staff Spoof X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Serge E. Hallyn" X-Spam-Relay-Country: X-Spam-Timing: total 5542 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.5 (0.1%), b_tie_ro: 2.4 (0.0%), parse: 1.05 (0.0%), extract_message_metadata: 13 (0.2%), get_uri_detail_list: 2.1 (0.0%), tests_pri_-1000: 4.5 (0.1%), tests_pri_-950: 1.15 (0.0%), tests_pri_-900: 0.95 (0.0%), tests_pri_-400: 23 (0.4%), check_bayes: 22 (0.4%), b_tokenize: 7 (0.1%), b_tok_get_all: 7 (0.1%), b_comp_prob: 2.4 (0.0%), b_tok_touch_all: 2.8 (0.1%), b_finish: 0.67 (0.0%), tests_pri_0: 177 (3.2%), check_dkim_signature: 0.65 (0.0%), check_dkim_adsp: 3.3 (0.1%), tests_pri_500: 5315 (95.9%), poll_dns_idle: 5308 (95.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH RFC] user-namespaced file capabilities - now with even more magic X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2665 Lines: 59 "Serge E. Hallyn" writes: > On Thu, Dec 08, 2016 at 05:43:09PM +1300, Eric W. Biederman wrote: >> "Serge E. Hallyn" writes: >> >> > Root in a user ns cannot be trusted to write a traditional >> > security.capability xattr. If it were allowed to do so, then any >> > unprivileged user on the host could map his own uid to root in a >> > namespace, write the xattr, and execute the file with privilege on the >> > host. >> > >> > This patch introduces v3 of the security.capability xattr. It builds a >> > vfs_ns_cap_data struct by appending a uid_t rootid to struct >> > vfs_cap_data. This is the absolute uid_t (i.e. the uid_t in >> > init_user_ns) of the root id (uid 0 in a namespace) in whose namespaces >> > the file capabilities may take effect. >> > >> > When a task in a user ns (which is privileged with CAP_SETFCAP toward >> > that user_ns) asks to write v2 security.capability, the kernel will >> > transparently rewrite the xattr as a v3 with the appropriate rootid. >> > Subsequently, any task executing the file which has the noted kuid as >> > its root uid, or which is in a descendent user_ns of such a user_ns, >> > will run the file with capabilities. >> > >> > If a task writes a v3 security.capability, then it can provide a >> > uid (valid within its own user namespace, over which it has CAP_SETFCAP) >> > for the xattr. The kernel will translate that to the absolute uid, and >> > write that to disk. After this, a task in the writer's namespace will >> > not be able to use those capabilities, but a task in a namespace where >> > the given uid is root will. >> > >> > Only a single security.capability xattr may be written. A task may >> > overwrite the existing one so long as it was written by a user mapped >> > into his own user_ns over which he has CAP_SETFCAP. >> > >> > This allows a simple setxattr to work, allows tar/untar to work, and >> > allows us to tar in one namespace and untar in another while preserving >> > the capability, without risking leaking privilege into a parent >> > namespace. >> >> Any chance of a singed-off-by? > > Yes, sorry, Stéphane had pointed out that I'd apparently forgotten to do > -s. Do you want me to resend the whole shebang, or does > > Signed-off-by: Serge Hallyn > > suffice? (My previous iterations did have it fwiw so I don't think I could > legally disavow it now :) That should be good enough. I just wanted to make certain it existed somewhere. The whole inode->i_op->getxattr reference was also a bit of a problem as that method was removed in 4.9-rc1 but otherwise things are looking reasonable. Thank you, Eric