Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1440578pxa; Thu, 13 Aug 2020 08:34:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAQpm76mXrIzzhEdeZpjfNUrYQ57AdcLbE+9DenL4/YNewaMJb2Ti4wcioA19Y05BYAiTr X-Received: by 2002:a17:906:c8d2:: with SMTP id gc18mr69457ejb.24.1597332897470; Thu, 13 Aug 2020 08:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597332897; cv=none; d=google.com; s=arc-20160816; b=TdBNOeWuaQY/W37gehqQp+aIdtGXZKsLSI5tiRNjfZHzqKqAJ2DVnrbILYEBqkBoT0 J8vYy3+aS21IT+y3WtCoRfChrpHz1YkwfHe7WRdp0+cj3KKqf0bBbPx5bLbXmYvsa0f1 eYkAIU9X1BOPyNyViIYut8uxEQek+DMX4PS/cX68HmwrUgyoT57P746Ys+5kSW1LyrOs lqJnPvR0p4v7F5GsaylGTnZ6g6DPbJDcT0LENKGa1ucE8Af//MbNnkq3969nr3HNJzmo 76u3hNU/HEHto04l5Y4pWHkjomKiGSZESW40PqP8fnuaQJxKKDvO8qtgUV3gaMBC3wEJ h3LQ== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U+DZxetMKI4jVQKv/cLX0z4HNCC6l+3oyJGtLYHcX8o=; b=fpcXEEvQKd+aLseexG/cjWKh2eUpWKrKD+smU/1d73pfS7r/hLjJ3DfaWDjIKmCryi vgaDNghSyaomX2xySFv6Q+55e/wzZxDCV0wSr7OANz88+6nASEfVZfmWysN78Elt9fDq GQ1InLWxkTkreZy2pTWn/sCbeuzCrFZBJvs0s992LkPGSg173XzCC6lptZpAM0ySjIIJ 420LWc2MuyLEfBUeRs9IJCgHRdr/vfKiXPp1Trom+tU/UAvbyq5zIAFQDpu2AN32zmvt HRZS2tDiqYgLQj7BQXo6ZeDO3aPw8pu2Tr76wjrRkRHddNsdKnr+dYdc8vjEl5/WO83u HGrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XAWewq3B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si3625416edr.402.2020.08.13.08.34.34; Thu, 13 Aug 2020 08:34:57 -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=@redhat.com header.s=mimecast20190719 header.b=XAWewq3B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbgHMPds (ORCPT + 99 others); Thu, 13 Aug 2020 11:33:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:35637 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726732AbgHMPdq (ORCPT ); Thu, 13 Aug 2020 11:33:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597332825; 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; bh=U+DZxetMKI4jVQKv/cLX0z4HNCC6l+3oyJGtLYHcX8o=; b=XAWewq3B9ffElLPLK8aqXEdtA0lEYNv0TEcNPEvzuPpuKkqxxXovnF9IBkamQqxqnwOH5d vbaiYgvvqm0SkxTxkI0w1i/SA50l6SAEi0TPTa0z0WXMiD5c3dNd4H8VCRVQTV4MerO89+ qCIVor4oyVizlmurC+dje/EROwsSDUU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-rFiyPInxM7CpmkqnLbRD4g-1; Thu, 13 Aug 2020 11:33:19 -0400 X-MC-Unique: rFiyPInxM7CpmkqnLbRD4g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDC1910060C3; Thu, 13 Aug 2020 15:33:17 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-113-140.ams2.redhat.com [10.36.113.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3F4360C04; Thu, 13 Aug 2020 15:33:02 +0000 (UTC) From: Stefano Garzarella To: Jens Axboe Cc: Christian Brauner , Jann Horn , Jeff Moyer , linux-fsdevel@vger.kernel.org, Sargun Dhillon , Kees Cook , Alexander Viro , Kernel Hardening , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Aleksa Sarai , io-uring@vger.kernel.org Subject: [PATCH v4 0/3] io_uring: add restrictions to support untrusted applications and guests Date: Thu, 13 Aug 2020 17:32:51 +0200 Message-Id: <20200813153254.93731-1-sgarzare@redhat.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v4: - rebased on top of io_uring-5.9 - fixed io_uring_enter() exit path when ring is disabled v3: https://lore.kernel.org/io-uring/20200728160101.48554-1-sgarzare@redhat.c= om/ RFC v2: https://lore.kernel.org/io-uring/20200716124833.93667-1-sgarzare@redh= at.com RFC v1: https://lore.kernel.org/io-uring/20200710141945.129329-1-sgarzare@red= hat.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. Thank you in advance, Stefano [1] https://lore.kernel.org/io-uring/20200609142406.upuwpfmgqjeji4lc@steredha= t/ Stefano Garzarella (3): io_uring: use an enumeration for io_uring_register(2) opcodes io_uring: add IOURING_REGISTER_RESTRICTIONS opcode io_uring: allow disabling rings during the creation fs/io_uring.c | 160 ++++++++++++++++++++++++++++++++-- include/uapi/linux/io_uring.h | 60 ++++++++++--- 2 files changed, 203 insertions(+), 17 deletions(-) --=20 2.26.2