From nobody Tue Jun 16 01:18:59 2026 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 94757303C8A for ; Wed, 15 Apr 2026 01:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776217437; cv=none; b=nJ/4C7S3ADEYl2RJoQvVS0as6wBQwEFOHL0ipBavNrRzN1AnJIxI36g1SGQD5KNoqeIkLfCh60cmYMw/s5aziuulhW6jne2TnrpTX233d9N9RnZ8ihZc1dwUSfmV8iKLZ8pFNbn6WJUqO69AyQbOulUl9dxaYGX6T1dRGNPG1oA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776217437; c=relaxed/simple; bh=rXz81SC4dwM8OJTAE7oRDTvv3L0eXjRm0qZ5WY2yDS0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=joV/TUNP9JzSDvcDT4/7eWTH2K7f4SLbe+qwmhT3v0gW8ip3aXye+iVZylQvMFXZ8iFoEsvI6QCbRLU0Km4aIRq0bN/LKp0Ja2K1VH12cszX5Moik5gVs8O8AuyllUdZrxg1KAGnqN/WdpRPXFxeKpXrF6QHqubcQc1xGMEWsOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OeWEXNkh; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OeWEXNkh" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-35d9f68d011so4000279a91.2 for ; Tue, 14 Apr 2026 18:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776217433; x=1776822233; 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=PVlced8ZEbgtrqydV7q14rWr2DPIXOWW1lsRdxcg6Po=; b=OeWEXNkhlKJixQCDgGjok3V71VwRzAq6wLwLUNP+T2x+5W6XmMJTz3wGSk0Nt5kI4q m4SkpOGCcdzciPdaC7PgGLh60GL+MIUOGTPvOBC34eyItJKw+bUYKeQGpPWZQY7X1uRg OZKP2zB/ZPF8pgrzEnJT1diD+arPf3LOa2F4iWOa5kn53ps0jzN/em/8/4LIvLeEMaFh kSLMDbF6Mh2d1Fo+egcEFGIIk2r12MpwFj5+KInfHLAO7ICqoT6d9JOwyaGIKJ3zd3Jd xj1LPhooPWQGKxBg7MIUbQSBixtUMCcWaegcNQ1zkjkVSAHZY6Z3UXar1FeoqzaDlk+Y LI9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776217433; x=1776822233; 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=PVlced8ZEbgtrqydV7q14rWr2DPIXOWW1lsRdxcg6Po=; b=pbuWexylTPKJoKglpUnH22nyfM4dlhuWlpNGxFSLOCvgSJUgL8uYtFpqSy+h5TzG8C Jl5WEAwiGxb6RmRjiJjl4Ue5qUBidC4dHG6WaKNw1+KYrtx0zybPpPHDc/6dYKX8lgR/ pK9HDKR8hLVsmyB++I28v6NbVIx+4G8pFkPOeFcFoKWCM06vWxa2eD3FrVXisP5/TtBQ K8hLyhnI8e0tq8uVCr6i0LBbYKyoMR5nnypqY63mRN95+sRbk8XOdDhLDRugVX4OfyXl +lqawa15o73mTK2AkHTBxpIwC73jngo+imKFFqnxmeoE33GLxX6r10f058jR8R/htNtj xAgQ== X-Forwarded-Encrypted: i=1; AFNElJ93SGsGH2nlsO8g2K6joZswT8uXe/QlD7QUBCYrjMofP6MwvbuDhkpPJlwNdnRZy1OewtepV61OtKEyVsw=@vger.kernel.org X-Gm-Message-State: AOJu0YyZoG/QCSoKRg4pRx/dG2n046BbG3BHQJWd4XBJtfxJ18j6+tEj avSG1d6ecG3id1tUSqrOGKYOyh6VYPOVci7tbc6owzXqTwycy2KhTf6G X-Gm-Gg: AeBDiet3C5YS9aurKThEds6L1vz6ximc/mfSPRSVHADaiRMA3NQHshupG2sX8wdO2gV 3+v1hz0CbZqbl+PGQJ/rUl7CQ9Ti19QmfJETdgvB4CLOv6Au10IJ2alyPIuNa+5cS/czLL/ekG3 rL0gA9HXbcbQdnHjFtCQN0jJnpAk7dE7b6sDORIa0ijQn+7rz6ALcmISmnTZ1juphYd+2cnN+Bc c3i0CLBJY7B16Rjc5YSpha21QsM4pVP0cs8KYTt70oRYIm1zkMgIVAMtw+TjrseXKtgbFLGkWAo izWAQUoIasn9XGRM/camjH5AJGXCC7XgFOBqcSS+rBS3QvNyL+B0OIHG0ucp6MjKitW0pK9kF+M vPPHxzTxoKJrp3eUCpcQRvT/JDfVO/71eWT4qJEi3ijvsXwlNZ8S/kiebEquky7hdtKR17VXMhx 6okDXD3p+U3LrW2Jn04I1r8POeMegF5QBhxYOeoDaJ7djhMpYQJHgZNh1dSOkodj8wc+If3RkjL 7Y12AHFLpmGn99r X-Received: by 2002:a17:90b:4d88:b0:35f:ba3f:e04e with SMTP id 98e67ed59e1d1-35fba3fe3ddmr9227139a91.11.1776217433447; Tue, 14 Apr 2026 18:43:53 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:383f:836d:58a:d945:24a2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35fd2010246sm393749a91.6.2026.04.14.18.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2026 18:43:52 -0700 (PDT) From: Deepanshu Kartikey To: slava@dubeyko.com, glaubitz@physik.fu-berlin.de, frank.li@vivo.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com Subject: [PATCH v3] hfsplus: fix null-ptr-deref in hfsplus_cat_write_inode Date: Wed, 15 Apr 2026 07:13:45 +0530 Message-ID: <20260415014345.77796-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 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" When a corrupt HFS+ image is mounted where the hidden directory is absent, hfsplus_fill_super() handles -ENOENT from hfsplus_get_hidden_dir_entry() silently and continues with sbi->hidden_dir left as NULL. hfsplus_link() and hfsplus_unlink() call hfsplus_cat_write_inode(sbi->hidden_dir) unconditionally without checking whether hidden_dir is NULL, triggering a general protection fault caught by KASAN as a null-ptr-deref at offset 0x28. Other call sites in dir.c already guard against this by checking hidden_dir for NULL before use. Apply the same guard to the two unprotected call sites in hfsplus_link() and hfsplus_unlink(). Changes in v3: - Correct fix location: guard sbi->hidden_dir before calling hfsplus_cat_write_inode() in hfsplus_link() and hfsplus_unlink() in dir.c, as suggested by Vyacheslav Dubeyko. Changes in v2: - Fixed commit message: hfsplus_delete_cat() is called from multiple callers, not just hfsplus_unlink() as incorrectly stated in v1. Reported-by: syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dc0ba772a362e70937dfb Tested-by: syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey --- fs/hfsplus/dir.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index d559bf8625f8..a7feef53d8cb 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -362,9 +362,11 @@ static int hfsplus_link(struct dentry *src_dentry, str= uct inode *dst_dir, if (res) goto out; =20 - res =3D hfsplus_cat_write_inode(sbi->hidden_dir); - if (res) - goto out; + if (sbi->hidden_dir) { + res =3D hfsplus_cat_write_inode(sbi->hidden_dir); + if (res) + goto out; + } =20 res =3D hfsplus_cat_write_inode(inode); =20 @@ -431,11 +433,10 @@ static int hfsplus_unlink(struct inode *dir, struct d= entry *dentry) out: if (!res) { res =3D hfsplus_cat_write_inode(dir); - if (!res) { + if (!res && sbi->hidden_dir) res =3D hfsplus_cat_write_inode(sbi->hidden_dir); - if (!res) - res =3D hfsplus_cat_write_inode(inode); - } + if (!res) + res =3D hfsplus_cat_write_inode(inode); } =20 mutex_unlock(&sbi->vh_mutex); --=20 2.43.0