netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: avoid NULL deref in inet_ctl_sock_destroy()
@ 2015-11-02 15:50 Eric Dumazet
  2015-11-02 16:53 ` Hannes Frederic Sowa
  2015-11-03  3:46 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2015-11-02 15:50 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Dmitry Vyukov

From: Eric Dumazet <edumazet@google.com>

Under low memory conditions, tcp_sk_init() and icmp_sk_init()
can both iterate on all possible cpus and call inet_ctl_sock_destroy(),
with eventual NULL pointer.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
 include/net/inet_common.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 279f83591971..109e3ee9108c 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -41,7 +41,8 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
 
 static inline void inet_ctl_sock_destroy(struct sock *sk)
 {
-	sock_release(sk->sk_socket);
+	if (sk)
+		sock_release(sk->sk_socket);
 }
 
 #endif

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-03 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 15:50 [PATCH net] net: avoid NULL deref in inet_ctl_sock_destroy() Eric Dumazet
2015-11-02 16:53 ` Hannes Frederic Sowa
2015-11-02 17:00   ` Eric Dumazet
2015-11-02 17:59     ` Dmitry Vyukov
2015-11-03  3:46 ` David Miller
2015-11-03  5:04   ` Eric Dumazet
2015-11-03 15:22     ` David Miller

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).