Skip to contentSkip to conversation

sock_diag: fix autoloading of the raw_diag module

PATCH In review Andrei Vagin 3 participants 4 messages Nov 5, 2018 – Nov 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sock_diag: fix autoloading of the raw_diag module

IPPROTO_TCP isn't registred as an inet protocol, so inet_protos[protocol] is always NULL for it.

Cc Cyrill Gorcunov <[email protected]>
Cc Xin Long <[email protected]>
Fixes bf2ae2e4bf93 ("sock_diag: request _diag module only when the family or proto has been registered")
---
 net/core/sock.c | 1 +
 1 file changed, 1 insertion(+)
net/core/sock.c +1 -0
index 6fcc4bc07d19..080a880a1761 100644
@@ -3279,6 +3279,7 @@ int sock_load_diag_module(int family, int protocol)
 
 #ifdef CONFIG_INET
 	if (family == AF_INET &&
+	    protocol != IPPROTO_RAW &&
 	    !rcu_access_pointer(inet_protos[protocol]))
 		return -ENOENT;
 #endif
Signature · 1 line
2.17.2
#1 lore raw
Quoted 2 lines · Andrei Vagin

IPPROTO_TCP isn't registred as an inet protocol, so inet_protos[protocol] is always NULL for it.

Typo, IPPROTO_RAW

Quoted 14 lines
Cc Cyrill Gorcunov <[email protected]>
Cc Xin Long <[email protected]>
Fixes bf2ae2e4bf93 ("sock_diag: request _diag module only when the family or proto has been registered")
---
 net/core/sock.c | 1 +
 1 file changed, 1 insertion(+)
net/core/sock.c +0 -0
index 6fcc4bc07d19..080a880a1761 100644

net/core/sock.c int sock_load_diag_module(int family, int protocol) · line 3285

Quoted 7 lines
net/core/sock.c +1 -0
@@ -3279,6 +3279,7 @@ int sock_load_diag_module(int family, int protocol)
 
 #ifdef CONFIG_INET
 	if (family == AF_INET &&
+	    protocol != IPPROTO_RAW &&
 	    !rcu_access_pointer(inet_protos[protocol]))
 		return -ENOENT;
 #endif

Andrew, looking into kernel code I wonder, maybe we should simply add this protocol into inet_protos during net/ipv4/af_inet.c:inet_init? It will require to add netns_ok into raw_prot of course.

Reviewed-by
#2 lore raw
Quoted 4 lines · Cyrill Gorcunov

Andrew, looking into kernel code I wonder, maybe we should simply add this protocol into inet_protos during net/ipv4/af_inet.c:inet_init? It will require to add netns_ok into raw_prot of course.

After spending some time on this idea I think your patch is better, since it is small and suitable for a -stable fix (because the former issue is definitely changing the kernel behaviour, the fix should be passed to -stable as well).

maintainer
#3 lore raw
In reply to Andrei Vagin

From: Andrei Vagin <[email protected]>
Date: Sun, 4 Nov 2018 22:37:15 -0800

Quoted 7 lines

IPPROTO_TCP isn't registred as an inet protocol, so inet_protos[protocol] is always NULL for it.

Cc Cyrill Gorcunov <[email protected]>
Cc Xin Long <[email protected]>
Fixes bf2ae2e4bf93 ("sock_diag: request _diag module only when the family or proto has been registered")

Applied and queued up for -stable.