From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C44C34753B for ; Thu, 7 May 2026 22:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778191333; cv=none; b=apP6SBqHGCmaFsIXA6TBnrXk/bZ4SSbzzBIPBgBd09cWcx+EXNw4zMDkfK02THSFaEE5I9PPioDBBJ8+nWtowXnohvSrnV1L3Wrm8trsDYBxFa1vuiG6RIQWE7+DhacE8qiOTYNc6bqQN0+vlbYXq+QwJoiK7s9VT/upzjNZtrs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778191333; c=relaxed/simple; bh=aevgSz8+YiQkYmwbwa2Znv00DPcN+ByyI9F0Fhh1YWc=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=hiUwpSZCfUvcFqkiM7vgcJwCNyca17w4yQoRIR1Ld7ALMugKT6T7s3xLuNiQl+HPcOVOgWu1V41Cpr23hUSFRGNxBd2HpTyJ9qrPfWOqe5Q7h0AnHd1pO2rvSMv1WbcoAbG2I6RXIHaV1JFJAjV6cHbCJPW30STwZMp0b4cmoX8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DnsNbsC7; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=SuLL8QPQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DnsNbsC7"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="SuLL8QPQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778191331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/FARJZgNi0r+qVrAoVHMHW1WahLtk0szPiWx0DrMUtU=; b=DnsNbsC7xfZq7JbXoaF1DZzLKGt+l9BD4mElpRjIOPY/38JcOfmlEKT8VQgtZCndfN5+4q bTUkotX4uyMEO8IAUnACdMbe8qwMvUjkrQ0FdgSBN+eqgMWiZWra4EsS3k7W5ToSTpu14D lxHV+MGfBZtdjWIP49zugLZ7xD12Xoo= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-V-tQYheoMkSVgFcUB92MfA-1; Thu, 07 May 2026 18:02:10 -0400 X-MC-Unique: V-tQYheoMkSVgFcUB92MfA-1 X-Mimecast-MFC-AGG-ID: V-tQYheoMkSVgFcUB92MfA_1778191329 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-7bda7959fadso20211357b3.2 for ; Thu, 07 May 2026 15:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778191328; x=1778796128; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=/FARJZgNi0r+qVrAoVHMHW1WahLtk0szPiWx0DrMUtU=; b=SuLL8QPQhFqs6xc29yOTIKgj/6YPfZMs7j0Ocz5AXIfAmgYHUp5mXP2sdX6MMyDh2b CndQZpYMp/Sfy4P3GnGgP4YqUxEJbHESxbfEf8ozD4SLC2Con1q+GcZmNt5AUHzmJ+Co 5ukz7sjCY7lZ5z6ZsuuwEKLFRkOlvVSXYsO6GRZ/NkJuNFMGqygCrFPZGH26EqrF3rMT 37Wv9UA9B9Y0ZtB+OLwXVVdxxUC9nETPsn8+tqRMwXi+bROgvLuopdes1FN+fNzRRpKf kFHEdHjvBT00Osxh5LmPJtRn6gyre/0zEW/MEc3xoeQ6wNQRlBQ4tInMvjjTdwtkd5dA c9rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778191328; x=1778796128; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/FARJZgNi0r+qVrAoVHMHW1WahLtk0szPiWx0DrMUtU=; b=YA/loaffbZlRabOeZY6sNlj/CaacMhrGPxtttcio5s3W4vGILdQSM1fvyGM7TEvQUp xDwBOX0MuiuisD7GmxeQ7sUcnA2Gmz+8FArlbZ+taQ+6VMDTJu2JH/Pn9kYmzYs2/6R9 nwE7qwGrmaZcCpM9aIUBPzsznqoOMitGd++fKvLfpDsBQCfsj3M9bbnKofCcsiQo85HW 5vxNa4O6NvHxdIEuRA1hDvRA6n4Md9TAl0ZGW54bvnX0P6Um6ovEa8UiWs2lsfiQFNoN F4gxiTCXXoN89M30+BDUZj0KoNXEbKhlnWB0hW3Vp+uukaXXDxGQjhfJezCcyXDfpkge Wmgg== X-Forwarded-Encrypted: i=1; AFNElJ9YLTS5gUbrsj8aTB1L5u+/GeMeCBQuzF0EzJaRDl05Uf4C1xbwtGFjTeIIP7m8q3auDdaxYmqVeDRdCYQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyTn42aiYLXP1+ZI/KiN1Nc/sR5XrnnRvWLVso+sVGBAzpPKzLK eDAXXjbAiEe+eFaQycP71zsR+PnYgHq2cMuRGybY3yNT+E1zGNhTLRzwxJDIFyITeaOa5I97yCM xLycPyQBIiacM5BUVMe4FMEuF8KYsPK4ArE6uov/dbvMpSVngkvKdR6AYUsv8JQovBCXypSu0vQ == X-Gm-Gg: Acq92OGyVcaBzOB1tKMww297G4X4fqgvFlPg0sHH7hYaytvzXEaWLBioUPDfuz24iYM sE74/9qB+bo030si7AffswsWuC4F1sV6ne02pWlB4oPzKyruWXZaRt0/VNX5F1g25Rv6Xtqr9kK SFjuieYscq11yL1gx0tYNOIHnFWfDrgmyGewVWr+xzODN7XHrODPRbFcZdB0vN0E2A2T3Vhg+xK Q0skpABOgJoJcc5M/iIIWDrdgeiqMWTeA1Icu26pdNvZfZW55Y615GVDhBIu/J7uG5VDypewT+U hLP6OVKJh+jnuxabMhV1xgubBi3WIraxWr/+7XjWGYyudvaCFlZYIsxrUmp8zhEh/qBhiY0mNc2 TRrftsGSOYvTD6AglLqyvGeSICSYAdVeOlga6mnIefrM+xSmnU7bJ X-Received: by 2002:a05:690c:399:b0:798:7879:1ab4 with SMTP id 00721157ae682-7bdf5ece4f6mr106303007b3.37.1778191328125; Thu, 07 May 2026 15:02:08 -0700 (PDT) X-Received: by 2002:a05:690c:399:b0:798:7879:1ab4 with SMTP id 00721157ae682-7bdf5ece4f6mr106302387b3.37.1778191327403; Thu, 07 May 2026 15:02:07 -0700 (PDT) Received: from li-4c4c4544-0032-4210-804c-c3c04f423534.ibm.com ([2600:1700:6476:1430::29]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7bd6656d218sm97273237b3.22.2026.05.07.15.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 15:02:06 -0700 (PDT) Message-ID: <8cfc69ac21525b037c7e238ac6690f440dbff9c0.camel@redhat.com> Subject: Re: [PATCH v2 1/2] hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length From: Viacheslav Dubeyko To: Tristan Madani , Viacheslav Dubeyko Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 07 May 2026 15:02:05 -0700 In-Reply-To: <20260505111300.3592757-2-tristmd@gmail.com> References: <20260501110218.29906-1-tristmd@gmail.com> <20260505111300.3592757-1-tristmd@gmail.com> <20260505111300.3592757-2-tristmd@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.0 (3.60.0-1.fc44app2) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-05-05 at 11:12 +0000, Tristan Madani wrote: > From: Tristan Madani >=20 > 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. >=20 > For example, with off=3D14 and len=3D0xFFFFFFF2 (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. >=20 > Fix this by widening the addition to u64 before comparing against > node_size. This prevents the u32 wrap while keeping the logic > straightforward. >=20 > Reported-by: syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3D6df204b70bf3261691c5 > Tested-by: syzbot+6df204b70bf3261691c5@syzkaller.appspotmail.com > Reported-by: syzbot+e76bf3d19b85350571ac@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3De76bf3d19b85350571ac > 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(-) >=20 > 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) > =20 > node_size =3D node->tree->node_size; > =20 > - if ((off + len) > node_size) { > + if ((u64)off + len > node_size) { > u32 new_len =3D node_size - off; > =20 > 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_bno= de *node, u32 off, u32 len) > =20 > node_size =3D node->tree->node_size; > =20 > - if ((off + len) > node_size) { > + if ((u64)off + len > node_size) { > u32 new_len =3D node_size - off; > =20 > pr_err("requested length has been corrected: " Looks good. Thanks for the fix. Reviewed-by: Viacheslav Dubeyko Thanks, Slava.