Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp492974pxa; Thu, 27 Aug 2020 07:52:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFcnv7D79awAuUGooHDObleeZp03GDgGXKBE9V/XhbkLla/1D6V5PdoGDczNRPdTC82vFu X-Received: by 2002:a17:907:388:: with SMTP id ss8mr20623355ejb.479.1598539934661; Thu, 27 Aug 2020 07:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598539934; cv=none; d=google.com; s=arc-20160816; b=bZ9lsJdg+E0aUG1lGZyafjlWOvNPX/p45uUKobqzkAC0g5OwN5G6r1S0jnMnkTKyMu sEt6jruwtlHrIbP6aRb+vO9r/XRERovfIcYsQ3TZUbalj2CK5LDPhfJS4kX8Y6ORrQcI 4t2NBd9oTYlazDuzaSjxYVm8Oid42EKlPzWchO9jS0/6ZdVuT03+m41Er622VlwVhVXK FpMsMMLqBmvAvyx3QfvXpOwOjCrWhvPUYTRbJZv+eeE8+UPw7oBoGBOkMz2QVXgdQ2PE AYAaU+bCggKHgZkAVge+ZwzWmPfBizFG9+4QPuAtkfuEDVFufaQpZFUB4EjGQH1A8XZb hOAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=BvBnzh3obuyUM8uwyAg6+Zl7AVs2adJQvrnXXuqR/PQ=; b=rUq0KY1Y+NiiGDlHE1WTdXCjXTJXsFC188cXT+bSLLaPrAS1VALI4M7S3xdH2mT3hw dqkPNSzhwKk9Gqcmkr6mNNbHy6fPyDmvYMRTrDA10t17oNUz2qUMPWu9ngFKxsBtV7vB E3T223OdPhiue3nbnYrdF/kgfVQQDIC0iGITPiigIR3ZuQpuzA5KnSt4F/8xKcIvRrMl nmN7zXjrioVwgox69KhbkhvsGPpAbZq2BmCGbWhFGS2Xu+Uj8dHjgTsxXX4m+0j0o1Ku kzcFF1el2zOkjuBEwLOxqvkhCzp0WD1b0D0mFIVpc01hmV8YYC9qY/NLYurI0DN2l3NA YcuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=aOAHV6uQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id li24si1491723ejb.205.2020.08.27.07.51.52; Thu, 27 Aug 2020 07:52:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=aOAHV6uQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726246AbgH0Or7 (ORCPT + 99 others); Thu, 27 Aug 2020 10:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728013AbgH0OoY (ORCPT ); Thu, 27 Aug 2020 10:44:24 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C960C061264 for ; Thu, 27 Aug 2020 07:44:23 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id t13so5060716ile.9 for ; Thu, 27 Aug 2020 07:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BvBnzh3obuyUM8uwyAg6+Zl7AVs2adJQvrnXXuqR/PQ=; b=aOAHV6uQAQVlX4aoMFWjdC9v57E5cC0AjZCtTF6GYcTrghuXOf8Fw6NLk/suxXkhU2 zViUAl0NmIZa5ihE9PMDueIuiBFx5DOasGmrvktLc7e5r6OD+0oD9nDKl+0KvqGqIPFG BJgbssBNxa/kZTlS8BkLeqcQv9YXiLpmx5a1uN4P7h3oSSQxcwaKCwHZ165OdvIZC6Mf psv8Kta/q8Tz5GLxlrDhjSIyyxS9VAN9i/dZW1VxTUcPr5O+whKoDNqy6I5g64EB8ADD nEMZwCuBhJtzs7j4zgYA+Mf//9dosIRnf7H/UKL2qnhHQSkaeh0rjSiXZ/QXzYwKM4m+ fCWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BvBnzh3obuyUM8uwyAg6+Zl7AVs2adJQvrnXXuqR/PQ=; b=mEO12Lc0fDRg+5KxlzoVAZGVzBNxF2u9PUcIZNG3kn7GstGtXCIigq8lssVEkKo9cH XnaC9kRQBLau+Dq2YbklvKsRaD6JjtpwD6ndXKIvSIunXqjxmKbdlmi+A2JvYoMyvjd/ OA7o3HSq7oaOxT9l351TFK7VLyVgWPPMzpTXMKScJiaOdZvpL89jEFX7+Mj8P0gqzJMq eIp6T+lAHbnBCiRAEUD6uGlDXyIzVwe6lkEnX+Yz7b7va5gQyaydH6gsgipinj4hqIlc tOrtW0PEzcxhRhFCusueErYGIPcz6uKwcpKAAaggjd39K7SBx1/I7HH0xT0SJfhET6q3 rZwg== X-Gm-Message-State: AOAM531huhr/MUUVv1J5+DxkzUgSGzNGVgMFoDocdaK3inl49GoFb4+O vr8/rZqT1ddWXipaPe+tqnf2pw== X-Received: by 2002:a92:dd8c:: with SMTP id g12mr16624564iln.184.1598539462409; Thu, 27 Aug 2020 07:44:22 -0700 (PDT) Received: from [192.168.1.58] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id j4sm1280083ilk.39.2020.08.27.07.44.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Aug 2020 07:44:21 -0700 (PDT) Subject: Re: [PATCH v5 0/3] io_uring: add restrictions to support untrusted applications and guests To: Stefano Garzarella Cc: Aleksa Sarai , Kernel Hardening , Jann Horn , io-uring@vger.kernel.org, Christian Brauner , linux-fsdevel@vger.kernel.org, Alexander Viro , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Sargun Dhillon , Kees Cook , Jeff Moyer References: <20200827134044.82821-1-sgarzare@redhat.com> <2ded8df7-6dcb-ee8a-c1fd-e0c420b7b95d@kernel.dk> <20200827141002.an34n2nx6m4dfhce@steredhat.lan> <20200827144129.5yvu2icj7a5jfp3p@steredhat.lan> From: Jens Axboe Message-ID: Date: Thu, 27 Aug 2020 08:44:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200827144129.5yvu2icj7a5jfp3p@steredhat.lan> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/27/20 8:41 AM, Stefano Garzarella wrote: > On Thu, Aug 27, 2020 at 08:10:49AM -0600, Jens Axboe wrote: >> On 8/27/20 8:10 AM, Stefano Garzarella wrote: >>> On Thu, Aug 27, 2020 at 07:50:44AM -0600, Jens Axboe wrote: >>>> On 8/27/20 7:40 AM, Stefano Garzarella wrote: >>>>> v5: >>>>> - explicitly assigned enum values [Kees] >>>>> - replaced kmalloc/copy_from_user with memdup_user [kernel test robot] >>>>> - added Kees' R-b tags >>>>> >>>>> v4: https://lore.kernel.org/io-uring/20200813153254.93731-1-sgarzare@redhat.com/ >>>>> v3: https://lore.kernel.org/io-uring/20200728160101.48554-1-sgarzare@redhat.com/ >>>>> RFC v2: https://lore.kernel.org/io-uring/20200716124833.93667-1-sgarzare@redhat.com >>>>> RFC v1: https://lore.kernel.org/io-uring/20200710141945.129329-1-sgarzare@redhat.com >>>>> >>>>> Following the proposal that I send about restrictions [1], I wrote this series >>>>> to add restrictions in io_uring. >>>>> >>>>> I also wrote helpers in liburing and a test case (test/register-restrictions.c) >>>>> available in this repository: >>>>> https://github.com/stefano-garzarella/liburing (branch: io_uring_restrictions) >>>>> >>>>> Just to recap the proposal, the idea is to add some restrictions to the >>>>> operations (sqe opcode and flags, register opcode) to safely allow untrusted >>>>> applications or guests to use io_uring queues. >>>>> >>>>> The first patch changes io_uring_register(2) opcodes into an enumeration to >>>>> keep track of the last opcode available. >>>>> >>>>> The second patch adds IOURING_REGISTER_RESTRICTIONS opcode and the code to >>>>> handle restrictions. >>>>> >>>>> The third patch adds IORING_SETUP_R_DISABLED flag to start the rings disabled, >>>>> allowing the user to register restrictions, buffers, files, before to start >>>>> processing SQEs. >>>>> >>>>> Comments and suggestions are very welcome. >>>> >>>> Looks good to me, just a few very minor comments in patch 2. If you >>>> could fix those up, let's get this queued for 5.10. >>>> >>> >>> Sure, I'll fix the issues. This is great :-) >> >> Thanks! I'll pull in your liburing tests as well once we get the kernel >> side sorted. > > Yeah. Let me know if you'd prefer that I send patches on io-uring ML. > > About io-uring UAPI, do you think we should set explicitly the enum > values also for IOSQE_*_BIT and IORING_OP_*? > > I can send a separated patch for this. No, I actually think that change was a little bit silly. If you inadvertently renumber the enum in a patch, then tests would fail left and right. Hence I don't think this is a real risk. I'm fine with doing it for the addition, but doing it for the others is just going to cause stable headaches for patches. -- Jens Axboe