From nobody Fri Jun 28 10:18:52 2024 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 4W9WcY1cWgz5FCyH; Fri, 28 Jun 2024 10:18:53 +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 4W9WcX72BWz4ppr; Fri, 28 Jun 2024 10:18:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719569933; 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=jK2gi4IQz0HFTMBMJ/2rmLOFdsXRtVbiTkJBB2Q5JOw=; b=F3CtK8/A2gJRHTFr5dWmt75sLHrifdvaD+M+n+RCHAsPbhu6LVq7Cd9yvcMDlX+vUO0C4g Lu1zOY33Ou9nYLvtNOr7EPitYy3DffKKb7ozAh8M87dZI9lx3UtYowHoengDSjYvVaqvPg vRZS0vI3KtG9drBDawaXihvbp+embsHUCMq7Pp2zz9CdWZ2L5EV5SH1S1NcVq00DrH45ti EXr8XLZ2XK3OFonyFR2WpPuARkIxy6oZEcpwWBob6X/PaK0kytevhWP5MikIEyAw4nh6MZ E7FZbgktmGsTn5zoXOFG44S2Z1Un0FdQwKnwf1aK3nYd6Dt3qBdr8qwNt8Ry7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719569933; a=rsa-sha256; cv=none; b=OtqQMxUwJUiAb1bVZiKhRPHEEETZw1yynLYbOZmOE4pwN3LJLPfQD6R0Z597lXqahEFuE4 uKTsbEoZfRU0+zKx2JaCTfqUCEKdknuBm8vLNagimONjzqrTxoYU7lrvvjXxGBoAnbo/Tx n6LQab4VXefLwUphZzMAfgCosA7MZHBnvyfWfMFvg5cVOj2ygbzuoCttBTS9vu/m0yy/B4 CQSBsWWIz0VwZRaXQeENWH4jhw8J+ZRZ/KJhsw2hzoY8D+twAhyyBJqTEhyac4eBSZnJ5M 7LW+x3WCmllCccD2kdBQvV6HnXFs47PvShDXVttRkomJNf83hC5llVMxBbAWNQ== 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=1719569933; 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=jK2gi4IQz0HFTMBMJ/2rmLOFdsXRtVbiTkJBB2Q5JOw=; b=Au6KCuefLtKQ5d46A5inU5UateSVji65jnN29gACAHWGB92FOOUumX+L/5yArzAosbHH82 voexpE0oh9vtKM3aW5UOu4hY165hP8yjUvRf1sMfBaQBr7FTzNiEJAG+Ihq9mvCXctMc7f tkjLLvvaRp4gyqfmpHsFQm5tAV1oi93Ugidm/DB4nU/Q4zMc38L8TjYjdsJwxzbhwPW0nJ VmtHIstpMuS44QCyGM0ne8ctlBadaym2cabQyk14nx8h1S6biQQsHO03Nab7EYNuxlqYP8 4HDasI0Xy2P7TWAM4+tzjyeAiw481W0rTl3p1fk4jTPDILkz29Vs9gK+5UU05Q== 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 4W9WcX6cVBzrn9; Fri, 28 Jun 2024 10:18:52 +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 45SAIqp6076340; Fri, 28 Jun 2024 10:18:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45SAIqjJ076337; Fri, 28 Jun 2024 10:18:52 GMT (envelope-from git) Date: Fri, 28 Jun 2024 10:18:52 GMT Message-Id: <202406281018.45SAIqjJ076337@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 2c88494a3364 - stable/14 - libcapsicum: cache more time zone information List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/14 X-Git-Reftype: branch X-Git-Commit: 2c88494a336488caa3eec75a126d8b9bc23c20b0 Auto-Submitted: auto-generated The branch stable/14 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=2c88494a336488caa3eec75a126d8b9bc23c20b0 commit 2c88494a336488caa3eec75a126d8b9bc23c20b0 Author: Mariusz Zaborski AuthorDate: 2024-05-27 11:17:03 +0000 Commit: Mariusz Zaborski CommitDate: 2024-06-28 10:20:15 +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=, 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=) 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