From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 20 08:42:38 2023 Received: (at 60890) by debbugs.gnu.org; 20 Jan 2023 13:42:38 +0000 Received: from localhost ([127.0.0.1]:45885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIrf9-0000Gc-Dc for submit@debbugs.gnu.org; Fri, 20 Jan 2023 08:42:38 -0500 Received: from mail-qt1-f181.google.com ([209.85.160.181]:35597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIrf7-0000GO-As for 60890@debbugs.gnu.org; Fri, 20 Jan 2023 08:42:33 -0500 Received: by mail-qt1-f181.google.com with SMTP id g16so2060850qtu.2 for <60890@debbugs.gnu.org>; Fri, 20 Jan 2023 05:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=zYSU3vVpYJ2rm/IcbwswrKHHyzWjoJqvnksPPg1P0Uc=; b=pEGYz1WkMMzb/7k1YSdDdPWLy2qXXuzzxdBSJc8ImUnN+Mzkoyw9VzETUyd3DxhOjk WWsrcmtuybnmGRw7G2ilTBBPkxMno1fUrep64wV4ap8Fs87vZLGhzdYqOowgtw5ZwMXW Hj5RMJhmim55wbDjTciGHwpyJdKCFpLORL7V00LU6tHgSrr5ioqqO0KU6z4N/Bz6Mj3J 7OzbNqpMKjo2vs+JYDWVY1Qh+jJedVBjMkb3CpWBvzz/W2AhIsreOIXZmyle1CrrWuFB a28kGNqqsMrfXRw7n0v/7ykjrVq1E/CvyzPm7LyFoDWn2gNF9vPIVMaSgJSOnE6ZZpUL 5pBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zYSU3vVpYJ2rm/IcbwswrKHHyzWjoJqvnksPPg1P0Uc=; b=wcuouglEH7OOsGi1+npHNGcooue6F5bvuLW4sPPdNMu04xv0TUZjOY9cc+/M+cvhRc 8LH1/wn9biFJBLKvKUaAer6rGjgNwQBUctwtf1gtXxjYjByN+ckkD8FbLzI0rxNoMgDj V2uxW4AwXGWpISr82qr9YP+C5IB3uHjU8IuhPegnhA5X8vP3HsbeKYA/m/hv5C5ZUbPz BB9OnDeKjRo7KfUX3i8mLVbqVLX6bTKL7yCDB3sxk8qAw5gbZtuogl7YojXfsQWXPtBQ WCIKhP8s+28UjuTMShAm2ejz5qWk7eB9bDOCT0jKXJ6JY4sOtkjf4CCmTrdbcI2+tziE TzDw== X-Gm-Message-State: AFqh2krXEv2Ka4iGhHFITKz6TllaXb/Y7FgYbWRnjp+odjgrk8FjVkZR cEgg0/eIge548ysX3b4Krc8/cEgVJGuSyA== X-Google-Smtp-Source: AMrXdXvxGI8Zi+Joxcjt0SkRvIgkl0FzYFm9EacznT8UV/M2Vw/6390rnwmvAaof9KyuOipZOzIRZA== X-Received: by 2002:ac8:4519:0:b0:3b6:2c10:a3e1 with SMTP id q25-20020ac84519000000b003b62c10a3e1mr20369845qtn.57.1674222147541; Fri, 20 Jan 2023 05:42:27 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id z24-20020ac875d8000000b003b68c7aeebfsm2778744qtq.3.2023.01.20.05.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 05:42:26 -0800 (PST) From: Maxim Cournoyer To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#60890: least-authority-wrapper and make-forkexec-constructor composition problem References: <87zgahyn5w.fsf@gmail.com> <87pmba8nhp.fsf@gnu.org> Date: Fri, 20 Jan 2023 08:42:25 -0500 In-Reply-To: <87pmba8nhp.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Thu, 19 Jan 2023 18:04:18 +0100") Message-ID: <87lelxcofy.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60890 Cc: 60890@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Hello! > > Maxim Cournoyer skribis: > >> It was found that using something like: >> >> (make-forkexec-constructor >> (least-authority >> (list (file-append coreutils "/bin/true")) >> (mappings (delq 'user %namespaces)) >> #:user "nobody" >> #:group "nobody")) >> >> Would fail with EPERM, because in order to be able to drop the user >> namespace, the CAP_SYS_ADMIN capability is required, but in the above >> case, make-forkexec-constructor has already changed the user to >> "nobody", which lacks such capability. > > Thanks for the reminder! > > I guess the problem is limited to cases where you need the program to > run in the global user namespace. Yes, it's limited to that case, because when clone(2) is called without CLONE_NEWUSER, the child process does *not* start with a complete set of capabilities (CAP_SYS_ADMIN), quoting my original investigation from [0]: > The problem then seems to be that since we need CAP_SYS_ADMIN when > dropping the user namespace, as CLONE_NEWUSER is what gives us > superpowers. Per 'man user_namespaces': > The child process created by clone(2) with the CLONE_NEWUSER flag starts > out with a complete set of capabilities in the new user namespace. [0] https://issues.guix.gnu.org/54786#16 --=20 Thanks, Maxim