Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4031265ybg; Sun, 7 Jun 2020 19:12:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6iYn8cw0avOOw+5sJntpRnnlVAR9oE1mLm5sS1ZWD31vobgGfAkgKPOvRpBSIMFVSxo5D X-Received: by 2002:a17:906:6b8e:: with SMTP id l14mr19515072ejr.32.1591582326940; Sun, 07 Jun 2020 19:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591582326; cv=none; d=google.com; s=arc-20160816; b=IaiYfvIb8GONid2y9vryTwt67bD68/AlNdyXlxw3o3IHs/BPJVHXkalklynMGpwdoG pW5P5mpjnoLRhXKjo1IEbYbFnixXbOL4dI4L3zEWgb6pa1gbhtatqfOZrJjvGCpiAbTU 89oXCkoXoWU5GmbgtOuv7TUnHByRsa6DJjbLnEHIz1yF53Ifs1dcLLQukpaLu3ENLEVT mbDW8jsujTts9BmL+NQ48ht0PBH0CgTYoaxNIK7zxcMXeNsEOXsQWzV6XhzFm2kWY0Jj CECW3I/Bnf7qfMizbfSd8vDpmZURAOmSVMggeYEJxSgGqQThv7U9lC6Nt89YOwuOJ7+i G/uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eGfIVEEObayEQ8qL7hEZY++qwOcPSMpFns1BIw6npEs=; b=WrcY8H3zPZZDlxQ7UaBBG+LUV1+iMi3I8Ya+SUK+mwNy1W8mZbzba95WqDkDXihyxq 1k6Konmm94cNc9U3ecodBzYHugY47H42oygqjzZ6xeiFudIprGkEQxrSQ9DVv7HUn/5o 7lV2W83tSp+Cs4EEnHV13yX3ovpC5hzJ/BXMayxBTGTb2Xv/tl+Ht8r+vXyJK76wwlIe JhzCv+NhXp8AbeeFxb4G4bG0TcNNrxFDM76bWFLN3ZPtUDBup2NJjyEdsbhG3W2bIdSR VOovRrpLYTzfVsgaAJChaBlda3Rue3j8+vj3msObrRrVQvSUvP0afJZ3Cr4T9VCMZgfQ uflw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ma1LGDHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si7694829eji.495.2020.06.07.19.11.43; Sun, 07 Jun 2020 19:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ma1LGDHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728501AbgFHCKC (ORCPT + 99 others); Sun, 7 Jun 2020 22:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726662AbgFHCKB (ORCPT ); Sun, 7 Jun 2020 22:10:01 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9D65C08C5C3; Sun, 7 Jun 2020 19:09:59 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id n6so3060072otl.0; Sun, 07 Jun 2020 19:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eGfIVEEObayEQ8qL7hEZY++qwOcPSMpFns1BIw6npEs=; b=ma1LGDHvnbGHopULdudmm4/ulC9DKtWolC+sKArlDnN16fc4VyrdbAIE7u4hGQLt6A t+uEiBgoztuGeomxb5p7mVQW525mMGI2G86zSDdS10J0g1VHWmluvE+q04wGbo5EbaPN LQlpF3iuyCj7DBYVzGGYWuthrKT0jozXf2cFpTDykuT+mgvpgLBROlPOfY2o2hhxhbwT jhEKYKZ8uGnZDnQkiuKkXeXTvMlTafUjG7D+1Y0+Obkb1Xisil4aqxyMpHICYyFB3uhc ChNFAwnbziN+0ni4qPWG2o2+e13L06/pE689t0XsIwIPq3lSDEI5+Zw8/QYlWw26PEC6 J8pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eGfIVEEObayEQ8qL7hEZY++qwOcPSMpFns1BIw6npEs=; b=b0ApwUxGyok8IsDszx/Y+Z1Pjom579EfdC+xXdkobJlo1GzKpL+aEr1Fk43AJStImK dhtTwySB9YhSMuvEbjL2DJtvxXTpd1eYnR7TmMkgYHx2Et5qF+DSAaTgps8cuj3+ijFq HN0DRmsrXUtnaD0hlOZuhZz8gfuxaHC6sse2khBIEs/haxZpAO3AQW6wLs+MEXHFj58Z GNEnZfwySQ2VQEo5OcyExCNmk08bkklKouO4da+cb4xWJgNIXBFioy0ArRTl8mh5Fc2+ 7/B/RO18JxkRcp52xwi16FmATn0ddJA5WrPtPfvX7V4G83Jfdl7WF6PKgaqvRDnfev5Z Zs7g== X-Gm-Message-State: AOAM53146BOB9m4tKnh3Kh9yVkWc1xYmuSZgAPJOSj6dlfWfRYaAfFWe UC+U+cNAQ2p1nfHOcPMCuXBL1wubhdIkkIEzuqA= X-Received: by 2002:a9d:554d:: with SMTP id h13mr4530942oti.201.1591582198714; Sun, 07 Jun 2020 19:09:58 -0700 (PDT) MIME-Version: 1.0 References: <20200522055350.806609-1-areber@redhat.com> <20200525080541.GF104922@dcbz.redhat.com> <877dwybxvi.fsf@x220.int.ebiederm.org> <20200527141403.GC250149@dcbz.redhat.com> <20200527152955.jbbipgb6icb4nwgv@wittgenstein> <20200528094839.gw7aqd3xs3kix273@wittgenstein> In-Reply-To: <20200528094839.gw7aqd3xs3kix273@wittgenstein> From: Andrei Vagin Date: Sun, 7 Jun 2020 19:09:47 -0700 Message-ID: Subject: Re: [PATCH] capabilities: Introduce CAP_RESTORE To: Christian Brauner Cc: Nicolas Viennot , Adrian Reber , "Eric W. Biederman" , Casey Schaufler , Pavel Emelyanov , Oleg Nesterov , Dmitry Safonov <0x7f454c46@gmail.com>, =?UTF-8?B?TWljaGHFgiBDxYJhcGnFhHNraQ==?= , Kamil Yurtsever , Dirk Petersen , Christine Flood , Mike Rapoport , Radostin Stoyanov , Cyrill Gorcunov , Serge Hallyn , Stephen Smalley , Sargun Dhillon , Arnd Bergmann , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "selinux@vger.kernel.org" , Eric Paris , Jann Horn Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > I would argue that setting the current process exe file check should just be reduced to a "can you ptrace a children" check. > > Here's why: any process can masquerade into another executable with ptrace. > > One can fork a child, ptrace it, have the child execve("target_exe"), then replace its memory content with an arbitrary program. > > Then it should probably be relaxed to CAP_SYS_PTRACE in the user > namespace and not CAP_CHECKPOINT_RESTORE. (But apparently you also have > a way of achieving what you want anyway. Imho, it's not necessarily > wrong to require a bit more work when you want something like fully > unprivileged c/r that's a rather special interest group.) > > > With CRIU's libcompel parasite mechanism (https://criu.org/Compel) this is fairly easy to implement. > > In fact, we could modify CRIU to do just that (but with a fair amount of efforts due to the way CRIU is written), > > and not rely on being able to SET_MM_EXE_FILE via prctl(). In turn, that would give an easy way to masquerade any process > > into another one, provided that one can ptrace a child. > > I think you misunderstand this. In the case of malicious processes, when only one or two processes must be hidden, they can use this trick with execve+ptrace and this is relatively simple. But in the case of CRIU, where we need to restore a process tree with cow memory mappings, shared mappings, file descriptors and etc, this trick with execve+ptrace doesn't work at all. We are in a weird situation when malicious processes can do some operations, but useful tools like CRIU needed to be running with extra capabilities that actually reduces the security of the entire system.