Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1163017pxb; Thu, 23 Sep 2021 20:40:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCjMx3bMSKi0ja+Rncwf72FwWd78iFBOlbpZUZJlnpPTKLd1W4Xg2e+ppFTevsSBOJIBtj X-Received: by 2002:a02:c006:: with SMTP id y6mr7186530jai.125.1632454838156; Thu, 23 Sep 2021 20:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632454838; cv=none; d=google.com; s=arc-20160816; b=CZ3pEJ1IM1kc2nJUqlHnGojcSSd/HkAU9/4BBZjswJdrmwl8nhAuuJmNaioDuGsPdE Zk6v9a4cm2ASyehG0yp02lc5Xdt8j29adJX/U+TJBSAvkMe6DG1Pr6bWc74yR3jjwcHi PCqRS/dugoi5I2yiwp5vNSzSoFPzHxDaGw67CBoE71lXBXPRlGyTYA2VjN0rZMGQyOSe 4t54DrSZCD2JpiDXsuQoqEDvvvxDqLUXPtkO3v/jPBFVhku9RXxMpwr1CckQ0xJ4bx6i 4RNwQNm4zWV3adohwEt+mpI/3PbilvEylynEBHB8xQtEB3rBQC0kn8DGoxzRG9Ml0PkA ymAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:cc:to:subject:message-id :from:content-transfer-encoding:date:dkim-signature:mime-version; bh=H32Do5KLQwbmwW23dyqRQ7oezzkGBTzKs2qPrn/A6BI=; b=BBC9YOXcJDBB0KRHP9SCu+XtsjHN74Hx4dwK9oCLzr5N95Z4QotKbo3zxbiO4PVUav 5urNSF9ov6GVL8N3s8hBYQuVcLrPx/EJdOmyL+HR4Xmdx93Ym0ksjooMIdDVMUEeHbeV t6IYXg+7jlwcA6Jq/WXgan5Z7rA8w1DapDmNzsmtm0Q/Bx4LWeQOVqherzvgxmTHdTGZ 9vrCHAsXegZt7gru5KUB0gjv6sRGLC/RTy2PSLvOXjuITsiojdOgxxKYfGGbEekO75fM /ilYjjaUWQqo96/G5XuJdAnVv3uv3R06HpivScmuMLWPBoo9tKSQDYyzxB5k/Busqsnd mnxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LtEYvTtQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si8432708iot.67.2021.09.23.20.40.26; Thu, 23 Sep 2021 20:40:38 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b=LtEYvTtQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244022AbhIXDlF (ORCPT + 99 others); Thu, 23 Sep 2021 23:41:05 -0400 Received: from out2.migadu.com ([188.165.223.204]:26124 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243927AbhIXDlE (ORCPT ); Thu, 23 Sep 2021 23:41:04 -0400 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1632454770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H32Do5KLQwbmwW23dyqRQ7oezzkGBTzKs2qPrn/A6BI=; b=LtEYvTtQlvSOuPSX7f6ybpGHMdmXvp8e+kJzd3iEb8ylyL26BUgU69p/LMpBkoc2Fax9iU 1Os8oSJ6Z45RkgnRbtQ+wYxQ3AiX16h5W3rncrAF6m8e9MpopTLN5y0/yG9QiTDXk9ou5N hWHpFpNGLlo+Xw+4EgIW8GYkSJPFUG4= Date: Fri, 24 Sep 2021 03:39:30 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: yajun.deng@linux.dev Message-ID: <016b34c6de78009c8617c521e8d1ee0d@linux.dev> Subject: Re: [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light() To: "Al Viro" , kuba@kernel.org, "Eric Dumazet" Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: <20210922063106.4272-1-yajun.deng@linux.dev> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org September 24, 2021 10:56 AM, "Al Viro" wrote:= =0A=0A> On Wed, Sep 22, 2021 at 02:31:06PM +0800, Yajun Deng wrote:=0A> = =0A>> -#define sockfd_put(sock) fput(sock->file)=0A>> int net_ratelimit(v= oid);=0A>> +#define sockfd_put(sock) \=0A>> +do { \=0A>> + struct fd *fd = =3D (struct fd *)&sock->file; \=0A> =0A> Have you even bothered to take a= look at struct fd declaration?=0A> Or struct socket one, for that matter= ... What we have there is=0A> ...=0A> struct file *file;=0A> struct sock = *sk;=0A> ...=0A> =0A> You are taking the address of 'file' field. And tre= at it as=0A> a pointer to a structure consisting of struct file * and=0A>= unsigned int.=0A> =0A>> + \=0A>> + if (fd->flags & FDPUT_FPUT) \=0A> =0A= > ... so that would take first 4 bytes in the memory occupied=0A> by 'sk'= field of struct socket and check if bit 0 is set.=0A> =0A> And what sign= ificance would that bit have, pray tell? On=0A> little-endian architectur= es it's going to be the least=0A> significant bit in the first byte in 's= k' field. I.e.=0A> there you are testing if the contents of 'sk' (a point= er=0A> to struct sock) happens to be odd. It won't be. The=0A> same goes = for 32bit big-endian - there you will be checking=0A> the least significa= nt bit of the 4th byte of 'sk', which=0A> again is asking 'is the pointer= stored there odd for some=0A> reason?'=0A> =0A> On 64bit big-endian you = are checking if the bit 32 of=0A> the address of object sock->sk points t= o is set. And the=0A> answer to that is "hell knows and how could that po= ssibly=0A> be relevant to anything?"=0A=0AWell, the forced conversion is = wrong. sorry for that.