]> git.hungrycats.org Git - linux/commitdiff
net: properly release sk_frag.page
authorEric Dumazet <edumazet@google.com>
Wed, 15 Mar 2017 20:21:28 +0000 (13:21 -0700)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:47:04 +0000 (00:47 +0200)
commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 upstream.

I mistakenly added the code to release sk->sk_frag in
sk_common_release() instead of sk_destruct()

TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call
sk_common_release() at close time, thus leaking one (order-3) page.

iSCSI is using such sockets.

Fixes: 5640f7685831 ("net: use a per task frag allocator")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/core/sock.c

index e3cb45411f345bf2d132ab77ce9aecc1d8ff991a..96e12591932425c205041d8ea3b98aa93b438e7a 100644 (file)
@@ -1403,6 +1403,11 @@ static void __sk_free(struct sock *sk)
                pr_debug("%s: optmem leakage (%d bytes) detected\n",
                         __func__, atomic_read(&sk->sk_omem_alloc));
 
+       if (sk->sk_frag.page) {
+               put_page(sk->sk_frag.page);
+               sk->sk_frag.page = NULL;
+       }
+
        if (sk->sk_peer_cred)
                put_cred(sk->sk_peer_cred);
        put_pid(sk->sk_peer_pid);
@@ -2556,11 +2561,6 @@ void sk_common_release(struct sock *sk)
 
        sk_refcnt_debug_release(sk);
 
-       if (sk->sk_frag.page) {
-               put_page(sk->sk_frag.page);
-               sk->sk_frag.page = NULL;
-       }
-
        sock_put(sk);
 }
 EXPORT_SYMBOL(sk_common_release);