From: Al Viro <viro@zeniv.linux.org.uk>
To: Yajun Deng <yajun.deng@linux.dev>
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()
Date: Fri, 24 Sep 2021 02:56:00 +0000 [thread overview]
Message-ID: <YU0+QDerqF5+pPB7@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <20210922063106.4272-1-yajun.deng@linux.dev>
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?"
next prev parent reply other threads:[~2021-09-24 2:56 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-23 16:49 ` Eric Dumazet
2021-09-24 2:39 ` yajun.deng
2021-09-24 2:49 ` yajun.deng
2021-09-24 2:56 ` Al Viro [this message]
2021-09-24 3:39 ` yajun.deng
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=YU0+QDerqF5+pPB7@zeniv-ca.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yajun.deng@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.