lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  6 Jul 2022 16:22:37 +0800
From:   Jianglei Nie <niejianglei2021@....com>
To:     djwong@...nel.org, dchinner@...hat.com, chandan.babu@...cle.com
Cc:     linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jianglei Nie <niejianglei2021@....com>
Subject: [PATCH] xfs: fix potential memory leak in xfs_bmap_add_attrfork()

xfs_bmap_add_attrfork() allocates a memory chunk for ip->i_afp with
xfs_ifork_alloc(). When some error occurs, the function goto trans_cancel;
without releasing the ip->i_afp, which will lead to a memory leak.

We should release the ip->i_afp with kmem_cache_free() and set "ip->i_afp
= NULL" if ip->i_afp is not NULL pointer.

Signed-off-by: Jianglei Nie <niejianglei2021@....com>
---
 fs/xfs/libxfs/xfs_bmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 6833110d1bd4..0c99726c0968 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1088,6 +1088,10 @@ xfs_bmap_add_attrfork(
 trans_cancel:
 	xfs_trans_cancel(tp);
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
+	if (ip->i_afp) {
+		kmem_cache_free(xfs_ifork_cache, ip->i_afp);
+		ip->a_afp = NULL;
+	}
 	return error;
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ