Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1142429pxb; Thu, 23 Sep 2021 19:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM+Cfn4Swog4uYXap8+vXwIVA6divEvGjsO5MOYCZk8jHmsKT6GUEczlnYSDboyeQrQqw1 X-Received: by 2002:a92:c04c:: with SMTP id o12mr6614033ilf.124.1632452232211; Thu, 23 Sep 2021 19:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632452232; cv=none; d=google.com; s=arc-20160816; b=nqTrijR5qp4l+y9jZ7hWYLHy7gH/KksVlIHOAWncKkpMdLML7/wZIfNYDuFdQo/uaW Guvspzrb8TKgm4LAmKBFBUOvrfWbQryQ0v3RrsanRcIVTZJJlFqsY80RH0Oh/MvIgr+v HJkXPMXAS6q74eW0XSkgGrh4GbfjlXkXo1q5wSl0YcPsYbCsOuQlVyMJSOFI6An21CP6 SrqBLb0zCC8vW5gCLgoCH5wVbblVEqwiNCCPw9CU2MuSahPvo718iY7MAZNHqqf4s5/F axareX9l5xVZVpr19cllI4menuY29YMrt6Dov/S5rIVv4DntWcIBmEHSEMYsEYlNPpjd i/jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=o7ptnxiuei87eG/lwvJCIBY24wsWuR72LwD1vUx0IJ0=; b=EyZvq/Zv5mDBVC2tDAup2YXsd8c4wauIfma1GX4GoWft8dZPU88zi+yTOdVPLZxy4k ulm12uMZUNvgE9OowsA35H3lmtSyLL/F8BF8Eyx5s+QaLeNDH+7N+Cw8cioNvHWXlHsc n/4RaWbOV0k+YKkppl1HMvFHNiQ3MCsGAC8Iz1hZ48Ne/bp8vQJXVe0Q5zJX/5ZPYSbb n4gyqJ6+ifahjjrbydxuGX4+4eB01JnONoYbcbFEo5LJLASO5a0EJ9GFyw087KgKmShk JZU3PNXWbxGE/VTKDt0/cpKki4kZhWmu40zgVmZJXKBV7vhA3vsLgLE6Lg1hT0rNY9OD PhUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b69si8169785jab.32.2021.09.23.19.56.59; Thu, 23 Sep 2021 19:57:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243960AbhIXC5n (ORCPT + 99 others); Thu, 23 Sep 2021 22:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbhIXC5g (ORCPT ); Thu, 23 Sep 2021 22:57:36 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9934CC061574 for ; Thu, 23 Sep 2021 19:56:04 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTbNY-006qBt-0g; Fri, 24 Sep 2021 02:56:00 +0000 Date: Fri, 24 Sep 2021 02:56:00 +0000 From: Al Viro To: Yajun Deng Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light() Message-ID: References: <20210922063106.4272-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210922063106.4272-1-yajun.deng@linux.dev> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 22, 2021 at 02:31:06PM +0800, Yajun Deng wrote: > -#define sockfd_put(sock) fput(sock->file) > int net_ratelimit(void); > +#define sockfd_put(sock) \ > +do { \ > + struct fd *fd = (struct fd *)&sock->file; \ Have you even bothered to take a look at struct fd declaration? Or struct socket one, for that matter... What we have there is ... struct file *file; struct sock *sk; ... You are taking the address of 'file' field. And treat it as a pointer to a structure consisting of struct file * and unsigned int. > + \ > + if (fd->flags & FDPUT_FPUT) \ ... so that would take first 4 bytes in the memory occupied by 'sk' field of struct socket and check if bit 0 is set. And what significance would that bit have, pray tell? On little-endian architectures it's going to be the least significant bit in the first byte in 'sk' field. I.e. there you are testing if the contents of 'sk' (a pointer to struct sock) happens to be odd. It won't be. The same goes for 32bit big-endian - there you will be checking the least significant bit of the 4th byte of 'sk', which again is asking 'is the pointer stored there odd for some reason?' On 64bit big-endian you are checking if the bit 32 of the address of object sock->sk points to is set. And the answer to that is "hell knows and how could that possibly be relevant to anything?"