Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4548055imw; Tue, 12 Jul 2022 09:48:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uN5BkxNsKrPZ6VzfqP++TeVf5HqIChX7N1ZzU3v4RvPAaL8Yx/guGVVByccvxioRsy5IEn X-Received: by 2002:a63:ff66:0:b0:412:6f4c:1e11 with SMTP id s38-20020a63ff66000000b004126f4c1e11mr21466196pgk.396.1657644524946; Tue, 12 Jul 2022 09:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657644524; cv=none; d=google.com; s=arc-20160816; b=pprrSKqTEu2YWomQlbhCZjwLnCTAFPvdygUkhPpTvXGQUIZ6zVUe0DGdVUNTmbo5Kn 57iis3pt5ar8etKxhSQCNy4NOsFQfBAZT4O9bpldrY/fqaVb0qxf9fJSeRnVciXrE62P KSHCijwPtOwKieEebVhkCWjeVWhoDBGp7csuswz7Eo6SmhSjDacScuF0moFYrMnZnG4r Jpo9Dwsjri1MxWd8gp0SHeuRa37gB0WlLO0BKLpKd+KSzEL64crKU6WeMo7gFN3PeyMQ Aim83eTM8fns3+Lfw/jM2OWu6dGQB6JXVKKMI9vGGgO5ITnSz+qSmMzmGmA9jeIRjWtt IU5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G3Svshh0CSIKBecEYyWOPWehxtR8pBn+wN2kw/qyhZM=; b=t32y62YfOZzue6Fpw6iWr6aB62o63ZjorhQKnwIJORULrnEwR/x4f0royLW1PvzY0R zsLHGiB+9YYIBNjHYSvRLWZ9523wF5Mz7zdreJT+oq164NEFZ+QHE+lgfUGQ53e6VwjY l4LBIfmwhqJ9gITo2cSBCMaxfZix+/4gscU1ft5LimTnfcrrfotX2e+m2ppQID+1rNwD EsS4WFC/VrfFIRNilX0baUsg89jwbrbqBOH2UhVy4raL6UszcMrpS7DsfR5jn72sCGI0 EfkkPrWp7M4ytKFpe0YYZ8aDS5+6/L1AVJ/awpfi6Ami6NeNPquSTQK+GrTBss3cQQ98 eWIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d1vTbBHj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902d41100b0016c049be6c9si12062576ple.79.2022.07.12.09.48.22; Tue, 12 Jul 2022 09:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d1vTbBHj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbiGLQrM (ORCPT + 99 others); Tue, 12 Jul 2022 12:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiGLQrL (ORCPT ); Tue, 12 Jul 2022 12:47:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DA921177 for ; Tue, 12 Jul 2022 09:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657644430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G3Svshh0CSIKBecEYyWOPWehxtR8pBn+wN2kw/qyhZM=; b=d1vTbBHjF1TBWrfhuc3AiGykP7kTQagpZ7nhUZVsnZEAtz0qNGkm841kdcfdgHb0/Ae+xI 29vXmta9ENf+EiItY+IQX6/z9ug/GPtaDQUNaCfOHFZgbSgJeukJCkOcCjDMTuuFRzyUcx 9EWwkIUZxyZ66xMsJCM8w+I35TPZpLg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-6coTC7AOMUyVvxJ9Rq57pA-1; Tue, 12 Jul 2022 12:47:08 -0400 X-MC-Unique: 6coTC7AOMUyVvxJ9Rq57pA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC23C1C04B4C; Tue, 12 Jul 2022 16:47:07 +0000 (UTC) Received: from [172.16.176.1] (unknown [10.22.48.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99E0E40CF8E4; Tue, 12 Jul 2022 16:47:06 +0000 (UTC) From: "Benjamin Coddington" To: "Eric W. Biederman" Cc: "David Howells" , linux-kernel@vger.kernel.org, "Ian Kent" , "Trond Myklebust" , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Linux Containers" Subject: Re: [RFC PATCH 0/2] Keyagents: another call_usermodehelper approach for namespaces Date: Tue, 12 Jul 2022 12:47:05 -0400 Message-ID: <148B818D-0F61-42F6-A0EA-20D060E42560@redhat.com> In-Reply-To: <875yk25scg.fsf@email.froward.int.ebiederm.org> References: <875yk25scg.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 12 Jul 2022, at 10:16, Eric W. Biederman wrote: > Adding the containers list to the discussion so more interested people > have a chance of seeing this. > > Benjamin Coddington writes: > >> A persistent unsolved problem exists: how can the kernel find and/or = >> create >> the appropriate "container" within which to execute a userspace = >> program to >> construct keys or satisfy users of call_usermodehelper()? >> >> I believe the latest serious attempt to solve this problem was = >> David's "Make >> containers kernel objects": >> https://lore.kernel.org/lkml/149547014649.10599.12025037906646164347.s= tgit@warthog.procyon.org.uk/ >> >> Over in NFS' space, we've most recently pondered this issue while = >> looking at >> ways to pass a kernel socket to userspace in order to handle TLS = >> events: >> https://lore.kernel.org/linux-nfs/E2BF9CFF-9361-400B-BDEE-CF5E0AFDCA63= @redhat.com/ >> >> The problem is that containers are not kernel objects, rather a = >> collection >> of namespaces, cgroups, etc. Attempts at making the kernel aware of >> containers have been mired in discussion and problems. It has been >> suggested that the best representation of a "container" from the = >> kernel's >> perspective is a process. >> >> Keyagents are processes represented by a key. If a keyagent's key is = >> linked >> to a session_keyring, it can be sent a realtime signal when a calling >> process requests a matching key_type. That signal will dispatch the = >> process >> to construct the desired key within the keyagent process context. = >> Keyagents >> are similar to ssh-agents. To use a keyagent, one must execute a = >> keyagent >> process in the desired context, and then link the keyagent's key onto = >> other >> process' session_keyrings. >> >> This method of linking keyagent keys to session_keyrings can be used = >> to >> construct the various mappings of callers to keyagents that = >> containers may >> need. A single keyagent process can answer request-key upcalls = >> across >> container boundaries, or upcalls can be restricted to specific = >> containers. >> >> I'm aware that building on realtime signals may not be a popular = >> choice, but >> using realtime signals makes this work simple and ensures delivery. = >> Realtime >> signals are able to convey everything needed to construct keys in = >> userspace: >> the under-construction key's serial number. >> >> This work is not complete; it has security implications, it needs >> documentation, it has not been reviewed by anyone. Thanks for = >> reading this >> RFC. I wish to collect criticism and validate this approach. > > At a high level I do agree that we need to send a message to a = > userspace > process and that message should contain enough information to start = > the > user mode helper. > > Then a daemon or possibly the container init can receive the message > and dispatch the user mode helper. > > Fundamentally that design solves all of the container issues, and I > think solves a few of the user mode helper issues as well. > > The challenge with this design is that it requires someone standing up = > a > daemon to receive the messages and call a user mode helper to retain > compatibility with current systems. Yes.. > I would prefer to see a file descriptor rather than a signal used to > deliver the message. Signals suck for many many reasons and a file > descriptor based notification potentially can be much simpler. In the example keyagent on userspace side, signal handling is done with signalfd(2), which greatly simplifies things. > One of those many reasons is that by not following the common pattern > for filling in kernel_siginfo you have left uninitialized padding in > your structure that will be copied to userspace thus creating a kernel > information leak. Similarly your code doesn't fill in about half the > fields that are present in the siginfo union for the _rt case. Yes, I just used the stack and only filled in the bare minimum. > I think a file descriptor based design could additionally address the > back and forth your design needs with keys to figure out what event = > has > happened and what user mode helper to invoke. The keys have already built out a fairly rich interface for accepting authorization keys, and instantiating partially-constructed keys. I = think the only communication needed (currently) is to dispatch and pass the = key serial value. If we used file descriptors instead of rt signals, there'd be some = protocol engineering to do. > Ideally I would also like to see a design less tied to keys. So that = > we > could use this for the other user mode helper cases as well. That = > said > solving request_key appears to be the truly important part, there = > aren't > many other user mode helpers. Still it would be nice if in theory the > design could be used to dispatch the coredump helper as well. What if there was a key_type "usermode_helper"? Requesting a key of = that type executes the binary specified in the callout info. A keyagent = could satisfy the creation of this key, which would allow the usermode_helper process to execute in the context of a container. If no keyagent, fall = back to the legacy call_usermode_helper. Thanks for the look, Ben