From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0123.outbound.protection.outlook.com ([104.47.40.123]:41136 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728318AbeIBRaJ (ORCPT ); Sun, 2 Sep 2018 13:30:09 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Olga Kornievskaia , Anna Schumaker , Sasha Levin Subject: [PATCH AUTOSEL 4.9 15/62] NFSv4.0 fix client reference leak in callback Date: Sun, 2 Sep 2018 13:14:20 +0000 Message-ID: <20180902131411.183978-5-alexander.levin@microsoft.com> References: <20180902131411.183978-1-alexander.levin@microsoft.com> In-Reply-To: <20180902131411.183978-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: Olga Kornievskaia [ Upstream commit 32cd3ee511f4e07ca25d71163b50e704808d22f4 ] If there is an error during processing of a callback message, it leads to refrence leak on the client structure and eventually an unclean superblock. Signed-off-by: Olga Kornievskaia Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/callback_xdr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index eb094c6011d8..67903eeb2ca4 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -968,16 +968,21 @@ static __be32 nfs4_callback_compound(struct svc_rqst = *rqstp, void *argp, void *r =20 if (hdr_arg.minorversion =3D=3D 0) { cps.clp =3D nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident); - if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) + if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) { + if (cps.clp) + nfs_put_client(cps.clp); goto out_invalidcred; + } } =20 cps.minorversion =3D hdr_arg.minorversion; hdr_res.taglen =3D hdr_arg.taglen; hdr_res.tag =3D hdr_arg.tag; - if (encode_compound_hdr_res(&xdr_out, &hdr_res) !=3D 0) + if (encode_compound_hdr_res(&xdr_out, &hdr_res) !=3D 0) { + if (cps.clp) + nfs_put_client(cps.clp); return rpc_system_err; - + } while (status =3D=3D 0 && nops !=3D hdr_arg.nops) { status =3D process_op(nops, rqstp, &xdr_in, argp, &xdr_out, resp, &cps); --=20 2.17.1