Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp642471rdb; Fri, 8 Sep 2023 11:26:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFu5z1yF88WbrpOKashgyVxJTJizKwvho40uTqtmbhMBDTtPe55D1EY+YyHUgaAdmr8tXTZ X-Received: by 2002:a05:6a00:1989:b0:68e:3c2b:20b9 with SMTP id d9-20020a056a00198900b0068e3c2b20b9mr3454811pfl.31.1694197578490; Fri, 08 Sep 2023 11:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694197578; cv=none; d=google.com; s=arc-20160816; b=Z0+fjptAt+PtwpfOGqpgrp7QkzHsGeR+Uc/s2GHeVzAc7u1SKgdW+cUgDPfornWfIw IUZUxa0ZIo4VEpIq8ossovONHrMyiNMxEznVmpZPzZm0P3fRvNoQbuomTahAiaM9rC/V UdsYveDSaHyO63Ht5jC2qcNTKcDjQOq7OsPaV63wDgy2rFOktgArEh+UB+VtsP4ZbI+x r7CNKiTHkj/BNmgnNCxl0P/2RQAeL/kaUozxn3yG0vnedyi0LV8pIO+4fjo/V8AepdE1 +iXAlQBF439QYlX0opc+fiW4txPT1eKy3AZiGL4/Rnm4SXVc9QkSjSGL+yEmU+Z9Ifde h5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=57ZvQzT8uSwMhJOxXEiVm+FHuG7dmlxUbz/rogmB6vU=; fh=pyV0YbchP55JIw7xvz60Xv/iBXgfgOHQXZ572n1Ns2c=; b=pXaSv0hFKth6kgeUXTknja1lmDM30OQI2zwpaKNixOj3e3f3vnqpW7x1H87tctOooy n29R3CMiGzk6G5RpMb8I2BSK5nmYTyXavVN94aBOfHTFngHvSO+Hfsy68FDxJNePojvY odFeY6bHW0ctK6F3CxHJubBBV/JSHioJrIPVkdg4VHePnvNiX2LW6Xj0ZMfjCBwV+IGw 7Qr+xGLAqP8U9LmoIygpCZHrswTaA82fz7LmTrzFjHMgaI+kzDNqJPucdZwwNQMRMm+v /MC+2pjWirhHaOgbGDfl2mShTiH2CuPC1xGkKD0TjiWEUwM4Ag5GI46nGBPiBg+leF+l 5LOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fa25-20020a056a002d1900b0068bde27f688si1940608pfb.81.2023.09.08.11.26.03; Fri, 08 Sep 2023 11:26:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245284AbjIHREn (ORCPT + 99 others); Fri, 8 Sep 2023 13:04:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244336AbjIHREm (ORCPT ); Fri, 8 Sep 2023 13:04:42 -0400 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F04F19B6; Fri, 8 Sep 2023 10:04:38 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-99bf3f59905so280047266b.3; Fri, 08 Sep 2023 10:04:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694192677; x=1694797477; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=57ZvQzT8uSwMhJOxXEiVm+FHuG7dmlxUbz/rogmB6vU=; b=EPMP/TFgPalYscCqdFqGTpYOe7NGdjaEwiQqkQpEwqHEEJTLoApoRlzP2rBPpsEE54 8KsYvllR7rLl6lh6ZhonZvJR1XrE9cuHWIx4PvrWf+ZyMwFBetAKWfY7QIm8uP2F7nWF zSEpXY5ltSFNtbIdZvXcrgSSMCYNikhoAYEIdUeaeWADs5OnPAUtmF8/2fu4dp/ZpZ1n EH+wO4/mBEJQG76WLfVonmsZtvH5+2TJ11tT82Kw2+TwbFE5IGjLo5KM8bgSpHZeuDHw it8xDga3RtQh7Ukv1YgOJQLr51L/jfDFELcWIs9uHTcEjMN2ZlWeE5MZ/JnVz2qidYVm ddVQ== X-Gm-Message-State: AOJu0YztReAQFOdqWQiE8Up9QvBj4/PNhSinqcYaeflvyZamz9Wh2MlU OJZVtJnyqpUsKnBbAxvpeXE= X-Received: by 2002:a17:906:292a:b0:99d:f6e9:1cf8 with SMTP id v10-20020a170906292a00b0099df6e91cf8mr2540705ejd.20.1694192676666; Fri, 08 Sep 2023 10:04:36 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-022.fbsv.net. [2a03:2880:31ff:16::face:b00c]) by smtp.gmail.com with ESMTPSA id op5-20020a170906bce500b00992ea405a79sm1276001ejb.166.2023.09.08.10.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 10:04:36 -0700 (PDT) Date: Fri, 8 Sep 2023 10:04:34 -0700 From: Breno Leitao To: Gabriel Krisman Bertazi Cc: sdf@google.com, axboe@kernel.dk, asml.silence@gmail.com, willemdebruijn.kernel@gmail.com, martin.lau@linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, io-uring@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Subject: Re: [PATCH v4 07/10] io_uring/cmd: return -EOPNOTSUPP if net is disabled Message-ID: References: <20230904162504.1356068-1-leitao@debian.org> <20230904162504.1356068-8-leitao@debian.org> <871qfcby28.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qfcby28.fsf@suse.de> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Tue, Sep 05, 2023 at 08:32:15AM -0400, Gabriel Krisman Bertazi wrote: > Breno Leitao writes: > > > Protect io_uring_cmd_sock() to be called if CONFIG_NET is not set. If > > network is not enabled, but io_uring is, then we want to return > > -EOPNOTSUPP for any possible socket operation. > > > > This is helpful because io_uring_cmd_sock() can now call functions that > > only exits if CONFIG_NET is enabled without having #ifdef CONFIG_NET > > inside the function itself. > > > > Signed-off-by: Breno Leitao > > --- > > io_uring/uring_cmd.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > > index 60f843a357e0..6a91e1af7d05 100644 > > --- a/io_uring/uring_cmd.c > > +++ b/io_uring/uring_cmd.c > > @@ -167,6 +167,7 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, > > } > > EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); > > > > +#if defined(CONFIG_NET) > > int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > { > > struct socket *sock = cmd->file->private_data; > > @@ -192,4 +193,11 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > return -EOPNOTSUPP; > > } > > } > > +#else > > +int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > +{ > > + return -EOPNOTSUPP; > > +} > > +#endif > > + > > EXPORT_SYMBOL_GPL(io_uring_cmd_sock); > > It doesn't make much sense to export the symbol on the !CONFIG_NET case. > Usually, you'd make it a 'static inline' in the header file (even though > it won't be ever inlined in this case): > > in include/linux/io_uring.h: > > #if defined(CONFIG_NET) > int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags); > #else > static inline int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > { > return -EOPNOTSUPP; > } > #endif > > But this is a minor detail. I'd say to consider doing it if you end up doing > another spin of the patchset. Other than that, looks good to me. This makes sense, and I will add the symbol export inside the "if defined(CONFIG_NET)" block, since I need to respin this patchset to address the sockptr_t concern. Thanks for the good reviews!