Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5604730rwb; Mon, 14 Nov 2022 07:04:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4fSW0+6e+b6/mMwBt1PFONWL477XAfrWIdogYTGqbnRycyC6uq+ETInjkeLEdyceBu8HDU X-Received: by 2002:a17:902:8d8d:b0:188:6300:640f with SMTP id v13-20020a1709028d8d00b001886300640fmr14081688plo.124.1668438258788; Mon, 14 Nov 2022 07:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438258; cv=none; d=google.com; s=arc-20160816; b=Zo5M2fCNueMCWvPK5/SOPCVsF4QCTExiQpltJpl96GYfLqcAuIrDfuHb/Vjz9uUkYk L4CFc9T6zB5P4dYUkywjZCeEcxmubCmVzsI5HCAiifxkSf8Fk6i3n5xgWpXGmAywkUZw N79+ZtZfaOGgphkL4CH/wHMaT9hfwPcCuRItSKkNNrDraswMrq5G2jzqb9ceh+1P7qOa zO0qNcAsbXYzyASS6c7FDiAb/wwmxdOyysc/5tpc2Q33XIyKGpgpCvTsV+13oKTRbCB/ GrzwskkGuEceiVKbc4ocdJW5lw7WeEsOA+VoiGgBUVQgF4cFhfCaz1GfeyPjRRGpU3jV m5zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=dQNwfBdIpqaepn/RDINMXYASngIiK5me72nEGTHG5UY=; b=N27GBhYrsl5C5bTP+yTUN5rk/OkYM9Rs1hGJQnMXNX+qz/Tnqv5ZjaKFHbiIM3LLte ADCWLuOiiWHeu/z9qW0ixx0O+1CBWTJI8ataJErv52dsiurbkq4I3ByldDNpZX2wI8HF T3K0gd4UQul6Tsk5h3kt0gyND/Tl+zjpIx232Xflw3QfzubhcA/xSQn3BNfEvl3n3qZJ pPiVFLmN6WQwdAGQkjfXjzvyklhRapIz3PANs40chrw7Aann0ygxTQ4Wb1qqP0DkIuBQ cqsd5E1FGKdmcThXFP86W5GS+8WDPr1OFWDhiSiNwUbnZjhUMGL10K7mYu3EUK3kRG6N EErA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YsMxlYkI; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a17090a948a00b00205ebfd6d35si8669117pjo.76.2022.11.14.07.03.51; Mon, 14 Nov 2022 07:04:18 -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=@samsung.com header.s=mail20170921 header.b=YsMxlYkI; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236842AbiKNOcD (ORCPT + 87 others); Mon, 14 Nov 2022 09:32:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236695AbiKNObu (ORCPT ); Mon, 14 Nov 2022 09:31:50 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E3AC29369; Mon, 14 Nov 2022 06:31:49 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221114143148euoutp022e1d72158b421ec29cb993275bb61e50~nefuKvsWt1523315233euoutp02c; Mon, 14 Nov 2022 14:31:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221114143148euoutp022e1d72158b421ec29cb993275bb61e50~nefuKvsWt1523315233euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1668436308; bh=dQNwfBdIpqaepn/RDINMXYASngIiK5me72nEGTHG5UY=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=YsMxlYkIA4Kw86rr8e90jC0rKprf6oQqf3N2ORtAOi8XkzrNfPZInuCPWRkDfoNYa E9SKp2KHmLHQPNn4HzV8qYo+3wlqVJkIqpBcjFadVdrBs6nxtsSJnG37uxecnoem3W 3bWgJ2LBK2AjxxfhabWaGfuK2wMYFwIOoWDoGhFQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221114143147eucas1p122ae102cdc6d073ab5498e9745195930~neft7Xi9p2102821028eucas1p1B; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7F.54.09561.35152736; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221114143147eucas1p1902d9b4afc377fdda25910a5d083e3dc~neftYp_GB1176311763eucas1p1Y; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221114143147eusmtrp20aac6134b5cc3d3136fcf567899c2e12~neftXwote2551925519eusmtrp2r; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) X-AuditID: cbfec7f2-0b3ff70000002559-04-63725153c12d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 47.AC.09026.35152736; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221114143147eusmtip15cf4f3c97add76f0639c4b23fc1db327~neftH2Kxk1514615146eusmtip1d; Mon, 14 Nov 2022 14:31:47 +0000 (GMT) Received: from localhost (106.110.32.133) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Nov 2022 14:31:46 +0000 Date: Mon, 14 Nov 2022 15:31:45 +0100 From: Joel Granados To: Paul Moore CC: Jeffrey Vander Stoep , Gil Cukierman , Jens Axboe , Pavel Begunkov , James Morris , "Serge E. Hallyn" , Stephen Smalley , Eric Paris , , , , , Subject: Re: [PATCH v1 0/2] Add LSM access controls for io_uring_setup Message-ID: <20221114143145.ha22rdxphhpgd53u@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="2ctr4pslrx4mhrsa" Content-Disposition: inline In-Reply-To: X-Originating-IP: [106.110.32.133] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNKsWRmVeSWpSXmKPExsWy7djP87rBgUXJBstnGFrMWbWN0WL13X42 i3+rYyw6H55ltnjXeo7FYk7rLnaLdesXM1ns2C5icXnXHDaLDz2P2CxuT5rOYnH++DF2i/MX zrFbPD8/mdGBz2Pb7m2sHjtn3WX3WLCp1OPa7kiPy2dLPXq+J3uc/RrlsXbvC0aPz5vkAjij uGxSUnMyy1KL9O0SuDJWXt7CWnBQv+LE9ZtMDYzN6l2MnBwSAiYSB3bMY+li5OIQEljBKLH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MailID: 20221114143147eucas1p1902d9b4afc377fdda25910a5d083e3dc X-Msg-Generator: CA X-RootMTR: 20221114143147eucas1p1902d9b4afc377fdda25910a5d083e3dc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221114143147eucas1p1902d9b4afc377fdda25910a5d083e3dc References: <20221107205754.2635439-1-cukie@google.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 --2ctr4pslrx4mhrsa Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 limi= ting > > > > the sharing of credentials and access to the sensitive uring_cmd fi= le > > > > 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. >=20 > [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] >=20 > 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. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > If I'm missing something you believe to be important, please share the de= tails. >=20 > > 2. It aligns well with how resources are managed on Android. We often > > do not grant direct access to resources (like memory buffers). >=20 > Accessing the io_uring buffers requires a task to mmap() the io_uring > fd which is controlled by the normal SELinux mmap() access controls. >=20 > > 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. >=20 > 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. >=20 > -- > paul-moore.com --2ctr4pslrx4mhrsa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmNyUUoACgkQupfNUreW QU+inAv/do7MKKHTSeQFTr+qTo1NYVoXryjw9rfz3xinweQV5XNVCvmzY1OO7Gkk pnDb+FOXdVjDrp97L5lQfHM7jRsJY2Ia8x1KYW+zhn79rxH9BQxWs646Q6g7ORJz 6C9NlOMyoBIgssRaPqLMRe8E9ewIzfhgLpjn4yI23kl7uDkyVStGLTZtCarWTMi2 ffFN8DFmZm3hm42LUKElGqSlrDxR5eWDGBQYBknkFHwsHKj5C/cL1ch020decZwB JSponYgw4OIAslxF+nWhTtIFBk40m+ji4QuxZv16bVxy1ei4yQayZYHelnT/Swvv j4BR2S0ifeBp5HEprMRpPBKMxRe045J0IcHsDlg6d5Sz1039yLGcNySQnQwOND+t dsVYv3f//2NIJF3eThgBi+KPAQS33USVk9qZujIFdcESRYfIoL0uA8el8TOop2gM DaFkBKQqNrq3s01NUfuTrOoK7wrvalgngev67gVv0TAEQQebaWZovjgR/NHl16nI ywSdStI+ =aESw -----END PGP SIGNATURE----- --2ctr4pslrx4mhrsa--