netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yajun.deng@linux.dev
To: "Al Viro" <viro@zeniv.linux.org.uk>,
	kuba@kernel.org, "Eric Dumazet" <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light()
Date: Fri, 24 Sep 2021 03:39:30 +0000	[thread overview]
Message-ID: <016b34c6de78009c8617c521e8d1ee0d@linux.dev> (raw)
In-Reply-To: <YU0+QDerqF5+pPB7@zeniv-ca.linux.org.uk>

September 24, 2021 10:56 AM, "Al Viro" <viro@zeniv.linux.org.uk> wrote:

> 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?"

Well, the forced conversion is wrong. sorry for that.

      reply	other threads:[~2021-09-24  3:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  6:31 [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light() Yajun Deng
2021-09-23 15:24 ` Jakub Kicinski
2021-09-24  2:39   ` yajun.deng
2021-09-23 16:49 ` Eric Dumazet
2021-09-24  2:49   ` yajun.deng
2021-09-24  2:56 ` Al Viro
2021-09-24  3:39   ` yajun.deng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=016b34c6de78009c8617c521e8d1ee0d@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).