Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp99017imm; Thu, 10 May 2018 16:18:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqMbWeMPZoIZ7UsiWKIhe/1Oqtvq+LO46rehrcwVQeJkcMfmh47BBXV4do9rKj/LtRqrlbw X-Received: by 2002:a62:1e02:: with SMTP id e2-v6mr3131703pfe.212.1525994283755; Thu, 10 May 2018 16:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525994283; cv=none; d=google.com; s=arc-20160816; b=QiLkqmOQNN8Xqdb/Q5FJNHTL+tiF+ZSiVVsHdZ8Bo1lJWx1bPUP+tcDDNk4+srxNLE ZkD3yvljJtVelJN3lSR8lFyxd+ltBYXyTaGmMC3PrBceX4+rvk9JzR+XOYUwRYaaeid6 4xfnYp2ZCMaLYScBthaMXSJPnZzvHmoEvVhznkwigsUye1DonSZZ/ZHfIRqut7+cG5K+ ATJXzjtyYliKju2159NNP6RR9plGV1qZToxIZcwyrxTs9pSqCg98zSFcqxdRLCg8NVHS y3GJeNF3vQ8CXZz2It6IIvc/sXAWInP8i+QDEQeFMoOnRurPdGCt0ITIpRfppuAMI1mu 7hAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=NYLvZOxe1bifCYuEVMEwnQr6DmFmCqLihKVTkPDzUHg=; b=A8L6CZTlj92QAJbzKrd1tskSngnMZBUQKggyRgEVs5kwcVp7/2poCGVFC9Es2YYeQc ci0VpncEGufID6SpAosFjqf7uK7B9Jijla+hoMxN8bBzFmgK/F1eEToVwMaJB7QM47VM iTBZHxMTEzuRKyVvGuk8NcK9RmJY2r6o54IkIG8+PDdHOYFXXSc+4E0LK2n+nPhTLNSt mu6MmvCAp9kOTP99J4sUrO3BuHWFfn7Y3vxDVx1i2gFWTalbW3TQDiH86lW0tUmdvYKD fsk8iwPSaltAwmDkTcJEWsyHBZEB12xDGaSx0x4Q833I46QxuK4upPKh88Tl3mGVQoj/ pFVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WRPqSxL0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si1529494pgc.64.2018.05.10.16.17.49; Thu, 10 May 2018 16:18:03 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=WRPqSxL0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbeEJXQf (ORCPT + 99 others); Thu, 10 May 2018 19:16:35 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37782 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbeEJXQc (ORCPT ); Thu, 10 May 2018 19:16:32 -0400 Received: by mail-pf0-f195.google.com with SMTP id e9-v6so1784876pfi.4; Thu, 10 May 2018 16:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NYLvZOxe1bifCYuEVMEwnQr6DmFmCqLihKVTkPDzUHg=; b=WRPqSxL0EieZKrc3EMFp5MXAppfs4Zti7VtUWsUmCjEFGHoRE1KyLyKQZJNkaInee1 Pl2WdNpH74MJZKoa4CdYq9m4KmYwoSS8I5g7oU/KUp+t4A2HZWTALYX5e7z9EAJNnIhx /hrNlMIe0UUxRtoXTVSdARnRWDWaLO1UL7MlKB8nC7KRhRuC1QNHXC5Icf+7RSCabltR r+zl3ARBzCBOgWk/j4ZzjDA6T6eZ3YDaVIg9b05DgBcywqyT3To15++M5fzudP3dK5Tr 2D0cuaRYMjnjz6g5ITBqyqjffGY2WQfo9/p5AwNBdb1im6iDNQSIX0oe39o52O3vafSb nC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NYLvZOxe1bifCYuEVMEwnQr6DmFmCqLihKVTkPDzUHg=; b=BgIFCby3ksegn3t65aJ0oHYQyhrjrt3Bh2gDlTAKHAq8MEgODCoAnEG4NfRODVjmHB Wr+xxQYmC/jJje7qmVx/gO4bhbpjOvu3Z0lwUwB24zUqgEKrT56owPTSYB4gsMfw/Rs+ P47shecVBkkVwehHeBo+mWr2UdfacuiFhdBm3zHTRPmq6tVt2GS8Vx04Wgkaplnemzfo Hg1AGaF4PoM38lNXJVbH3fXjQlL2gFDi7bf6k2dDYbfd4Jdgw5CDOz3WuOiQ2KDaKDSU l1aKvmq3rHEtLi2Wds8VBjBSHQ11iDFHi2NKaqoBL5YrZ03HZXa78Gi0ERvLJr5jHKh3 6/Bg== X-Gm-Message-State: ALKqPwfczfY9sJBWXtKKZqSPK513eqnEJyBIqt2Qw1ngnnf8GKRiYN4Y 3CxvaX8yoVxw1R/M0Jr+580= X-Received: by 2002:a62:fe0e:: with SMTP id z14-v6mr3115145pfh.73.1525994191388; Thu, 10 May 2018 16:16:31 -0700 (PDT) Received: from ast-mbp ([2620:10d:c090:180::1:d829]) by smtp.gmail.com with ESMTPSA id y7-v6sm4229058pfy.52.2018.05.10.16.16.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 May 2018 16:16:30 -0700 (PDT) Date: Thu, 10 May 2018 16:16:27 -0700 From: Alexei Starovoitov To: Kees Cook Cc: "Luis R. Rodriguez" , Alexei Starovoitov , "David S. Miller" , Daniel Borkmann , Linus Torvalds , Greg KH , Andy Lutomirski , Network Development , LKML , kernel-team , Al Viro , David Howells , Mimi Zohar , Andrew Morton , Dominik Brodowski , Hugh Dickins , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , "Rafael J. Wysocki" , Linux FS Devel , Peter Jones , Matthew Garrett , linux-security-module , linux-integrity , Jessica Yu Subject: Re: [PATCH v2 net-next 1/4] umh: introduce fork_usermode_blob() helper Message-ID: <20180510231625.ypn7ymq5roibucwd@ast-mbp> References: <20180503043604.1604587-1-ast@kernel.org> <20180503043604.1604587-2-ast@kernel.org> <20180504195642.GB12838@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 10, 2018 at 03:27:24PM -0700, Kees Cook wrote: > On Fri, May 4, 2018 at 12:56 PM, Luis R. Rodriguez wrote: > > What a mighty short list of reviewers. Adding some more. My review below. > > I'd appreciate a Cc on future versions of these patches. > > Me too, please. And likely linux-security-module@ and Jessica too. > > > On Wed, May 02, 2018 at 09:36:01PM -0700, Alexei Starovoitov wrote: > >> Introduce helper: > >> int fork_usermode_blob(void *data, size_t len, struct umh_info *info); > >> struct umh_info { > >> struct file *pipe_to_umh; > >> struct file *pipe_from_umh; > >> pid_t pid; > >> }; > >> > >> that GPLed kernel modules (signed or unsigned) can use it to execute part > >> of its own data as swappable user mode process. > >> > >> The kernel will do: > >> - mount "tmpfs" > >> - allocate a unique file in tmpfs > >> - populate that file with [data, data + len] bytes > >> - user-mode-helper code will do_execve that file and, before the process > >> starts, the kernel will create two unix pipes for bidirectional > >> communication between kernel module and umh > >> - close tmpfs file, effectively deleting it > >> - the fork_usermode_blob will return zero on success and populate > >> 'struct umh_info' with two unix pipes and the pid of the user process > > I'm trying to think how LSMs can successfully reason about the > resulting exec(). In the past, we've replaced "blob" style interfaces > with file-based interfaces (e.g. init_module() -> finit_module(), > kexec_load() -> kexec_file_load()) to better let the kernel understand > the origin of executable content. Here the intent is fine: we're > getting the exec from an already-loaded module, etc, etc. I'm trying > to think specifically about the interface. > > How can the ultimate exec get tied back to the kernel module in a way > that the LSM can query? Right now the hooks hit during exec are: > kernel_read_file() and kernel_post_read_file() of tmpfs file, > bprm_set_creds(), bprm_check(), bprm_commiting_creds(), > bprm_commited_creds(). It seems silly to me for an LSM to perform > these checks at all since I would expect the _meaningful_ check to be > finit_module() of the module itself. Having a way for an LSM to know > the exec is tied to a kernel module would let them skip the nonsense > checks. > > Since the process for doing the usermode_blob is defined by the kernel > module build/link/objcopy process, could we tighten the > fork_usermode_blob() interface to point to the kernel module itself, > rather than leaving it an open-ended "blob" interface? Given our > history of needing to replace blob interfaces with file interfaces, > I'm cautious to add a new blob interface. Maybe just pull all the > blob-finding/loading into the interface, and just make it something > like fork_usermode_kmod(struct module *mod, struct umh_info *info) ? I don't think it will work, since Andy and others pointed out that bpfilter needs to work as builtin as well. There is no 'struct module' in such case, but fork-ing of the user process still needs to happen.