From nobody Mon Aug 10 16:08:04 2026 X-Original-To: dev-commits-src-branches@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 4hJfmh6j9Hz6p0SS for ; Mon, 10 Aug 2026 16:08:04 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hJfmh3vQqz3q9r for ; Mon, 10 Aug 2026 16:08:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786378084; 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=ptM35T3ICfUMywnvdG1YG2TUa7klIrs5Pprr/rYdO6U=; b=gr28yfJy3vzMXwq+bWcpVxlosZhBy4VhYoehD/Z4LOS4Uxc4z59EAAa084Ye6Mv8g1P2zh j4kZVHoXfPITRJLfpsyRKO++R0sRdrJAv1Bp433xQicARH5D5pMjInjhDnjs13kuS9VrJo D75dZWuwdZKiopwwWdt15TrOJlm8OHN3DzPTcWiw3MDViM0Pv/b2/MHtCRO7Ail25hMaHr /APeeff6u9cwUK0/boHZiaGqz5ZX/b0YReU9BXSUoS++iC67a8Dl4zLIyuVUDF56TYa+X9 vhr8wnlF8dvAyj5NqEeex77p/dcmtFUpodETil0ztlZysprF2NmC6cSYUQHebA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786378084; a=rsa-sha256; cv=none; b=eajwP5ohz1PBu1IIu4fjqvZJIoVUK8/PUek9K1TWKHJW3PfVQWKYu4teDpv57hqE2cxpZj KxtpjtVSoiCRDRFn10I3DegrJ90gwX7Ly80plT6aV4+ILwIA1FyRkTqfN65TNBuqNgl8mQ nZLPybIETsdcUGhLDa6Itw6p5AW7HF6YBe8UVsIxdRJbZ67xMxk+UtSflJybcLXT2hx3SG YHqR7fy/+BrCpI0hQEBBtmAXiqn6c1VBktnvV6yvYYA+Y6QoroDzJTeJ/zUphPo6+Qv2ns NrZgKif+PBgGx6vc0mcGEGI9FioragR8sXrHIeHqi6smo81ED9B/RvF9PyJPKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786378084; 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=ptM35T3ICfUMywnvdG1YG2TUa7klIrs5Pprr/rYdO6U=; b=p5tmZXCXW+ysCMmYgsjBF8MxNuKAJszu3G1DyIMxYM6nJPzVf8L1lbm0+otpgyt/Upv9k6 uaMDDpNn+yA0bK8UvHkN4dzknKAAgXAxcQwDZfeQOQLCAxuQSHRT516/g40pk6/dVq3ig+ LjGwOZ+m7c3kFQWfzkELDGcpUSsZD2a2E54Ayyd0HwuyO79WzvFuUfH8asPYwyfAMqPNQf 13vSkndFRB6cHWL4dyybRClRnTX5Q8flwdz0P/4d4wA49ley9sXuTYVcE+XZUyzZtvZ7wl JWQBA4N5jGMBBoWdHFVFreaW7Z7EqdJeWrcvWWY8SGxTRkeenGDatNOHQKQCyg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hJfmh2LdHz1Yb for ; Mon, 10 Aug 2026 16:08:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 348bb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 10 Aug 2026 16:08:04 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bojan Novk=?utf-8?Q?ovi=C4=87?= Subject: git: a8c598de78fd - stable/15 - mpool/mpool_get.c: Avoid clobbering 'errno' when handling 'pread' errors List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: 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: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a8c598de78fd9ef6724d5f9366bc4b03fd5cbf9c Auto-Submitted: auto-generated Date: Mon, 10 Aug 2026 16:08:04 +0000 Message-Id: <6a79f764.348bb.6ae7a33e@gitrepo.freebsd.org> The branch stable/15 has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=a8c598de78fd9ef6724d5f9366bc4b03fd5cbf9c commit a8c598de78fd9ef6724d5f9366bc4b03fd5cbf9c Author: Bojan Novković AuthorDate: 2026-02-23 15:30:26 +0000 Commit: Bojan Novković CommitDate: 2026-08-10 16:06:02 +0000 mpool/mpool_get.c: Avoid clobbering 'errno' when handling 'pread' errors POSIX.1-2024 states that the 'free' function "shall not modify errno if ptr is a null pointer or a pointer previously returned as if by malloc() and not yet deallocated". However this is a fairly recent addition and non-compliant allocators might still clobber 'errno', causing 'mpool_get' to return the wrong error code. Fix this by saving and restoring 'errno' after calling 'free'. Sponsored by: Klara, Inc. Reviewed by: obiwac Differential Revision: https://reviews.freebsd.org/D55463 MFC after: 1 week (cherry picked from commit bce0c14fe19defeef4f02cfebc018e9adf979783) --- lib/libc/db/mpool/mpool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index 1bab66d73baf..0df19dc09e4d 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -214,10 +214,14 @@ mpool_get(MPOOL *mp, pgno_t pgno, /* Read in the contents. */ off = mp->pagesize * pgno; if ((nr = pread(mp->fd, bp->page, mp->pagesize, off)) != (ssize_t)mp->pagesize) { + int serrno; + switch (nr) { case -1: /* errno is set for us by pread(). */ + serrno = errno; free(bp); + errno = serrno; mp->curcache--; return (NULL); case 0: