Message ID | 20240216134541.31577-1-a.burakov@rosalinux.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp524394dyb; Fri, 16 Feb 2024 05:53:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUC7KJUMr3lDq503Pi6qGAB0RYa0FHK+z1Z85PJIrqB/0/dtkhugttAE0HCLPi2JYMyBwsaLDF/C4euAKlxrflLkGJnZQ== X-Google-Smtp-Source: AGHT+IEjwoDv8JydoiNcgZY0SbvbNF+rXxqB8t/goTLdVNMumscWOHpM8zWrev4Ou6ngd4bw9wVn X-Received: by 2002:a17:90b:1245:b0:298:d1ee:17fb with SMTP id gx5-20020a17090b124500b00298d1ee17fbmr4982487pjb.31.1708091621462; Fri, 16 Feb 2024 05:53:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708091621; cv=pass; d=google.com; s=arc-20160816; b=Gl5XAyyxcc4/tIhFbDxzjfJML4S+ydz2kqSFLvUgTe26ozWFfLAGDi5ocUbojILTL6 rDedlicb9btq3elH2h2E0nkd3gGqtODGI1mwdrEZxlKP7JHHAmQO5f+XMWHqL7BrKfCs 1Q6MJJfPbiJ75ikYzH6HAwKhXmpxYyg1MEbxsjqC9m6m8/pxcm/tDrDaWVwJua5RkWIK WVVHNQa7bQtLmOYJ18VZS0QTWbcg6Auo+a7KBowYEERo6/2hljcRiWN6GfiwW84tzrc3 CMsn8UpXTVBbPdu4HVBLGCtzcEztTJGNLkhKMhQpRNCmSTJ8kswELDlmh4rZDE1hCB5e CyQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=qPIBi6C+A8vJ3oyRznET/i8fe773IKKnMw8e+TueiO0=; fh=MnpLgSGxfZXtTlBK39ngcZTjm3LAy/BAb4vEB/eFJiY=; b=qu2Cm8/TwaZmdDykmRxg13+OaoPOCKoC9ZwzrSuAJDcBAocMoKbgbsthygYMEWGmLd ZSiIcsdxHoc29z4QBuXjuYwp90ld+KOcJuMUXoz3LlUC6loBzjjzYBlEPxLXBhM5Pm/i QoXsBKDfBxAS9EXRcrUggguR33CZj16HCPtWBkm09fq5ixZWIHtV7tC9h/oroprgEbfi 15gkgWFnwPkGQrk1yAncq7saaLTcaSYJdWKynJxgwy1X3KJSA3wJS5s2XlROpj9F+UKy XLqoYbKYQ+s8Zi0ZftEt+WIA6H6B9RIxY9XAQV3oN8aPK43bHFJeJ1iBCp683V7xnQHT aD6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=UG3raTfE; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id pq9-20020a17090b3d8900b00296f87a7ae4si3204100pjb.107.2024.02.16.05.53.41 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 05:53:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=UG3raTfE; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68661-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 41ADDB21890 for <ouuuleilei@gmail.com>; Fri, 16 Feb 2024 13:46:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A94C812C52A; Fri, 16 Feb 2024 13:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b="UG3raTfE" Received: from mail.rosalinux.ru (mail.rosalinux.ru [195.19.76.54]) (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 630A612BEB8; Fri, 16 Feb 2024 13:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.19.76.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708091193; cv=none; b=g3thNDvllvJ3sKEjfeLFXlWTLz2HsqVUFoV6NC+ZOtJruMmEjSx9tQBR3T+edAQrwLQMM0d6rtQFznWOvlEYPCW0il1qo1LXO6L3axLL4rsHlUO59f8bLpPHWIMjS/ZxkG47FluujbCGLOkvugcc6zQcWVvbrZlMlO7L8XpMo0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708091193; c=relaxed/simple; bh=yvpJWuM60ZPIcyXXM0SB7Q+oj//ZjvAfrXM/VqE+HUY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UzyVYmZQNH2/10RJTkoUWskFSFA/ZI3sR/uW43GXweMQky/3l5Xd/+pkR/xzEkeuQ160xMljx3qweLq2xtKzTPKsaxbKJx4rJQYe3AjytVSqKbopnlJ0qMZOS5HYwf582mA3jd+n77wrrBsz69Aou7FKo3dsWbs9ByjbP+1I2co= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru; spf=pass smtp.mailfrom=rosalinux.ru; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b=UG3raTfE; arc=none smtp.client-ip=195.19.76.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rosalinux.ru Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id DD0DCCFEFE864; Fri, 16 Feb 2024 16:46:23 +0300 (MSK) Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id leNxKGuf2m42; Fri, 16 Feb 2024 16:46:23 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id AEC77CFEFE867; Fri, 16 Feb 2024 16:46:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru AEC77CFEFE867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1708091183; bh=qPIBi6C+A8vJ3oyRznET/i8fe773IKKnMw8e+TueiO0=; h=From:To:Date:Message-Id:MIME-Version; b=UG3raTfEkdR2YHFEaBj4ZpgMn2S7qe6nkNs2LcVRPyWWWJcrusj15hZbMNIFA3fsY 0tncMFqDBQjyFxzgSnCLsprNtLtAN1Sx/zk5mtwz0mPBKAgB55cDUlcxkXGagIAZMv SR1r3Wkr8avxvwuRrKeHl/f/qTWwg3YOTuvyE40lPqaU26oq/YiX5v0e6aOaxH1qu2 kVoz+bYDyX9PiuhicXEp0/iqgxE/p9e2rBs3VXsKDB0my4z3oZmicHnzBHvUzNpGsD E8DNAQNKAd8VfnCusP7va9Jx7Hv3llXF50fN3MDXcr9NerRfWX5jmhc2Olf+ZVM7ij vwCCSkH4V7gaA== X-Virus-Scanned: amavisd-new at rosalinux.ru Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id C84PylsAgnwt; Fri, 16 Feb 2024 16:46:23 +0300 (MSK) Received: from ubuntu.localdomain (unknown [144.206.93.23]) by mail.rosalinux.ru (Postfix) with ESMTPSA id 4B700CFEFE864; Fri, 16 Feb 2024 16:46:23 +0300 (MSK) From: Aleksandr Burakov <a.burakov@rosalinux.ru> To: huck Lever <chuck.lever@oracle.com>, Jeff Layton <jlayton@kernel.org> Cc: Aleksandr Burakov <a.burakov@rosalinux.ru>, Neil Brown <neilb@suse.de>, Olga Kornievskaia <kolga@netapp.com>, Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] nfsd: fix memory leak in __cld_pipe_inprogress_downcall() Date: Fri, 16 Feb 2024 16:45:41 +0300 Message-Id: <20240216134541.31577-1-a.burakov@rosalinux.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791063880209590722 X-GMAIL-MSGID: 1791063880209590722 |
Series |
nfsd: fix memory leak in __cld_pipe_inprogress_downcall()
|
|
Commit Message
Aleksandr Burakov
Feb. 16, 2024, 1:45 p.m. UTC
Dynamic memory, referenced by 'princhash.data' and 'name.data',
is allocated by calling function 'memdup_user' and lost
at __cld_pipe_inprogress_downcall() function return
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 11a60d159259 ("nfsd: add a "GetVersion" upcall for nfsdcld")
Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru>
---
fs/nfsd/nfs4recover.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Hello Aleksandr, On 24/02/16 04:45PM, Aleksandr Burakov wrote: > Dynamic memory, referenced by 'princhash.data' and 'name.data', > is allocated by calling function 'memdup_user' and lost > at __cld_pipe_inprogress_downcall() function return It is not actually lost. If nfs4_client_to_reclaim() fails and thus returns NULL - this error case is already properly handled. If nfs4_client_to_reclaim() succeeds then reference to the memory in question is passed to crp->cr_name.data and crp->cr_princhash.data correspondingly, and crp->cr_strhash entry is added to the list associated with nfsd_net. In this case the memory is supposed to be freed by nfs4_remove_reclaim_record(). See comment for nfs4_client_to_reclaim(). So I think the patch just introduces a double-free. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 11a60d159259 ("nfsd: add a "GetVersion" upcall for nfsdcld") > Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru> > --- > fs/nfsd/nfs4recover.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c > index 2c060e0b1604..02663484782d 100644 > --- a/fs/nfsd/nfs4recover.c > +++ b/fs/nfsd/nfs4recover.c > @@ -850,6 +850,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, > kfree(princhash.data); > return -EFAULT; > } > + kfree(name.data); > + kfree(princhash.data); > return nn->client_tracking_ops->msglen; > } > return -EFAULT; > -- > 2.25.1 -- Fedor
On Mon, 19 Feb 2024, Fedor Pchelkin wrote: > Hello Aleksandr, > > On 24/02/16 04:45PM, Aleksandr Burakov wrote: > > Dynamic memory, referenced by 'princhash.data' and 'name.data', > > is allocated by calling function 'memdup_user' and lost > > at __cld_pipe_inprogress_downcall() function return > > It is not actually lost. If nfs4_client_to_reclaim() fails and thus > returns NULL - this error case is already properly handled. > > If nfs4_client_to_reclaim() succeeds then reference to the memory in > question is passed to crp->cr_name.data and crp->cr_princhash.data > correspondingly, and crp->cr_strhash entry is added to the list associated > with nfsd_net. In this case the memory is supposed to be freed by > nfs4_remove_reclaim_record(). See comment for nfs4_client_to_reclaim(). > > So I think the patch just introduces a double-free. Agreed - this patch is incorrect. Thanks, NeilBrown > > > > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > > > Fixes: 11a60d159259 ("nfsd: add a "GetVersion" upcall for nfsdcld") > > Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru> > > --- > > fs/nfsd/nfs4recover.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c > > index 2c060e0b1604..02663484782d 100644 > > --- a/fs/nfsd/nfs4recover.c > > +++ b/fs/nfsd/nfs4recover.c > > @@ -850,6 +850,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, > > kfree(princhash.data); > > return -EFAULT; > > } > > + kfree(name.data); > > + kfree(princhash.data); > > return nn->client_tracking_ops->msglen; > > } > > return -EFAULT; > > -- > > 2.25.1 > > -- > Fedor > >
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 2c060e0b1604..02663484782d 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -850,6 +850,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, kfree(princhash.data); return -EFAULT; } + kfree(name.data); + kfree(princhash.data); return nn->client_tracking_ops->msglen; } return -EFAULT;