Return-Path: Received: from mail-by2nam01on0139.outbound.protection.outlook.com ([104.47.34.139]:60384 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932166AbeARVAd (ORCPT ); Thu, 18 Jan 2018 16:00:33 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Eric Dumazet , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] net: properly release sk_frag.page Date: Thu, 18 Jan 2018 20:59:55 +0000 Message-ID: <20180118205908.3220-60-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Eric Dumazet This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 ] I mistakenly added the code to release sk->sk_frag in sk_common_release() instead of sk_destruct() TCP sockets using sk->sk_allocation =3D=3D 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/sock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index e369262ea57e..76e0b874f378 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1435,6 +1435,11 @@ static void __sk_free(struct sock *sk) pr_debug("%s: optmem leakage (%d bytes) detected\n", __func__, atomic_read(&sk->sk_omem_alloc)); =20 + if (sk->sk_frag.page) { + put_page(sk->sk_frag.page); + sk->sk_frag.page =3D NULL; + } + if (sk->sk_peer_cred) put_cred(sk->sk_peer_cred); put_pid(sk->sk_peer_pid); @@ -2622,11 +2627,6 @@ void sk_common_release(struct sock *sk) =20 sk_refcnt_debug_release(sk); =20 - if (sk->sk_frag.page) { - put_page(sk->sk_frag.page); - sk->sk_frag.page =3D NULL; - } - sock_put(sk); } EXPORT_SYMBOL(sk_common_release); --=20 2.11.0