From nobody Fri Jun 28 10:18:36 2024
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 4W9WcD4RPvz5FCyF;
	Fri, 28 Jun 2024 10:18:36 +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 "R11" (verified OK))
	by mx1.freebsd.org (Postfix) with ESMTPS id 4W9WcD2XSwz4pbs;
	Fri, 28 Jun 2024 10:18:36 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1719569916;
	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=Nnb0ARn/T46seoql92pp2TjMQULdqG1MGy238s6F4e4=;
	b=NuND0FciRHr8HVB2MaqiRki3QOFNLd087JfvJR7uksiuH8LwOYW89zxMEilj1X4ak9KxXW
	wTYsYa/Hwz4hZsM0qXqdB6PsazkuyvvwpAUx42jP4Hne9ZqaaONelJoU2R9CaSPGVPxWEP
	LD6NdiwBFLTjtASCQKgyGuoym+kddSZMIAARU/7U6rNkG+zpjpcyQpUA9MxDqoMRovKTXH
	mro6vOhuB8yj4b4BnhbC6ccIwM7U/PADX3fcQ0EShGBwKPdlvaYbGDbIzEkjK2vlvFGkJW
	iQHnGjHSnoeXXWRllYu1Gxz5ZzR3y0AirgXyaOFenJQOgCYKXbp86T7eTwQnAg==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719569916; a=rsa-sha256; cv=none;
	b=b197MNifzDUuK4sNLUvHoCaBLKwSZH+V4v9MfWBhh7Kkkv5fIGG/MqB5No+q847oOA8Y97
	17l54ISMf/OyDththXS75bLttKnyjhjzem0N2w1jytryfkSelrjkITZUZ0+q2NHs0Dk+XY
	XRuRxuucar9OAGqaL2mjFRhulYzUAmGIJKuifZQBHxI3urivFD31P5cAOtwODhmYy6YyoB
	9BjhZpahxZXY6TCiefU0CFKONaA4V0kAWSGuZvchsazUtsxcgH/rssGryyatE36/YE9pHI
	T35p0KXO+JhSXtkJwxtifhdqfvzC4N18nMDJWvUZcWluBThiADu9WLfTgJfLTw==
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=1719569916;
	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=Nnb0ARn/T46seoql92pp2TjMQULdqG1MGy238s6F4e4=;
	b=gY6L6vD9OOvRLtd1lmTGSMMzzvqCIyuH0oypSDj6JqJsikgNNvHdrJYn1J6Td0z40j7LBi
	HrteslsasybS+nocPTWgVHMeaTXlEQNv9a6bm3i6a+Vh7LKrLNKtYjQHmmyVWCvo7Os/6k
	jQM0dnW9L4zECeyW1EDeZbG06KWV6pvH5sbIbzyz6jbu2Sg8RrEibrXiOtEaly+J7DCOwR
	rCJQVhLvayp33reoggWJei/sbRguBnkWOgKyz8G5cTv53HugcEl6LGhvBcROAG0v7/M4tm
	DQgB17jwURDzzLPaIZcPZHToKR8FLmMZ4z1OtmswPu2C5Y4caG7vVGkKOhI3dg==
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
	(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 did not present a certificate)
	by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4W9WcD1sgXzrss;
	Fri, 28 Jun 2024 10:18:36 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
	by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45SAIaCC076144;
	Fri, 28 Jun 2024 10:18:36 GMT
	(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
	by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45SAIa8S076141;
	Fri, 28 Jun 2024 10:18:36 GMT
	(envelope-from git)
Date: Fri, 28 Jun 2024 10:18:36 GMT
Message-Id: <202406281018.45SAIa8S076141@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
        dev-commits-src-branches@FreeBSD.org
From: Mariusz Zaborski <oshogbo@FreeBSD.org>
Subject: git: c7bb7a23336a - stable/13 - libcapsicum: cache more
  time zone information
List-Id: Commits to the stable branches of the FreeBSD src repository <dev-commits-src-branches.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches
List-Help: <mailto:dev-commits-src-branches+help@freebsd.org>
List-Post: <mailto:dev-commits-src-branches@freebsd.org>
List-Subscribe: <mailto:dev-commits-src-branches+subscribe@freebsd.org>
List-Unsubscribe: <mailto:dev-commits-src-branches+unsubscribe@freebsd.org>
X-BeenThere: dev-commits-src-branches@freebsd.org
Sender: owner-dev-commits-src-branches@FreeBSD.org
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: oshogbo
X-Git-Repository: src
X-Git-Refname: refs/heads/stable/13
X-Git-Reftype: branch
X-Git-Commit: c7bb7a23336ad1c526b7fb910092a828455094ee
Auto-Submitted: auto-generated

The branch stable/13 has been updated by oshogbo:

URL: https://cgit.FreeBSD.org/src/commit/?id=c7bb7a23336ad1c526b7fb910092a828455094ee

commit c7bb7a23336ad1c526b7fb910092a828455094ee
Author:     Mariusz Zaborski <oshogbo@FreeBSD.org>
AuthorDate: 2024-05-27 11:17:03 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2024-06-28 10:19:56 +0000

    libcapsicum: cache more time zone information
    
    The functions like gmtime(3) expect to cache a GMT time zone. Some
    sandboxed programs (like last(1)) use the gmtime(3) function.
    In case of last(1), this function fails to load a proper time zone
    because it is called after entering the capability mode.
    
    _open () at _open.S:4
    0x00000008011bc5a8 in tzloadbody (name=0x8018b9580 "/usr/share/zoneinfo/Etc/UTC", sp=0x801870140,
    tzload (name=<optimized out>, sp=0x801870140, doextend=true)
    0x00000008011bb8ba in gmtload (sp=0x801870140) at /usr/src/contrib/tzcode/localtime.c:1456
    gmtcheck () at /usr/src/contrib/tzcode/localtime.c:1581
    0x000000080111f85a in _libc_once (once_control=0x80127c550, init_routine=0x0)
    _once (once_control=0x80127c550, init_routine=0x0) at /usr/src/lib/libc/gen/_once_stub.c:63
    0x00000008011bb9d0 in gmtime_r (timep=0x7fffffffe3a8, tmp=0x80127c568)
    gmtime (timep=timep@entry=0x7fffffffe3a8) at /usr/src/contrib/tzcode/localtime.c:1865
    0x0000000001024cd4 in printentry (bp=bp@entry=0x8018b4800, tt=tt@entry=0x80186a0a0)
    0x00000000010245ae in doentry (bp=0x8018b4800)
    0x00000000010243a7 in main (argc=1, argv=<optimized out>)
    
    This time zone is not loaded by the tzset(3) function. Because of
    that, extend the caph_cache_tzdata(3) function to also include the
    GMT time zone. There is no other way to cache this data than
    calling gmtime(3) once.
    
    MFC after:      5 days
    Reviewed by:    emaste, markj
    Differential Revision:  https://reviews.freebsd.org/D45297
    
    (cherry picked from commit e24ff5c99be080007ff9086398fbe3ef56cd94dc)
---
 lib/libcapsicum/capsicum_helpers.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libcapsicum/capsicum_helpers.h b/lib/libcapsicum/capsicum_helpers.h
index f137ec1806f9..a6c696aa9a8e 100644
--- a/lib/libcapsicum/capsicum_helpers.h
+++ b/lib/libcapsicum/capsicum_helpers.h
@@ -133,8 +133,17 @@ caph_limit_stdio(void)
 static __inline void
 caph_cache_tzdata(void)
 {
+	time_t delta;
 
 	tzset();
+
+	/*
+	 * The tzset() function does not cache all time zones.
+	 * Some functions, such as gmtime(), require a GMT time zone.
+	 * The only way to cache them is to call the function directly.
+	 */
+	delta = 0;
+	(void)gmtime(&delta);
 }
 
 static __inline void