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]
Message-ID: <f5fe5674adee792e663a86d680d836c5@kernel.org>
Date: Sun, 01 Feb 2026 07:05:50 -1000
From: Tejun Heo <tj@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Will Rosenberg <whrosenb@....edu>, Oliver Rosenberg <olrose55@...il.com>,
 杜义恒 <duyiheng@....edu.cn>, linux-kernel@...r.kernel.org,
 stable@...r.kernel.org
Subject: [PATCH] kernfs: fix NULL pointer dereference in __kernfs_new_node()

Commit 382b1e8f30f7 ("kernfs: fix memory leak of kernfs_iattrs in
__kernfs_new_node") introduced an err_out4 error path which frees iattr
when security_kernfs_init_security() fails. However, iattr is only
allocated by __kernfs_setattr() when the node has non-default uid/gid.
If the node uses default ownership, iattr remains NULL, and
security_kernfs_init_security() failure would cause a NULL pointer
dereference when err_out4 tries to access kn->iattr->xattrs.

Add a NULL check before freeing iattr.

Fixes: 382b1e8f30f7 ("kernfs: fix memory leak of kernfs_iattrs in __kernfs_new_node")
Cc: stable@...r.kernel.org
Reported-by: 杜义恒 <duyiheng@....edu.cn>
Signed-off-by: Tejun Heo <tj@...nel.org>
---
 fs/kernfs/dir.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 5c0efd6b239f..29baeeb97871 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -681,8 +681,10 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
 	return kn;

  err_out4:
-	simple_xattrs_free(&kn->iattr->xattrs, NULL);
-	kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
+	if (kn->iattr) {
+		simple_xattrs_free(&kn->iattr->xattrs, NULL);
+		kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
+	}
  err_out3:
 	spin_lock(&root->kernfs_idr_lock);
 	idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
--
2.47.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ