From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60FB8C433E0 for ; Thu, 16 Jul 2020 20:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30371207DD for ; Thu, 16 Jul 2020 20:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="SlhjXobo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725980AbgGPUva (ORCPT ); Thu, 16 Jul 2020 16:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgGPUva (ORCPT ); Thu, 16 Jul 2020 16:51:30 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A2EBC061755 for ; Thu, 16 Jul 2020 13:51:30 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id q74so7544585iod.1 for ; Thu, 16 Jul 2020 13:51:29 -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=/OMgh93Kb2HkE6P0kAr28R6z12ut/xwA3vG3iFDckbI=; b=SlhjXoboBAxGh2VTbr9NcInkijK7jQpCCQnuS6p+0nfgmyeVsheY4bc3BdXFSkBPTD j3PQMvPR5EZ0k3Bz8aBB5FiDK5eypyjPNP42owrGwPGZalFhiDbNSwOk1bM4s3eSCZkC t1nHWdMiS5XFpAFhIGk1PPbIC5sxZ+0K5oQFobuIKINk+5fhlhrQu/zBAXEjKjL+37fc B6KHhfMuEiwftkGVc+I9WskJLKiqmTxyD0TGV3XaLT5nKUXr0t/bhvar61NQsvEBNFm8 bk9eKcwh96dfrbzu5YVUq0wY8MOR9LXEocoukxOjqRuQYvzHQ7lq/lJ6VWFgpiEeWzYQ hvYA== 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=/OMgh93Kb2HkE6P0kAr28R6z12ut/xwA3vG3iFDckbI=; b=nheaXpYxPR4Q/Lp8RWGORbC07X94B3XtrTRUn6BvK59nKDwsIKjMExznUJYHjTpDC+ afP0z2MV7Z+1604uKZSoceWrPRDIaj3Gj6sHNx9kqvAhUdaFUuTyJmBv/5LbhwdVRyvK nKWDN/+2+h8JKhsIOjQIbTPi4vFCxkFEdw5h8zo3YzpIiu9ui7AqMnmfyMtWHLYWU0yl 9kemqWyLxqgRHOyGZ8bnaYBnErskyzUcgXHLEbqIZb3ykzZt2ZWwuk/L+qlNK91sN7MO hLs+LHIwKqVYju17Cp4wMJ53FosTbEemBAbLFwYfWPe1NmWxxmrMlxX5OvMuQMihwWE5 aL3w== X-Gm-Message-State: AOAM530u87+wKjD091Zep1qceZrbJAA468MZeVJlvaB2p25o2btNjQfl 1bsocQG7BFkeMAsgU3oumAnypw== X-Google-Smtp-Source: ABdhPJy2wUZWh2Y4jruQ6d5kCL/LKMYVm6LNd8/aYi1fc8AM2ykPWqla4cvX5vltX/y94v5ZxMTqlA== X-Received: by 2002:a5e:a60d:: with SMTP id q13mr6237726ioi.199.1594932689231; Thu, 16 Jul 2020 13:51:29 -0700 (PDT) Received: from [192.168.1.58] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id i12sm3469283ioi.48.2020.07.16.13.51.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jul 2020 13:51:28 -0700 (PDT) Subject: Re: [PATCH RFC v2 1/3] io_uring: use an enumeration for io_uring_register(2) opcodes To: Pavel Begunkov , Stefano Garzarella Cc: Alexander Viro , Kernel Hardening , Kees Cook , Aleksa Sarai , Stefan Hajnoczi , Christian Brauner , Sargun Dhillon , Jann Horn , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jeff Moyer , linux-kernel@vger.kernel.org References: <20200716124833.93667-1-sgarzare@redhat.com> <20200716124833.93667-2-sgarzare@redhat.com> <20326d79-fb5a-2480-e52a-e154e056171f@gmail.com> From: Jens Axboe Message-ID: <76879432-745d-a5ca-b171-b1391b926ea2@kernel.dk> Date: Thu, 16 Jul 2020 14:51:26 -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: <20326d79-fb5a-2480-e52a-e154e056171f@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 7/16/20 2:47 PM, Pavel Begunkov wrote: > On 16/07/2020 23:42, Jens Axboe wrote: >> On 7/16/20 2:16 PM, Pavel Begunkov wrote: >>> On 16/07/2020 15:48, Stefano Garzarella wrote: >>>> The enumeration allows us to keep track of the last >>>> io_uring_register(2) opcode available. >>>> >>>> Behaviour and opcodes names don't change. >>>> >>>> Signed-off-by: Stefano Garzarella >>>> --- >>>> include/uapi/linux/io_uring.h | 27 ++++++++++++++++----------- >>>> 1 file changed, 16 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h >>>> index 7843742b8b74..efc50bd0af34 100644 >>>> --- a/include/uapi/linux/io_uring.h >>>> +++ b/include/uapi/linux/io_uring.h >>>> @@ -253,17 +253,22 @@ struct io_uring_params { >>>> /* >>>> * io_uring_register(2) opcodes and arguments >>>> */ >>>> -#define IORING_REGISTER_BUFFERS 0 >>>> -#define IORING_UNREGISTER_BUFFERS 1 >>>> -#define IORING_REGISTER_FILES 2 >>>> -#define IORING_UNREGISTER_FILES 3 >>>> -#define IORING_REGISTER_EVENTFD 4 >>>> -#define IORING_UNREGISTER_EVENTFD 5 >>>> -#define IORING_REGISTER_FILES_UPDATE 6 >>>> -#define IORING_REGISTER_EVENTFD_ASYNC 7 >>>> -#define IORING_REGISTER_PROBE 8 >>>> -#define IORING_REGISTER_PERSONALITY 9 >>>> -#define IORING_UNREGISTER_PERSONALITY 10 >>>> +enum { >>>> + IORING_REGISTER_BUFFERS, >>>> + IORING_UNREGISTER_BUFFERS, >>>> + IORING_REGISTER_FILES, >>>> + IORING_UNREGISTER_FILES, >>>> + IORING_REGISTER_EVENTFD, >>>> + IORING_UNREGISTER_EVENTFD, >>>> + IORING_REGISTER_FILES_UPDATE, >>>> + IORING_REGISTER_EVENTFD_ASYNC, >>>> + IORING_REGISTER_PROBE, >>>> + IORING_REGISTER_PERSONALITY, >>>> + IORING_UNREGISTER_PERSONALITY, >>>> + >>>> + /* this goes last */ >>>> + IORING_REGISTER_LAST >>>> +}; >>> >>> It breaks userspace API. E.g. >>> >>> #ifdef IORING_REGISTER_BUFFERS >> >> It can, yes, but we have done that in the past. In this one, for > > Ok, if nobody on the userspace side cares, then better to do that > sooner than later. > > >> example: >> >> commit 9e3aa61ae3e01ce1ce6361a41ef725e1f4d1d2bf (tag: io_uring-5.5-20191212) >> Author: Jens Axboe >> Date: Wed Dec 11 15:55:43 2019 -0700 >> >> io_uring: ensure we return -EINVAL on unknown opcod >> >> But it would be safer/saner to do this like we have the done the IOSQE_ >> flags. > > IOSQE_ are a bitmask, but this would look peculiar > > enum { > __IORING_REGISTER_BUFFERS, > ... > }; > define IORING_REGISTER_BUFFERS __IORING_REGISTER_BUFFERS Yeah true of course, that won't really work for this case at all. That said, I don't think it's a huge deal to turn it into an enum. -- Jens Axboe