Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1610340rdb; Sat, 20 Jan 2024 06:09:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7ryOUEWuD3BOTTRQFrZjBU/fW1NwCU0vcLnZ0jkc84sH5D9ziE0oSuBz74KDcqTORvxmE X-Received: by 2002:a17:907:cc08:b0:a2b:c7ce:8a93 with SMTP id uo8-20020a170907cc0800b00a2bc7ce8a93mr604171ejc.4.1705759781839; Sat, 20 Jan 2024 06:09:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705759781; cv=pass; d=google.com; s=arc-20160816; b=kXN+AofFAcMO52BueVyt3haRzRo6sujLPDBBcT0Djd6tIjWY7eEoa0dHOyQ8FDt3az vWGMIE8D0bZBLzr8SUw21jv7WgucsvSYQkn8wOX2Vwweq40+XdqcA048dYck1NwJobay dygDy51PLWrwPQGhuW/hT4TrME9qCbkr808ZM73Hrv446NsLI6qR6OEqNXWmGi8tT7/0 01YObRdkEYU8CAXJ0gv0C4ByvxaUYgMD/3OlkLY+v56ekbb2gh9vHmAyzVU20ahhCRNv dwn28fAydQudn9ZTnxtq1kojYQnDFzYPQCaLl+8uWzS4wqTTmUEPZt8202u7V81KRzRh SuvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=H5wYT7HPbgBxM6i7zSXIWjWAG+fcTAGm1HNEEhELniM=; fh=1hujxE6jtot3LwwNyHcLhyH0pk3HQQMmOHJMRe/aZ1M=; b=ZPvN8PQCPxEBBXLvooyF+KpgSL7B0QctRcRd597AoSRieqOy3JSokDdB7DV6Cp9N1n VONqw/gj5JQSVxbtP3D+vHXhre9PePcj7c48XojDN0r8qFhPDRN489C9WX6r7HGTWVrV bf1ZJXyGnFLNUIdUGFhvXbd+sh475sdkBVaSHfxmyvLzHUALBasNMydFuGqtd59vkNMc A6g12+2CyJKRHUijFyBsaAxCx25Nsem4LNJ8H7LKj9TfkcHLSTgTWMKND/j2DXckKtPs mqrEob1V18LlM34iruDTTqJZv+sSdY5Tpg3FFTY5PvSxXAZ5m4mPfBME0iJac6glgAIt dGyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M08P381Z; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31812-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id la26-20020a170906ad9a00b00a2fd03474ffsi757122ejb.133.2024.01.20.06.09.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 06:09:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31812-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M08P381Z; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31812-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6857E1F226A3 for ; Sat, 20 Jan 2024 14:09:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 209EDFC0A; Sat, 20 Jan 2024 14:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M08P381Z" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA603D262; Sat, 20 Jan 2024 14:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705759770; cv=none; b=uKKKQIa/XPFceY+4bpUowyGzFmPeYKG9Vzt4BgfQYxCjQmCqWcfqlzeycPWJRtxeiXWrJYBGpisUPoICgCXymaNTftrdL7r5BwJe0mrAbix0//lnIJVmTbRIMJAf3ELx9C5hSCBtHEiiGwgc8xh7SEbi0syZ/FwdxQdCtl/MnYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705759770; c=relaxed/simple; bh=CID8wslCSPlIu7z6Sspwr6XnulZg3T/quj323AKPIwc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=d/N1B78jhgYEj10ues5T8B9xfG/0qhSOomawoKHLuKbjrsieRENX6bVPZlOPerUaLrBVp/LM5IuA4khf98l1LZF1M+XAZmdp+WycFyY+RNKAo4W1MBaMlxWIA6mup5Ra62IOw1vOhaZe9heF4baxsSS5ZWEQOA1BewdH6A/YUGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M08P381Z; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6d9344f30caso1162651b3a.1; Sat, 20 Jan 2024 06:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705759768; x=1706364568; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=H5wYT7HPbgBxM6i7zSXIWjWAG+fcTAGm1HNEEhELniM=; b=M08P381ZaEuJf2F12OQzRhV02Fe690qJeGOyZ+z+9CLHs2gi0BSHuHF3bl1Hx9zaE/ 7HmM7LoPO4u9HZKEyC4uUbISNGrTzu/UpJzIMXyuekKI8Ob9xu+HSuVC99Sny9FHUO/J 5aSXm2hZNFbjjcQB2K0wUFSxD5bVGCRfuJ5PsymSVVSZg2SeRP7l5k/JbNwBJw/7bm4C gUpQ0XNnqTsUVoKczBYzgJkVbF234ANZLt6+kjYL3ktMHllReaBBJfRC3wb6eP1+5qX3 mdEN4oe76NV8CizwAI8Vpo9IczxgGDeqN3qz+i99Ok36lBRfVRSXeWpPpN/L4RBtvu/K ulXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705759768; x=1706364568; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H5wYT7HPbgBxM6i7zSXIWjWAG+fcTAGm1HNEEhELniM=; b=Lm0MXLtuYzjinHdxKw8CsNpbIomrbPR/r3YYzYER/l1P9aoixl1aKralVoYX+Muqc7 3R/VNt67LMze8dEKxtfZybplNw5kWkn7P9VepOPMDSpKQplHUk+3ug5t3QCv1zRLdBk1 iaRpzfVG5qAlMzs3MKTKqYYpHOhknWAtJ0ItK8jN/jLL5I0dyuutGFLaQYYrxTpQns1R VoAUwvDKXlGxpUfHQHWuoxbolXO6rzM8NjcEIJkPSLgQzqCbyo4TauMFWCjoQiHxXyOS NhX3vQVeq62jkGLEqGTEBf1P+rsL8DMmh0DpetqIfMn79xaBxCgsYxY5J0L/iNT9jQKp gDYg== X-Gm-Message-State: AOJu0YwJTfKhGEYROkQai5SharSDEcHlRTrnWnDOEM+tEG4EsbLSty7l tgWH/Ph4Nm26z93O2sJUULBImAqLyi4oCHaoWSeyD/KcT2AYq5uR X-Received: by 2002:a05:6a00:170c:b0:6d9:a856:eec2 with SMTP id h12-20020a056a00170c00b006d9a856eec2mr1847379pfc.14.1705759768062; Sat, 20 Jan 2024 06:09:28 -0800 (PST) Received: from ?IPV6:2406:7400:94:dd16:106d:864:6ca4:72b7? ([2406:7400:94:dd16:106d:864:6ca4:72b7]) by smtp.gmail.com with ESMTPSA id m6-20020a62f206000000b006dbd1678512sm991139pfh.162.2024.01.20.06.09.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Jan 2024 06:09:27 -0800 (PST) Message-ID: <37ed354a-6b69-4e24-9557-5ca62179b76a@gmail.com> Date: Sat, 20 Jan 2024 19:39:22 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iouring:added boundary value check for io_uring_group systl Content-Language: en-US To: Jeff Moyer Cc: corbet@lwn.net, axboe@kernel.dk, asml.silence@gmail.com, ribalda@chromium.org, rostedt@goodmis.org, bhe@redhat.com, akpm@linux-foundation.org, matteorizzo@google.com, ardb@kernel.org, alexghiti@rivosinc.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org References: <20240115124925.1735-1-subramanya.swamy.linux@gmail.com> From: Subramanya Swamy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Jeff,            Thank you for reviewing the patch. On 16/01/24 23:16, Jeff Moyer wrote: > Subramanya Swamy writes: > >> /proc/sys/kernel/io_uring_group takes gid as input >> added boundary value check to accept gid in range of >> 0<=gid<=4294967294 & Documentation is updated for same > Thanks for the patch. You're right, the current code artificially > limits the maximum group id. > >> Signed-off-by: Subramanya Swamy >> --- >> Documentation/admin-guide/sysctl/kernel.rst | 9 ++++----- >> io_uring/io_uring.c | 8 ++++++-- >> 2 files changed, 10 insertions(+), 7 deletions(-) >> >> diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst >> index 6584a1f9bfe3..3f96007aa971 100644 >> --- a/Documentation/admin-guide/sysctl/kernel.rst >> +++ b/Documentation/admin-guide/sysctl/kernel.rst >> @@ -469,11 +469,10 @@ shrinks the kernel's attack surface. >> io_uring_group >> ============== >> >> -When io_uring_disabled is set to 1, a process must either be >> -privileged (CAP_SYS_ADMIN) or be in the io_uring_group group in order >> -to create an io_uring instance. If io_uring_group is set to -1 (the >> -default), only processes with the CAP_SYS_ADMIN capability may create >> -io_uring instances. >> +When io_uring_disabled is set to 1, only processes with the >> +CAP_SYS_ADMIN may create io_uring instances or process must be in the >> +io_uring_group group in order to create an io_uring_instance. >> +io_uring_group is set to 0.This is the default setting. > You are changing the default from an invalid group to the root group. I > guess that's ok, but I'd rather keep it the way it is. The text is a > bit repetitive. Why not just this? > > "When io_uring_disabled is set to 1, a process must either be > privileged (CAP_SYS_ADMIN) or be in the io_uring_group group in order > to create an io_uring instance." Yes this looks neat , will add in v2 >> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c >> index 09b6d860deba..0ed91b69643d 100644 >> --- a/io_uring/io_uring.c >> +++ b/io_uring/io_uring.c >> @@ -146,7 +146,9 @@ static void io_queue_sqe(struct io_kiocb *req); >> struct kmem_cache *req_cachep; >> >> static int __read_mostly sysctl_io_uring_disabled; >> -static int __read_mostly sysctl_io_uring_group = -1; >> +static unsigned int __read_mostly sysctl_io_uring_group; >> +static unsigned int min_gid; >> +static unsigned int max_gid = 4294967294; /*4294967294 is the max guid*/ > Right, INVALID_GID is -1. > >> #ifdef CONFIG_SYSCTL >> static struct ctl_table kernel_io_uring_disabled_table[] = { >> @@ -164,7 +166,9 @@ static struct ctl_table kernel_io_uring_disabled_table[] = { >> .data = &sysctl_io_uring_group, >> .maxlen = sizeof(gid_t), >> .mode = 0644, >> - .proc_handler = proc_dointvec, >> + .proc_handler = proc_douintvec_minmax, >> + .extra1 = &min_gid, > This should be SYSCTL_ZERO. will change this to SYSCTL_ZERO in v2 >> + .extra2 = &max_gid, >> }, >> {}, >> }; > Thanks! > Jeff > -- Best Regards Subramanya