git: 70f6696f0f90 - stable/15 - MFC: fsck_msdosfs: fix head bitmap over-allocation on 32-bit platforms
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 02 Oct 2026 05:05:10 UTC
The branch stable/15 has been updated by delphij:
URL: https://cgit.FreeBSD.org/src/commit/?id=70f6696f0f90b0de9dba554faafc50ec3444443d
commit 70f6696f0f90b0de9dba554faafc50ec3444443d
Author: Yunheeee <yunhe27@126.com>
AuthorDate: 2026-09-26 03:10:04 +0000
Commit: Xin LI <delphij@FreeBSD.org>
CommitDate: 2026-10-02 05:04:40 +0000
MFC: fsck_msdosfs: fix head bitmap over-allocation on 32-bit platforms
bitmap_ctor() computed the allocation size as
roundup2(bits, LONG_BIT) / (LONG_BIT / 8)
The dividend is a count of bits, so converting it to bytes requires
dividing by 8 (bits per byte), not by LONG_BIT / 8 (bytes per long).
The two divisors happen to coincide on LP64, but on ILP32 platforms
the head bitmap was allocated at twice the required size; for a
FAT32 file system with close to 2^28 clusters, that is 64 MiB instead
of 32 MiB.
The extra half of the allocation was never accessed, so there is no
functional change other than the reduced memory footprint.
Pull Request: https://github.com/freebsd/freebsd-src/pull/2440
(cherry picked from commit 269002da453895fc935101afefeb02d2c7d10360)
---
sbin/fsck_msdosfs/fat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sbin/fsck_msdosfs/fat.c b/sbin/fsck_msdosfs/fat.c
index 7d0ad9a595cf..ef788c9826a4 100644
--- a/sbin/fsck_msdosfs/fat.c
+++ b/sbin/fsck_msdosfs/fat.c
@@ -121,7 +121,7 @@ bitmap_count(long_bitmap_t *lbp)
static int
bitmap_ctor(long_bitmap_t *lbp, size_t bits, bool allone)
{
- size_t bitmap_size = roundup2(bits, LONG_BIT) / (LONG_BIT / 8);
+ size_t bitmap_size = roundup2(bits, LONG_BIT) / 8;
free(lbp->map);
lbp->map = calloc(1, bitmap_size);