From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 0CC7B35A38C for ; Fri, 1 May 2026 11:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777633342; cv=none; b=PIXM4Q59pEob74Pnj+/3ACz+IW5CAE+z5Prpnp/mhOm+YggrBnGZZembFHpTqhe+dvdi+vytk4EQPZs0MhLOBcTmEQHa3WJV4lX7ggsCXIFshRNKX1LAwlmAnHKPGnJJ+bDdY7afNbONKdFMTJ4RcQ/GB9rAD3XnlCFnMILLYvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777633342; c=relaxed/simple; bh=6q7Cse9LTZEajpIegGdnRfkT5EI8IG2GJIGVRzPO0tM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WuPzszAU1xPCQLhCJuGmR4J14TFiGfb1mo+2YISQlBoAIIOTZQ2k6U82q4scwNRLyzv3CbxIzZB8w/aOkoCc497FNf/z0WJDJ0zm/Rm6pdZmm+2ISz52MGcNVycjHzOWpe9UyTO9USYDsgcuTeEcSotGqzSasQjUtSGfMqumiFU= 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=BNjju8WS; arc=none smtp.client-ip=209.85.128.45 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="BNjju8WS" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-488a9033b2cso16312875e9.2 for ; Fri, 01 May 2026 04:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777633339; x=1778238139; 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=J+eCDUN5/k1aTUcp0ocOWEOuyZhFTl6ujThN0C1b1A0=; b=BNjju8WS4lnA/Alb5bTNhxbGspl/940t68iZBlNDpyqPt1F5lQc04bfTvt0/2vAOWk nthzTPpNDR/H6bqdX7T3urcyO97P1LP/tl1+CC3aSZE9uRrdSIlombaPWPrPS5+q0Ixu XRDZGZyQ7e4zmZIRtTzOwUuoINLT0Ak0Y4Q8Sv2S9WY+O423cVQNOPxysCTxejUXIeB3 iyMdwDG++oN0LGiBFq4nOZ8X1KC6jXFSkIEj0gLlHd/DT8gg/KE9TKcnTgssThmeyQYT u9t5X6r2Iosg0JsqNwMcy1zzPwTs6U4CD7S7KuNJu6DS/tk9gI9VrhH5AhJhvPqo7Zus GqFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777633339; x=1778238139; 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=J+eCDUN5/k1aTUcp0ocOWEOuyZhFTl6ujThN0C1b1A0=; b=DRxdbfTTkqFu436pGYQqWfnQec8WyQNuQ/2q1f/u3u2aHRY5iWbihFG4+oGdFlHOFQ urOfxrfo8nzIMw1XfUK5+6m2zR8nfY6bCI9ay1rQAS49hjUjspHquT7/6AOePdIFVDz6 DW3Nqo/yLyNDzgDINFzYtoF8a9AEL/BJDfd0BAEvCxPRXP8fPYLw4Bdx2N7P+oE2eAEg 5NxhvMhYvczx1ieM/9P4zzpLgaZSVuFto/XkKl+ZdL4l1KGVXQqKN91SHnMsFiklKP9p TObgEdhXyun1wdevLyzzsyqnfbsS4Q242V+LdQHJNj40XhNQBbSwetCksORqqUDVeyCb vsyQ== X-Forwarded-Encrypted: i=1; AFNElJ8wPC6kLiHW/YMXyv+qCGGZWbp82ySvbhQSfC0bsGAwJ/tsyWc5+Di96BInRMUL8qw67mriinn77fwBzOQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyjWLLHdJo0EiNCjyX6Ts/ziUhH0UPQzWRsJWImEOCEL+pZL3Oj Vjzg8tSK9ULcegmfgwCJzLgmlJfl0ItFg4s6ExYVPUvd2LiGW63IFr4= X-Gm-Gg: AeBDieu4Un+ZXtxwudI7iZGCEyLzjWMHrJv63Se3GYbylKnHUVCaGT1K3S71x0cYJ2K 9ETcKMS3oSgyt+b8i49z6pVZbmuoC9NzSxBzrredzgyIX6U0oioLHCdSBEjnopqmS+B3PCJRFAC PTna1AQNMi5FcY4gg8AeFx45gWSlWgi90TNMArCiH4GhPN+NlZxARtCM1Luh4nybD2hsvZaEXeh 8iTc6/BBTj5hdWE3ue4XHhI4H1Wp26cSH8quRxe73DUKnscGmxJGF/A1vJdl1E7mZYIkyUxNVg5 saO26zL+ZmkkD0tREIXdxOM/MvMhT3TRcAEqJpxlNI7lxjziS08uRPzy/83YtLJNhzKPfse8DW5 J0o+97pyNBfhuLk/RyOAmy+WyLwHbPyy0dXILGQ9iQxF+XA774iNz8b/0G9g/C1lO0DbbstHgRh jaHoE= X-Received: by 2002:a05:600c:a00a:b0:487:219e:42d with SMTP id 5b1f17b1804b1-48a8eb73a3cmr38267405e9.11.1777633339156; Fri, 01 May 2026 04:02:19 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a820c8556sm121627405e9.4.2026.05.01.04.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 04:02:18 -0700 (PDT) From: Tristan Madani To: Viacheslav Dubeyko , John Paul Adrian Glaubitz , Yangtao Li Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tristan Madani , syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com, syzbot+e76bf3d19b85350571ac@syzkaller.appspotmail.com Subject: [PATCH 1/3] hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length Date: Fri, 1 May 2026 11:02:15 +0000 Message-ID: <20260501110218.29906-1-tristmd@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Tristan Madani check_and_correct_requested_length() compares (off + len) against node_size using u32 arithmetic. When the caller passes a large len value (e.g. from an underflowed subtraction in hfs_brec_remove()), off + len can wrap past 2^32 and produce a small result, causing the bounds check to pass when it should fail. For example, with off=14 and len=0xFFFFFFF2 (underflowed from data_off - keyoffset - size in hfs_brec_remove), off + len wraps to 6, which is less than a typical node_size of 512, so the check passes and the subsequent memmove reads ~4GB past the node buffer. Fix this by comparing len against (node_size - off) instead. Since is_bnode_offset_valid() already guarantees off < node_size before this point, the subtraction cannot underflow. Reported-by: syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=6df204b70bf3261691c5 Tested-by: syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com Reported-by: syzbot+e76bf3d19b85350571ac@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=e76bf3d19b85350571ac Tested-by: syzbot+e76bf3d19b85350571ac@syzkaller.appspotmail.com Fixes: a431930c9bac ("hfs: fix slab-out-of-bounds in hfs_bnode_read()") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/hfs/bnode.c | 2 +- fs/hfsplus/hfsplus_fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c index 13d58c51fc46b..c00645a4a5733 100644 --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -41,7 +41,7 @@ u32 check_and_correct_requested_length(struct hfs_bnode *node, u32 off, u32 len) node_size = node->tree->node_size; - if ((off + len) > node_size) { + if (len > node_size - off) { u32 new_len = node_size - off; pr_err("requested length has been corrected: " diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 3545b8dbf11c5..10b2dda3f8044 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -600,7 +600,7 @@ u32 check_and_correct_requested_length(struct hfs_bnode *node, u32 off, u32 len) node_size = node->tree->node_size; - if ((off + len) > node_size) { + if (len > node_size - off) { u32 new_len = node_size - off; pr_err("requested length has been corrected: " -- 2.47.3