Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp291061rdb; Sat, 19 Aug 2023 01:45:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3KnODLj1AAYisnS5E7HUgbJujT2fMKa+SZgvP5UIS1q1uoWRAVaIEpuw5/ZXtzRkez7jt X-Received: by 2002:a05:6a20:7da6:b0:12e:f6e6:882b with SMTP id v38-20020a056a207da600b0012ef6e6882bmr2305889pzj.1.1692434744254; Sat, 19 Aug 2023 01:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692434744; cv=none; d=google.com; s=arc-20160816; b=tM5zKBtlgn7U/2EKKhJZEul3KDW4uICgIj+PsDQL+OgWMnnfo1NvvWfE9sPeQ3ND/o 45wxSZ3Dn664wYGa31QPBuzYChJqPU8MZObljK86wk1pQWFWsOWcVQRg1wTSVvL+so0c 1flhci67D/Ir5zz0u1oyUM1TS4YGCWVsdd1Jid3ZtBrSHVXyIJAs6GFq2h/XblPjNTR6 uf7H3wdOkDYh/C245eMuFB1qzhBJaV/XcZLUd9Ym2symYXi3hqxJKAmlAaJa+JMa74+K +BoTTAAnvWLXUtOYSMDVceeUV94P/+tDk2PSSt+NarkHHi+ybAs7HVRz75NEzNr9IfZE CRkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=4NCk5EuygTllxrThg0vFVBSkXpm2Kj6r/bz6FMUkUls=; fh=C61WcxmcgVRZumuuvUXYnmmww68ovProtHBFbCVqY6w=; b=Jth7qlWCJkPU/tSR2Ae3sujkYXzADDahZCWKnfSgz+6hiApktoTTEPxjRbR2wKLvhT GwXICW5R8F0ny8HYU5DEHWc/xCpdxaiAvTk9VhNGV9ILGwVysqfXe35SQ38Ycc5/zzn2 PTcf6VxZFHMG1P3AFuCmvbh991qEL5eSHxrQ6Hgx84yVtYuookWWBwC4z7c6NlUfYSh4 KvpzYh1YqZLcDyE5aJcbW9HhHrOev2FhZ6J2qwtzTrNE1Fg4vVmI9ZYnFFIjpBfwTmDE 22UYZpH3W2v1vwv4warWYUOkZEp3grOnJvq+SyJMe7fSAUQDskZGtXfhCS9QtIGzHPVN CakQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejMgq1I3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e3-20020a656483000000b005692f51e6e7si2914314pgv.808.2023.08.19.01.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 01:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejMgq1I3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FB857696; Sat, 19 Aug 2023 01:25:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345453AbjHPSRK (ORCPT + 99 others); Wed, 16 Aug 2023 14:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345452AbjHPSQk (ORCPT ); Wed, 16 Aug 2023 14:16:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8891BF8 for ; Wed, 16 Aug 2023 11:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692209757; 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: in-reply-to:in-reply-to:references:references; bh=4NCk5EuygTllxrThg0vFVBSkXpm2Kj6r/bz6FMUkUls=; b=ejMgq1I32I19kIIPvhtQEpkxahbiSpYn2EiePcf2J/UIOQHNIiwEAZtMnicr1S/uQWsGsA 3GblbZC/IkrMOWBtuqrjkJEUxhDvTW6xeo5HuG0oW2hRWWG7mMVJHq/g9E6KMpqvt8Oa+s nXzyV2ihDkN2qvLaoNVcXvl6KX8FhxA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-8Hh94IScOuyW4gb4qhhidQ-1; Wed, 16 Aug 2023 14:15:54 -0400 X-MC-Unique: 8Hh94IScOuyW4gb4qhhidQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 131FC857A84; Wed, 16 Aug 2023 18:15:52 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E626492C13; Wed, 16 Aug 2023 18:15:51 +0000 (UTC) From: Jeff Moyer To: Gabriel Krisman Bertazi Cc: matteorizzo@google.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, axboe@kernel.dk, asml.silence@gmail.com, corbet@lwn.net, akpm@linux-foundation.org, keescook@chromium.org, ribalda@chromium.org, rostedt@goodmis.org, jannh@google.com, chenhuacai@kernel.org, gpiccoli@igalia.com, ldufour@linux.ibm.com, evn@google.com, poprdi@google.com, jordyzomer@google.com, andres@anarazel.de Subject: Re: [PATCH v4] io_uring: add a sysctl to disable io_uring system-wide References: <87cyzm504h.fsf@suse.de> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Wed, 16 Aug 2023 14:21:39 -0400 In-Reply-To: <87cyzm504h.fsf@suse.de> (Gabriel Krisman Bertazi's message of "Wed, 16 Aug 2023 14:10:38 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Gabriel Krisman Bertazi writes: > Jeff Moyer writes: > >> From: Matteo Rizzo >> >> Introduce a new sysctl (io_uring_disabled) which can be either 0, 1, or >> 2. When 0 (the default), all processes are allowed to create io_uring >> instances, which is the current behavior. When 1, io_uring creation is >> disabled (io_uring_setup() will fail with -EPERM) for processes not in >> the kernel.io_uring_group group. When 2, calls to io_uring_setup() fail >> with -EPERM regardless of privilege. >> >> Signed-off-by: Matteo Rizzo >> [JEM: modified to add io_uring_group] >> Signed-off-by: Jeff Moyer >> >> --- >> v4: >> >> * Add a kernel.io_uring_group sysctl to hold a group id that is allowed >> to use io_uring. One thing worth pointing out is that, when a group >> is specified, only users in that group can create an io_uring. That >> means that if the root user is not in that group, root can not make >> use of io_uring. > > Rejecting root if it's not in the group doesn't make much sense to > me. Of course, root can always just add itself to the group, so it is > not a security feature. But I'd expect 'sudo ' to not start giving > EPERM based on user group settings. Can you make CAP_SYS_ADMIN > always allowed for option 1? Yes, that's easy to do. I'd like to gather more opinions on this before changing it, though. >> I also wrote unit tests for liburing. I'll post that as well if there >> is consensus on this approach. > > I'm fine with this approach as it allow me to easily reject non-root users. Thanks for taking a look! -Jeff