Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6483023rwb; Mon, 14 Nov 2022 22:01:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7GkV/q5L3S08S9lmAIlBLyiqzE2puzRca8lJc/kWJ4kGduhRhv2OpvWAGWfG0b2fsGw/p9 X-Received: by 2002:a17:902:b104:b0:188:53bd:877a with SMTP id q4-20020a170902b10400b0018853bd877amr2590180plr.84.1668492077236; Mon, 14 Nov 2022 22:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668492077; cv=none; d=google.com; s=arc-20160816; b=eHfn3Y77n/IX8t4EPeHPOCOZOSeD9RdXrQ6bqbEU+0TMF4P/DBCQqvl6k+49CfEuru AK4ZQUZeSTxfPFCEtFmk+h4hq+F3eiIBPCfJo/jCZaK/pXSYHsGnbGU8aKFGqEq2gXma 0n8t63f9M1QJMFTRVwKMoUq22IqkvjveQdn6hrbx1ezBiu9SC1sM4teID2IH1jmeQ62C tEqKa8+PRURE0Es27NdtTo/4UU9Wrt0eNNnb2hYYuu7HFU9Nxg1DQEXyk3Co3o5MhamQ Gv00q4TGLrsGIlTDzKdUNI6c7N8NA4UX3F3jGpAAArAlCiWVIDqtxvSyZioMTCbsexXj dQjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9K3V25osQLREMG6ZUk7AC0ZkFnZLHBbL3WZnP0tsfH4=; b=o6WPnJyioHz0H62g3LF21bJLI6Qe6y7MbwML5iS4PGy+xavVoSAfyvKr1+RNQUgplh lNfN6qQbhGvFxRyPBkGc+KTcULL/m7rzWLbM42a0b+mCASSSQtwtwMTM8oMQakcTDqct J2UFL5R+dD0vN1Gpi6QHZA/s/mkaD5ckyr0jxn/SS28VbPwJgDbhQh7P8BGkR2Dhr53v AB18efPFlzC0vQK1GRArPcrmafn+6wFvdPbPHGK0yXC2D+DqLfsI9rY0aWRxoFSlocel gSh/FDwmZwgDvRzC7x0TFqrPyTD7k7tY7VgKqWqMwjDldcQvD15krnJeY9fH8Uiy82fA NbeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lP1c+Qct; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902e54700b00188c5696683si4864135plf.188.2022.11.14.22.01.05; Mon, 14 Nov 2022 22:01:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20210112 header.b=lP1c+Qct; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231807AbiKOFjn (ORCPT + 89 others); Tue, 15 Nov 2022 00:39:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiKOFjm (ORCPT ); Tue, 15 Nov 2022 00:39:42 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27351AF2A for ; Mon, 14 Nov 2022 21:39:40 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id f18so451000ejz.5 for ; Mon, 14 Nov 2022 21:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9K3V25osQLREMG6ZUk7AC0ZkFnZLHBbL3WZnP0tsfH4=; b=lP1c+QctBSuAkoA0Voq5SO1rZHAodr96QmUnxvNWlD5+dWN0+a+G2GJSKPjIWX/FP2 yEf+NE2GSx/2I5MZekALkcGZ8fWAnnGpaxXL47vF1dPwqA/e4AVM2x9VT96NMomw6PIM NFiXrtCZPAgVWLg3AbpT7mEzwkJKD1dRuwghDCmDown3PemV71JAfKEJAK18qY+R1drY yTGHzc6xOjYGTZJL1+eK79Pf9py2dwz8vvc49geY7D98Q+v/bHXRmmcO7rWyP1SxOSp3 wLBijaAXnhZPHyAAk0yHwAwelCZATdN4NJbqmolDb7AvnOEHfNz/ut64iBqOyb6ykDlT f76g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9K3V25osQLREMG6ZUk7AC0ZkFnZLHBbL3WZnP0tsfH4=; b=xALRfcYsiZa40ut5O0i4CU662t3BoaaNkiCLXy//KRMZz54YaWTOhRc77OrG+YiPlj pCK+8lHxrkv5pCx3sNOoeLdB7nexBnQuhyz3v872nnf7H/rsVjgUTzXyZXSSW4Xt0z0g A0AXdSEkgNxOft19siWbuGB7iv/r9G1YVMNFBuqh7LyvRldM/27x/IMnKQXoaLww4Hh6 JKy35qkGfT7pempCLiMdlFQ+GtaQUgNskaCcPb3MgoG1KR+N8MBp4KVYwXgGkmjdnifF cYUYEwlS0hLVhzT9pC2YnoJodUJpXIuT3UCOxW6CKrHNKFEnEu35NJgpgWSe/8bwRcky g7ZA== X-Gm-Message-State: ANoB5pkpVXDINYhgAqg6yUp9CCl5esumYAPIRJu5FlePFFvDlrFpM+5U Ep69HEzPNkEvFuwfRa+wi3LqpSSpcTj9k179fRoYzQ== X-Received: by 2002:a17:906:71b:b0:7ad:9892:91e8 with SMTP id y27-20020a170906071b00b007ad989291e8mr12896729ejb.620.1668490779010; Mon, 14 Nov 2022 21:39:39 -0800 (PST) MIME-Version: 1.0 References: <20221107205754.2635439-1-cukie@google.com> <20221114143145.ha22rdxphhpgd53u@localhost> In-Reply-To: <20221114143145.ha22rdxphhpgd53u@localhost> From: Jeffrey Vander Stoep Date: Tue, 15 Nov 2022 06:39:26 +0100 Message-ID: Subject: Re: [PATCH v1 0/2] Add LSM access controls for io_uring_setup To: Joel Granados Cc: Paul Moore , Gil Cukierman , Jens Axboe , Pavel Begunkov , James Morris , "Serge E. Hallyn" , Stephen Smalley , Eric Paris , kernel-team@android.com, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-kernel@vger.kernel.org Super helpful, thanks Paul! We'll look into this and get back to you if it doesn't fit our needs. On Mon, Nov 14, 2022 at 3:31 PM Joel Granados wrote: > > On Thu, Nov 10, 2022 at 04:04:46PM -0500, Paul Moore wrote: > > On Thu, Nov 10, 2022 at 12:54 PM Jeffrey Vander Stoep wrote: > > > On Mon, Nov 7, 2022 at 10:17 PM Paul Moore wrote: > > > > > > > > On Mon, Nov 7, 2022 at 3:58 PM Gil Cukierman wrote: > > > > > > > > > > This patchset provides the changes required for controlling access to > > > > > the io_uring_setup system call by LSMs. It does this by adding a new > > > > > hook to io_uring. It also provides the SELinux implementation for a new > > > > > permission, io_uring { setup }, using the new hook. > > > > > > > > > > This is important because existing io_uring hooks only support limiting > > > > > the sharing of credentials and access to the sensitive uring_cmd file > > > > > op. Users of LSMs may also want the ability to tightly control which > > > > > callers can retrieve an io_uring capable fd from the kernel, which is > > > > > needed for all subsequent io_uring operations. > > > > > > > > It isn't immediately obvious to me why simply obtaining a io_uring fd > > > > from io_uring_setup() would present a problem, as the security > > > > relevant operations that are possible with that io_uring fd *should* > > > > still be controlled by other LSM hooks. Can you help me understand > > > > what security issue you are trying to resolve with this control? > > > > > > I think there are a few reasons why we want this particular hook. > > > > > > 1. It aligns well with how other resources are managed by selinux > > > where access to the resource is the first control point (e.g. "create" > > > for files, sockets, or bpf_maps, "prog_load" for bpf programs, and > > > "open" for perf_event) and then additional functionality or > > > capabilities require additional permissions. > > > > [NOTE: there were two reply sections in your email, and while similar, > > they were not identical; I've trimmed the other for the sake of > > clarity] > > > > The resources you mention are all objects which contain some type of > > information (either user data, configuration, or program > > instructions), with the resulting fd being a handle to those objects. > > In the case of io_uring the fd is a handle to the io_uring > > interface/rings, which by itself does not contain any information > > which is not already controlled by other permissions. > > > > I/O operations which transfer data between the io_uring buffers and > > other system objects, e.g. IORING_OP_READV, are still subject to the > > same file access controls as those done by the application using > > syscalls. Even the IORING_OP_OPENAT command goes through the standard > > VFS code path which means it will trigger the same access control > > checks as an open*() done by the application normally. > > > > The 'interesting' scenarios are those where the io_uring operation > > servicing credentials, aka personalities, differ from the task > > controlling the io_uring. However in those cases we have the new > > io_uring controls to gate these delegated operations. Passing an > > io_uring fd is subject to the fd/use permission like any other fd. > > > > Although perhaps the most relevant to your request is the fact that > > the io_uring inode is created using the new(ish) secure anon inode > > interface which ensures that the creating task has permission to > > create an io_uring. This io_uring inode label also comes into play > > when a task attempts to mmap() the io_uring rings, a critical part of > > the io_uring API. > > > > If I'm missing something you believe to be important, please share the details. > > > > > 2. It aligns well with how resources are managed on Android. We often > > > do not grant direct access to resources (like memory buffers). > > > > Accessing the io_uring buffers requires a task to mmap() the io_uring > > fd which is controlled by the normal SELinux mmap() access controls. > > > > > 3. Attack surface management. One of the primary uses of selinux on > > > Android is to assess and limit attack surface (e.g. > > > https://twitter.com/jeffvanderstoep/status/1422771606309335043) . As > > > io_uring vulnerabilities have made their way through our vulnerability > > > management system, it's become apparent that it's complicated to > > > assess the impact. Is a use-after-free reachable? Creating > > > proof-of-concept exploits takes a lot of time, and often functionality > > > can be reached by multiple paths. How many of the known io_uring > > > vulnerabilities would be gated by the existing checks? How many future > > > ones will be gated by the existing checks? I don't know the answer to > > > either of these questions and it's not obvious. This hook makes that > > > initial assessment simple and effective. > > > > It should be possible to deny access to io_uring via the anonymous > > inode labels, the mmap() controls, and the fd/use permission. If you > > find a way to do meaningful work with an io_uring fd that can't be > > controlled via an existing permission check please let me know. > > Also interested in a more specific case. Sending reply so I get added to > the group response. > > > > -- > > paul-moore.com