From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 5B60432BF44 for ; Tue, 5 May 2026 11:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777979587; cv=none; b=oMuCg8tKOaPQMPA1ydRNjZRPkHkl/fSTo7WvIMU3qVHmF8WM4hPFwwJVm2RrJd/KVM3n5EeYXaVar5WUbLuP9XGhQMDF/aWCxYpuck2qI2ZeEtfO0LOQ9pTiCkWz08K7bux6/N2Tv5TUkT5+Uxh11EQCe1ppSSmNLEFITehYDUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777979587; c=relaxed/simple; bh=bL0oPCKQKfXVk7I7nA9PujVriVuw8xDtuerHvQi6xV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMe26XHY/GyOrP3NPJQAcdp56J0HesCEh9bCNiFh+8DnEKEMMdEq4AaG/bPflmPl7R21pxoG4+EMv0oZuuJyJAq5+stbS4ghXRqHq3YxSypksx/fC5gXvZvZs7XByrjK8uBPsQjdA4QGs6AQn5EMEETLdojopY0SwE5JGZsZ/Js= 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=WME1J2Lt; arc=none smtp.client-ip=209.85.221.49 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="WME1J2Lt" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-44da2de25f3so1430604f8f.1 for ; Tue, 05 May 2026 04:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777979582; x=1778584382; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZeJL4p/1hA/fUCWuNw2juyWWdFBKuFTt+VDUIZEBMPM=; b=WME1J2LtB8ZKOBfr/9VbSTbP+kzWMN+UqRYqVeojqyQvHpGy99C/lRBV9mqr/KorsK +OQJRl8KJ/j5kshMpD1qET+r1ZU4GevJsAeh4ZuYhks10m/vzh5ChFQy3nxqG1UaJzd4 khzspjHx3kUmycZb021adyM1wXH2wNl3pEu2vbGIY1pUeE8yJlFKq2OL+UkiJfeLkGwk o1CVlFFPRd7SCbWbFAUMIoSfFxBUbf6uiU9kYp0PD1WUY7zzw+224S5oYrFDMsUxXVjz Nif1Wl9ChrQtfZQlMLVhVwd5JCQzKwXG/NdY88Qegq/dVF+P5Y6hG+zDiFv6u1VYQAWm +uoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777979582; x=1778584382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZeJL4p/1hA/fUCWuNw2juyWWdFBKuFTt+VDUIZEBMPM=; b=I4/ok/5iEssVZGHVrX9OJKV2IHRNOt61T/9flxspuwIRMqpA1HAJ9EyrkIhwhklWOu U2Wt8An+DClwdIuuqCcNRYXEXBrWBjrPPjiJSZoK8Le1+961XdCb41o6bkPk8ISBKu/c sJLOvs322Kw5gCTj+QgihCLRa7Kpg4kyHvKKIVNs3DUIg/eVhjvLjeZWx7pPR3mBJaTT xF5eJT0gVYcLRMKXPUn6IMnPuN4LTUAXnd1JDl0yZHCAx6cNbX4LD7wOZWXyP4Ml5+rb ZJmTl1ovmu/1276Z8eoCbiY6LM5K3MvsFdSwrHELvbjH5gbwNnducEciUZ38Vf+Toe28 Ra7Q== X-Forwarded-Encrypted: i=1; AFNElJ9xF4YDHcgZbPQ2Vafw9WCMCi4RhcfqXHmJucdT2vkGwLSgdTMqFW+czoJtbFNUVR4FAz3NRjRrrP83LY4=@vger.kernel.org X-Gm-Message-State: AOJu0YzN421ETIz3ZaYbHc6DtNkl38BiI9pnQvlA8onnhjGvPdb1AQMp klF5s2RWFfLGG90SXDeUfldjBrsjmJRFKdCK2RdAUQGLbw2znTkhtx2exWX+ X-Gm-Gg: AeBDiet1djk6LOpQj8mjh4zXWb1L/hKP/93yayMgSx2QYsXYQvH7r00LuvvGM6B40VA HxuZtSsQxTB3mH6mc17pXgjRp0FB6zqhnW0LZy6PZRc15Bxjg6YfQsEJtzIZ9IBLRjgm72Y8435 wZyEGb1d6qx3HW6Fu4HyS2i1JHtoIAHOeoBSTHbJbwz6vmsiR+AhVicTuOAwPwCISog8SCysi9O OFM97CKFMEXIHTHnPM8x1GByzVJ1i4DLxKPCZg6p1UXDZPzJSfKLdhtlrMrHzQt1o5dgha3X2iP AZSk6wz3f+XZL8GzNGi5m/BNwPaSArQTTtQIcxCEkhTqDcsFtFh/jaeq1+GIhh5Lc//KcDAGA7p VWNMgVZW5M6ryfM13kmytR5vDZqzDZ7i3IMYSmGcOY7/aItkxPj06tOSQqu6p3d4dbuUEnGnvNi lrJ4k= X-Received: by 2002:a05:6000:1acf:b0:441:2473:c30a with SMTP id ffacd0b85a97d-44bb5c425d4mr23628093f8f.31.1777979582334; Tue, 05 May 2026 04:13:02 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45052a488d8sm3786183f8f.12.2026.05.05.04.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 04:13:01 -0700 (PDT) From: Tristan Madani To: Viacheslav Dubeyko Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length Date: Tue, 5 May 2026 11:12:58 +0000 Message-ID: <20260505111300.3592757-2-tristmd@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260505111300.3592757-1-tristmd@gmail.com> References: <20260501110218.29906-1-tristmd@gmail.com> <20260505111300.3592757-1-tristmd@gmail.com> 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 widening the addition to u64 before comparing against node_size. This prevents the u32 wrap while keeping the logic straightforward. 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..9571f33b91085 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 ((u64)off + len > node_size) { 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..0e4268de9e60e 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 ((u64)off + len > node_size) { u32 new_len = node_size - off; pr_err("requested length has been corrected: " -- 2.47.3