Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2034601rdb; Sun, 24 Dec 2023 13:31:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDkdGTThAqgL9c5JbSvpAvMH0bIFDRXfptEycdLXDJJi+ob4c9olLAMzSkPSsyABw1irLj X-Received: by 2002:aa7:da49:0:b0:551:c988:1e52 with SMTP id w9-20020aa7da49000000b00551c9881e52mr3061074eds.62.1703453478973; Sun, 24 Dec 2023 13:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703453478; cv=none; d=google.com; s=arc-20160816; b=dPjmg+bUiu042yTIXqTuMTVVz6BQJy7+5pQm1U7vr4671G9+ll/ytisbNjnJ4KHxU9 uyxNDFbaZeE1jwCSz6SkJtAkvjFdsmqVw+tGPkGG5TjytH34y2kJuqLyINW4HgR84BqX dNCJatUHX1tMsqOPWGZvJkgSH5j3KP5iZOJ4dFqxk20YmlPY/qHN0WYUCmU4DKFuDavw 5iDiolwm0Ed3g0jmP0vJw7eXV31IJR2vgCzXwQjpJm8k2F4SF62W4z9ZAcARl3NF7OMh MEOy2INUxYixPJBsOpx44Sb7J4Z8T1A7yGy98yjODiIUM+A8yudB/9s4KEUwBOXZb5Pt OW6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Is5Oeip08kqs8kmkvCAmLi2e2vHdOU++6TXLAX4G6K4=; fh=eaIvFPzeARZCWYRHKmu4+YXa3KPUrfFk6WRFD3rRSv4=; b=vnaAQLBq5EdCm4IFAyACyn3tLvU7dLTq0yzcM5SrF/oBK1tA4MyaCISFP5/Rp3Vgsq 8hNo7COylYgcD1pPGLleOOCbBibBVcbRfSxCD4waIg26f3O1m6qCVzTWalb1dMuA8W+N lwJn6InVbPR/a1rXD52qUoOJjo+b4Yww6QuBdp7ZarPM746hBNGe9lwINZzkH9gC1U8Y CeS7VbHh2xXMo8YqqKQ9bYKOfdYyNhzgpjlpdi9TNnu9o+qKmQwdRzcpaRFTj7FWERgb M5rLXsDfgAccAoD8B0rC7ykSHAKcbXDWELYQ9dSIqZMClm1KRuvHdPqdXp/ix0gy+cmE O3iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BhoQfGkU; spf=pass (google.com: domain of linux-nfs+bounces-799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 22-20020a508e56000000b0055411420e18si3856133edx.232.2023.12.24.13.31.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 13:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BhoQfGkU; spf=pass (google.com: domain of linux-nfs+bounces-799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B82311F212D2 for ; Sun, 24 Dec 2023 21:31:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DA2BEAD9; Sun, 24 Dec 2023 21:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BhoQfGkU" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C6F010788; Sun, 24 Dec 2023 21:31:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44CDDC433C7; Sun, 24 Dec 2023 21:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703453463; bh=V3y8H0LCCFvixptpsJ19a+YP7/R9X0uB52si6Uy778I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BhoQfGkUjBTljkttuo6xzfiFBCBPrCrulCgOE4WtrxGdlND12xvTWzwlnY7yfU0Rz b8sliqRHJ/VlxfQMIIHIojLaK7jLhObzgW3zWPOscmdTyOCiOEf48qEsv2Y71KVkdD zV0/0us9JWfp+bSKHt1tHEHivMwMajDJb13VExpUy96ybpOXZVlkX7boiDSdtZ1BjK +AfRjS0v2MQJtexT9SjkBsCIao6r3UAxqX5hdQdoC59Y6BBdW2hLLWfo2nboB7LFSb /gV6Z+fPthMIMO6lAh5mBC8QEPCJ/5MRm1FoTzOvAGheXNJoJHZtmf5/FoNL7j180n MgRp+AV/clsGg== Date: Sun, 24 Dec 2023 21:30:57 +0000 From: Simon Horman To: Zhipeng Lu Cc: Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simo Sorce , Steve Dickson , Kevin Coffman , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] SUNRPC: fix a memleak in gss_import_v2_context Message-ID: <20231224213057.GC5962@kernel.org> References: <20231224082035.3538560-1-alexious@zju.edu.cn> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231224082035.3538560-1-alexious@zju.edu.cn> On Sun, Dec 24, 2023 at 04:20:33PM +0800, Zhipeng Lu wrote: > The ctx->mech_used.data allocated by kmemdup is not freed in neither > gss_import_v2_context nor it only caller radeon_driver_open_kms. > Thus, this patch reform the last call of gss_import_v2_context to the > gss_krb5_import_ctx_v2, preventing the memleak while keepping the return > formation. > > Fixes: 47d848077629 ("gss_krb5: handle new context format from gssd") > Signed-off-by: Zhipeng Lu > --- > net/sunrpc/auth_gss/gss_krb5_mech.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c > index e31cfdf7eadc..1e54bd63e3f0 100644 > --- a/net/sunrpc/auth_gss/gss_krb5_mech.c > +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c > @@ -398,6 +398,7 @@ gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, > u64 seq_send64; > int keylen; > u32 time32; > + int ret; > > p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags)); > if (IS_ERR(p)) > @@ -450,8 +451,14 @@ gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, > } > ctx->mech_used.len = gss_kerberos_mech.gm_oid.len; > > - return gss_krb5_import_ctx_v2(ctx, gfp_mask); > + ret = gss_krb5_import_ctx_v2(ctx, gfp_mask); > + if (ret) { > + p = ERR_PTR(ret); > + goto out_free; > + }; Hi Zhipeng Lu, I think you need to handle the non-error case here: return 0; > > +out_free: > + kfree(ctx->mech_used.data); > out_err: > return PTR_ERR(p); > } > -- > 2.34.1 >