Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp389994rwd; Thu, 8 Jun 2023 02:05:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44R5a4g9xt+LN57qbCZzVxrFGTd9C4ubaIJWw1V5Oau2VPhoy8FWSTzwA+NPEd2lszodpW X-Received: by 2002:a17:902:d503:b0:1b0:10a1:3da9 with SMTP id b3-20020a170902d50300b001b010a13da9mr1849283plg.32.1686215126429; Thu, 08 Jun 2023 02:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686215126; cv=none; d=google.com; s=arc-20160816; b=f4Wow95owwUXgkQaLF/VHOL/+qtv8ZomuS88MpUvLISxyfXL4XesEzo3H9lyDqsMpi 4Skp8vsy9EhoXP8PLYe280pDPHi31xlS8X2FbIDKQg5UmHR0Uma+Fh2FaJZeDVKYK0IV Et3fFxRE4RUaSZGlBjlOn9cBHA8vEPeV3xqwvniiQokRy9viSz9EQCtKN8Cx9F99vBtl Lhim5AP3jjSk19NEZeGEh+kaIAa6/5fpMZhzJ341HLwTI5AK6VewlB4kD+GBSDbyYXXD 0n3+K+JkE0t8uJGzwBjsDZH20aZ+81ayXgmDlVmBDKNkuB1x5NdYYe206uKH7smc4XPi dGdw== 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=PM0M/xxWO+GYo8qM7bZgfmTBJclcCiBWNAU2zxTbSYA=; b=Ktx7yHSDgy02D/Ap1/GslDhYHGG40L3G8F/wUAFRvEoCz0TYT0WX/tB7JyPr9TPBKn gYjSZMYoPCftmXUspYAx2uIvWvQbJU/qh1kS9EVeyOYk1fa59zB283E+eAI7ZhlzbEiw w0pC/oaAmwH5WlsgftcgXtTVzkaV6ZknB4VNLrkv+b9aKCSlHa89hc5wwQ/CP/i9GAhN lKBcNwdVNMXtrVxmsyHQMHu4+1Ha1vrGlcWx+mlklvDz0WpRxLiIDRaDc7SuMfa+Q94c D1JnROHrGYmaiPHYP9cOzMqI26bP0R16r0Wn48n2PAVrRg3lTolUMVdQjrh653MdublU g4OA== 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 h11-20020a170902748b00b001b3414a1fa9si737490pll.175.2023.06.08.02.05.14; Thu, 08 Jun 2023 02:05:26 -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 S234131AbjFHInW (ORCPT + 99 others); Thu, 8 Jun 2023 04:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233969AbjFHInU (ORCPT ); Thu, 8 Jun 2023 04:43:20 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB64199D; Thu, 8 Jun 2023 01:43:18 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-30e57e0a0c7so226740f8f.2; Thu, 08 Jun 2023 01:43:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686213797; x=1688805797; 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=PM0M/xxWO+GYo8qM7bZgfmTBJclcCiBWNAU2zxTbSYA=; b=DvA2KJpHG/ncFnt7ooyrJNEl5iZapAGxEOiN6SS0HeNl7Md+YrDGeVlluvaoNda4xt 4cBnxjTi507WebBugDnkxpoZejUOSiw/FoIr1xci2cwmvduz6gfJV3oFGN8YbNOK2Irl ssZC7Sygoqceyl/acZXL2bEhkrVKKYhhLH6xFOuAPPvMTRfr4L/h+IBCUKodTSGVisw3 cTSzyqfjGjM3df/HKroaucHbmclg4xwIRkG5vVVJFvhUMV6Tn2fZiO0lsIJInxZ2gRFt vAGQGIG3L9QbOuGVCHpsFdxoApNiBAYNWMhwRjV71enPM2bYjilCZ1aL/NBYvF5HChrM Ci3g== X-Gm-Message-State: AC+VfDyTCQbcE7nJYpYnKBF/dJ/axI9QDAF59ZnFGGNwHTYq0Pioj07K OfgHqJm/RS1POhHS/zwLfrc= X-Received: by 2002:adf:fccf:0:b0:309:5068:9ebe with SMTP id f15-20020adffccf000000b0030950689ebemr5748626wrs.50.1686213796423; Thu, 08 Jun 2023 01:43:16 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-016.fbsv.net. [2a03:2880:31ff:10::face:b00c]) by smtp.gmail.com with ESMTPSA id l15-20020adff48f000000b003078cd719ffsm882156wro.95.2023.06.08.01.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 01:43:15 -0700 (PDT) Date: Thu, 8 Jun 2023 01:43:13 -0700 From: Breno Leitao To: Kuniyuki Iwashima Cc: alex.aring@gmail.com, andrea.righi@canonical.com, asml.silence@gmail.com, ast@kernel.org, axboe@kernel.dk, courmisch@gmail.com, davem@davemloft.net, dccp@vger.kernel.org, dsahern@kernel.org, edumazet@google.com, gnault@redhat.com, hbh25y@gmail.com, joannelkoong@gmail.com, kernelxing@tencent.com, kuba@kernel.org, leit@fb.com, linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-wpan@vger.kernel.org, lucien.xin@gmail.com, marcelo.leitner@gmail.com, martin.lau@kernel.org, martineau@kernel.org, matthieu.baerts@tessares.net, miquel.raynal@bootlin.com, mptcp@lists.linux.dev, netdev@vger.kernel.org, pabeni@redhat.com, stefan@datenfreihafen.org, willemdebruijn.kernel@gmail.com, wojciech.drewek@intel.com Subject: Re: [PATCH net-next v6] net: ioctl: Use kernel memory on protocol ioctl callbacks Message-ID: References: <20230606180045.827659-1-leitao@debian.org> <20230607173142.86395-1-kuniyu@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607173142.86395-1-kuniyu@amazon.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hello Kuniyuki, On Wed, Jun 07, 2023 at 10:31:42AM -0700, Kuniyuki Iwashima wrote: > > +/* This is the most common ioctl prep function, where the result (4 bytes) is > > + * copied back to userspace if the ioctl() returns successfully. No input is > > + * copied from userspace as input argument. > > + */ > > +static int sock_ioctl_out(struct sock *sk, unsigned int cmd, void __user *arg) > > +{ > > + int ret, karg = 0; > > + > > + ret = sk->sk_prot->ioctl(sk, cmd, &karg); > > We need READ_ONCE(sk->sk_prot) as IPv4 conversion or ULP chnage could > occur at the same time. Thanks for the heads-up. I would like to pick you brain and understand a bit more about READ_ONCE() and what is the situation that READ_ONCE() will solve. Is the situation related to when sock_ioctl_out() start to execute, and "sk->sk_prot" changes in a different thread? If that is the case, the arguments (cmd and arg) will be from the "previous" instance. Also, grepping for "sk->sk_prot->", I see more than a bunch of calls that do not use READ_ONCE() barrier. Why is this case different? Thank you