Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1195161rwl; Thu, 10 Aug 2023 07:46:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtf1MKAkBYpwavloLs34rAr7+J1lZ4g5eCCRwUWlwIWsYXcN9leVdx2IrB1JJiNKKU6i5S X-Received: by 2002:a05:6a21:7807:b0:137:23f1:4281 with SMTP id be7-20020a056a21780700b0013723f14281mr2357115pzc.12.1691678812955; Thu, 10 Aug 2023 07:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691678812; cv=none; d=google.com; s=arc-20160816; b=zuyqWIIRXoShd+sfIxSQ3/isEejt9Pn+MvoIHQYy+DQHkVGbYGk8kr7UEH1bhBNjvR U4Lu8w9k9HFRJTsYjyYz8S6x8lTG+qxc5t19DvWgkuUraEnxkjxJkbK5907Jeevj/xa/ u5eo52qpVa0JgY3a6yArmaNoxdX8lyGCpd6qIbiJ8Yl4yBWWbo9P0rYmJXhuwmNVe9sk FIsavOZVQZFz5P2l2pzazrAj3TmkzFzakrgClecixXpPMdKPMyjjEvS0zTWO0HaWgRu2 peOQ1tz5T3P5RLJcr1mgn5/iHAzdXloFMthGfrPFuQnOc63k2B7jRF4aY18hoRnw6yxp qnYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=o2IFYmxJ69iOtAnIBZxcgpw37s7rFsv/wEwdYi37y7A=; fh=V7m/Q24Gues9lKFKgCo9/0q0XoR7QbQ/GKMKTU1XoNs=; b=rhd90GxhhHbk6yXR/Ed3s18SV6skr6FqVMd1w9wyrOm3xrGVlMK+ckL9C+0JjFA3nu iMmK+V9luDi+CDzI8kg5fXRbtAJPIvlIKAXI+57NyI4TP5iZg2rS0bIc0aQI79VuUVP6 yOZB+ESs6MG0w7o5GkaR6HOZq6zr1zbJemCDecREwxxSgQ/zRS5kMF4fGCesZ2GUQhB0 geLw4wxR4/wSu3cFE6/Dnt2iL/5dThmNoZwq68oPDjeHJZyukOpc72S5c0XufUdm6Gwx s2qPBjKAuU+mA/wXtvWK2SHIHqJIr8TFcnYsptPjnyUNW6tIGwlPH9JG7LReOW4eMt5W u1Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VAlgLTuZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a632158000000b00564997692c2si1657748pgm.711.2023.08.10.07.46.40; Thu, 10 Aug 2023 07:46:52 -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=@gmail.com header.s=20221208 header.b=VAlgLTuZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234842AbjHJNA1 (ORCPT + 99 others); Thu, 10 Aug 2023 09:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjHJNA0 (ORCPT ); Thu, 10 Aug 2023 09:00:26 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34C65E5D; Thu, 10 Aug 2023 06:00:26 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-99cdb0fd093so133318766b.1; Thu, 10 Aug 2023 06:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691672424; x=1692277224; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=o2IFYmxJ69iOtAnIBZxcgpw37s7rFsv/wEwdYi37y7A=; b=VAlgLTuZTZu7oNH68LpSRV/qYAOx4ESLfto9jVRmJy04nKNPx+whhf1iCd8/5U5ISA c5aMU1mk2NxD10kILB7vxRuuPjwSD6plO/N7fX/AaQVffZP1Az2+mG8yAP2IcC/2WRhq 1v0ndgchr1szE1ZsIUexVpg+46WjBNsAqrEjB+cQb8T20Il02eraX/Vsk5ghhk/yJN4X DMT+z4WpNcJuZg7R9DcGcTZsydZrr95Li2idtMzvCDeQu1C7OgNp3V7umUPnv7IZ9UOn 8GqiVSkFFRKS3VLus7dLf6+oZFugvkidWBnP4f4nkxCcQRI6YXD10F1VofQVJZ+rOlRA 0U4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691672424; x=1692277224; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o2IFYmxJ69iOtAnIBZxcgpw37s7rFsv/wEwdYi37y7A=; b=UUhOogJX64zbQAsEKytKCWJlas8cvIjUi5VvcPRZ4sllXm3Rb7xBbLnaD8dbs24kVG y7UpF0LWRLgyaoOquT379U3RWOj/NV4KFEUVe0u0yjgXnZol2rqjuTTz85nsShtxCwpE P1zw93GoXN197Bb46doH4btud94k9l99euwdLLVMsWiJ1VNNxvdFfkoHSNIMa/HQa/A5 LM23rvN4nnrzJfG4xXykz6my1saro42QbEJZ6oUvmPnwO/AL1CNDDNmQmTwALhFlEbRJ RcNVzadLRNpAixzU3i3YP2GD86pe6TorF4p75/iaXIx4j6uzRFej7ETUOkAU5xT4GtSQ FKLw== X-Gm-Message-State: AOJu0YxXZce68NIET0dNF6Q60mFasy5gW7FSEzNSFRZ4IJAkBb5lMikB vnIJ9xgZ15gLGvm5xiCHWFxCOIjhPAY= X-Received: by 2002:a17:906:304b:b0:99b:674c:44eb with SMTP id d11-20020a170906304b00b0099b674c44ebmr2032503ejd.9.1691672424268; Thu, 10 Aug 2023 06:00:24 -0700 (PDT) Received: from [192.168.8.100] ([85.255.237.36]) by smtp.gmail.com with ESMTPSA id n8-20020a1709065e0800b0096f6a131b9fsm909147eju.23.2023.08.10.06.00.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Aug 2023 06:00:23 -0700 (PDT) Message-ID: <58840e8e-a8e5-41d6-bb25-48a3a1ffc3b8@gmail.com> Date: Thu, 10 Aug 2023 13:57:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/8] io_uring/cmd: Introduce SOCKET_URING_OP_GETSOCKOPT To: Willem de Bruijn , Breno Leitao , sdf@google.com, axboe@kernel.dk Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, io-uring@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com References: <20230808134049.1407498-1-leitao@debian.org> <20230808134049.1407498-3-leitao@debian.org> <64d392c0235c6_267bde294c3@willemb.c.googlers.com.notmuch> Content-Language: en-US From: Pavel Begunkov In-Reply-To: <64d392c0235c6_267bde294c3@willemb.c.googlers.com.notmuch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 8/9/23 14:21, Willem de Bruijn wrote: > Breno Leitao wrote: >> Add support for getsockopt command (SOCKET_URING_OP_GETSOCKOPT), where >> level is SOL_SOCKET. This is leveraging the sockptr_t infrastructure, >> where a sockptr_t is either userspace or kernel space, and handled as >> such. >> >> Function io_uring_cmd_getsockopt() is inspired by __sys_getsockopt(). >> >> Differently from the getsockopt(2), the optlen field is not a userspace >> pointers. In getsockopt(2), userspace provides optlen pointer, which is >> overwritten by the kernel. In this implementation, userspace passes a >> u32, and the new value is returned in cqe->res. I.e., optlen is not a >> pointer. >> >> Important to say that userspace needs to keep the pointer alive until >> the CQE is completed. > > What bad things can happen otherwise? > > The kernel is not depending on a well behaved process for its > correctness here, is it? Any user pages have to be pinned while Right, it's the user api thing. There are always userspace progs that would try to do: submit_async() { char buf[20]; do_submit(sqe = {buf = buf, ...}); } submit_async(); wait_completions(); > kernel might refer to them, for instance. fwiw, it's passed down as a user ptr, which will be eventually used in copy_[from,to]_user() or so. -- Pavel Begunkov