From nobody Mon Dec 16 14:46:15 2024 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 4YBjS81P2Cz5hWdN; Mon, 16 Dec 2024 14:46:16 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YBjS76TrGz4fQp; Mon, 16 Dec 2024 14:46:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360375; 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=ABEcKuTFB8qaEUaT58BI0Bh2saPktP6RQAmC80d57J8=; b=HCi4NxqRs942lq5mgtb+/QR3/IdKOgoF82F0tC+QcQsIpxvEC4Dk/jOLi11mjUjpz3hxY9 kdCuAsJidaOdJiLxuFRQhoM2ux9+PgT3M4AqUW2iWTtDgjMxcYciCIJ6aWOvYa/Wk57gFV 6NhILLY8d7Kb5t7nZUQS0r3iuIVJ1JJZn8x+AMxKZAay1CpzS1wsWaW0ZBueiwkrCF/Yup kUW1ATFIuneDaThClDJDXg6MDpGmlR0JRWz73gChKu+i169zu63ml3cyGfUVWILmBAuf5l oQX0v8eZ5TK8G1bgxDDGfCq4L/OusVO45oKWPZ32NQ0ow1yqyikLK4TK+BEesA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360375; 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=ABEcKuTFB8qaEUaT58BI0Bh2saPktP6RQAmC80d57J8=; b=gvgxxj85Ux6sIGB0C+dGZYDNgqXgt7NbOW8E26FyXS8OVJZMRH4iVd+u9omP2zdRttXPSY TY932hPhO2B+bV58xiER4t5VJKybHrYPqjmABxVZhTuDNxrMTQlClJb/M5RDzgJUyBlFVi YIT4bIPn6yjaBP1U6OgLtT/KG+OQMAtdfXu85qDFjSIIjGBxocaB9C+GvkBpaRiK3i3gDi kbOEpRgfRqb9zrrhpKt+Fk8n4gQEtdoZXQBvxoquaSXcMdmnMzjGc+veeCJdOmbtt5Nmpd /lQDMuYZkpdIog0NKPiRN+YIhVYMzmx6noAhbArTjXfHvUcIZd/vV4wFdYO+bQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734360375; a=rsa-sha256; cv=none; b=GxSHs2uktR3HZzdoW/pV6pFtVIJmTtyPYVYpBru935KqI+y5880ohZlhO7UrT/Y2GBmSxj wVzJiUb0eLHK3nKlWMgp013rQsgmqkJ9VSvswhoqmn4xYMai8/0JlJkCwp7MJnvqdcKaKV nRsqbY7StiqVbY4Cn7Ps7EFYciRGLuqmiS6Z+3jQMiFwTPhezpv+DAh7aHN/g2jGe+VlZM w6j5n28cez/baA8CtVH5UZpz81y5lISg2Iahp0XyUb7mHV9M59lLPMIbkorhBNN7n1Fc1l EoMrcf/CVXgAQw5ZcTGAhORfA4DxKSeLAuI+ZHWXttVAsP8DgxxXjFCP4FMJlA== 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 4YBjS75ptCzxkf; Mon, 16 Dec 2024 14:46:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BGEkFg5054276; Mon, 16 Dec 2024 14:46:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BGEkFJg054272; Mon, 16 Dec 2024 14:46:15 GMT (envelope-from git) Date: Mon, 16 Dec 2024 14:46:15 GMT Message-Id: <202412161446.4BGEkFJg054272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: c7fc71c6af07 - main - MAC/do: Convert internal TAILQs to STAILQs 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7fc71c6af0761f81ecafdb281dd43a081b3b22f Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=c7fc71c6af0761f81ecafdb281dd43a081b3b22f commit c7fc71c6af0761f81ecafdb281dd43a081b3b22f Author: Olivier Certner AuthorDate: 2024-11-12 17:31:33 +0000 Commit: Olivier Certner CommitDate: 2024-12-16 14:42:40 +0000 MAC/do: Convert internal TAILQs to STAILQs We only browse these forward and never need to remove arbitrary elements from them. No functional change (intended). Reviewed by: bapt, emaste Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47624 --- sys/security/mac_do/mac_do.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 669f0cfefdfb..44c33d7cfa57 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -147,7 +147,7 @@ typedef uint16_t id_nb_t; typedef uint16_t id_type_t; struct rule { - TAILQ_ENTRY(rule) r_entries; + STAILQ_ENTRY(rule) r_entries; id_type_t from_type; u_int from_id; flags_t uid_flags; /* See MDF_* above. */ @@ -158,7 +158,7 @@ struct rule { struct id_spec *gids; }; -TAILQ_HEAD(rulehead, rule); +STAILQ_HEAD(rulehead, rule); struct rules { char string[MAC_RULE_STRING_LEN]; @@ -171,11 +171,11 @@ struct rules { */ struct id_elem { - TAILQ_ENTRY(id_elem) ie_entries; + STAILQ_ENTRY(id_elem) ie_entries; struct id_spec spec; }; -TAILQ_HEAD(id_list, id_elem); +STAILQ_HEAD(id_list, id_elem); #ifdef INVARIANTS static void @@ -313,7 +313,7 @@ toast_rules(struct rules *const rules) struct rulehead *const head = &rules->head; struct rule *rule, *rule_next; - TAILQ_FOREACH_SAFE(rule, head, r_entries, rule_next) { + STAILQ_FOREACH_SAFE(rule, head, r_entries, rule_next) { free(rule->uids, M_DO); free(rule->gids, M_DO); free(rule, M_DO); @@ -328,7 +328,7 @@ alloc_rules(void) _Static_assert(MAC_RULE_STRING_LEN > 0, "MAC_RULE_STRING_LEN <= 0!"); rules->string[0] = 0; - TAILQ_INIT(&rules->head); + STAILQ_INIT(&rules->head); rules->use_count = 0; return (rules); } @@ -730,7 +730,7 @@ parse_target_clause(char *to, struct rule *const rule, } ie = malloc(sizeof(*ie), M_DO, M_WAITOK); ie->spec = is; - TAILQ_INSERT_TAIL(list, ie, ie_entries); + STAILQ_INSERT_TAIL(list, ie, ie_entries); check_type_and_id_spec(type, &is); check_type_and_finish: check_type_and_type_flags(type, *tflags); @@ -776,14 +776,14 @@ pour_list_into_rule(const id_type_t type, struct id_list *const list, size_t idx = 0; /* Fill the array. */ - TAILQ_FOREACH_SAFE(ie, list, ie_entries, ie_next) { + STAILQ_FOREACH_SAFE(ie, list, ie_entries, ie_next) { MPASS(idx < *nb); array[idx] = ie->spec; free(ie, M_DO); ++idx; } MPASS(idx == *nb); - TAILQ_INIT(list); + STAILQ_INIT(list); /* Sort it (by ID). */ qsort(array, *nb, sizeof(*array), id_spec_cmp); @@ -865,8 +865,8 @@ parse_single_rule(char *rule, struct rules *const rules, int error; MPASS(*parse_error == NULL); - TAILQ_INIT(&uid_list); - TAILQ_INIT(&gid_list); + STAILQ_INIT(&uid_list); + STAILQ_INIT(&gid_list); /* Freed when the 'struct rules' container is freed. */ new = malloc(sizeof(*new), M_DO, M_WAITOK | M_ZERO); @@ -935,7 +935,7 @@ parse_single_rule(char *rule, struct rules *const rules, if (error != 0) goto einval; } - MPASS(TAILQ_EMPTY(&uid_list)); + MPASS(STAILQ_EMPTY(&uid_list)); if (!has_clauses(new->uids_nb, new->uid_flags)) { /* No UID specified, default is "uid=.". */ MPASS(new->uid_flags == 0); @@ -951,7 +951,7 @@ parse_single_rule(char *rule, struct rules *const rules, if (error != 0) goto einval; } - MPASS(TAILQ_EMPTY(&gid_list)); + MPASS(STAILQ_EMPTY(&gid_list)); if (!has_clauses(new->gids_nb, new->gid_flags)) { /* No GID specified, default is "gid=.,!gid=.". */ MPASS(new->gid_flags == 0); @@ -960,16 +960,16 @@ parse_single_rule(char *rule, struct rules *const rules, check_type_and_type_flags(IT_GID, new->gid_flags); } - TAILQ_INSERT_TAIL(&rules->head, new, r_entries); + STAILQ_INSERT_TAIL(&rules->head, new, r_entries); return (0); einval: free(new->gids, M_DO); free(new->uids, M_DO); free(new, M_DO); - TAILQ_FOREACH_SAFE(ie, &gid_list, ie_entries, ie_next) + STAILQ_FOREACH_SAFE(ie, &gid_list, ie_entries, ie_next) free(ie, M_DO); - TAILQ_FOREACH_SAFE(ie, &uid_list, ie_entries, ie_next) + STAILQ_FOREACH_SAFE(ie, &uid_list, ie_entries, ie_next) free(ie, M_DO); MPASS(*parse_error != NULL); return (EINVAL); @@ -1279,7 +1279,7 @@ mac_do_jail_get(void *obj, void *data) rules = find_rules(pr, &ppr); jsys = pr == ppr ? - (TAILQ_EMPTY(&rules->head) ? JAIL_SYS_DISABLE : JAIL_SYS_NEW) : + (STAILQ_EMPTY(&rules->head) ? JAIL_SYS_DISABLE : JAIL_SYS_NEW) : JAIL_SYS_INHERIT; error = vfs_setopt(opts, "mac.do", &jsys, sizeof(jsys)); if (error != 0 && error != ENOENT) @@ -1967,7 +1967,7 @@ mac_do_priv_grant(struct ucred *cred, int priv) * privilege granting functions interpreting the "to"/"target" part. */ error = EPERM; - TAILQ_FOREACH(rule, &rules->head, r_entries) + STAILQ_FOREACH(rule, &rules->head, r_entries) if (rule_applies(rule, cred)) { error = rule_grant_setcred(rule, cred, new_cred); if (error != EPERM)