From nobody Mon Apr 17 15:47:55 2023 X-Original-To: dev-commits-src-main@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 4Q0WfN59zxz44q9D; Mon, 17 Apr 2023 15:47:56 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q0WfN2hdHz49cl; Mon, 17 Apr 2023 15:47:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681746476; 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=qHEniHoqekgUeA+S8W3MK4bX0hE0DnXoqonv8LezODQ=; b=m50FIsUYwQ2oTBuJjUdIn2Jm01Ns4eVKnhzt41UpnZrH5v8UtRRrDpbCYxhA4buEm1UAeu madF+biZDugbPvYqUUzjIttmtj8exFuQ8JI0vDkxm0S9PFZ/dTTbkFiaEndHaDZMP4XK4Y PPVAnsp1lMW/FKhbw4T/0TVtzcvILC2Cg4N9nKYsGCw3qewc0QriMOaDR2TlmOAWJnk3y+ mJ5LYsZTflwTDzFk493j7zLqqsFcd8EkWEA+qzVUIIKofUacRo03to8JwlS8ul0NWh1Sqp MHeouSvpkvMVFkHOyU4y19rmyH6JavNUexvHxjfY7jc7FhFVfKACrlx2RTbWZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681746476; 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=qHEniHoqekgUeA+S8W3MK4bX0hE0DnXoqonv8LezODQ=; b=QgbeIa8FC3VgiK/4KWSvtilTYhoIhtylvgldd8LiF7oO5+kHI3PaFeVLslXdmWJaKliy8a GuzXpCJSWLhfq4BiJA1iQisCuNI6Y3u6OADYAx0RrWAF4rgwnehLxHrCcykhCJmEdpEBvQ dwUOVGJIPlt8T3Djn1f9pmFsztkYFgFYUn8Jq+jtX++TpmK8Mpr6Rhoe32PxmjbjZEbBcU pzq9Cky7SKlJvxdCaq4S/hL9m/fE1YdiRVoZNR1DVeE9d45LWzi0eeJFdSwsQp8tr5nLwL kzJekEQLAIuttIM2r1x6/aNjA6RvMyGYxxRlYplsxGAMyuFYIwhWVAGHFGajPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681746476; a=rsa-sha256; cv=none; b=HA1bCWg+xzBPcTvdMcvR/ByCSNLL4yPvKOyYn/8h7UZY/iKdqXkQ3Yf+5BWVkNwz6ut1/2 eMPv7deuTsL751RRNoTJctlB7wwe3xApONCiXBIiNlA1nUX+YNX71IlCic5RverYfy0rt2 s+p8GhpbGLIeZUxyuRpkQNO9ZGX7n6iSLhPQe/HTdt5ccq4nI2I8ioguw5qNQGwF94iS6F ogepH9PK1NJHI20Qyc5RhGDvTkhSz5R5q8U3+ddvzwbxGcfyYV6oU5gZjsGyupkoGkVqW9 Xrus0OAIGIicvUlpb1upHtakK6IERKsNODAOFiJ4Y/z+Z9B2wHJVR9FaFROTRQ== 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 4Q0WfM6sRYzbL4; Mon, 17 Apr 2023 15:47:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33HFltEg070555; Mon, 17 Apr 2023 15:47:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33HFltr1070554; Mon, 17 Apr 2023 15:47:55 GMT (envelope-from git) Date: Mon, 17 Apr 2023 15:47:55 GMT Message-Id: <202304171547.33HFltr1070554@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: 48ffacbc8487 - main - veriexec: Add function to get label associated with a file List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 48ffacbc8487e583794f740ac5d08f5d9a457a20 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=48ffacbc8487e583794f740ac5d08f5d9a457a20 commit 48ffacbc8487e583794f740ac5d08f5d9a457a20 Author: Steve Kiernan AuthorDate: 2023-04-03 00:33:12 +0000 Commit: Stephen J. Kiernan CommitDate: 2023-04-17 15:47:33 +0000 veriexec: Add function to get label associated with a file Add mac_veriexec_metadata_get_file_label to avoid the need to expose internals to other MAC modules. Obtained from: Juniper Networks, Inc. --- sys/security/mac_veriexec/mac_veriexec.h | 2 ++ sys/security/mac_veriexec/veriexec_metadata.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/sys/security/mac_veriexec/mac_veriexec.h b/sys/security/mac_veriexec/mac_veriexec.h index e4d336ce4ff4..9e30143a8615 100644 --- a/sys/security/mac_veriexec/mac_veriexec.h +++ b/sys/security/mac_veriexec/mac_veriexec.h @@ -178,6 +178,8 @@ int mac_veriexec_metadata_add_file(int file_dev, dev_t fsid, long fileid, unsigned long gen, unsigned char fingerprint[MAXFINGERPRINTLEN], char *label, size_t labellen, int flags, const char *fp_type, int override); +const char *mac_veriexec_metadata_get_file_label(dev_t fsid, long fileid, + unsigned long gen, int check_files); int mac_veriexec_metadata_has_file(dev_t fsid, long fileid, unsigned long gen); int mac_veriexec_proc_is_trusted(struct ucred *cred, struct proc *p); diff --git a/sys/security/mac_veriexec/veriexec_metadata.c b/sys/security/mac_veriexec/veriexec_metadata.c index 4b9cc9b3052f..4ff635335e9f 100644 --- a/sys/security/mac_veriexec/veriexec_metadata.c +++ b/sys/security/mac_veriexec/veriexec_metadata.c @@ -586,6 +586,31 @@ mac_veriexec_metadata_fetch_fingerprint_status(struct vnode *vp, return (error); } +/** + * Return label if we have one + * + * @param fsid file system identifier to look for + * @param fileid file to look for + * @param gen generation of file + * @param check_files look at non-executable files? + * + * @return A pointer to the label or @c NULL + */ +const char * +mac_veriexec_metadata_get_file_label(dev_t fsid, long fileid, + unsigned long gen, int check_files) +{ + struct mac_veriexec_file_info *ip; + int error; + + error = mac_veriexec_metadata_get_file_info(fsid, fileid, gen, NULL, + &ip, check_files); + if (error) + return (NULL); + + return ((ip->flags & VERIEXEC_LABEL) != 0 ? ip->label : NULL); +} + /** * Add a file and its fingerprint to the list of files attached * to the device @p fsid.