Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1714174rwb; Fri, 28 Jul 2023 13:48:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFup1V68xHvCv/jEMGDddvzlavyVdq05CCixiwcPz/3KQKeILKczZIwluLAJhcRZMTje1wV X-Received: by 2002:a17:902:a518:b0:1b5:fb8:a821 with SMTP id s24-20020a170902a51800b001b50fb8a821mr2310531plq.13.1690577331706; Fri, 28 Jul 2023 13:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690577331; cv=none; d=google.com; s=arc-20160816; b=niJrFMTxPRgXfNj0nihA36CX1qNi6Oa9/qNmHdkYew434N2v3VI2tjSJfvkRt8fny5 Ibpi7Rjp7MtFzDAiF5v6r9DTSUCH9yOIPo/s25p5YdJZJ3g3fWmMIGosX6RRDtN8DS1K l7N2qiwuGVk1V3gXMQrezcvSAwzlIOt/a3RjA2qHrcmyLE58tQaaNQXtBU+TXket+ajG TrXmiKW5Dfln5ugK+eN98GFncSIqWvOzKy7oqtmFw4ir5KkQ6Pa3Nt+/gx/vtTq/qiYA mzKzRtodJsmFu1hrtCOZgSTKnXsU3OtcMWZbk30PvRBnOpYXVEQwOKiPY39djZxjFOIx O3Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0j1xWKyarV49sAVolaI4AB1ZfYUgMNGUimAsLLV4Mug=; fh=Uc46kbYcIWdP3kqxqkWhF2r/nFEpZRzkqC4AJgVXJrg=; b=a6RN0WlwH9dn/QIgoKYXzHfF+4XyNsd1BiWclvaFaUCdhKYmcehHuY3PdNy73yuJD/ sLTuspe4PTaR7UxaLBS6YEipaIQ6ZAxWnUQObzwpbmAPIYfLkPLdzy+omZFYDCNTy1rE ZTiQXo5k4Z9zwYF9XUeBYvq3ynApCfrHbjdcHviJ4TGZgRXRvjpIx/u0Pd1wQxvVHr6w lX2GfbxWPeZsAIfr6s+ReWLISbpOiS2jvZ/qoVzeN+FjBDttraNc3TzJshJDBZKLZjV6 49G20bLvS6JULFHZAbqsWSQ5viXX76ZuyyIQczRWxcos0EED+8VFlq4qCeixvzINVij3 gWGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=bthRLJgm; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a170902d50f00b001b8ac52a1b2si3670578plg.551.2023.07.28.13.48.39; Fri, 28 Jul 2023 13:48:51 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=bthRLJgm; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjG1SH2 (ORCPT + 99 others); Fri, 28 Jul 2023 14:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbjG1SH0 (ORCPT ); Fri, 28 Jul 2023 14:07:26 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D1F23C1F for ; Fri, 28 Jul 2023 11:07:22 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-563f752774fso1369853a12.1 for ; Fri, 28 Jul 2023 11:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690567642; x=1691172442; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0j1xWKyarV49sAVolaI4AB1ZfYUgMNGUimAsLLV4Mug=; b=bthRLJgmCvjOnYvWo+2qon30TpingFUg2Fsc6mWV841J6V//QLFLhA/3pFUZ3RWjjp lvqPYA00NNy/7rUAp+SRbT6DXYQV9P2xYvt6Fw87chrCyM0dslS+R/6hc5wlsGx04nxH 0m+HjUzgJ46oDMGQuIwdEtvGiOlhwqQO7dlBEa8W8NizZqJBs/5UmVIm7NdU+q4u2kwT Ig/XvZWu743pJjwIQVwK0TnKLi848DKrm8Rcsm7V8TXDR7pyX+R3tOBiI8YtrQRupbSq VYHkCSyOu+v4UnQfxGoiP/bFyUwxKmqJjciC1srz6+GGr7OHRgKVsqbjV3O/RlK8YIV7 7yGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690567642; x=1691172442; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0j1xWKyarV49sAVolaI4AB1ZfYUgMNGUimAsLLV4Mug=; b=ACiNrmYYCnULyjtnodoooxDy82n2nBE4aiLfC4Al67jhLTZcaOpuVetAU13Z9JwUxv USRBLhiF63+AGQYsn7+YgyB+KN2dLHScGp+EDX1Nsz2Cgv9gt5UKOFIe30ybIeZ1brFq ij55BA+FMX64kOSFcZW0ws9kkwBaHNk5QGgzGyw8Y1DH4gNnoFnJPqPQHiUMIzh2E1Xu TtMwLNtSwH47jom15LdykPsSSsa1m4URgIz6+wdkmbcUzV9dwwhEGfILtKziMwvUx373 jm5oDadtY02m6MJXISm51do0FfpYR2p0+JK9whDNf05HEPhk9pcFnYhWOYR5PRfYMy6K gcZw== X-Gm-Message-State: ABy/qLbpEOgkDXNDnT1plCqNrMKT9xZgW5PXFN/UrhptRH4mmUhllgp1 uqEC97y7IUq5ROa0de2FawnagM0wljzdyuep7biO5g== X-Received: by 2002:a17:90b:8c4:b0:268:23d7:21c with SMTP id ds4-20020a17090b08c400b0026823d7021cmr2007489pjb.30.1690567641609; Fri, 28 Jul 2023 11:07:21 -0700 (PDT) MIME-Version: 1.0 References: <20230724142237.358769-1-leitao@debian.org> <20230724142237.358769-3-leitao@debian.org> In-Reply-To: From: Stanislav Fomichev Date: Fri, 28 Jul 2023 11:07:10 -0700 Message-ID: Subject: Re: [PATCH 2/4] io_uring/cmd: Introduce SOCKET_URING_OP_GETSOCKOPT To: Breno Leitao Cc: asml.silence@gmail.com, axboe@kernel.dk, io-uring@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kernel@vger.kernel.org, leit@meta.com, bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Fri, Jul 28, 2023 at 10:03=E2=80=AFAM Breno Leitao w= rote: > > Hello Stanislav, > > On Tue, Jul 25, 2023 at 10:02:40AM -0700, Stanislav Fomichev wrote: > > On 07/25, Breno Leitao wrote: > > > On Mon, Jul 24, 2023 at 10:31:28AM -0700, Stanislav Fomichev wrote: > > > > On 07/24, Breno Leitao wrote: > > > > > Add support for getsockopt command (SOCKET_URING_OP_GETSOCKOPT), = where > > > > > level is SOL_SOCKET. This is leveraging the sockptr_t infrastruct= ure, > > > > > where a sockptr_t is either userspace or kernel space, and handle= d as > > > > > such. > > > > > > > > > > Function io_uring_cmd_getsockopt() is inspired by __sys_getsockop= t(). > > > > > > > > We probably need to also have bpf bits in the new > > > > io_uring_cmd_getsockopt? > > > > > > It might be interesting to have the BPF hook for this function as > > > well, but I would like to do it in a following patch, so, I can > > > experiment with it better, if that is OK. > > I spent smoe time looking at the problem, and I understand we want to > call something as BPF_CGROUP_RUN_PROG_{G,S}ETSOCKOPT() into > io_uring_cmd_{g,s}etsockopt(). > > Per the previous conversation with Williem, > io_uring_cmd_{g,s}etsockopt() should use optval as a user pointer (void _= _user > *optval), and optlen as a kernel integer (it comes as from the io_uring > SQE), such as: > > void __user *optval =3D u64_to_user_ptr(READ_ONCE(cmd->sqe->optva= l)); > int optlen =3D READ_ONCE(cmd->sqe->optlen); > > Function BPF_CGROUP_RUN_PROG_GETSOCKOPT() calls > __cgroup_bpf_run_filter_getsockopt() which expects userpointer for > optlen and optval. > > At the same time BPF_CGROUP_RUN_PROG_GETSOCKOPT_KERN() expects kernel > pointers for both optlen and optval. > > In this current patchset, it has user pointer for optval and kernel value > for optlen. I.e., a third combination. So, none of the functions would > work properly, and we probably do not want to create another function. > > I am wondering if it is a good idea to move > __cgroup_bpf_run_filter_getsockopt() to use sockptr_t, so, it will be > able to adapt to any combination. Yeah, I think it makes sense. However, note that the intent of that optlen being a __user pointer is to possibly write some (updated) value back into the userspace. Presumably, you'll pass that updated optlen into some io_uring completion queue? (maybe a stupid question, not super familiar with io_uring) > Any feedback is appreciate. > Thanks!