From nobody Sun Feb 8 21:05:47 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57154238C03 for ; Mon, 15 Dec 2025 23:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765841402; cv=none; b=C6zZfXaJCJxqUh1Dx/xgN3tjycJSjH5Ru8oFhxJOtXYkqs2TGPDrbP/50O0eTFbDlg5N9IZ65UmyDg+JIemBmc/KEfQjAduw3izUi+wVtqPZ+Emwuoa6WhzdrLV6zlXAr/63Yt/eKd7g/+wNNO3+ihdpnuRxfOWgiMNUiTtlY0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765841402; c=relaxed/simple; bh=F7JE9QiGIUk0dsOlDiTzS6MY+cht2x5y2KS8wLNpdRg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G0DTA7bwQwUeCgqNz4wqLVd3mSIbCQdC+w2LUgTnxCaQloC2vDVZ9G72tTeAp+j8Oej1mM/MttXWkQr9zePPbPM2KII6eYvOYhWGvKpaUKeFea/RbShP8gBeoSVsXzw2xMw/hdlsC1o+76JRxiKQpjFyeKjf5g3lT0k8oANOxu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=I1ctTXvS; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="I1ctTXvS" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2a0833b5aeeso40666755ad.1 for ; Mon, 15 Dec 2025 15:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1765841400; x=1766446200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FLOeKAYZ4D6KDiisR+mWJxUPrgWmfmlRLefOH4tEqCI=; b=I1ctTXvSrHSsAEeC1bTf+Yf7giwgi5o1bvXbdhRioY+4WUKTQkpcVSPZqPxwGa79ei Y1nWwO9tREfZrQzq3JqnkNXeCjuhvcqxlLFd6xeQ/QtglXejdg8hhs4jRNrdWpCQwWz4 QUTow9IrZGcFNtf0O8mz5rNHZSSz7076TQdqxKSSOOFnAR36X72OlpdHNI7/RS9+tG6p MbwAFv6ykzGcLOTeJttizZuqcl19EvE64l6pDU0nwmdAk54myXZAvrN97Q0SFKgS7uZv Mwar2nm50TzGbJBDPr8u/zg5cX99eBL16aj5CjlPvgZqClsUlV+U/dbORuhozwSxJ/vW P5Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765841400; x=1766446200; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FLOeKAYZ4D6KDiisR+mWJxUPrgWmfmlRLefOH4tEqCI=; b=oINXnwjJB40TPSQ+GIgctdIOxtIZm4qHz1FdQnX5xPRFNajp9TbKFkHi/ycB+K9HG+ jZsmjjaQdttxKxQ+CO0o8v63NocSIhkyrvyRvlaIYXNfkmY/rS4SKPEXWaN2BR1/nM3e 7brvuBA5tYZyMvsE8qmOFIC39fZYSG3r9KGUIV91UKdk9wzRpYn9KQpzTYckEbRWkZGH 0oLhVT7/gAKFKbsYSyvWGcdAk1CXUu1m0n5AoGeS2EYmd7eP4RfivDEmTSuid+z7N0vy oIBN6tt3aptS4ExCrDDil3ZmplB1W66qAXA6wTHPSqU+RDdiXhea4urpRzt10nMkOC4r QXzg== X-Forwarded-Encrypted: i=1; AJvYcCUIfBMayNe3NmfirEtGy5ZJKqAcblHztxgXQU21ggafVQjDo9QOmQULw3dW0cHP/UhIR8lA0leofvvtJuk=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ1jO1n2W9Ck2VDJAvHwhBf6Y2v7w7MV7+qzi+2+Zp4C5utCpl BoTu6Mba2JvCM2oPXRd7tutBU0pWCHIWh3GZ5YMkIAFXHiAa6TDDqYZJBjIBjYUtXQ== X-Gm-Gg: AY/fxX6/3BKaA1uNb2KESHeT3aQkYZPgk8ne2bFHXDPHSR2bQeg6+jdiDTgM+QuvsWB hk2WGd0KnbCcFRK/2DwHQZwRBx59bYNgjWDq5ddOWEUvA9rX6K/Lkz7MgJjaUTwqC0N6xCfwQjQ rBUe4RO5vbJO/ZZV5PpiUXbYONiKAGVnm4KA4yPlP4WwWwJcVVo21c/flcKpgaxhv+ytspOPz08 XkWvIEt1F+5NxmBxDnvk4g3OMdIKjKLP33Mj+R+D2grlIvFSLFZ71gpgQVopMjCTJzBM8DStAoY jSJ2jongr6ABpkPSQVVUluetcmC925idmKVpDJei8eIbAz8dIVAcxjj/JwNu9ZzpBqhvlq9Q9ii Fyp27swAD1fJAXtBvoQyPcQlkvcUGjooNiLs5bnUPN84JEEFKCXYS8zC3UPFfR3PC92ncnMVgI9 z2nk5vIcuSZ+r0EMCUv2ivhOEUXjDmKDMaQ0tuBmb9HzFq2tol+DpFrh4wfK8Z X-Google-Smtp-Source: AGHT+IEInd/J4iCW9bzJbIckME8iT6lYeT27Pbvwimmk1pTycb33sjjRZDQi2KQTX1Q2znKpxNeZuA== X-Received: by 2002:a05:7022:ea45:b0:11b:9bbe:2aac with SMTP id a92af1059eb24-11f34c15dccmr6911239c88.40.1765841399498; Mon, 15 Dec 2025 15:29:59 -0800 (PST) Received: from will-mint.dhcp.asu.edu (209-147-139-190.nat.asu.edu. [209.147.139.190]) by smtp.googlemail.com with ESMTPSA id a92af1059eb24-11f2e153e7esm39456937c88.0.2025.12.15.15.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 15:29:59 -0800 (PST) From: Will Rosenberg To: Cc: Paul Moore , Will Rosenberg , syzbot+6aaf7f48ae034ab0ea97@syzkaller.appspotmail.com, Greg Kroah-Hartman , Tejun Heo , Oliver Rosenberg , linux-kernel@vger.kernel.org Subject: [PATCH] fs/kernfs: null-ptr deref in simple_xattrs_free() Date: Mon, 15 Dec 2025 16:26:11 -0700 Message-Id: <20251215232612.3880995-1-whrosenb@asu.edu> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There exists a null pointer dereference in simple_xattrs_free() as part of the __kernfs_new_node() routine. Within __kernfs_new_node(), err_out4 calls simple_xattr_free(), but kn->iattr may be NULL if __kernfs_setattr() was never called. As a result, the first argument to simple_xattrs_free() may be NULL + 0x38, and no NULL check is done internally, causing an incorrect pointer dereference. Add a check to ensure kn->iattr is not NULL, meaning __kernfs_setattr() has been called and kn->iattr is allocated. Note that struct kernfs_node kn is allocated with kmem_cache_zalloc, so we can assume kn->iattr will be NULL if not allocated. An alternative fix could be to not call simple_xattr_free() at all. As was previously discussed during the initial commit, simple_xattr_free() is not strictly needed and is included to be consistent with kernfs_free_rcu(), which also helps the function maintain correctness if changes are later made in __kernfs_new_node(). Reported-by: syzbot+6aaf7f48ae034ab0ea97@syzkaller.appspotmail.com Fixes: 382b1e8f30f7 ("kernfs: fix memory leak of kernfs_iattrs in __kernfs_= new_node") Signed-off-by: Will Rosenberg --- Notes: This bug was introduced as part of a patch I made, fixing a memory leak in the error out case. =20 I apologize for the oversight. Further fuzzing revealed the bug, and after checking, I found that syzbot detected the same issue. 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..90b7cbe9048c 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -681,8 +681,10 @@ static struct kernfs_node *__kernfs_new_node(struct ke= rnfs_root *root, return kn; =20 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)); base-commit: d358e5254674b70f34c847715ca509e46eb81e6f --=20 2.34.1