lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87275ec67ed69d077e0265bc01acd8a2@linux.dev>
Date:   Sat, 18 Sep 2021 02:53:59 +0000
From:   yajun.deng@...ux.dev
To:     "Jakub Kicinski" <kuba@...nel.org>
Cc:     davem@...emloft.net, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] net: socket: add the case sock_no_xxx
 support

September 18, 2021 9:33 AM, "Jakub Kicinski" <kuba@...nel.org> wrote:

> On Thu, 16 Sep 2021 20:29:43 +0800 Yajun Deng wrote:
> 
>> Those sock_no_{mmap, socketpair, listen, accept, connect, shutdown,
>> sendpage} functions are used many times in struct proto_ops, but they are
>> meaningless. So we can add them support in socket and delete them in struct
>> proto_ops.
> 
> So the reason to do this is.. what exactly?
> 
> Removing a couple empty helpers (which is not even part of this patch)?
> 
> I'm not sold, sorry.

When we define a struct proto_ops xxx, we only need to assign meaningful member variables that we need.
Those {mmap, socketpair, listen, accept, connect, shutdown, sendpage} members we don't need assign
it if we don't need. We just need do once in socket, not in every struct proto_ops.

These members are assigned meaningless values far more often than meaningful ones, so this patch I used likely(!!sock->ops->xxx) for this case. This is the reason why I send this patch.

I would send a set of patchs remove most of the meaningless members assigned rather than remove sock_no_{mmap, socketpair, listen, accept, connect, shutdown, sendpage} functions if this patch was accepted. 
e.g.  

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1d816a5fd3eb..86422eb440cb 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1059,20 +1059,16 @@ const struct proto_ops inet_dgram_ops = {
        .release           = inet_release,
        .bind              = inet_bind,
        .connect           = inet_dgram_connect,
-       .socketpair        = sock_no_socketpair,
-       .accept            = sock_no_accept,

--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1059,20 +1059,16 @@ const struct proto_ops inet_dgram_ops = {
        .release           = inet_release,
        .bind              = inet_bind,
        .connect           = inet_dgram_connect,
-       .socketpair        = sock_no_socketpair,
-       .accept            = sock_no_accept,
        .getname           = inet_getname,


        .gettstamp         = sock_gettstamp,
-       .listen            = sock_no_listen,
        .shutdown          = inet_shutdown,
        .setsockopt        = sock_common_setsockopt,
        .getsockopt        = sock_common_getsockopt,
        .sendmsg           = inet_sendmsg,
        .read_sock         = udp_read_sock,
        .recvmsg           = inet_recvmsg,
-       .mmap              = sock_no_mmap,
        .sendpage          = inet_sendpage,
        .set_peek_off      = sk_set_peek_off,
 #ifdef CONFIG_COMPAT
@@ -1091,19 +1087,15 @@ static const struct proto_ops inet_sockraw_ops = {
        .release           = inet_release,
        .bind              = inet_bind,
        .connect           = inet_dgram_connect,
-       .socketpair        = sock_no_socketpair,
-       .accept            = sock_no_accept,
        .getname           = inet_getname,
        .poll              = datagram_poll,
        .ioctl             = inet_ioctl,
        .gettstamp         = sock_gettstamp,
-       .listen            = sock_no_listen,
        .shutdown          = inet_shutdown,
        .setsockopt        = sock_common_setsockopt,
        .getsockopt        = sock_common_getsockopt,
        .sendmsg           = inet_sendmsg,
        .recvmsg           = inet_recvmsg,
-       .mmap              = sock_no_mmap,
        .sendpage          = inet_sendpage,
 #ifdef CONFIG_COMPAT
        .compat_ioctl      = inet_compat_ioctl,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ