From nobody Sat Oct 17 17:08:37 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4j6Sv95x5Jz6wSJH for ; Sat, 17 Oct 2026 17:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4j6Sv93krFz4VV3 for ; Sat, 17 Oct 2026 17:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792256917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EvzmCOsHq2bTDfP6PPKByKKdkGTOkEz2NUZKixSiR04=; b=t3piQJW6+olCW5YdzDmZoBlLKi5ycbTcdP9DCKp5vpGxkBvrsQdujybiugSd3/EbDBCSv+ f9D60yoiT6XTfLjmPxNol+sGTcdgbGBmGv9+TYrMXBPoqK6A0lZAc8QByL+ZHWaFnafuM6 G4KPKX4mr6I8LChXPEelXnF8o3loTgRSWFdvM37qe2QKizTlHPldYiCA/CJ1XyN6q7yTty 7dT6fMBWtCOxnoJEy5KMkmuvBMnyilxuAyCk8gv7XAZptL9YKjORBWaZX1bDh3KsxGHw2T 6wERIo1ru7wSBXhdvnhefFDXvQIeXa31a1jHtiw++v6UMuLsreexbSrb5PicVw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792256917; b=STRxVadkIRZpPhAb99V2miIni9G3R5UcKrHJ+RphPsQ4ybVETn9Gw3hqlEZEWbhbV3bp03 9apx1l3gOCxgOZ44NMhawukw7UV9sZm4Q0vrs+UrPvFeYsqiooIB3Jp4zyhaOQSrm7s7wk C1zz2Ru18f/CAdet3oFqhS0h+iu8ylbxKy0Ib0YsYuNHgiQSfFhSisLAXsZviSCvLYwqOY ECMHnM87l+uck3NwmQQir1Ei8w1guIwbyTMkdH+SaniM/FopoF3UucZ8tR4t+0sAvwA5iU PtZzYBfS33Rc55W+6m4Yu9eG4B6EK1dSbWeXRAq3zf0q84md4Ce2e27qn6G/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792256917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EvzmCOsHq2bTDfP6PPKByKKdkGTOkEz2NUZKixSiR04=; b=OpZfq7uUvMgMbGzKcEBB42+ibhBYidQViygt4sFnXkcyL+ss1MOce75O9EX+PEy81ZBcHf rtyRvbcmrrJlbVSQPN85p36F+qqaTsTPH/aN4W0EcvZgLfyWxWTEojJBptyiRPFO3NANrB fwbs8eUUaVoWMSaSpqtbYNZ1+HXPQlF7mITKkRe5u+ASclfPGWHghVYoVW7q8ived95Htz nAJg/8IEc8/Vr0l5o44QIxXzUxIul+cTlC7koTv7Y8oGdTYyIzKuWu2WyiNSut/bBQuVap mfKn3EEHS1NKNpuVG9sIvj085pLZvo0gGImIziGA9P/eS3Xob4S7NrnuAukAGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j6Sv92WvXz1B2f for ; Sat, 17 Oct 2026 17:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c5e1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 17 Oct 2026 17:08:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: 2c085d5bbdff - stable/15 - mkimg: Avoid leaking a page of mmap List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 2c085d5bbdff38e0d237913158c04681de18e35e Auto-Submitted: auto-generated Date: Sat, 17 Oct 2026 17:08:37 +0000 Message-Id: <6ad3ab95.1c5e1.6dce8705@gitrepo.freebsd.org> The branch stable/15 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=2c085d5bbdff38e0d237913158c04681de18e35e commit 2c085d5bbdff38e0d237913158c04681de18e35e Author: Colin Percival AuthorDate: 2026-09-26 00:42:40 +0000 Commit: Colin Percival CommitDate: 2026-10-17 17:02:26 +0000 mkimg: Avoid leaking a page of mmap The image_file_map function adjusts the provided file offset to be page-aligned, with a resulting increase in the size of the mapped region; the increased size needs to be used when unmapping as well. Reported by: Claude Opus 5.5 Fixes: baf4abfc39b2 ("Allow building mkimg as cross-tool") MFC after: 2 weeks Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D60148 (cherry picked from commit 434819b4fec5e508bdfe72f91e73402e9c2fca22) --- usr.bin/mkimg/image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.bin/mkimg/image.c b/usr.bin/mkimg/image.c index 90817206e317..84d66af97a60 100644 --- a/usr.bin/mkimg/image.c +++ b/usr.bin/mkimg/image.c @@ -330,10 +330,11 @@ image_file_map(int fd, off_t ofs, size_t sz, off_t *iofp) } static int -image_file_unmap(void *buffer, size_t sz) +image_file_unmap(void *buffer, size_t sz, off_t iof) { size_t unit; + sz += iof; unit = (secsz > image_swap_pgsz) ? secsz : image_swap_pgsz; sz = (sz + unit - 1) & ~(unit - 1); if (madvise(buffer, sz, MADV_DONTNEED) != 0) @@ -381,7 +382,7 @@ image_copyin_stream(lba_t blk, int fd, uint64_t *sizep) error = errno; else error = 0; - image_file_unmap(buffer, iosz); + image_file_unmap(buffer, iosz, iof); /* XXX should we relinguish unused swap space? */ if (error) return (error); @@ -465,7 +466,7 @@ image_copyin_mapped(lba_t blk, int fd, uint64_t *sizep) buf += iof; error = image_chunk_copyin(blk, buf, sz, data, fd); - image_file_unmap(mp, sz); + image_file_unmap(mp, sz, iof); } else error = errno; @@ -590,7 +591,7 @@ image_copyout_file(int fd, size_t size, int ifd, off_t iofs) return (errno); buf += iof; error = image_copyout_memory(fd, sz, buf); - image_file_unmap(mp, sz); + image_file_unmap(mp, sz, iof); if (error) return (error); size -= sz;