From patchwork Thu Feb 22 23:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568369 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D1918049 for ; Thu, 22 Feb 2024 23:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646377; cv=none; b=ZmQi++kTbuhX4ZZvuKEJcCBSMFy7Z4SIF7NtAM6pZueV1Y5/ETOaR6PqCaFN33H4YBSqrRuUWTkXon8Vzkjm1uC+gt09xhxfCgyR7JB/KwgoRCDE2HV9sB8iLANJhl0gz3WWdhueFvbRKeiNuNy0zhfyviQqKfI+iSigY9xiU+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646377; c=relaxed/simple; bh=fvL7WoYVtfWDA0eSgIz2/uxmggKJ3caMkp6L58c1Vzg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fHz+pN9akWQRqJURd0CE4yY4AgoTfIP6jMMLY4ScPDic65GExY+/p8iUAihW5kl6lLZJjm6S6rclgv6ZsPIY52OEa6ioDCxoLfOTfXf9o4CXPH8jiwoCMxZzn7WLC+00Ey0wqNam5njlXbPIZ/RuU5fN5fEDbJMMSUt+zqWDlIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=SnCNfmRZ; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="SnCNfmRZ" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-787a2e56b11so15776685a.3 for ; Thu, 22 Feb 2024 15:59:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646374; x=1709251174; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lrYECuMGVE9PrAxQaTbZ/EU8UxUGn9u8rh+su4zaWr4=; b=SnCNfmRZE61w2w4t2qa+dfe8kHcu5qjhidjN7DMpooHOkZPDW6yRxXd7++TqwUnmiH 29mHjWYVask4dGOlFm+LyxKAzEuHr42LMX1guUTq6madXw/8TPeOGlxBisU9bRdSdnyS 8+tie6g5GnfO4lwbiIfYtHqHrwA9wbYcDgy74j8y62MXPYHj7+rKmhnp65KdHAjDVRYx nq5IZSH1gt4xhDj0h8cqkjVV/HguCXI4WPEGvyu9bDxw5+BAiSr4WnOknz8jM9RlrjdO K1wSpvRSYsfpQvhBfWtAGmrIxd5CBtdNMRnmQXgiKDU1Kh0ULz6MyZM1zmGXwAwCR01N hxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646374; x=1709251174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lrYECuMGVE9PrAxQaTbZ/EU8UxUGn9u8rh+su4zaWr4=; b=UTYkBOJXXseMiZ6ChPLUVpHnqmDpN7jvV05zEAKNB1fsb/c2G3uWRAW1mqOWE1/iLP 4t+i5S0p6YwU79IoRRbGJIDdginXuPkzHiz4lrkVVNKTrA7LGvv6s/olgJVI2JOPkjke 3smQludcPmSgld7b9pr4FgEL4KmC6hPqOXkWzcW/umVgvy/+uPMYDMYVm+9jlL4D1EMA +R5d2GzAptXY+EOYvX57ME2QNjSPmxpsPAeLT0SyENqR6xVxfcW2UBmYzz5JZRjPZU26 uGqLCk4tP6c/IhMEqWsZi1ls0cZ5gWyjiLY+kNCZHGHzSPcUCY6VmCPTe8iGzylqVQlw GdvA== X-Gm-Message-State: AOJu0YydppQ9Qd4MHuLIILVraa9Qu/A108HOLOJ8qiP63bb5qF6dzFO7 Zn5dBnzd+9hSv8+w8S5oNqPJ33SN9t5hm65iPQcMlhIDl0SaDd1pXhmG2u1yTxazKnYdkRdmZdU = X-Google-Smtp-Source: AGHT+IFOGw7RmDIztTNvTmK5NwvVqQ9Z2qktRtH7EJLz10mrWlVQQSQyHCH4ZCuRJi+rkgcQ1OoNGQ== X-Received: by 2002:a05:620a:1727:b0:787:88a1:6852 with SMTP id az39-20020a05620a172700b0078788a16852mr730605qkb.16.1708646374294; Thu, 22 Feb 2024 15:59:34 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id s13-20020a05620a0bcd00b007878458ba10sm2103168qki.59.2024.02.22.15.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:34 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 01/21] selinux: fix style issues in security/selinux/ss/avtab.h Date: Thu, 22 Feb 2024 18:52:19 -0500 Message-ID: <20240222235708.386652-24-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5595; i=paul@paul-moore.com; h=from:subject; bh=fvL7WoYVtfWDA0eSgIz2/uxmggKJ3caMkp6L58c1Vzg=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199UpyYtdgLaBUcvEp7Q425Na4B5rZo5ffzeI chK5iROot6JAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffVAAKCRDqIPLalzeJ c8hJEAClqTJhxDzqsCx5Uq3YxYi+ThgY+dsI7yjj75OQWfRCsKMpxl099+4QJ030AIhuEJLTzg1 SOOmTF+JWnqRC0ZKsBA0Yc87Acd1mH5v0wK2irrQ0A53wq5pWP1hL4lx6Lrcq7clikKbLRGMkew uUC3qwwKxJddvfkvCPwa7aPCsSAKa9YS2HWTCEQxR3mZCqHCqBK/kxzNyLq5atr0GOGVY/C3Xte MZynrLC+p5QQXmxW/53Hg9YVpblx5hzU8TYSbVHx92iZ+iowFcVDhqePutu9UWly5zPSH+bAN35 IWzHa+q0zUEQ56Eg5pNZg8A1jYdf0a7RoNoLpAyOeIpHqUzecXuVXsYvycQunbyW9h2Ge42a7jo GeI4uW/b2aSyOw0C7MYWdc1Vrc1kGV3xCJ6KyCVwulvKu1mK4VGlXlNjPd+wTd1Alhv8TZqNV9B Q5AlIpP+5fSbBQ+a57qMGA46R6rv7uleaTFTIlSLcyouml+2GIC25cq0AStYqoIM9g8vnFXI2Wh SKe469oXkeTrxrZsXJp6tPCoMA+dT+YEVt5YkzPIpjtFyU6qC8URup6W5X3DrwSSvNPDl3vAOrV vUoFdCMKel21yYlKNCOup263GFM8z3gXXBGZYUQuAtW/Kmv72vpyDnpVh9dOAdmyZ1ORPQO4JdA CJhJfAJJIMcQUHg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/avtab.h | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/security/selinux/ss/avtab.h b/security/selinux/ss/avtab.h index 3c3904bf02b0..8e8820484c55 100644 --- a/security/selinux/ss/avtab.h +++ b/security/selinux/ss/avtab.h @@ -9,42 +9,42 @@ * Author : Stephen Smalley, */ -/* Updated: Frank Mayer and Karl MacMillan - * - * Added conditional policy language extensions - * - * Copyright (C) 2003 Tresys Technology, LLC +/* Updated: Frank Mayer and + * Karl MacMillan + * Added conditional policy language extensions + * Copyright (C) 2003 Tresys Technology, LLC * * Updated: Yuichi Nakamura - * Tuned number of hash slots for avtab to reduce memory usage + * Tuned number of hash slots for avtab to reduce memory usage */ + #ifndef _SS_AVTAB_H_ #define _SS_AVTAB_H_ #include "security.h" struct avtab_key { - u16 source_type; /* source type */ - u16 target_type; /* target type */ - u16 target_class; /* target object class */ -#define AVTAB_ALLOWED 0x0001 -#define AVTAB_AUDITALLOW 0x0002 -#define AVTAB_AUDITDENY 0x0004 -#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY) -#define AVTAB_TRANSITION 0x0010 -#define AVTAB_MEMBER 0x0020 -#define AVTAB_CHANGE 0x0040 -#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE) + u16 source_type; /* source type */ + u16 target_type; /* target type */ + u16 target_class; /* target object class */ +#define AVTAB_ALLOWED 0x0001 +#define AVTAB_AUDITALLOW 0x0002 +#define AVTAB_AUDITDENY 0x0004 +#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY) +#define AVTAB_TRANSITION 0x0010 +#define AVTAB_MEMBER 0x0020 +#define AVTAB_CHANGE 0x0040 +#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE) /* extended permissions */ #define AVTAB_XPERMS_ALLOWED 0x0100 -#define AVTAB_XPERMS_AUDITALLOW 0x0200 +#define AVTAB_XPERMS_AUDITALLOW 0x0200 #define AVTAB_XPERMS_DONTAUDIT 0x0400 -#define AVTAB_XPERMS (AVTAB_XPERMS_ALLOWED | \ - AVTAB_XPERMS_AUDITALLOW | \ - AVTAB_XPERMS_DONTAUDIT) -#define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */ -#define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */ - u16 specified; /* what field is specified */ +#define AVTAB_XPERMS \ + (AVTAB_XPERMS_ALLOWED | AVTAB_XPERMS_AUDITALLOW | \ + AVTAB_XPERMS_DONTAUDIT) +#define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */ +#define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */ + u16 specified; /* what field is specified */ }; /* @@ -53,8 +53,8 @@ struct avtab_key { */ struct avtab_extended_perms { /* These are not flags. All 256 values may be used */ -#define AVTAB_XPERMS_IOCTLFUNCTION 0x01 -#define AVTAB_XPERMS_IOCTLDRIVER 0x02 +#define AVTAB_XPERMS_IOCTLFUNCTION 0x01 +#define AVTAB_XPERMS_IOCTLDRIVER 0x02 /* extension of the avtab_key specified */ u8 specified; /* ioctl, netfilter, ... */ /* @@ -82,9 +82,9 @@ struct avtab_node { struct avtab { struct avtab_node **htable; - u32 nel; /* number of elements */ - u32 nslot; /* number of hash slots */ - u32 mask; /* mask to compute hash func */ + u32 nel; /* number of elements */ + u32 nslot; /* number of hash slots */ + u32 mask; /* mask to compute hash func */ }; void avtab_init(struct avtab *h); @@ -92,6 +92,9 @@ int avtab_alloc(struct avtab *, u32); int avtab_alloc_dup(struct avtab *new, const struct avtab *orig); void avtab_destroy(struct avtab *h); +#define MAX_AVTAB_HASH_BITS 16 +#define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS) + #ifdef CONFIG_SECURITY_SELINUX_DEBUG void avtab_hash_eval(struct avtab *h, const char *tag); #else @@ -107,7 +110,8 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, void *p); int avtab_read(struct avtab *a, void *fp, struct policydb *pol); -int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp); +int avtab_write_item(struct policydb *p, const struct avtab_node *cur, + void *fp); int avtab_write(struct policydb *p, struct avtab *a, void *fp); struct avtab_node *avtab_insert_nonunique(struct avtab *h, @@ -116,11 +120,7 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_node *avtab_search_node(struct avtab *h, const struct avtab_key *key); +struct avtab_node *avtab_search_node_next(struct avtab_node *node, + u16 specified); -struct avtab_node *avtab_search_node_next(struct avtab_node *node, u16 specified); - -#define MAX_AVTAB_HASH_BITS 16 -#define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS) - -#endif /* _SS_AVTAB_H_ */ - +#endif /* _SS_AVTAB_H_ */ From patchwork Thu Feb 22 23:52:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568370 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1B8213BAE4 for ; Thu, 22 Feb 2024 23:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646378; cv=none; b=AjNDIBtkAJBWmthMz2sdPRaTRT9s14KmgcfTcpW3yhMIlxKgJGbXifH18W9UzdRXrYst8LwQEUSi4/G1UexxOG/RFZ/eczv0CT1QCWlxo5U3Ryn0iXMtTW7mW3WRGPXcDhllsizf8YJhjHBmlqBw7yeAd0ESIIbzf084eaGceIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646378; c=relaxed/simple; bh=0fVSh2FjiZdmeQLP8Uxj8vTi9A5AAMiY1pz5LNo1qEU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CrPNjOyZ6lArD9jfa6fRUA2XKhUE17+DFp93CwC48MyQHvZOz5HJlmiW6XmIIdJ/Zpqk6IaMHKkNoOlQH+k1W9NUo3SV0gUf7JolbgBWz2C0UfWiR147JAWOuHQ6xjt1pGcwpMkz791kep+q/jCL8UiSN8RafsBedsutnkbalpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=WaSrDbYx; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="WaSrDbYx" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-68f41af71ebso3038386d6.1 for ; Thu, 22 Feb 2024 15:59:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646375; x=1709251175; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=C6NCNpAh9fK3zsSUfb8VZalzo09bT41aWRdPAN/2tmQ=; b=WaSrDbYxn8Scal0hMmPCRc1JSzfYd7V8VraLHPSOP5j1mYM6VcTv7bMLwWB7D7PfOA KbNehzI4zRdh0LeH495Odu7sEemTSjZWOGBIUgxwbyXwm1lblU9YXtwNM+Bh44+sC3pA 9DKBb2gvPp1L//dXxL+WT7u37nPqnXG61dNzGavI1WFeWtyiQdcD/qNhigIRYZi1bWeX hDCekhmxc9NdoEjk8rMwEvo2ceNk9KGhc64YzyUZcWON7XBlyegR3MR+xLKgCpQ2C2kn UFbeo8w6qtB8vHDT1Y+Ue2FVmCWhuwbKgI4ctWPYoHVuvsE85O9lTKIaQ85E6BuaqJVd QAww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646375; x=1709251175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C6NCNpAh9fK3zsSUfb8VZalzo09bT41aWRdPAN/2tmQ=; b=sh7MyQPe+mGWNkwt0NYzKTjdMU4H/uCIwHGX5d5EGos/1rsg+i1DsMkPMof+0QMHWq nYvNOV+Cr8xs0TjAwMk9UvHHThrgG9Gefa3Oyd+2zE4oxaVVY1LivLq88Rd2lNsjVmD0 zfmgAMewO3Qg2qNZqII6gA6wwVr+RlcEto7+kn0O1yURKuxDIEKQC7wuK2p5iEl+eHuz LLsSh8VVtmAo9rJECj8/1dpQWmp6O6t/sBxmQXu8znHZQVuS1gZ+VT5ty2utIbtgrYcO C71ZzAzvutgEtG1PWR2Pt+Xb1sucdNsc2mQ5whhed6W1muLqJxmCoB9Vqb2yfj1aX7la HcdA== X-Gm-Message-State: AOJu0YyYJcL0NjRMkVTVtU7250lZFng7wrYmwj/VHq6lahCgbsTFIiNl x/hgcn+bKBt9z6Vqle/Yfp2nMEjqVyQREMgWPEYzujxHC2vmXdrcvM0S2drn7281Lp9jCQUN6dg = X-Google-Smtp-Source: AGHT+IH+x3XLztcH74tchXvJjxeHF4/sC/GrP297WF8ShsdDG9kzYANrE6/VzHtN9xN3PxHqAeOrWQ== X-Received: by 2002:a05:6214:29e4:b0:68f:2f2d:d01 with SMTP id jv4-20020a05621429e400b0068f2f2d0d01mr642666qvb.10.1708646375396; Thu, 22 Feb 2024 15:59:35 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id d11-20020a05621416cb00b0068d11cf887bsm7475661qvz.55.2024.02.22.15.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:34 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 02/21] selinux: fix style issues in security/selinux/ss/avtab.c Date: Thu, 22 Feb 2024 18:52:20 -0500 Message-ID: <20240222235708.386652-25-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10549; i=paul@paul-moore.com; h=from:subject; bh=0fVSh2FjiZdmeQLP8Uxj8vTi9A5AAMiY1pz5LNo1qEU=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199b8FKGaDhUD8aWuiNiaStUOCwmEHaGIu8+J y97UfoWjnaJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffWwAKCRDqIPLalzeJ c/BRD/9+nBy7Y5UgvcP5ZmvUctXWh8L4xFgdgBozWLi9fIJMMcBrOBuESacb6iapIk+TJ0UdC/e 9bkTAuqM+llbwu9Pb97bcwfkSFwRG0m0yvH6Pf7+ZAZXEeuGwIp88hKla35eSwBzOYRIuAdxa1a iFQU4sj1A5Fy5kmxs29zECBJATLPsVNUxktO0RDUZvQFKqBfQGDEnwDTjlCApMjW6ANaXk+qWgA yc1F7SXxuXUMhRabYcBKvaKoPh6uhx42USRkapbxYOo5PEADDxIbD5/ZRbtVXHXeU2EsfRXPP2b Drk0Wcla912rOiiw1lEx4HZ9oeKhHb6RRZsniIDT4CqmueIvsyn+72JJ5RZC+m3T0008xYJzBvV H1TaBz4fQSRU+8TLTQ1Y8dEN5AhjaNqPmBxSWeEUbAZ4iAJRadULqneaaKmtbHglaQvVyNJEUt0 588+1Z8XVyREIfi69UMKa5hGiIsmBZS/Gs8Z/6DHI/bj0pO4/+FmngGO9YnYd9zw4qVBOG8xinN EvexDjp1Q8uOOdjJUYfHW7gi6KlcwKw1yT/UepKx/i0k1H3htO92KTrKBQ96fGfWsPvekhUpg/R +N8UadfMznejM+h71q913vNPxzeoWGkDyEeIg1dQHcdH14cmlTtEa99US2uaRobER8h44REZDxA 14K6SBPAMhOgUxw== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/avtab.c | 105 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c index 697eb4352439..2ad98732d052 100644 --- a/security/selinux/ss/avtab.c +++ b/security/selinux/ss/avtab.c @@ -1,20 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Implementation of the access vector table type. * * Author : Stephen Smalley, */ -/* Updated: Frank Mayer and Karl MacMillan - * - * Added conditional policy language extensions - * - * Copyright (C) 2003 Tresys Technology, LLC - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2. +/* Updated: Frank Mayer and + * Karl MacMillan + * Added conditional policy language extensions + * Copyright (C) 2003 Tresys Technology, LLC * * Updated: Yuichi Nakamura - * Tuned number of hash slots for avtab to reduce memory usage + * Tuned number of hash slots for avtab to reduce memory usage */ #include @@ -36,19 +33,20 @@ static inline u32 avtab_hash(const struct avtab_key *keyp, u32 mask) static const u32 c2 = 0x1b873593; static const u32 r1 = 15; static const u32 r2 = 13; - static const u32 m = 5; - static const u32 n = 0xe6546b64; + static const u32 m = 5; + static const u32 n = 0xe6546b64; u32 hash = 0; -#define mix(input) do { \ - u32 v = input; \ - v *= c1; \ - v = (v << r1) | (v >> (32 - r1)); \ - v *= c2; \ - hash ^= v; \ +#define mix(input) \ + do { \ + u32 v = input; \ + v *= c1; \ + v = (v << r1) | (v >> (32 - r1)); \ + v *= c2; \ + hash ^= v; \ hash = (hash << r2) | (hash >> (32 - r2)); \ - hash = hash * m + n; \ + hash = hash * m + n; \ } while (0) mix(keyp->target_class); @@ -66,9 +64,10 @@ static inline u32 avtab_hash(const struct avtab_key *keyp, u32 mask) return hash & mask; } -static struct avtab_node* -avtab_insert_node(struct avtab *h, struct avtab_node **dst, - const struct avtab_key *key, const struct avtab_datum *datum) +static struct avtab_node *avtab_insert_node(struct avtab *h, + struct avtab_node **dst, + const struct avtab_key *key, + const struct avtab_datum *datum) { struct avtab_node *newnode; struct avtab_extended_perms *xperms; @@ -99,7 +98,7 @@ avtab_insert_node(struct avtab *h, struct avtab_node **dst, static int avtab_node_cmp(const struct avtab_key *key1, const struct avtab_key *key2) { - u16 specified = key1->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); + u16 specified = key1->specified & ~(AVTAB_ENABLED | AVTAB_ENABLED_OLD); if (key1->source_type == key2->source_type && key1->target_type == key2->target_type && @@ -129,8 +128,7 @@ static int avtab_insert(struct avtab *h, const struct avtab_key *key, return -EINVAL; hvalue = avtab_hash(key, h->mask); - for (prev = NULL, cur = h->htable[hvalue]; - cur; + for (prev = NULL, cur = h->htable[hvalue]; cur; prev = cur, cur = cur->next) { cmp = avtab_node_cmp(key, &cur->key); /* extended perms may not be unique */ @@ -163,8 +161,7 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h, if (!h || !h->nslot || h->nel == U32_MAX) return NULL; hvalue = avtab_hash(key, h->mask); - for (prev = NULL, cur = h->htable[hvalue]; - cur; + for (prev = NULL, cur = h->htable[hvalue]; cur; prev = cur, cur = cur->next) { cmp = avtab_node_cmp(key, &cur->key); if (cmp <= 0) @@ -188,8 +185,7 @@ struct avtab_node *avtab_search_node(struct avtab *h, return NULL; hvalue = avtab_hash(key, h->mask); - for (cur = h->htable[hvalue]; cur; - cur = cur->next) { + for (cur = h->htable[hvalue]; cur; cur = cur->next) { cmp = avtab_node_cmp(key, &cur->key); if (cmp == 0) return cur; @@ -199,8 +195,8 @@ struct avtab_node *avtab_search_node(struct avtab *h, return NULL; } -struct avtab_node* -avtab_search_node_next(struct avtab_node *node, u16 specified) +struct avtab_node *avtab_search_node_next(struct avtab_node *node, + u16 specified) { struct avtab_key tmp_key; struct avtab_node *cur; @@ -314,17 +310,19 @@ void avtab_hash_eval(struct avtab *h, const char *tag) if (chain_len > max_chain_len) max_chain_len = chain_len; - chain2_len_sum += (unsigned long long)chain_len * chain_len; + chain2_len_sum += + (unsigned long long)chain_len * chain_len; } } pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " - "longest chain length %d, sum of chain length^2 %llu\n", - tag, h->nel, slots_used, h->nslot, max_chain_len, - chain2_len_sum); + "longest chain length %d, sum of chain length^2 %llu\n", + tag, h->nel, slots_used, h->nslot, max_chain_len, + chain2_len_sum); } #endif /* CONFIG_SECURITY_SELINUX_DEBUG */ +/* clang-format off */ static const uint16_t spec_order[] = { AVTAB_ALLOWED, AVTAB_AUDITDENY, @@ -336,6 +334,7 @@ static const uint16_t spec_order[] = { AVTAB_XPERMS_AUDITALLOW, AVTAB_XPERMS_DONTAUDIT }; +/* clang-format on */ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, int (*insertf)(struct avtab *a, const struct avtab_key *k, @@ -365,9 +364,8 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, if (items2 > ARRAY_SIZE(buf32)) { pr_err("SELinux: avtab: entry overflow\n"); return -EINVAL; - } - rc = next_entry(buf32, fp, sizeof(u32)*items2); + rc = next_entry(buf32, fp, sizeof(u32) * items2); if (rc) { pr_err("SELinux: avtab: truncated entry\n"); return rc; @@ -400,8 +398,7 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, pr_err("SELinux: avtab: null entry\n"); return -EINVAL; } - if ((val & AVTAB_AV) && - (val & AVTAB_TYPE)) { + if ((val & AVTAB_AV) && (val & AVTAB_TYPE)) { pr_err("SELinux: avtab: entry has both access vectors and types\n"); return -EINVAL; } @@ -428,7 +425,7 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, return 0; } - rc = next_entry(buf16, fp, sizeof(u16)*4); + rc = next_entry(buf16, fp, sizeof(u16) * 4); if (rc) { pr_err("SELinux: avtab: truncated entry\n"); return rc; @@ -454,10 +451,11 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, } if ((vers < POLICYDB_VERSION_XPERMS_IOCTL) && - (key.specified & AVTAB_XPERMS)) { + (key.specified & AVTAB_XPERMS)) { pr_err("SELinux: avtab: policy version %u does not " - "support extended permissions rules and one " - "was specified\n", vers); + "support extended permissions rules and one " + "was specified\n", + vers); return -EINVAL; } else if (key.specified & AVTAB_XPERMS) { memset(&xperms, 0, sizeof(struct avtab_extended_perms)); @@ -471,7 +469,8 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, pr_err("SELinux: avtab: truncated entry\n"); return rc; } - rc = next_entry(buf32, fp, sizeof(u32)*ARRAY_SIZE(xperms.perms.p)); + rc = next_entry(buf32, fp, + sizeof(u32) * ARRAY_SIZE(xperms.perms.p)); if (rc) { pr_err("SELinux: avtab: truncated entry\n"); return rc; @@ -507,7 +506,6 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol) __le32 buf[1]; u32 nel, i; - rc = next_entry(buf, fp, sizeof(u32)); if (rc < 0) { pr_err("SELinux: avtab: truncated table\n"); @@ -561,7 +559,8 @@ int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp) return rc; if (cur->key.specified & AVTAB_XPERMS) { - rc = put_entry(&cur->datum.u.xperms->specified, sizeof(u8), 1, fp); + rc = put_entry(&cur->datum.u.xperms->specified, sizeof(u8), 1, + fp); if (rc) return rc; rc = put_entry(&cur->datum.u.xperms->driver, sizeof(u8), 1, fp); @@ -570,7 +569,7 @@ int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp) for (i = 0; i < ARRAY_SIZE(cur->datum.u.xperms->perms.p); i++) buf32[i] = cpu_to_le32(cur->datum.u.xperms->perms.p[i]); rc = put_entry(buf32, sizeof(u32), - ARRAY_SIZE(cur->datum.u.xperms->perms.p), fp); + ARRAY_SIZE(cur->datum.u.xperms->perms.p), fp); } else { buf32[0] = cpu_to_le32(cur->datum.u.data); rc = put_entry(buf32, sizeof(u32), 1, fp); @@ -593,8 +592,7 @@ int avtab_write(struct policydb *p, struct avtab *a, void *fp) return rc; for (i = 0; i < a->nslot; i++) { - for (cur = a->htable[i]; cur; - cur = cur->next) { + for (cur = a->htable[i]; cur; cur = cur->next) { rc = avtab_write_item(p, cur, fp); if (rc) return rc; @@ -606,10 +604,9 @@ int avtab_write(struct policydb *p, struct avtab *a, void *fp) void __init avtab_cache_init(void) { - avtab_node_cachep = kmem_cache_create("avtab_node", - sizeof(struct avtab_node), - 0, SLAB_PANIC, NULL); - avtab_xperms_cachep = kmem_cache_create("avtab_extended_perms", - sizeof(struct avtab_extended_perms), - 0, SLAB_PANIC, NULL); + avtab_node_cachep = kmem_cache_create( + "avtab_node", sizeof(struct avtab_node), 0, SLAB_PANIC, NULL); + avtab_xperms_cachep = kmem_cache_create( + "avtab_extended_perms", sizeof(struct avtab_extended_perms), 0, + SLAB_PANIC, NULL); } From patchwork Thu Feb 22 23:52:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568371 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82C7717C6B for ; Thu, 22 Feb 2024 23:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646379; cv=none; b=cmyQKK2aRrjyMHd6WwlgMQasFb7nYMlX/Dvu9M6x05xF8nhojnvYRzqDmAkpLr4dRB49IoM5kaPTnWUr2URZDDbR405poszSeMcrsvCz+CkJxEPlDqdxh6kIhppmKb1usdV+T+0huY8ZLGysoZkSz/ffto8ILDPGIDLN+tJNhDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646379; c=relaxed/simple; bh=rU4Aoj8b7obCE5FUPb2bH8cgy59sAqCvEFGT8kXfjRE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3d/eocf9DBpaSX19pnz7Dcfw2PMZp9GbJFDVNfMvqPBF3i0ESf2D4CAUumqUgJjwHsdzduc13QJGG0RJ49A/IsuQPT8kVkwyFrHVD9Jx36A5js2VPWJRpCFn0zXxb3VXde+8xpzhfUXRmvE29Phpb82q/U8djJiF+lbMGuv1H8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=dTytBrS2; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="dTytBrS2" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-785bdb57dfaso125085985a.1 for ; Thu, 22 Feb 2024 15:59:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646376; x=1709251176; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dUFfgvT2p2NGB9BEp7fJ7yIOIoBEkH6tXFA3/vA00Ys=; b=dTytBrS2RXubgPL6Q6Dr13ptmf53RvT+c6IAFMKBgNBFp60j1bxAFmBV0m1sZGAbUD rm2sWG+B+kB3692ypPERhIFHD05OUme9rrhrQHVw8FQ3KuKUdDJK7R6Ve0vamo+mgksV Cu70ZAYBtDMCC9sssQ5he/sHO3gy3vBUKCMh+G9vJrroZRs3b7BXv9uVyAdTqIH5Y84j LTgcJmpO02KfDR0GVJL9LvjaxasUSh0cwuZpOz+bzY2zeh7NpL7+A14PWpBb1XOtVUen pc/JNsR+zI1Sfqx2INHLjfkGxNdSLbI1Jn5Z+RtrQQjUgKTYKM2vUXu6iZQTU0O/lzO8 XWwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646376; x=1709251176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dUFfgvT2p2NGB9BEp7fJ7yIOIoBEkH6tXFA3/vA00Ys=; b=p9e/j45Ym6Sx1FJwyVRCNPPFKBisnyMXHGqsTRwcxI10Z2Bf3tBPYpluaVwM+EYpKt SfgXjdkUKUleKxyMKiSlj282BrVJNVafNnY5gJr/+osFKVnO7+OAWfmehR4O0X6ZbjhG sVZL1B1opvEsftDM6nTxEiG3dQpvQnWVfSMjH1JlEXOMRP/jvuTti3UsR7oE+NpyjBAo oo8CzM2l/wcQcd2dDlLEOqshUBiYz+JwRAJIR803r9wxs10WihnLnAojTSRNX+jLCsyo gTpeaOL6P1dGef2kraPND7tEDdBMnm8KiOZ+IjKvSto97wrNUt6UAST7KEJbOxh8Uyuk f3kw== X-Gm-Message-State: AOJu0YwRFQUREdtGZhLI62r0FQFiogSHrVzZX4frwvdkMJPXkG1FezxR KHcgdC4B1kvzvIH70uJqIZUaT9ZaR/AzQmP0xNZAJbQC+UfSheqROs5VIP2CsCsegWxTtw7h1xg = X-Google-Smtp-Source: AGHT+IESExn85nftMTHIY7lVJ7LSuhUFW2BYIYi/4pND1MyaitPe7HbqfmXp2pjj0K5nTJ8u8ikpUg== X-Received: by 2002:a0c:f04b:0:b0:68f:30ec:f357 with SMTP id b11-20020a0cf04b000000b0068f30ecf357mr860302qvl.32.1708646376242; Thu, 22 Feb 2024 15:59:36 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ny13-20020a056214398d00b0068f133f4120sm7483604qvb.126.2024.02.22.15.59.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:35 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 03/21] selinux: fix style issues in security/selinux/ss/conditional.h Date: Thu, 22 Feb 2024 18:52:21 -0500 Message-ID: <20240222235708.386652-26-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2563; i=paul@paul-moore.com; h=from:subject; bh=rU4Aoj8b7obCE5FUPb2bH8cgy59sAqCvEFGT8kXfjRE=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199h/48DdJ7ez7VOy4xLLHd4Gy7daIParF/JL snvSm5aljuJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffYQAKCRDqIPLalzeJ c3VWEADbAZdp5CEUoJ+6ffNAkFrLfeVqHxRx6II2fPlx9Wjsd5NzH+ZfvBgGEVTyMLqZ90CJ1/D HcOSY7DLJ8OUb3pJ3Fu3DHogQmIhC9G38k/Z0DgxZDN4joc8uApXdoWAEuKj/UFEZoqBYuVw+Lj sGd0tIKtt0e0NVst8GNDDDhjxPHdMyTVSjJ9IoFY4H6CtJlgMQPDtCtlP96I1vEgcztkdKVgKrE aHAKHD+hc81d1dwKxzlAxhign/Pnkdi2zXWZqb7cpVR6LHuym89y2DK87/nsMSFDUziaYWoMdtO DCneQj1mGAf5tUbIaPQD4EWFBcIA55etl5csUXQ0R26S/DqCEOUvmEMbJJ1i1/nt/euDMmhhnGB 9xcw9hNos3iyVNhbu69bqPb2f2LHVqXaY0vFeMhUOZ9iH+3cBSuLaZi6vnHsxIDQTwwrIboBKMd 816u9YsrSs7u4bPN8MXzeddMsilwDzn2D+NRQ5uiwDWRH7giHJbDPl9T6vH9br9tSWukcZTR41V R186+1iV7K6U/gRei2FlTh52DDUjjl1dMk6uZO7hHUWYiav28cdxGUJSxrMaP6iIA09Z1MEY79X Of/1M9GrfgUMm7+kSU16aQvwcSyD2CCfMyUCL+LxUEZns6gGGaoEelOWVi+0UlmcuwqJF345hur gbHon29CcwC0/5w== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/conditional.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/security/selinux/ss/conditional.h b/security/selinux/ss/conditional.h index 5a7b51278dc6..b972ce40db18 100644 --- a/security/selinux/ss/conditional.h +++ b/security/selinux/ss/conditional.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* Authors: Karl MacMillan * Frank Mayer - * - * Copyright (C) 2003 - 2004 Tresys Technology, LLC + * Copyright (C) 2003 - 2004 Tresys Technology, LLC */ #ifndef _CONDITIONAL_H_ @@ -20,14 +19,14 @@ * in reverse polish notation. */ struct cond_expr_node { -#define COND_BOOL 1 /* plain bool */ -#define COND_NOT 2 /* !bool */ -#define COND_OR 3 /* bool || bool */ -#define COND_AND 4 /* bool && bool */ -#define COND_XOR 5 /* bool ^ bool */ -#define COND_EQ 6 /* bool == bool */ -#define COND_NEQ 7 /* bool != bool */ -#define COND_LAST COND_NEQ +#define COND_BOOL 1 /* plain bool */ +#define COND_NOT 2 /* !bool */ +#define COND_OR 3 /* bool || bool */ +#define COND_AND 4 /* bool && bool */ +#define COND_XOR 5 /* bool ^ bool */ +#define COND_EQ 6 /* bool == bool */ +#define COND_NEQ 7 /* bool != bool */ +#define COND_LAST COND_NEQ u32 expr_type; u32 boolean; }; @@ -75,9 +74,9 @@ int cond_write_bool(void *key, void *datum, void *ptr); int cond_write_list(struct policydb *p, void *fp); void cond_compute_av(struct avtab *ctab, struct avtab_key *key, - struct av_decision *avd, struct extended_perms *xperms); + struct av_decision *avd, struct extended_perms *xperms); void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, - struct extended_perms_decision *xpermd); + struct extended_perms_decision *xpermd); void evaluate_cond_nodes(struct policydb *p); void cond_policydb_destroy_dup(struct policydb *p); int cond_policydb_dup(struct policydb *new, struct policydb *orig); From patchwork Thu Feb 22 23:52:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568372 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A19ED18049 for ; Thu, 22 Feb 2024 23:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646380; cv=none; b=UptjNWZoVdma3mPuUeNVWK3p7JE9RNuIO/6839wib6CcTJ/JVM6DohvBGjzjObbx9MAqMqGkjaqj6wqP0V/gYE6qNfYqQOvZwDE5XmqPh0Bfnk16bfdgIrVozOmWC4eFNqPW1NS4oJZf8IuUJpON1W7ca4lX75axI5Ax76TIUVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646380; c=relaxed/simple; bh=LMQq413Eqt2J4vjabr+uBZYJ04yAIPv9qQHjRm1R/MU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WtnL8L5JtduCddx/XQPqHU46pvRhfrYPOjRoJE/bAwdPoofwSXNlNhR5cIcVEOE+JU0yyE8tTcIuzeQkz+78F4qHY28TJ2NM0SsPpmphkXLooXRLOv06YawjijwSuF81yoFfj9lY4MG04gDEEsbR3btWv0chiUYUpCK1+9NhGH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=PjsSDnYj; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="PjsSDnYj" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-787a405e724so20666485a.0 for ; Thu, 22 Feb 2024 15:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646377; x=1709251177; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O6W4PQhx/+ZIjjflGgrGprDfsDGNct6xtOBPwuAgZXA=; b=PjsSDnYjH4rDdRkzAdVHfiiug2fSOJbXAEiHT9axh6/TdUGBSBHga+8gVT/mfo+k1q cxq/Ju4tFFLullvuw8oURaHpOZ4qR53bSL+en4M/L5J0hxGYShtkPb4pj4n1Mbvj7Gzg gF+IsyfXrU1L3DP4e3mu4eFr0RG/M3gjshwOmzsqYvyDfebQgqPpZ5OptSAKB2zbcaMz h5cvXph6ZVA8UWXNA0PdLYfO6P8z/hCDtGrVXVoqP9LypnpLiU+YEfvFO2gPDFD2mSGV RRg818nQokwB763pziPVZrc0QwBegPSM9tu2eEIiXNSnvZlm73VpM7rvl4H2k4oFjZ18 BgWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646377; x=1709251177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O6W4PQhx/+ZIjjflGgrGprDfsDGNct6xtOBPwuAgZXA=; b=JLLd4c/Mm4zFvAJxP4OZ5+ASjkJs1AJaXc+kAxT0AI16OFQ9UOXknZKj80Ip52EwjL kZtG5CJrfyP9B5w1NbF/P+Z8UeNjHiBecHKf1TpNdubW71DHkVsyaS3qB7psVWPqzVdH w9Ql9XtfRaQZ+v4tC+fB2mvc4XjhCPQNg7dBhDESrAqG/s4oORwJ9Vc6lWpjn6hG38tm tTW2cv/7Izn+pIyCTF08CHu96g0DlNO/whokNgUq/do+Hi7nkw1oXTugDwK3oIPd2k59 l8LwfGPtdCPWQGn/kblMGw69eueTrLWjyjmxWJHEIyYlyjL8e9ilPmg3yRLzBFQGNp+l Jvow== X-Gm-Message-State: AOJu0YyoDum7zxsSk4XchB+o25RrpSjWKhBkznBwMQyBadX6jmbMWNMP M07lY635QkVYzBkkq8kNxDmmFdym3fvA+eXB3Z636lavLp7cdReOm6RRCZqPUtfzgNtB6pYTckQ = X-Google-Smtp-Source: AGHT+IGVd/9u3vQRts8kmHhVSb25brbZ8t+0GKycgx+KeMmhby9EUrig8LAFVSehbyDgunkuysxfjg== X-Received: by 2002:a05:620a:108c:b0:787:2377:a392 with SMTP id g12-20020a05620a108c00b007872377a392mr598223qkk.24.1708646377274; Thu, 22 Feb 2024 15:59:37 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id os22-20020a05620a811600b007871bac855fsm5812441qkn.47.2024.02.22.15.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:36 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 04/21] selinux: fix style issues in security/selinux/ss/conditional.c Date: Thu, 22 Feb 2024 18:52:22 -0500 Message-ID: <20240222235708.386652-27-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8139; i=paul@paul-moore.com; h=from:subject; bh=LMQq413Eqt2J4vjabr+uBZYJ04yAIPv9qQHjRm1R/MU=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199nDmPxau9Ly5Dnd7awfxantZdRQgedtMtwd +czdA+X1MuJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffZwAKCRDqIPLalzeJ c5r/EADDFZYbn+xzJ7AmvZMjtBXOl+RqOaRAjNkHxgCXV/iw12HyfDe2OBaP+SPBfx/qBuSMTh+ yjQ5t0JLBerGkSh0Z5rKjUpnqX6sVFrD7gB+miBvVaj4zRDpevwW+z9gzHuuvytyAZ3VzcAeWTk wamVZzB0yrkzCKXnafTevPAhyAkO21AvtRK9FUn4jvhKOLImqBE4cL/of03A1IdHhh2GW2VUveD V13iTMrF86BDdIl3HW0rzEjr7F/fSIvhl2SddE1VkqZKKlSwqGd4hljYTENJ24b1VDeWMeZg9l3 G/pTGdULukYikiBuaqD9ZVkUR9krtsTVRF3f+WkfhaGGlZSs8dMJM65gA23E1m9qkJ4mjOFFqjA 4HRhjghJsnSyZEeso72AllnSNBgTFrFKJRCSlgZP8ZM64PMUMvzLDxqHPzwoh71nYcJMxuIS86w cHRPUnoTDyLFBlsAeXUW7HvrkoUeg6GG6tByQNLgZArLK0Dxkft0DzRZ+w9zhhQ7mIpuJHeRTu1 w3I80ee+jQtYfb4CWtJakW8MHLxmYAktxmuN9qq+EW+1jdK9L3l9/vQvPf7VePgVvQdW0NYapz6 foJ/0IR8XAxzFI7wjtFKFURtYXH4jKmab/2iIH6xZHTOlwjZuIl33o5je8FaZngbNaIk2CqCkSt wek7P/WOQxqjKpg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/conditional.c | 68 +++++++++++++++---------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 81ff676f209a..f12476855b27 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -1,8 +1,7 @@ -// SPDX-License-Identifier: GPL-2.0-only +/* SPDX-License-Identifier: GPL-2.0-only */ /* Authors: Karl MacMillan * Frank Mayer - * - * Copyright (C) 2003 - 2004 Tresys Technology, LLC + * Copyright (C) 2003 - 2004 Tresys Technology, LLC */ #include @@ -166,9 +165,8 @@ void cond_policydb_destroy(struct policydb *p) int cond_init_bool_indexes(struct policydb *p) { kfree(p->bool_val_to_struct); - p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim, - sizeof(*p->bool_val_to_struct), - GFP_KERNEL); + p->bool_val_to_struct = kmalloc_array( + p->p_bools.nprim, sizeof(*p->bool_val_to_struct), GFP_KERNEL); if (!p->bool_val_to_struct) return -ENOMEM; return 0; @@ -287,7 +285,8 @@ static int cond_insertf(struct avtab *a, const struct avtab_key *k, if (other) { node_ptr = avtab_search_node(&p->te_cond_avtab, k); if (node_ptr) { - if (avtab_search_node_next(node_ptr, k->specified)) { + if (avtab_search_node_next(node_ptr, + k->specified)) { pr_err("SELinux: too many conflicting type rules.\n"); return -EINVAL; } @@ -478,8 +477,8 @@ int cond_write_bool(void *vkey, void *datum, void *ptr) * the conditional. This means that the avtab with the conditional * rules will not be saved but will be rebuilt on policy load. */ -static int cond_write_av_list(struct policydb *p, - struct cond_av_list *list, struct policy_file *fp) +static int cond_write_av_list(struct policydb *p, struct cond_av_list *list, + struct policy_file *fp) { __le32 buf[1]; u32 i; @@ -500,7 +499,7 @@ static int cond_write_av_list(struct policydb *p, } static int cond_write_node(struct policydb *p, struct cond_node *node, - struct policy_file *fp) + struct policy_file *fp) { __le32 buf[2]; int rc; @@ -555,7 +554,7 @@ int cond_write_list(struct policydb *p, void *fp) } void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, - struct extended_perms_decision *xpermd) + struct extended_perms_decision *xpermd) { struct avtab_node *node; @@ -563,7 +562,7 @@ void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, return; for (node = avtab_search_node(ctab, key); node; - node = avtab_search_node_next(node, key->specified)) { + node = avtab_search_node_next(node, key->specified)) { if (node->key.specified & AVTAB_ENABLED) services_compute_xperms_decision(xpermd, node); } @@ -572,7 +571,7 @@ void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, * av table, and if so, add them to the result */ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, - struct av_decision *avd, struct extended_perms *xperms) + struct av_decision *avd, struct extended_perms *xperms) { struct avtab_node *node; @@ -580,30 +579,29 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, return; for (node = avtab_search_node(ctab, key); node; - node = avtab_search_node_next(node, key->specified)) { - if ((u16)(AVTAB_ALLOWED|AVTAB_ENABLED) == - (node->key.specified & (AVTAB_ALLOWED|AVTAB_ENABLED))) + node = avtab_search_node_next(node, key->specified)) { + if ((u16)(AVTAB_ALLOWED | AVTAB_ENABLED) == + (node->key.specified & (AVTAB_ALLOWED | AVTAB_ENABLED))) avd->allowed |= node->datum.u.data; - if ((u16)(AVTAB_AUDITDENY|AVTAB_ENABLED) == - (node->key.specified & (AVTAB_AUDITDENY|AVTAB_ENABLED))) + if ((u16)(AVTAB_AUDITDENY | AVTAB_ENABLED) == + (node->key.specified & (AVTAB_AUDITDENY | AVTAB_ENABLED))) /* Since a '0' in an auditdeny mask represents a * permission we do NOT want to audit (dontaudit), we use * the '&' operand to ensure that all '0's in the mask * are retained (much unlike the allow and auditallow cases). */ avd->auditdeny &= node->datum.u.data; - if ((u16)(AVTAB_AUDITALLOW|AVTAB_ENABLED) == - (node->key.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED))) + if ((u16)(AVTAB_AUDITALLOW | AVTAB_ENABLED) == + (node->key.specified & (AVTAB_AUDITALLOW | AVTAB_ENABLED))) avd->auditallow |= node->datum.u.data; if (xperms && (node->key.specified & AVTAB_ENABLED) && - (node->key.specified & AVTAB_XPERMS)) + (node->key.specified & AVTAB_XPERMS)) services_compute_xperms_drivers(xperms, node); } } -static int cond_dup_av_list(struct cond_av_list *new, - struct cond_av_list *orig, - struct avtab *avtab) +static int cond_dup_av_list(struct cond_av_list *new, struct cond_av_list *orig, + struct avtab *avtab) { u32 i; @@ -614,9 +612,8 @@ static int cond_dup_av_list(struct cond_av_list *new, return -ENOMEM; for (i = 0; i < orig->len; i++) { - new->nodes[i] = avtab_insert_nonunique(avtab, - &orig->nodes[i]->key, - &orig->nodes[i]->datum); + new->nodes[i] = avtab_insert_nonunique( + avtab, &orig->nodes[i]->key, &orig->nodes[i]->datum); if (!new->nodes[i]) return -ENOMEM; new->len++; @@ -637,8 +634,7 @@ static int duplicate_policydb_cond_list(struct policydb *newp, newp->cond_list_len = 0; newp->cond_list = kcalloc(origp->cond_list_len, - sizeof(*newp->cond_list), - GFP_KERNEL); + sizeof(*newp->cond_list), GFP_KERNEL); if (!newp->cond_list) goto error; @@ -649,7 +645,8 @@ static int duplicate_policydb_cond_list(struct policydb *newp, newp->cond_list_len++; newn->cur_state = orign->cur_state; - newn->expr.nodes = kmemdup(orign->expr.nodes, + newn->expr.nodes = + kmemdup(orign->expr.nodes, orign->expr.len * sizeof(*orign->expr.nodes), GFP_KERNEL); if (!newn->expr.nodes) @@ -658,12 +655,12 @@ static int duplicate_policydb_cond_list(struct policydb *newp, newn->expr.len = orign->expr.len; rc = cond_dup_av_list(&newn->true_list, &orign->true_list, - &newp->te_cond_avtab); + &newp->te_cond_avtab); if (rc) goto error; rc = cond_dup_av_list(&newn->false_list, &orign->false_list, - &newp->te_cond_avtab); + &newp->te_cond_avtab); if (rc) goto error; } @@ -683,7 +680,8 @@ static int cond_bools_destroy(void *key, void *datum, void *args) return 0; } -static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig, void *args) +static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig, + void *args) { struct cond_bool_datum *datum; @@ -709,7 +707,7 @@ static int cond_bools_index(void *key, void *datum, void *args) } static int duplicate_policydb_bools(struct policydb *newdb, - struct policydb *orig) + struct policydb *orig) { struct cond_bool_datum **cond_bool_array; int rc; @@ -721,7 +719,7 @@ static int duplicate_policydb_bools(struct policydb *newdb, return -ENOMEM; rc = hashtab_duplicate(&newdb->p_bools.table, &orig->p_bools.table, - cond_bools_copy, cond_bools_destroy, NULL); + cond_bools_copy, cond_bools_destroy, NULL); if (rc) { kfree(cond_bool_array); return -ENOMEM; From patchwork Thu Feb 22 23:52:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568373 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9902017C6B for ; Thu, 22 Feb 2024 23:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646381; cv=none; b=Ai6OpWftRJSVqjRsYbG2OLLoB+caUJmV82EqUNsUtM0peX2vA8OEaaXQDf05CjFSF68xpPwNzb1sTsKapKgaXyeifRe6wAU9H+Sbqeo6blxppJ6FLLD2k0lN6mc6HtOQPpouq1MozI8al1ZkWv3f9y7zPB5iJwUsU1a2kjpGYS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646381; c=relaxed/simple; bh=Iihe8s1sFaOvE4CS3K2TO5MWVkqI4zzguQZqRU/8ZzA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PFkkZFqmw5kmD2crMOfIfFg9BMZXZyQ/1DEiYr9H4s1bM/7bXb1kZF8Vx1fy/RCOx609mGgnmKjDrCse+vMimDTTGgZaC84S3z6kuu/y/3dprexEfgAFUTW5/ZzuSBUpN9TMv/Ep+NxsN70GIAwV7zDsmOOj7uxBPe1uH1HCt84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=HtXSFk9N; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="HtXSFk9N" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dc74e33fe1bso302349276.0 for ; Thu, 22 Feb 2024 15:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646378; x=1709251178; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1UW1y8eGbJV0lEMF+NxX+J6VP42PfeC1qW7qh9t/xVs=; b=HtXSFk9NSOAoSwatZ8il0eCIkoNYQ/T9ckDM+cM+XGIf0VnLMJceQT+lWvc50wsKwy 8d0MjB4P7+d6iMzpCDywY0qYDmCSjeSvixV7H6g0lYupbSOTAHDkbdyRnn8FRSoc3ugF taFHHdfzLAi7JgmcC+Wc2tN+1SKRkeCS8l3w/bTYedh0yFHsVQwekVmsZ2qesGdQH07W Bpum5IMntjCPGaBUrMJB4pgGxF1080XxWhGecQLhJxxVDes2hgWUQJ207ClSFSz29HBP 4FGmXC/1rxxU6n1sc31fk+bt/qP1r+RegZQrAmm6e8X0ohtseHUL1AAO/W73k7MYEEPl Ob3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646378; x=1709251178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1UW1y8eGbJV0lEMF+NxX+J6VP42PfeC1qW7qh9t/xVs=; b=kyqfdPGLVUqsh1Ah+FB7FxFFDoJC0a71FNgsZfQ35yCuub96W4TJNLB4Lkw7r7ieOM fzSdNxw1/DvnCOrhosXYXuD3fmvf6umSTXYUWjilUMdA3n5SQPuzvz1Iw3sLyEbJfble m1oITIbfO2Bt73EBGXNSd34QBC9UjH6yxofrd8P0x4gOqNyy36gjOeppJcG2dFbBeIpa iK8o2Q9X0sLtZ6zJEW6t6lr+SuH9NDC+t2scaZcVctmSTcHKpVpcNCv2ckRQS5k5Xh/H sX3qulgeWWJyeGcwmh4lqMed/1jEAs8MLNI5fNq/Qps8yEGf4qbENX1Wvm5oEFAM0bBZ WH8Q== X-Gm-Message-State: AOJu0YxIE6PsPaq85e+q2LvJlMwleNkfwYcSI7nCN5fucyWcNnPxeVq6 jGDu+fnVcdVGl2z0T5c6+7IuYX6M1nvPkRO9qZVXdoylPF1nEPPrY9hw4iwQHt9d6ZT5IurPyqI = X-Google-Smtp-Source: AGHT+IHbmBilW1WasHK5Bm1hy7x7bDsQQw9pxSFtg6kBl9wmXa3iX9UBOppil+x+3p3WcGY8ES9Vdg== X-Received: by 2002:a81:bc45:0:b0:607:d46d:f8ac with SMTP id b5-20020a81bc45000000b00607d46df8acmr663090ywl.32.1708646378306; Thu, 22 Feb 2024 15:59:38 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id lr9-20020a0562145bc900b0068fd10638c0sm320559qvb.20.2024.02.22.15.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:37 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 05/21] selinux: fix style issues in security/selinux/ss/constraint.h Date: Thu, 22 Feb 2024 18:52:23 -0500 Message-ID: <20240222235708.386652-28-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4000; i=paul@paul-moore.com; h=from:subject; bh=Iihe8s1sFaOvE4CS3K2TO5MWVkqI4zzguQZqRU/8ZzA=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199tJazjAr2sUJW8+HDFz+gAx4XeQ3cj3NMuJ VqJ83RUzoyJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffbQAKCRDqIPLalzeJ c6HuEACjMQ4Vt7o7FLOBUreS0Ws0bAGFCDPl7DLTb39YZZVMn4TJ6O66il94s0Cgs4bDv7c0LRo vBcezRE8RCCmkVMZ74VKuO+5uAA7DEXKtO3rEzLeLewVfULQyzkJHqcu88zS6mfpkPpVyfCcfJC AUGW7uWwVJ6FQedHgqGZD7xBoBOuS8/OLFpfK9zuuT2zeex3PC0aCRZ6V24P0kcaIlacAFqn9GV Y/Hc9WypniHPDBhgqEwC1lIAIxfFT3us1aOWoDNZfIVGMPj6k+d0BAjgB4cYxlZYtpl+eYjl2OI trzB3ifwHMPYZHYU3esSjLfTYinU/u9eLlqiFzfBgkMrl7oBj+KSTbnqkcP6tvcBiy3bPfB8F7Z eNZgjz5k014o3slxoSx1x2wh0vLORRzGq3Lbts5gbtC/Moe9pa/bgKH/Vy9KURHabXZwd2b/z7/ /kIj0O6F3R4kQ0ROaE8CzHnVIx66VK0+4tFSTeZ47e+xK9iEWhCJdVx+CkMWqhRgc5Um2LVzh/r BCeH4FMzH174Ap314Ob2ypmOqgXEKM/TJnVeFqY8zsIzwpadSRHycij4ZfyF5tuXxeENZAETHXO dbny9cYGURYfnxt/ubOufNZpIPZzdKtXSzD22uRyjUmNwRYSvw5yfyP6oF/PvVPivPiUfhbNNg3 L4IV6f08GrRUOQg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/constraint.h | 61 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/security/selinux/ss/constraint.h b/security/selinux/ss/constraint.h index f76eb3128ad5..203033cfad67 100644 --- a/security/selinux/ss/constraint.h +++ b/security/selinux/ss/constraint.h @@ -13,6 +13,7 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_CONSTRAINT_H_ #define _SS_CONSTRAINT_H_ @@ -21,43 +22,43 @@ #define CEXPR_MAXDEPTH 5 struct constraint_expr { -#define CEXPR_NOT 1 /* not expr */ -#define CEXPR_AND 2 /* expr and expr */ -#define CEXPR_OR 3 /* expr or expr */ -#define CEXPR_ATTR 4 /* attr op attr */ -#define CEXPR_NAMES 5 /* attr op names */ - u32 expr_type; /* expression type */ +#define CEXPR_NOT 1 /* not expr */ +#define CEXPR_AND 2 /* expr and expr */ +#define CEXPR_OR 3 /* expr or expr */ +#define CEXPR_ATTR 4 /* attr op attr */ +#define CEXPR_NAMES 5 /* attr op names */ + u32 expr_type; /* expression type */ -#define CEXPR_USER 1 /* user */ -#define CEXPR_ROLE 2 /* role */ -#define CEXPR_TYPE 4 /* type */ -#define CEXPR_TARGET 8 /* target if set, source otherwise */ -#define CEXPR_XTARGET 16 /* special 3rd target for validatetrans rule */ -#define CEXPR_L1L2 32 /* low level 1 vs. low level 2 */ -#define CEXPR_L1H2 64 /* low level 1 vs. high level 2 */ -#define CEXPR_H1L2 128 /* high level 1 vs. low level 2 */ -#define CEXPR_H1H2 256 /* high level 1 vs. high level 2 */ -#define CEXPR_L1H1 512 /* low level 1 vs. high level 1 */ -#define CEXPR_L2H2 1024 /* low level 2 vs. high level 2 */ - u32 attr; /* attribute */ +#define CEXPR_USER 1 /* user */ +#define CEXPR_ROLE 2 /* role */ +#define CEXPR_TYPE 4 /* type */ +#define CEXPR_TARGET 8 /* target if set, source otherwise */ +#define CEXPR_XTARGET 16 /* special 3rd target for validatetrans rule */ +#define CEXPR_L1L2 32 /* low level 1 vs. low level 2 */ +#define CEXPR_L1H2 64 /* low level 1 vs. high level 2 */ +#define CEXPR_H1L2 128 /* high level 1 vs. low level 2 */ +#define CEXPR_H1H2 256 /* high level 1 vs. high level 2 */ +#define CEXPR_L1H1 512 /* low level 1 vs. high level 1 */ +#define CEXPR_L2H2 1024 /* low level 2 vs. high level 2 */ + u32 attr; /* attribute */ -#define CEXPR_EQ 1 /* == or eq */ -#define CEXPR_NEQ 2 /* != */ -#define CEXPR_DOM 3 /* dom */ -#define CEXPR_DOMBY 4 /* domby */ -#define CEXPR_INCOMP 5 /* incomp */ - u32 op; /* operator */ +#define CEXPR_EQ 1 /* == or eq */ +#define CEXPR_NEQ 2 /* != */ +#define CEXPR_DOM 3 /* dom */ +#define CEXPR_DOMBY 4 /* domby */ +#define CEXPR_INCOMP 5 /* incomp */ + u32 op; /* operator */ - struct ebitmap names; /* names */ + struct ebitmap names; /* names */ struct type_set *type_names; - struct constraint_expr *next; /* next expression */ + struct constraint_expr *next; /* next expression */ }; struct constraint_node { - u32 permissions; /* constrained permissions */ - struct constraint_expr *expr; /* constraint on permissions */ - struct constraint_node *next; /* next constraint */ + u32 permissions; /* constrained permissions */ + struct constraint_expr *expr; /* constraint on permissions */ + struct constraint_node *next; /* next constraint */ }; -#endif /* _SS_CONSTRAINT_H_ */ +#endif /* _SS_CONSTRAINT_H_ */ From patchwork Thu Feb 22 23:52:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568374 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C68313BAD8 for ; Thu, 22 Feb 2024 23:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646382; cv=none; b=RYvoiogE7T1yMQLATrP/Gl4RDWleQzebni3fu3DEXQnOv0MUnxwtBQ/fDh4UIf3a+K+oUiCNBxcck4LYfuAMlTyHdGyvRVfCVXCymThBeLl8MdMnt++HQ6lwMD0BAM/OHWYWS+SWGziJHUTpELRN7Spkb+Uko1HW5MkKNUMn35g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646382; c=relaxed/simple; bh=nWclI/WNaY953BNWPwF0H3A/2zAf4SLm8p/pX6i8ELg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PybEAwCbTAJmTYN2x4ILJOs3NG2W1nCOrqo2Kg/kUEb416u+iJ2/cxHO/921dICP/c/POUhJkG3aou+qxvM+8fnj4VgMOkfOZQakBwbU2/ZldvTmHTKh6tGYQRVkDLmb42aUkwJEA5Y/+apFeoeHko5d/dMLT7ohhVbZgxC8DqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=gOa97s6R; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="gOa97s6R" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-785d60ae6d5so17463285a.2 for ; Thu, 22 Feb 2024 15:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646380; x=1709251180; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XhRMDzIqMN9vAgL7g4G+De5ERjBqKSmTwN4GVi7IUac=; b=gOa97s6Rth76G3ByhQA+KRvpdfkWlzvNjqeQr1Dtp9cDJ83kHnqwoCM7yrbsK05PR3 B/M1CYQnRlzkm0BE0e6nrNNcbIrMUSrzkDny1ft5CA1PH3RUJffy2Tsd2NmdAGBvIWGn 0N8JNxWKBt80a4XxA6dpDQkTBaMPCe+nauIxysrCaYMQPJ4NmgfCl1wIrPa8d779awal YPN0/zNQuOLkKrI/dX6uDJn75h4tkooFkNsLjaqijanxUU5YWi5k6xM9P4V+YiFLFjOq 6MkL3f04Ue1uoOJKonHSA56q389g2ClGMQvsBGz88sBBoTxFGd8SybbVhZAox9sscWHr nFYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646380; x=1709251180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XhRMDzIqMN9vAgL7g4G+De5ERjBqKSmTwN4GVi7IUac=; b=LZcJ4il4CfE+VuaGuMTA/dvqPLo9SoBEeKlqa1AvJI5OQY5Hkf6eGue6hc/AEd4ZGG CgImMyCNjIRVpqFtCnHmWTa1uXkSbkIrPBgDFWwo/gu4rYvX/3J4m9qOEvy+X07GNpSs +JXiV1rYp6yvTAI7650u/4B4aO9yyUWMB4M6zg9bIhtmkgmo4hwudKFr0Rjm9VyCsrwr BHuo8rhcqim2PxN7Z+d0krKFS4G6eeN/YzWdTEvWIhj1YB60uAN9sngGX/QW+Rbsk/gJ zwXHbEDhcdcyCc0VAED5bQ9vWbb9r12nd9T7OkTMZyWbwMb/1x5FGuD2cE0fSGDqWG1v OYLA== X-Gm-Message-State: AOJu0YziqFWPfW3OXx4x86+788aBX7C5Iy22RMLyuA/2J+x8+JqwVmdj bB/59txUZ0wVrsYjKsYR8XQ2B56RBNJ8ObQiC2dnVTXjrKFjAHcFwzzunXUTXw+e+wIKgQpJpQU = X-Google-Smtp-Source: AGHT+IHu9aAH4ZGz6CWdA6vIG0/BwWXPtH7hC7B9rkkOb+YgVhJdzhUbEWTSLozGOw6t7Hu/B7+E4Q== X-Received: by 2002:a05:620a:ec7:b0:785:ce02:4f82 with SMTP id x7-20020a05620a0ec700b00785ce024f82mr634123qkm.17.1708646379287; Thu, 22 Feb 2024 15:59:39 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id u3-20020ae9c003000000b007873306737fsm5833299qkk.87.2024.02.22.15.59.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:38 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 06/21] selinux: fix style issues in security/selinux/ss/context.h Date: Thu, 22 Feb 2024 18:52:24 -0500 Message-ID: <20240222235708.386652-29-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4730; i=paul@paul-moore.com; h=from:subject; bh=nWclI/WNaY953BNWPwF0H3A/2zAf4SLm8p/pX6i8ELg=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl199zOeOr5DsTx3StwAehE3ck5MryfzdVXkNLr euyIyfQIUmJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffcwAKCRDqIPLalzeJ c6jVEADeTrp2S0+NkvBw+lJ/fc2t6brZyQOS1XCvUfohcbCMRwxJJdLwzW1DK+S9ysXgUPE67G9 OOKnLadGqO7A1mJawvswslRgX5H3UWrmK6xVnMK2KhCynj/CvTE7CNC1Dco/8e5tz8YWT4UfPie irC3oJ6cjOXhHxtxUY2e8TfX2pQhFO0IKZmy3eNkFFt3tpWsifX6CwPaK9xrib+cXe+emYmsKAf 7THmPOxKuoI3Z22P8+LvKr6qYmNVlHQJmADalTt2gm1Dg3wg3DBDCGW9UyvDGRBrNDeXKqf3Us6 gpwvRP/oPOuma+KNbHZTS+OaCFmoVXsdtDG7Ner+fCgJIQaMb2aIiFonhAtVHu7sXniaTacETva v6OKjv026qgLS/loNTWtA0OxRL9y5pwtGu+Ifr0xIrtuxYP/LiRxQDk4aAHuqvvbQ8IRhh6PQ74 8UQzo6rcBhbvDBDNgoegsm9dVSqCNe9CcjwuLchGMWqS6Csp6mC4fjoz0VLzTCTi9x/Vk02ZTts J6HNrTrJ5YB9cWsdIygkLNhTTPvETmvSdyl1U7io58E6fifZGu0STnw5HD578WYtahTIypze8dP nmRm/pXFW2SvLKLodU3FrQWG/5rYHo5clZ7hXMSlbiKSeg081XTatIuJQvl8AGN0Nj9ul0HxA0H Npk04EGneXmjTqw== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/context.h | 41 +++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/security/selinux/ss/context.h b/security/selinux/ss/context.h index 1f59468c0759..7ccab2e6965f 100644 --- a/security/selinux/ss/context.h +++ b/security/selinux/ss/context.h @@ -13,6 +13,7 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_CONTEXT_H_ #define _SS_CONTEXT_H_ @@ -28,9 +29,9 @@ struct context { u32 user; u32 role; u32 type; - u32 len; /* length of string in bytes */ + u32 len; /* length of string in bytes */ struct mls_range range; - char *str; /* string representation if context cannot be mapped. */ + char *str; /* string representation if context cannot be mapped. */ }; static inline void mls_context_init(struct context *c) @@ -38,7 +39,8 @@ static inline void mls_context_init(struct context *c) memset(&c->range, 0, sizeof(c->range)); } -static inline int mls_context_cpy(struct context *dst, const struct context *src) +static inline int mls_context_cpy(struct context *dst, + const struct context *src) { int rc; @@ -58,7 +60,8 @@ static inline int mls_context_cpy(struct context *dst, const struct context *src /* * Sets both levels in the MLS range of 'dst' to the low level of 'src'. */ -static inline int mls_context_cpy_low(struct context *dst, const struct context *src) +static inline int mls_context_cpy_low(struct context *dst, + const struct context *src) { int rc; @@ -78,7 +81,8 @@ static inline int mls_context_cpy_low(struct context *dst, const struct context /* * Sets both levels in the MLS range of 'dst' to the high level of 'src'. */ -static inline int mls_context_cpy_high(struct context *dst, const struct context *src) +static inline int mls_context_cpy_high(struct context *dst, + const struct context *src) { int rc; @@ -95,9 +99,9 @@ static inline int mls_context_cpy_high(struct context *dst, const struct context return rc; } - static inline int mls_context_glblub(struct context *dst, - const struct context *c1, const struct context *c2) + const struct context *c1, + const struct context *c2) { struct mls_range *dr = &dst->range; const struct mls_range *r1 = &c1->range, *r2 = &c2->range; @@ -114,13 +118,13 @@ static inline int mls_context_glblub(struct context *dst, /* Take the least of the high */ dr->level[1].sens = min(r1->level[1].sens, r2->level[1].sens); - rc = ebitmap_and(&dr->level[0].cat, - &r1->level[0].cat, &r2->level[0].cat); + rc = ebitmap_and(&dr->level[0].cat, &r1->level[0].cat, + &r2->level[0].cat); if (rc) goto out; - rc = ebitmap_and(&dr->level[1].cat, - &r1->level[1].cat, &r2->level[1].cat); + rc = ebitmap_and(&dr->level[1].cat, &r1->level[1].cat, + &r2->level[1].cat); if (rc) goto out; @@ -128,7 +132,8 @@ static inline int mls_context_glblub(struct context *dst, return rc; } -static inline int mls_context_cmp(const struct context *c1, const struct context *c2) +static inline int mls_context_cmp(const struct context *c1, + const struct context *c2) { return ((c1->range.level[0].sens == c2->range.level[0].sens) && ebitmap_cmp(&c1->range.level[0].cat, &c2->range.level[0].cat) && @@ -183,19 +188,17 @@ static inline void context_destroy(struct context *c) mls_context_destroy(c); } -static inline int context_cmp(const struct context *c1, const struct context *c2) +static inline int context_cmp(const struct context *c1, + const struct context *c2) { if (c1->len && c2->len) return (c1->len == c2->len && !strcmp(c1->str, c2->str)); if (c1->len || c2->len) return 0; - return ((c1->user == c2->user) && - (c1->role == c2->role) && - (c1->type == c2->type) && - mls_context_cmp(c1, c2)); + return ((c1->user == c2->user) && (c1->role == c2->role) && + (c1->type == c2->type) && mls_context_cmp(c1, c2)); } u32 context_compute_hash(const struct context *c); -#endif /* _SS_CONTEXT_H_ */ - +#endif /* _SS_CONTEXT_H_ */ From patchwork Thu Feb 22 23:52:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568375 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4076F18049 for ; Thu, 22 Feb 2024 23:59:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646382; cv=none; b=ZPZdH5B992BsokdmM9KUya2BaxqTak7WMdH0PgctvVIs9BisGyKo1HPjVLvsL2fefWGfKZ5O4MsUGTkjhejKzLUKBIG8EWSDja0s3qYRwptCVB0rJHPvahnUc6Eyvx7RvJVAWUHYLtUFhpCl8XN8V+Q2GPemQxHsUf5xGLVDOPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646382; c=relaxed/simple; bh=X6GvxoH9upAtZZCKBtoNzCj/Cj+wYIc8saKdJBgRo48=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IRUMgB5PVIsNSsNiXFy9VqGJpMY/DP32HpIr30toFcddpElYbGTu8HKvd0hs1cAQl78jdlFPCqCEIyMIUqMssu6LyrgWBKPY27lHNY900Uw4OwH9osN8xHNLmqysaTrFn6HDK/mGK7r+deFLCsebOxYZ2ohhZz36IfQxkiO4xgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=IFEJwwxX; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="IFEJwwxX" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-68facd7ea4aso3687546d6.0 for ; Thu, 22 Feb 2024 15:59:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646380; x=1709251180; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4SvuoRk8B655yhxkpxtSUFejc6HdgaEv+APTwGrMM7c=; b=IFEJwwxXCTnL03MJqt5xFiUsL0VpYZJiemQi9YnOzcHfEHOSWF8FihKpB5oN+2AugP unyWg1ZnNNMF+vZuIBlc/PFyCraNBI4zq84lHMXnp/PDwkGmDxhzQs5WW1inKLM4dM8c b50I8mMS5IFhPCdABS67JCJQJum+4fCN7seV4hZ0yE6gbXLcpOVrAQiMn+l6g31gmQvG +JBF+dX1FjPMWZdGFTT1zCB6qS7rC9G5wPpSsR+Xu739ED/2tyWkQZsJI2mh/++zuxll A9YA2MDUSZ/gBPFJ5EmhR+1JxcG9K4lIl922HI8jSaEserc0onSFPHJpqSeBOy/H/VMX I/DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646380; x=1709251180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4SvuoRk8B655yhxkpxtSUFejc6HdgaEv+APTwGrMM7c=; b=pkVEi34X4oYp87sM8hUfErUJ0IwbOKJGDQ/ktXhnaZLdgMHDYCnot+eEOzM9bYs7Qm 01F6l4vKVm6ipIp+MAi4OEc/sqs0KNhNkEOQD0uR1TLMrVy2L9M8fFrfH5BhqhZ2ly1a 46r8ciOQqOZvzcUA1YlRBNiLioqwHhydZ5ZOlXxZB6Xli9EYEV4jHUnZ9Tf0AzALnc+5 +dk/WEqyNtAUBIz7tLSJdzaWXC4hZbCDOdEHUn7jlm57XiWL5pZ/0hWai3WeCOMtPnPg odWQf1KMxoaZ8tHiXno6S8RyitJynPhmASAoOsSvu91NMrtn8FMdg++cySnUHzAWcl9L 6pzQ== X-Gm-Message-State: AOJu0YzUmEm90M5VbmIio78Dja2nb0azugJDKiuVEdkiMIXoeakwGadi eoPX88jiXwLzdScwdVoak+A8yj/xt9nAr/vcALQ9jiL6VQLqxiiRmVCRkLUp/N5JVa2dILLdfTw = X-Google-Smtp-Source: AGHT+IFcDAbW0M2d6xhqk6e93O0izsklps/YVECiPVH99iW5UeWqTE9AO3slXW2inmEwqzJdj19pMQ== X-Received: by 2002:a0c:f3c4:0:b0:68f:a7ff:1106 with SMTP id f4-20020a0cf3c4000000b0068fa7ff1106mr908487qvm.13.1708646380086; Thu, 22 Feb 2024 15:59:40 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ly10-20020a0562145c0a00b0068f4520e42dsm2115572qvb.16.2024.02.22.15.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:39 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 07/21] selinux: fix style issues in security/selinux/ss/context.h Date: Thu, 22 Feb 2024 18:52:25 -0500 Message-ID: <20240222235708.386652-30-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=971; i=paul@paul-moore.com; h=from:subject; bh=X6GvxoH9upAtZZCKBtoNzCj/Cj+wYIc8saKdJBgRo48=; b=kA0DAAgB6iDy2pc3iXMByyZiAGXX33qgXiKs52iOO7n6pVXNtVRfI2LqesyAzIG4LQPFSQrQg YkCMwQAAQgAHRYhBEtCqM8H8pnVVJd+7+og8tqXN4lzBQJl1996AAoJEOog8tqXN4lzcgcP/RA9 yncbudnYTuI5fcR9XKLiKeF/AgXPHMuLJ13F5IEjj8Fwpt0S6UF/QLCEQWav3/m0T4BkGcY4WmA LmL0wlkmwtXhrlP+wx8aL4/OYub2A3Ch8RoEmhnMsr5Sjs2GLSSidAnspuDNP9ZofgKcf/v/2nq /cO9cc6TWuE5wX450gDuKFBhKrxMfSz0sr16vCq2OHb+MimO+bJNc+zI88Wns0XJb/HdDzfjtoy mIVbG5Ymmi9+h58mlppLVEzP3O3vM9ikhcMwvnOoVeyPfkWRHfHrAeyW5m4glRGuVsdfpkECuTM n372NxwhQYgqGWpKAbKRJku2+iil1dPSEHNb4j7CdIU8sHK8u4GBbA+BMR429s5qfVoZK68Hfa3 RoYwq8aQPTzA6ZzOF2Zzr1f3hLmFcnf8M3XyxgYRPeeac9djTgRx2ZbEZ5XheXrh5wXvmouViwk Ro+BxnurYavFTk6UTIoHGnl+EfQForaD/6PifME0MQhiL5u+hEMHKbZeorziRZb2cxXYl4QiE4a hwvGk4OFPpuObyFaqqUVS+dnDba8LtZCXzYujpW+30zmW6rRRIDpyonBgynQzabA44370eNmA8B jp7Sh9L9cnhnkIzBNTEiX2IchAe6eJSESBl+Br98iB9Em2yAPchWkz6aO6i9kKZsMzSiaKgkdGF A4HPv X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/ss/context.c b/security/selinux/ss/context.c index 38bc0aa524a6..e39990f494dd 100644 --- a/security/selinux/ss/context.c +++ b/security/selinux/ss/context.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Implementations of the security context functions. * From patchwork Thu Feb 22 23:52:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568376 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3A0717C6B for ; Thu, 22 Feb 2024 23:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646384; cv=none; b=BdaECnHWaO41Zvr3xYxycaPfk1w/xD2YFTu3S1kOyuwapY76EiP1XXiQOuhkt+D8NVZS5LE3+bngpD3doX/J88MUq3H5LC/Uf9M/tE7QWEHX1Ff1dZv0Uh54v+o6pssqZPla71kODTTZr8yTrdpS69xcI0aWNn1cJk/sjgZh0Ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646384; c=relaxed/simple; bh=yDE+tDI7cUEkdMPkALUTQfUiZZBC2in7MJZ29+gi/8w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SvYRMN9/cVZWCpw30D3iM5Zjtj59cbET04FAazu+k/PZGiO9zX2oC9nYswksRfISkT3cYti90nWQG3Ulk+ZQudH46UStwNxnYqCq6PiQbGqWZYx52KmVP3UDKt6ObS1fqXDxHRJc2uYd/Mo18cJWPbfTwB7LcS2Ni5Xd1WUgYLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=HheUP069; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="HheUP069" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-42c7f8588c5so1497271cf.3 for ; Thu, 22 Feb 2024 15:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646381; x=1709251181; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mX3TfZuholLrNzzA3yxupVAoX8mKWN1ORkoMX1bdMBc=; b=HheUP069kkYupzWZhuN+eUdwNHtMVdOU3tB9v7lQ59qzWXIhwwnOKpHETYqy7Ggl6A 2b7OnIBdK+oMw94VI2HN4bYeP5Jj1rOjpLHVze6ZEbQcEA2ntipgzF5lMPBWDVliRPVj ahCcm3Vy7nPYT4gflDfBaf8HH01mv+Ze+Hk48TwO8CrHogmFXDRVqsySr4tz5hMIp05a QSoPErCxNLLSbFKMpHZ2O+oviywK7kBLM9maoei4m3xJZSG9VOXOoXppqXZQHE9D/hrU VxlNQjcLQMED1mkI8MGMMKbefsbV1Aya2EH2Y6o2Ym1uCwGOtfLvLrIB46Z3fi4ESv1F NWPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646381; x=1709251181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mX3TfZuholLrNzzA3yxupVAoX8mKWN1ORkoMX1bdMBc=; b=JjZJZqHvSed06IGTUD8wivrFrDNaNTHEpOGoLy45wp2lEY1tLHCzIfbHD4rYmS7bH9 0HDAstVLXhryQ2FB9YzgZOKkwwyCUcXZa+cs4ZhkVSDM+NstXdtBViI/oRCRpI45vQZs I5B1Rk05FqqLf3+40igj8gee6LmUz0ds/sG5fhrsQHWwIE2jSPb2ocVX475SMN2Pe/Pe 4nfQheHpN2q2bfrIUKhK6cAbYmdy8INUO9lSZKSLNmx/dYeqMGl212g81bQYHiiuR6rN bznqrT5xEvr9W4DGwCmK1xSD71AaUxJ0XBAPc32S6VCGDtOoHDW0G3SbKbyhpEY7hICI 3Fsw== X-Gm-Message-State: AOJu0YyEmpEW0j0YZnNA9o3MX4vMYGGnPZvBapFVTWtOxWYFfgFajNSM 3VgLLXoUr1jC0EnrqiVrUt6MVg8DZS+73ANibRZWZ63K5DIT1A28FMImm/05OW0Xv4fKISrQJmg = X-Google-Smtp-Source: AGHT+IFRC7vV/asmhEJXW8v6N6fk4MbdoF7zJeS0+BpeFj1wzsbk4h0qrpkycxMzcvCBUfyYb4SmTw== X-Received: by 2002:ac8:5ac3:0:b0:42e:2721:13b2 with SMTP id d3-20020ac85ac3000000b0042e272113b2mr884438qtd.12.1708646381094; Thu, 22 Feb 2024 15:59:41 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id mw2-20020a05621433c200b0068f3291f860sm7477260qvb.95.2024.02.22.15.59.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:40 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 08/21] selinux: fix style issues in security/selinux/ss/ebitmap.h Date: Thu, 22 Feb 2024 18:52:26 -0500 Message-ID: <20240222235708.386652-31-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4146; i=paul@paul-moore.com; h=from:subject; bh=yDE+tDI7cUEkdMPkALUTQfUiZZBC2in7MJZ29+gi/8w=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+AW3YBoiiEl/IPWz7zwKDwKUeZFLntqz7BH 4lpxKPO+WuJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffgAAKCRDqIPLalzeJ c26sEACdyY5P+MHb/gcZpNrjfhdB+xCSNd8l3kX1HGpkBJzxSJJXbSKdZm/QS4a48T5N8xi+LG+ 8JAysNn2wKptULWu5qEEgrbNTGF8/bA3X9mq4G9crlG9i05+WrDOiWgkdjui8eXa8YBXPjoV8Rn Bg1fYt91+sIFs5kZnnkCh4c3KGVwsBj06bvEC0TNDZaPJRisZZddqq32oSeCBa/NAOD1GNg9wZp Hkw5aoJM0CsT8q6nJ8OVV2ounAsIWY4NSM4mPxjFZyMg2LcqkNXyJKwtsApFM6ESPJN21+hSxOb HYPmjcxMSKAR1gNEmTcv7RyVje4JMAlNUE5Qb2EpOSPQSiRoLHgqjx94FnrLWhVlG7gMRT2OojS V5Y8wsafmlmYpaxqUZ6YEBbRNnSMp7hj/loGbuC3++MldKywJjg6aBMtabrFwr6KIp2GZJkKhp9 LLcMVg9UPuwXMuGcqLWnBpgnX3XEWZ78K0p612kgJcg+ZW/LA8RG5lhfvl6rpmcpFRiZdehj14k odXRtpuHT61E71991Akqt2kp8Jij06dpI66w3kpOGFzWbcQjPeSPZqGRcWivIcOG72175WlJuoO YvffZGibMysFD6d/JbM5U55iJFRrfO8ILRzdUxTp3GV43AXk5+sQYPy3+ta53EqIapIZtweW7y/ 8icaky+1X/HmMlw== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/ebitmap.h | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/security/selinux/ss/ebitmap.h b/security/selinux/ss/ebitmap.h index e3c807cfad90..02798b35eecc 100644 --- a/security/selinux/ss/ebitmap.h +++ b/security/selinux/ss/ebitmap.h @@ -12,23 +12,25 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_EBITMAP_H_ #define _SS_EBITMAP_H_ #include #ifdef CONFIG_64BIT -#define EBITMAP_NODE_SIZE 64 +#define EBITMAP_NODE_SIZE 64 #else -#define EBITMAP_NODE_SIZE 32 +#define EBITMAP_NODE_SIZE 32 #endif -#define EBITMAP_UNIT_NUMS ((EBITMAP_NODE_SIZE-sizeof(void *)-sizeof(u32))\ - / sizeof(unsigned long)) -#define EBITMAP_UNIT_SIZE BITS_PER_LONG -#define EBITMAP_SIZE (EBITMAP_UNIT_NUMS * EBITMAP_UNIT_SIZE) -#define EBITMAP_BIT 1ULL -#define EBITMAP_SHIFT_UNIT_SIZE(x) \ +#define EBITMAP_UNIT_NUMS \ + ((EBITMAP_NODE_SIZE - sizeof(void *) - sizeof(u32)) / \ + sizeof(unsigned long)) +#define EBITMAP_UNIT_SIZE BITS_PER_LONG +#define EBITMAP_SIZE (EBITMAP_UNIT_NUMS * EBITMAP_UNIT_SIZE) +#define EBITMAP_BIT 1ULL +#define EBITMAP_SHIFT_UNIT_SIZE(x) \ (((x) >> EBITMAP_UNIT_SIZE / 2) >> EBITMAP_UNIT_SIZE / 2) struct ebitmap_node { @@ -38,8 +40,8 @@ struct ebitmap_node { }; struct ebitmap { - struct ebitmap_node *node; /* first node in the bitmap */ - u32 highbit; /* highest position in the total bitmap */ + struct ebitmap_node *node; /* first node in the bitmap */ + u32 highbit; /* highest position in the total bitmap */ }; #define ebitmap_length(e) ((e)->highbit) @@ -80,9 +82,9 @@ static inline unsigned int ebitmap_next_positive(const struct ebitmap *e, return ebitmap_length(e); } -#define EBITMAP_NODE_INDEX(node, bit) \ +#define EBITMAP_NODE_INDEX(node, bit) \ (((bit) - (node)->startbit) / EBITMAP_UNIT_SIZE) -#define EBITMAP_NODE_OFFSET(node, bit) \ +#define EBITMAP_NODE_OFFSET(node, bit) \ (((bit) - (node)->startbit) % EBITMAP_UNIT_SIZE) static inline int ebitmap_node_get_bit(const struct ebitmap_node *n, @@ -117,15 +119,17 @@ static inline void ebitmap_node_clr_bit(struct ebitmap_node *n, n->maps[index] &= ~(EBITMAP_BIT << ofs); } -#define ebitmap_for_each_positive_bit(e, n, bit) \ - for ((bit) = ebitmap_start_positive(e, &(n)); \ - (bit) < ebitmap_length(e); \ - (bit) = ebitmap_next_positive(e, &(n), bit)) \ +#define ebitmap_for_each_positive_bit(e, n, bit) \ + for ((bit) = ebitmap_start_positive(e, &(n)); \ + (bit) < ebitmap_length(e); \ + (bit) = ebitmap_next_positive(e, &(n), bit)) int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2); int ebitmap_cpy(struct ebitmap *dst, const struct ebitmap *src); -int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, const struct ebitmap *e2); -int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, u32 last_e2bit); +int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, + const struct ebitmap *e2); +int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, + u32 last_e2bit); int ebitmap_get_bit(const struct ebitmap *e, unsigned long bit); int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value); void ebitmap_destroy(struct ebitmap *e); @@ -151,4 +155,4 @@ static inline int ebitmap_netlbl_import(struct ebitmap *ebmap, } #endif -#endif /* _SS_EBITMAP_H_ */ +#endif /* _SS_EBITMAP_H_ */ From patchwork Thu Feb 22 23:52:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568377 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65D1113BAD8 for ; Thu, 22 Feb 2024 23:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646385; cv=none; b=YguQOlFi3aYYJRLaEAxdOCRdsT0PwHbAh03zg3sMEPhjvAGYpILPzHxu1RXd+3UKucwyrBwKnr3BH2/gQBjWM3dmmO5MMVBE6LB+6TwTmUXM3vCjVkcioBTqnIRRGVAkKqbuCy4//FDD4XrpWrkqScYhcpAOFM9hpEaQREXDsNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646385; c=relaxed/simple; bh=0myqjR7bL7e9jczq8U37pmJ9D5uz1aYn/yTKEm8VFcg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HzzuYQ/QT2t3zSirfQYP2STtx0ibFoU6iVSS17J4F4mfw1AKVV/FGHiHlR/8HC9GnsG+2gnJZ0wi2fORiZ2y4rDVVJvepdZ44wsurkLdttfPWM8+o5t43rmweMu9bZdrlcIbKqKcrmn9TeREPOULZWmUwJ/O6zqRSqJYWaY8kYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=QMDWCx1A; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="QMDWCx1A" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6080a3eecd4so3266807b3.2 for ; Thu, 22 Feb 2024 15:59:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646382; x=1709251182; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fWYpiilN4nTrPbR6MOLP0d0xEslY2d0ttJvDdoofzd4=; b=QMDWCx1A+B49CHxKRt+egSyU2uIyaBX2a3TkC5KnHxgTJxVWNWTaCYJ52MXBHg66PJ wL4RMcWJVJCwrTbk6gHmyiqqxVcnacq+6nVgtWUj+3uY628Lbm9+rvgF7Q/INEFBy6Wz r5iAzEcrvweBsoM1escNy6AV8h46ClimC1vT0iZWk4a/pFi1wXnVXM97ENF1mDwxRoU8 reG7pLfn8W572dwz0pd+11tSqvjznISDWT5wi6+DfqEcOW+zAsYouz93QNayrlxEhC35 WLK2YH5qMm8P8O8H+NLwXfSJnRw00rEQj24efgOGXB4lL2EJv1D67CKSvQxKfrf1AHGb 5OAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646382; x=1709251182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fWYpiilN4nTrPbR6MOLP0d0xEslY2d0ttJvDdoofzd4=; b=rCPQZCCA5kadNIZasD3Jq0jq2G3PplF5dSu83rdHH02KgOgfq07Cn2+CjD5GhU+LDG Gel8QNIj4DM2ZYP3AhWSJUhEtMpOpJGwOitY5qbCrUC65zWmj28fjC1vcMdQ27W9rOao 3EflseQmylsgBzwhCx+V2avc1XcE6CGer8ruDKXsVxcMLp14XArgjrG/M3FEebqi3YVa elyppzWBUwhwn3w5YedQKfktfmXaZtCdQfBMqDkwm5JRDos7QWBC5Vvv691gfb/gZhNL TknSVNm8jctLqpEYZrDgRm7IwhoQvnv/x2uHGEUpcDfObH3G/iJ1NjJNneLUEc+F4AQF 5TdA== X-Gm-Message-State: AOJu0YwtPCM9yTqjSdiybRr5fhCfQrA97ZovDVuuLnDMsz8QEKTdJAFH 9Hmplxj1gWfxtnm+lWoHM3a6vU+9jHt1p6k289eBBn3v8o5bqtYgW+cnhCJOVUP0JWDZE5MTfCo = X-Google-Smtp-Source: AGHT+IGh53pUJTrrzw2OGrJoTzIaVEAywSlNuNGhzkCiO8Z9S5f3d2drKfw+16Oz0OxJAAjjMGGVRg== X-Received: by 2002:a05:690c:368f:b0:607:cc6a:58aa with SMTP id fu15-20020a05690c368f00b00607cc6a58aamr821000ywb.23.1708646382107; Thu, 22 Feb 2024 15:59:42 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id x6-20020ac81206000000b0042e5da69d93sm262513qti.1.2024.02.22.15.59.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:41 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 09/21] selinux: fix style issues in security/selinux/ss/ebitmap.c Date: Thu, 22 Feb 2024 18:52:27 -0500 Message-ID: <20240222235708.386652-32-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6400; i=paul@paul-moore.com; h=from:subject; bh=0myqjR7bL7e9jczq8U37pmJ9D5uz1aYn/yTKEm8VFcg=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+GJK5U7fQIfy5/hXNXI63a4SXgFNJqBTX/E Qz5LA35n6mJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffhgAKCRDqIPLalzeJ czMlEACNadQ7Z5UgunXJVkG4+JAHbpHlGJptwq1qD/voDRx4EGwd7mox2r71KyzXGfnaMDYtZed 5lHH+gxK9KLEs/iS+zHe2muYc7YiLZDApUWKDHNRxZ677aZ4HPUxzL/JFTipcpB9Ad9XOi4OYw6 /RV2g9gSG7F8XH+70OuzkrxdnwRdDN/jmCnCbFsRGQL7CmD0sbvXeXQZ1joA7cVSMdNBaOOJqSi i1u+J6qOBbg/fVSNbiXmsmXPi069RoXVrwrIKFrimqH41PJ8U4pvhSgrKFlUkU+V3x8p35k7y2b PDG5xvhHUoTC+vkX9f3t1RLvj4FNoqezH6uUnFzXW8+lD66H24o/4s4vFSRY3BpPghnAk5HzNp3 5xIxSDbuKmQ/t+2fzn2+Cgr3ZhS4O8qhMJV1y2rQ1dpBf6u6yG0kiXIvd1gASdU4L2NF8lIaRi6 cf7W4ZUyDn8i1+NCUfNUrY8IqPkxH93uzrQJ47DyJC5OueHkY5Rg7ajnzQrGkY3npZVSKqj9tAG XYB0QPYGEkDM8W1vJwH5xBSgqBmh34JftdKjMrlINDiNlg7BtUI/b+MmCpn1axM7kG07The5oyG fy16Kd7Z4197Jq/+6ZgWi+KBkXdwgiODR8cfi0VC25ImpP1jQl8oCZtzjsIGSRNjEXRp+KlV7VJ VeZ7Ta44AhFNsWg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/ebitmap.c | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c index 77875ad355f7..67c1a73cd5ee 100644 --- a/security/selinux/ss/ebitmap.c +++ b/security/selinux/ss/ebitmap.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Implementation of the extensible bitmap type. * @@ -6,14 +6,11 @@ */ /* * Updated: Hewlett-Packard + * Added support to import/export the NetLabel category bitmap + * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 * - * Added support to import/export the NetLabel category bitmap - * - * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 - */ -/* * Updated: KaiGai Kohei - * Applied standard bit operations to improve bitmap scanning. + * Applied standard bit operations to improve bitmap scanning. */ #include @@ -24,7 +21,7 @@ #include "ebitmap.h" #include "policydb.h" -#define BITS_PER_U64 (sizeof(u64) * 8) +#define BITS_PER_U64 (sizeof(u64) * 8) static struct kmem_cache *ebitmap_node_cachep __ro_after_init; @@ -37,8 +34,7 @@ int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2) n1 = e1->node; n2 = e2->node; - while (n1 && n2 && - (n1->startbit == n2->startbit) && + while (n1 && n2 && (n1->startbit == n2->startbit) && !memcmp(n1->maps, n2->maps, EBITMAP_SIZE / 8)) { n1 = n1->next; n2 = n2->next; @@ -79,14 +75,16 @@ int ebitmap_cpy(struct ebitmap *dst, const struct ebitmap *src) return 0; } -int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, const struct ebitmap *e2) +int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, + const struct ebitmap *e2) { struct ebitmap_node *n; int bit, rc; ebitmap_init(dst); - ebitmap_for_each_positive_bit(e1, n, bit) { + ebitmap_for_each_positive_bit(e1, n, bit) + { if (ebitmap_get_bit(e2, bit)) { rc = ebitmap_set_bit(dst, bit, 1); if (rc < 0) @@ -96,7 +94,6 @@ int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, const struct ebit return 0; } - #ifdef CONFIG_NETLABEL /** * ebitmap_netlbl_export - Export an ebitmap into a NetLabel category bitmap @@ -131,10 +128,8 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap, for (iter = 0; iter < EBITMAP_UNIT_NUMS; iter++) { e_map = e_iter->maps[iter]; if (e_map != 0) { - rc = netlbl_catmap_setlong(catmap, - offset, - e_map, - GFP_ATOMIC); + rc = netlbl_catmap_setlong(catmap, offset, + e_map, GFP_ATOMIC); if (rc != 0) goto netlbl_export_failure; } @@ -185,7 +180,8 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap, if (e_iter == NULL || offset >= e_iter->startbit + EBITMAP_SIZE) { e_prev = e_iter; - e_iter = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC); + e_iter = kmem_cache_zalloc(ebitmap_node_cachep, + GFP_ATOMIC); if (e_iter == NULL) goto netlbl_import_failure; e_iter->startbit = offset - (offset % EBITMAP_SIZE); @@ -218,7 +214,8 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap, * if last_e2bit is non-zero, the highest set bit in e2 cannot exceed * last_e2bit. */ -int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, u32 last_e2bit) +int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, + u32 last_e2bit) { const struct ebitmap_node *n1, *n2; int i; @@ -234,8 +231,8 @@ int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, u32 las n1 = n1->next; continue; } - for (i = EBITMAP_UNIT_NUMS - 1; (i >= 0) && !n2->maps[i]; ) - i--; /* Skip trailing NULL map entries */ + for (i = EBITMAP_UNIT_NUMS - 1; (i >= 0) && !n2->maps[i];) + i--; /* Skip trailing NULL map entries */ if (last_e2bit && (i >= 0)) { u32 lastsetbit = n2->startbit + i * EBITMAP_UNIT_SIZE + __fls(n2->maps[i]); @@ -302,8 +299,8 @@ int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value) * within the bitmap */ if (prev) - e->highbit = prev->startbit - + EBITMAP_SIZE; + e->highbit = prev->startbit + + EBITMAP_SIZE; else e->highbit = 0; } @@ -424,7 +421,8 @@ int ebitmap_read(struct ebitmap *e, void *fp) if (!n || startbit >= n->startbit + EBITMAP_SIZE) { struct ebitmap_node *tmp; - tmp = kmem_cache_zalloc(ebitmap_node_cachep, GFP_KERNEL); + tmp = kmem_cache_zalloc(ebitmap_node_cachep, + GFP_KERNEL); if (!tmp) { pr_err("SELinux: ebitmap: out of memory\n"); rc = -ENOMEM; @@ -481,7 +479,8 @@ int ebitmap_write(const struct ebitmap *e, void *fp) count = 0; last_bit = 0; last_startbit = -1; - ebitmap_for_each_positive_bit(e, n, bit) { + ebitmap_for_each_positive_bit(e, n, bit) + { if (rounddown(bit, (int)BITS_PER_U64) > last_startbit) { count++; last_startbit = rounddown(bit, BITS_PER_U64); @@ -497,7 +496,8 @@ int ebitmap_write(const struct ebitmap *e, void *fp) map = 0; last_startbit = INT_MIN; - ebitmap_for_each_positive_bit(e, n, bit) { + ebitmap_for_each_positive_bit(e, n, bit) + { if (rounddown(bit, (int)BITS_PER_U64) > last_startbit) { __le64 buf64[1]; @@ -559,6 +559,6 @@ u32 ebitmap_hash(const struct ebitmap *e, u32 hash) void __init ebitmap_cache_init(void) { ebitmap_node_cachep = kmem_cache_create("ebitmap_node", - sizeof(struct ebitmap_node), - 0, SLAB_PANIC, NULL); + sizeof(struct ebitmap_node), 0, + SLAB_PANIC, NULL); } From patchwork Thu Feb 22 23:52:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568378 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B92C17C6B for ; Thu, 22 Feb 2024 23:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646386; cv=none; b=g2ZAFPfHOCAckQPcPLMSACgCu11wz79srt8MjW6h9yci7X6uvV2BR7njXRYvzsT31dHG39VNe5CyVsTCxfxPy3g51Ro3zd0Xo0AgTO4N0b2Q4o5J9RY5D1tRIu6fDtqGx47KI21gUIFep3PTeDjDUS3yQUTMyz30FidfH1v9kxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646386; c=relaxed/simple; bh=+cHF7sSQC5d599SYzT8pAFGlUiNcrmMwJHCpKGYqWv0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a3pEZcIH2+saJlhFxAwygCUubc5XHEySJjpIC5n5u84MNgrRTZyU6smh4VJ8zBXoX/EwXqyi7trucGTmsE/9MpiuVj1IKr8EjTE43cHM51JHMLUfXE94TzpUuG9BBPz92wrJEk4kQBjeiUI4kh+SYVpE02q8vTkxguUhHKgc1Cg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=Dwi9uhz1; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="Dwi9uhz1" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-42e323a2e39so2619171cf.1 for ; Thu, 22 Feb 2024 15:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646383; x=1709251183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MOArciuZ8srbs0iBxL3Baqw1i4J8+zhAZs4Cj/MRiIk=; b=Dwi9uhz1sMzf9iT6kLjp+hnIHXJ0ZJf6enExOAulCLjDvkBZj83njw7VEzoRLAlhKt 9Si+jEEZxrYlbXftF/sni2wertn8nKI1iCfTvatahlhIfOSxAwxsvzODZDzj1cpPwZee vzvoICqQqmPMiRPMyQsnyrIjN1hwpqs5o6mJeHazLZiWstmsYtcZ9b3KCwfUOYj5Bk+k olTppGOWKizEa29DqesQwMj9xlPkqzOYECoyr/bWdzW4zOFCac83SemtXde5G+HHSaRP h8MAZPKcNV9rY7307l8gQRnNmYLTkdDfn9k26CH/hLBEMStynysSn22LFDsgf/Q0U8SR k7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646383; x=1709251183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MOArciuZ8srbs0iBxL3Baqw1i4J8+zhAZs4Cj/MRiIk=; b=Z5o6MrCGcoF9hQX8rWNt5E0MbSh0rtFw7k23PGqPFWKyP50rdyDklVPm7p3xQ/kPfE hIPcWsmkK6/zjgb1OqWBVGIi4UYDvNYN0lv5fzAecv1dklUoQ/jdy+Qk1M1fzkx8lpcM WmRfFveGC0a4UU1zTRHhWPJpHYoxN/Z8TfuRqWkQeMgnRi5qbHk/yHF/OXrgIT/aiYQ9 iCuatcCz2GGvKjIHfjcjgxBoE20MfBDjTy0MR/19P+BXj3AklhVihaMN9/0vXBdjWsSy 2g/wQtUQ4y/wCqP7NljzqZ2Xt0llL6bhV8lXt7Of5sN0kv11+YwJCuTtWqN3IWMTq9Bm vNcw== X-Gm-Message-State: AOJu0YxSqE8qEO4ejwuf4NewcqHq1aL76xOzkRshPRonZD6SrVDmCerD gMW2RO3z+m7+nU7SCfO5qMhYpJjhcVzBjiSi1pZC58oGEHhtyqV5FJDkl+G/5c1RZ7Qh8UPOTLw = X-Google-Smtp-Source: AGHT+IHdDoqvQWfEplCkBht7Q0RLMg79FFRAvS96axMn4bBMDyJl9/8bNKMbmBEfPBrFSVDSLQsuHw== X-Received: by 2002:a05:622a:15c7:b0:42e:6299:6cf2 with SMTP id d7-20020a05622a15c700b0042e62996cf2mr8007qty.4.1708646383173; Thu, 22 Feb 2024 15:59:43 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ks17-20020ac86211000000b0042e56fb8e0bsm734732qtb.93.2024.02.22.15.59.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:42 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 10/21] selinux: fix style issues in security/selinux/ss/hashtab.h Date: Thu, 22 Feb 2024 18:52:28 -0500 Message-ID: <20240222235708.386652-33-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3677; i=paul@paul-moore.com; h=from:subject; bh=+cHF7sSQC5d599SYzT8pAFGlUiNcrmMwJHCpKGYqWv0=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+Na8YRZ6/2zHwg9SiSFZKvHcXrVSxZ4NReA /unXFf6HxGJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffjQAKCRDqIPLalzeJ c161EACBrc5/koOqhxUrmih9q2dJ05b9ABeFgLsyOLyi3MM3jCqj/qDsJxb70JeqRUxg91Xcjlo y3jr308nemgfMPJRuj8xOkGUO/xrW/XPee8m/LG1mz2n4XqmlN/dCgHSHT4w1hkbkRSwYWrtFXS MUx0bN43rzPxxkbjLp6XuLIqTtgrQFDSjdZhA5wm8vKqubP5sYryTjeg9clpMZ1wq1WypjQ4tKj lXE8mHQ/lIQOB4u1XfhnApKzZbpVngp3+/9Y00zvVcdU/ClFazj+VkqRoBhi4v87VxSqiMLWxuP mtEXp1nPtzjhFJePpVcEzPLKGB6biz0qCvF5qM6VyS9S3T4JH2UaA6B7OqHt8VR5r8PAh5apjJF x01DxGfTQsKQt2n0TbdGzsQNiIxSCNVrtXQ4mpChroR28xCR+9Wq3fLA05wY9uoR41FbtwQhDWg gYcpj5GlhABMkVhpG9mo9WHFzesvZKlLGEv3OilQZzxG8qSUxsYD/01cxZEqyb4N8K3XvHGXos4 ARtuyunq5HS5Y0GRgShXyKQSj3qfke+/C97nX0xbCYdM289pkGEMPXuBu1WG4WNLV4G37yTAJKc w/QIsShxGgrbGV4ZDMmJoIx2VeZIFPg2G8pGsAnIeOX/f0imOPANrEx3RpRJCstR3z67M0WgEbA o5RgWDF1rRlmVxg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/hashtab.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/security/selinux/ss/hashtab.h b/security/selinux/ss/hashtab.h index 09b0a3744937..5f74dcc1360f 100644 --- a/security/selinux/ss/hashtab.h +++ b/security/selinux/ss/hashtab.h @@ -8,6 +8,7 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_HASHTAB_H_ #define _SS_HASHTAB_H_ @@ -15,12 +16,11 @@ #include #include -#define HASHTAB_MAX_NODES U32_MAX +#define HASHTAB_MAX_NODES U32_MAX struct hashtab_key_params { - u32 (*hash)(const void *key); /* hash function */ - int (*cmp)(const void *key1, const void *key2); - /* key comparison function */ + u32 (*hash)(const void *key); /* hash func */ + int (*cmp)(const void *key1, const void *key2); /* comparison func */ }; struct hashtab_node { @@ -30,9 +30,9 @@ struct hashtab_node { }; struct hashtab { - struct hashtab_node **htable; /* hash table */ - u32 size; /* number of slots in hash table */ - u32 nel; /* number of elements in hash table */ + struct hashtab_node **htable; /* hash table */ + u32 size; /* number of slots in hash table */ + u32 nel; /* number of elements in hash table */ }; struct hashtab_info { @@ -48,8 +48,8 @@ struct hashtab_info { */ int hashtab_init(struct hashtab *h, u32 nel_hint); -int __hashtab_insert(struct hashtab *h, struct hashtab_node **dst, - void *key, void *datum); +int __hashtab_insert(struct hashtab *h, struct hashtab_node **dst, void *key, + void *datum); /* * Inserts the specified (key, datum) pair into the specified hash table. @@ -84,8 +84,8 @@ static inline int hashtab_insert(struct hashtab *h, void *key, void *datum, cur = cur->next; } - return __hashtab_insert(h, prev ? &prev->next : &h->htable[hvalue], - key, datum); + return __hashtab_insert(h, prev ? &prev->next : &h->htable[hvalue], key, + datum); } /* @@ -133,15 +133,13 @@ void hashtab_destroy(struct hashtab *h); * iterating through the hash table and will propagate the error * return to its caller. */ -int hashtab_map(struct hashtab *h, - int (*apply)(void *k, void *d, void *args), +int hashtab_map(struct hashtab *h, int (*apply)(void *k, void *d, void *args), void *args); int hashtab_duplicate(struct hashtab *new, struct hashtab *orig, - int (*copy)(struct hashtab_node *new, - struct hashtab_node *orig, void *args), - int (*destroy)(void *k, void *d, void *args), - void *args); + int (*copy)(struct hashtab_node *new, + struct hashtab_node *orig, void *args), + int (*destroy)(void *k, void *d, void *args), void *args); #ifdef CONFIG_SECURITY_SELINUX_DEBUG /* Fill info with some hash table statistics */ @@ -149,7 +147,8 @@ void hashtab_stat(struct hashtab *h, struct hashtab_info *info); #else static inline void hashtab_stat(struct hashtab *h, struct hashtab_info *info) { + return; } #endif -#endif /* _SS_HASHTAB_H */ +#endif /* _SS_HASHTAB_H */ From patchwork Thu Feb 22 23:52:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568379 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58D1714037D for ; Thu, 22 Feb 2024 23:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646386; cv=none; b=Me89+szyoTyB4xEzQ9b7MrhCUZlHpyhOQOgF//IkCWNqOrVP33Z6YVbD6+vkdkG6goqkpW1v3r3CMOZ+YGAtKzpcYFAOzUCLsWpXvN50/SeGsPSnJ8kFJt/+5eo6j+z6UtPfJbduASwLDfoDM2RRGY7O+RqmN5mJEZjffb/A1Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646386; c=relaxed/simple; bh=ykE4MGNWCvoiBrtnN37K3r7n8RhH0lx2qkfzrVXbPas=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O6gjTSs4vhjnePqRrxsVIvSH3umJChhrHxCqq3KONgejSJuvhajkQcdwxymCZH+aPkLp/kVOkAi0xO2bP6E9+F05luBNhQq7Yt7rrIz+uahJrB6MY+zyhERJexc6wWNk3wkjYrdi1zLccw2A8fNizz5E1CUD9fukEf7yh/2dsFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=UTetIuM8; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="UTetIuM8" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-787ac650561so12666985a.3 for ; Thu, 22 Feb 2024 15:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646384; x=1709251184; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mkPkc8Y4Z3tXq/BArg1NNkxPALBbMp8YkjYfD2KM9DI=; b=UTetIuM8eF8G74LHeRmzfSfQIBswbl6jIbYOSKbsSNfh3qEn7YIT0NrvWEPuMU/TaB jrQSHLtCMCdxYCa0t/K7pgf5oBUxoEq9sb6s2RV3BEMUQ4ZVp4EQgRt/vUHU2Stji5T+ Ad2da+qUAYuWKu5ZkCbwr8x3PKIaNrW85D5O6hdSgsA0JTO5hP6pzt7nkuLUroHiLvEz 7W0CIDUcuvTwlOTQl533XE7aHpb0onMN4HipDsNYiVL42+wxld1byPX4wZhuW47f9FJq YR4hREL46cEkxthJ0+2Fm13PuS9sMqDDOpk1nFIFq5B4LAkynW/FuPnx+3JStT7PePci 11sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646384; x=1709251184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mkPkc8Y4Z3tXq/BArg1NNkxPALBbMp8YkjYfD2KM9DI=; b=SyiBP2X5xqlCsvF6ArZIGLUXZsIuoPeXiwjMsrED7TQmkcJW9N1M50CqNiASJBJDgC n31RLrXisU+33OnhSU7PX7UQSbN91M1E+ibGFZNQuIvv6VzkHXLJJb5Z55wdYBSuU87y wm1HcT7ikShvZLAJcW8B2WLXWe5XwsY3q1bkElfsjX0nrWnN5aNbgmnkLrTmW6wpUGAG t57Sgv5Cfy6g9hFBA8BGSHyMgRDfIWk6vhZjuCAA4ZJ6m23EQGmzArYLdHAXSlrWedf/ cHnanv2HlIL7wfPa9QCWxHnUr+V55dRfOxEjGV+Dm0QCL4bvSNgAJyy/+UFG8LavG4hZ pVfA== X-Gm-Message-State: AOJu0YwhBKYwVn2fm6qMyfIW25zz84fVYY2VpZLmqTfiX6VP8hKz+Ptb NH1HRmtrLFCqNJHr6dtsTh6SrjxQ7FUF6YTqU2higebKFiH8KwZr3+Dlvi+fpreF+EUbOl4/eUQ = X-Google-Smtp-Source: AGHT+IGGVZZQOcc9Kw+iJUGq/lBQ7/HOAdT/xoxHnQNRYMIrmbIsba9141nNGy902fgeIY4tIHYNKw== X-Received: by 2002:a05:620a:4494:b0:787:49b6:774d with SMTP id x20-20020a05620a449400b0078749b6774dmr615819qkp.23.1708646384079; Thu, 22 Feb 2024 15:59:44 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ow39-20020a05620a822700b007872acdc390sm5835932qkn.9.2024.02.22.15.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:43 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 11/21] selinux: fix style issues in security/selinux/ss/hashtab.c Date: Thu, 22 Feb 2024 18:52:29 -0500 Message-ID: <20240222235708.386652-34-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2816; i=paul@paul-moore.com; h=from:subject; bh=ykE4MGNWCvoiBrtnN37K3r7n8RhH0lx2qkfzrVXbPas=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+TTaAMaKGNr+lPK4p8orgqURCBVqzHb4XuL 4TRcrlZ0tOJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffkwAKCRDqIPLalzeJ c7KxEADTn60R5gfCz1rKJWymJdL2BAG9YRDBKcID9BnfQanVg+2JGGtZaxutdn6Ps6PQGp8gRGb f2eDC95EipRxPgJ2sRTTgY3JW09lQzIRnD2EwDl0+ZhbO/4a/iVqOl7gwOwdQAER0C0I9CuVzvz fFZtHhCDypMl56JIbbd0Lbj/32+h4buzgrqxCknk/WPOh3N8cS1Dd/YMPCjxFA63dUBdhxzFFlc OAUfE/y6kR4L1+P+C18ozYFQoNm++TBJoWu00Ctb39CDfrg4Oi/bXPw7pogTUSzDYZERsdUtIEj meA+5nnDWftwMjMiBz0axrhBP5GiLZgur9Z9/macAy4/DRWz0EvcxmW/5/dHrCsO7rRClni2Jcx lC61RYiAEKmeNoKZUvG6nPllYhq7LzPUwiDtW2qs8nY0mmHFK+2faRtDNfHpoEYqvvT59KUykon xrnZg2ZlcgprFcJe1NH6b+axxLw7nv+Wm4V+HDreY2txnVZZP+y3sj8QOq1sVThB83dkbCYRj+t RDSJJ6UlvAxOkyhsqvXLq+icHD1txdfkXK/OUv4HC84n5CW6AHfC1FtboOn1z8ueu+fNRyWmA1p G1quYd+/UQPOhxr2DL2j47DY4VvyYaqy6gD2R0JuqkughhQx+Og6yBRjmTOXEhLoeJxZEmtmpeK 5JF85pX8aYn0LMg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/hashtab.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/security/selinux/ss/hashtab.c b/security/selinux/ss/hashtab.c index c05d8346a94a..754bedbde133 100644 --- a/security/selinux/ss/hashtab.c +++ b/security/selinux/ss/hashtab.c @@ -4,6 +4,7 @@ * * Author : Stephen Smalley, */ + #include #include #include @@ -47,8 +48,8 @@ int hashtab_init(struct hashtab *h, u32 nel_hint) return 0; } -int __hashtab_insert(struct hashtab *h, struct hashtab_node **dst, - void *key, void *datum) +int __hashtab_insert(struct hashtab *h, struct hashtab_node **dst, void *key, + void *datum) { struct hashtab_node *newnode; @@ -83,8 +84,7 @@ void hashtab_destroy(struct hashtab *h) h->htable = NULL; } -int hashtab_map(struct hashtab *h, - int (*apply)(void *k, void *d, void *args), +int hashtab_map(struct hashtab *h, int (*apply)(void *k, void *d, void *args), void *args) { u32 i; @@ -137,10 +137,9 @@ void hashtab_stat(struct hashtab *h, struct hashtab_info *info) #endif /* CONFIG_SECURITY_SELINUX_DEBUG */ int hashtab_duplicate(struct hashtab *new, struct hashtab *orig, - int (*copy)(struct hashtab_node *new, - struct hashtab_node *orig, void *args), - int (*destroy)(void *k, void *d, void *args), - void *args) + int (*copy)(struct hashtab_node *new, + struct hashtab_node *orig, void *args), + int (*destroy)(void *k, void *d, void *args), void *args) { struct hashtab_node *cur, *tmp, *tail; u32 i; @@ -178,7 +177,7 @@ int hashtab_duplicate(struct hashtab *new, struct hashtab *orig, return 0; - error: +error: for (i = 0; i < new->size; i++) { for (cur = new->htable[i]; cur; cur = tmp) { tmp = cur->next; @@ -193,7 +192,7 @@ int hashtab_duplicate(struct hashtab *new, struct hashtab *orig, void __init hashtab_cache_init(void) { - hashtab_node_cachep = kmem_cache_create("hashtab_node", - sizeof(struct hashtab_node), - 0, SLAB_PANIC, NULL); + hashtab_node_cachep = kmem_cache_create("hashtab_node", + sizeof(struct hashtab_node), 0, + SLAB_PANIC, NULL); } From patchwork Thu Feb 22 23:52:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568380 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518EC14036E for ; Thu, 22 Feb 2024 23:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646387; cv=none; b=qBKmrnB60mqsJ5Rnjxz1/Ke7zs9y05ZVsf/u6g6zn/iyCF+MsEsQalhR5s+hhrVLWIxURuyQap8V/78OMwoTq1XRcXrinVtDwL7Gwks07ZUeLHzhA9b8rL1gzvgG74x/dt4PWy0pFb6hs22Jn5Gs5sSjR8DFcA1h8T4JvDBjhsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646387; c=relaxed/simple; bh=aM4vSla3FklEqzpSwFgI1CX/2aoG7RSbRnBFkFDJKcw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7zBOLI7FWKqxwPI+wTyy4cI0S+1OLOgcEJS9Mkt5gc/Awp44vh/o2rHigXnoIKyf/gaPgPCQRjg9h++dZNkwkMzPp+/hENo4Hi16e0T8eJrRg+l5QGTrwmNIlehryxPkHZUMGrXWVzZxCleZ3zxFgPtcR6CTYjvcLuePOo9XLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=CLdO16AP; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="CLdO16AP" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-787a405e724so20671085a.0 for ; Thu, 22 Feb 2024 15:59:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646385; x=1709251185; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7v+qkWGnNrZij6xJdUWz2TmdhdmHC1pGGdlSTc8y4WI=; b=CLdO16APTOsByrJPdnwEOYfjWol3rzxjyHqw0Ro3OQ0vG65vM57r2b8S6pHx7lL8Cb 4RRi5nTdCgBByCjY2p+4SyTo6SFdHV/dz9guvlpVipgoTa44sxpofs19aS/tzsNfWqA/ 5ZmMyv2ViDzHIZQTXgJY3nh7ECDSMFZY4lbJdzT/BHXE/bKVNClyQlteprSZm/po/CWE c8j36olPaRAkrOBSnYIYFAq8fzYeaaIc8jzYgbSo7QxvHjVHjFOXpc/nBDQaouEa2gs2 /xbMysZck3+dpHFAp3SqiZSzDT5XNGu2KBvhzk1aRKWwT7nQ1jGS2S9pxPmL3wOzepNu 0FVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646385; x=1709251185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7v+qkWGnNrZij6xJdUWz2TmdhdmHC1pGGdlSTc8y4WI=; b=XYSRPdooIoo1/ZEJrJBCJnGcmH0ZThbKhJxlIqaa8pP8L9NEPMB1hhidBTVozAyZuX BK5D7opUsGG7D/+P9fffnSiQvEQL5TOuGvxnD9pTZ37S2taE/4dcTjOH5rujL2lcTyo9 tuEDPQL98jbkGttBU3WRvcqUlBPY1wpV0BdN9KHeKlIDDxD+9vmYnBNM/c8s07FM2DCF 82NPKg31uqQON4qn5tiqZzM6Fd4XKzH1zAX0PXsjIISr3R1GO8kQM9MZ7Y0sZsXbupi1 aTQiwJ3m/JSobW+mLt66xvVHqFwHTL0MDZftA5TTtxecDnH2yQzFkmVDPjC9a2dk7xYV n/0A== X-Gm-Message-State: AOJu0Yy0AaYbr/c+TIYqmkQjuZ746VFvruqzJFGO+54fgNubZBUsYje2 mpNo0EtKR33Nn6/nTzaarcvPrHT84sSXz/R5Gnj9PXbpF5l3DSHj0tZW7OG+imDWDeF2RzBO488 = X-Google-Smtp-Source: AGHT+IHKrb11vv0OybUHBRD8awqyZuvEU8oL9dYGzbZ/B0Zv4wZWBp1U5bVHGnklzmFO3ctOwvrxUg== X-Received: by 2002:a05:620a:385c:b0:787:9e79:6f5c with SMTP id po28-20020a05620a385c00b007879e796f5cmr520701qkn.49.1708646384912; Thu, 22 Feb 2024 15:59:44 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id c20-20020a05620a135400b007877f9d9e11sm2564920qkl.119.2024.02.22.15.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:44 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 12/21] selinux: fix style issues in security/selinux/ss/mls.h Date: Thu, 22 Feb 2024 18:52:30 -0500 Message-ID: <20240222235708.386652-35-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4330; i=paul@paul-moore.com; h=from:subject; bh=aM4vSla3FklEqzpSwFgI1CX/2aoG7RSbRnBFkFDJKcw=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+c+4FgS1XjrF1uyPW0pnx6jq4Ao4RFfudKq YbEsHno82yJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffnAAKCRDqIPLalzeJ c1IZEACf6xRqTn2W4BThlr1uuprn1rBbVMIK/JuwgkrWwUXqYOtox4DyHyJOsUlyoxm2kOjC3vS 4F2jjn0ykS0w9rI9aZ4gewFvqXM7lY069BY4tF8XAZ9rie28mCBJk1JCCHpDru63XhsSgGD2j1y 7BpsFHboQt5xX9wPMlT2Kf6mx61zZmRKnbkiluDtfRHIRca4/HnUGfX9nBmQrOzJnXFLoeWFl6P OnQl3uxr07uQo9sDGpx1k8D5GUrbsjGoofbndffDUv4W6nBe2zpLzleCoA4os+DgszZS7mO0Mex mRmwbeYolT0fO5XSfeZRk/reaY186a4pGq2mXwg/g2CmyUrRluwvvronl2VgqLBDaZD0fVfuD2V jw6fViCuQGTcOcbqg4e94chAlKkACmLkQewO0HTFkpMpg1Vx7h3cifJgda61RRaxE3TiQ3afi0f 1SEY9gXh38ECZM1QAS+6BhrTzTsJb89xNPtk9nu8Oc262/bnJ5OhGMHAFR/PSE29YmHH3KxBZDl GXvDaCjX06ct6hIzEvHeEBwfJWvJ+dFLDBocw5c8VfPF13Gzp92t+cWsU6KtcAV6xoBlCkd27K5 10m0ptKV6f5Hpff78Ur0Ma25RRvZh0Vjh3UQ88QdPvwtN+4tURSVcyIUPGkMKd7jkaY+VgblpYr fQKd+V6eKIdwGOQ== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/mls.h | 58 +++++++++++++-------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/security/selinux/ss/mls.h b/security/selinux/ss/mls.h index 107681dd1824..07980636751f 100644 --- a/security/selinux/ss/mls.h +++ b/security/selinux/ss/mls.h @@ -4,19 +4,15 @@ * * Author : Stephen Smalley, */ + /* * Updated: Trusted Computer Solutions, Inc. + * Support for enhanced MLS infrastructure. + * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc. * - * Support for enhanced MLS infrastructure. - * - * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc. - */ -/* * Updated: Hewlett-Packard - * - * Added support to import/export the MLS label from NetLabel - * - * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 + * Added support to import/export the MLS label from NetLabel + * Copyright (X) Hewlett-Packard Development Company, L.P., 2006 */ #ifndef _SS_MLS_H_ @@ -35,47 +31,32 @@ int mls_context_isvalid(struct policydb *p, struct context *c); int mls_range_isvalid(struct policydb *p, struct mls_range *r); int mls_level_isvalid(struct policydb *p, struct mls_level *l); -int mls_context_to_sid(struct policydb *p, - char oldc, - char *scontext, - struct context *context, - struct sidtab *s, - u32 def_sid); +int mls_context_to_sid(struct policydb *p, char oldc, char *scontext, + struct context *context, struct sidtab *s, u32 def_sid); int mls_from_string(struct policydb *p, char *str, struct context *context, gfp_t gfp_mask); int mls_range_set(struct context *context, struct mls_range *range); -int mls_convert_context(struct policydb *oldp, - struct policydb *newp, - struct context *oldc, - struct context *newc); +int mls_convert_context(struct policydb *oldp, struct policydb *newp, + struct context *oldc, struct context *newc); -int mls_compute_sid(struct policydb *p, - struct context *scontext, - struct context *tcontext, - u16 tclass, - u32 specified, - struct context *newcontext, - bool sock); +int mls_compute_sid(struct policydb *p, struct context *scontext, + struct context *tcontext, u16 tclass, u32 specified, + struct context *newcontext, bool sock); -int mls_setup_user_range(struct policydb *p, - struct context *fromcon, struct user_datum *user, - struct context *usercon); +int mls_setup_user_range(struct policydb *p, struct context *fromcon, + struct user_datum *user, struct context *usercon); #ifdef CONFIG_NETLABEL -void mls_export_netlbl_lvl(struct policydb *p, - struct context *context, +void mls_export_netlbl_lvl(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr); -void mls_import_netlbl_lvl(struct policydb *p, - struct context *context, +void mls_import_netlbl_lvl(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr); -int mls_export_netlbl_cat(struct policydb *p, - struct context *context, +int mls_export_netlbl_cat(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr); -int mls_import_netlbl_cat(struct policydb *p, - struct context *context, +int mls_import_netlbl_cat(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr); #else static inline void mls_export_netlbl_lvl(struct policydb *p, @@ -112,5 +93,4 @@ static inline u32 mls_range_hash(const struct mls_range *r, u32 hash) return hash; } -#endif /* _SS_MLS_H */ - +#endif /* _SS_MLS_H */ From patchwork Thu Feb 22 23:52:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568381 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0A28140372 for ; Thu, 22 Feb 2024 23:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646388; cv=none; b=Q6+MmzZn1AgRymAZu8QJu20Kh5f7lStldQydRVN2V29JSxfU0DCfx2nNnu4hN1LgcAzy59yvyrsB1R/CPl2O/QzDjbUibTFy8oGW7+fGxu1EUY/byRbWw+086Aogl3x6l8NAVqjQAaXOdSwke/Xx8+mj6I4FLBap+OPT3MwDgsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646388; c=relaxed/simple; bh=SZ+zGVhSU6F3hsL4f/fO1qnXio9nfJN9GFUBbsVQj60=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PhyW5YETIkisPSaXOYbPaEkPQOEJaDfhKTjnUthbspb7h75iblB7SznUitFbts7Eo4sykdU09kOATgNEUd4bd8Dy01OdHL1YpcIiEbeCPzsXtyfKaXRMCWLFO/W42MeTIBtroE+ANwAnh5L9iYqEswWyxkGGWU4rhD9LNI6lwj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=ew4QP6L1; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="ew4QP6L1" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-68f51c5f9baso2002476d6.3 for ; Thu, 22 Feb 2024 15:59:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646386; x=1709251186; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G2UG23iVUyi2LU1m26pPSBPDlo3EpeahzkQM9ckCXSY=; b=ew4QP6L1vTt4DBAJxyfAx2yCROKgMp53uICwVRWvXv6c4jCmvbKIvX+d03P1HZt6VI udlKDIBzPtbwLEvDn97gLnO31lpM7t5DG+y76UkIVy93pkucYQJzlBz8WZ3CHtC8xjtb Jyu+uqJ1rVcPbrE2qscvvn71NtNrLtnZtkozarfPEla1b3X4HB5KKqfm+yoFGgKbCjiA Nj0x+qhD3Pmj322Ktb3QAECXqj1PPg4nF5snBEObtKwpbXOLuSj9HXYa3pJJe81IcDdp zjKFlS4ramk0BSzWBMMciwQYeObuayZD/vfyuMCDGfrKcmgtjVpdGCe1pDQJBA8a2cqj wUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646386; x=1709251186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G2UG23iVUyi2LU1m26pPSBPDlo3EpeahzkQM9ckCXSY=; b=o5zh/AlNL0cFVyqm9d3DLk3lu5/GIW1yVQM2+LEd/7E6DWRVG7aezJNWZl2KpuLqmt lqkvc0vT3+oRwy5wXLs2+zCYiywvw4tmsBGd7s6+qGQv8MXkK2yracX7Yd9DJKp6K6fF aH4XDDOoSvq5VpIpA8XYdxtMV+WXWq0N1v0+gBQgMaA2HhTGO28Y5hJiH12kgYuAjtJI aiK4KAgbfv1K/zSyVJQMivZDWoT2IjB593PLVvSNCXwZxgvG2yrUg2cVfngF4KdAy61m H/gqeGTeJgufOX8KNXwBoUsqrXcOQvnGH4UPjsC/mcF8/8dZjQ6q5gX9Ew8dViYCBcNT 2P5A== X-Gm-Message-State: AOJu0Yy4Rp7ZXFT5Ss1ApUNxjrIaMq0F0Xwx/KQMcVry4XGD2wS3hu4N BPhnTbV2qZ14nEq/UrmVj2bW3Klu0hQL70rC9KFfDtfxa7IHNqgxSqQU2VPMdHG6BmDOx+eUhlM = X-Google-Smtp-Source: AGHT+IHDVGKKq5P97M/7E/G/eaoH/YSa4oQdSsdk0rK9IWjXLr1BddPAHqptNtMJHKfRvRo9or7d9g== X-Received: by 2002:a0c:cb89:0:b0:68f:2eac:5e1e with SMTP id p9-20020a0ccb89000000b0068f2eac5e1emr649183qvk.38.1708646385794; Thu, 22 Feb 2024 15:59:45 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ql9-20020a056214540900b0068f920768a5sm3675403qvb.140.2024.02.22.15.59.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:45 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 13/21] selinux: fix style issues in security/selinux/ss/mls.c Date: Thu, 22 Feb 2024 18:52:31 -0500 Message-ID: <20240222235708.386652-36-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7905; i=paul@paul-moore.com; h=from:subject; bh=SZ+zGVhSU6F3hsL4f/fO1qnXio9nfJN9GFUBbsVQj60=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+iw/R+bBjm6QWeIaPJ9BZqxOriyLbLRzhGM da28F09aOyJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffogAKCRDqIPLalzeJ c+uYD/9lEu1WjEW/dqrBwD5YKuoGfJFThlkPlUVQ23q6g9V1hfTYkBjZcCN1tJiuH71rCZr/Dj7 ukDlt/iSoxuU41zirxuINir+rRHhGqEsvlV3p3UHJgEdzgz+m7o7s2QF6Hc44A8ZBCdz4GelI6F a6WhwvIILsiRlV99we3BlXEK8td/8QDEmMdI0qsueU9oN7/Hay3ZNzE194xHLv1yXH5bYNHG0Rw re76ZEm5uZydeN2zWl36tbGW2I17LZ7J3s14AqtIMERz+8ncuMFBtbUET8tfsl9oJLHCxtUQDAm HJm8AUp3nheDeko31Q/5+ln0wQelmlaQe33cyiagsDlBqOxQwXMW456OPCSEeoNmJXxs1Nh+YK8 1i0Ozj6mymuCW92PMksZWpB91lmdS3ILokmn8m8RENZpHVBB65ruyV/UEJICBOdVyuRXfo2w1a9 c0UVA7acQepjxXKeNF8CXMyEezL/7Hh7TSdOsJXKBkXTPSultbIypBcsBN+n1yyrVfOXnBHH5du OZcPLEVUhZ76lmgVKZ9LmLRca/NyQofBF3FoBBl8SX6umb453j25cPBf7+1ec1FfpLY8Yb/8S12 rut/JNB3byEca1enCL0yodFMhf06qZDaMw+yHYOUWG1Q6MyCzYskmkUleHC7H3R9kpywXT8Xh9/ vyanZ2rou7OX2Ww== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/mls.c | 83 ++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c index cd38f5913b63..989c809d310d 100644 --- a/security/selinux/ss/mls.c +++ b/security/selinux/ss/mls.c @@ -4,19 +4,15 @@ * * Author : Stephen Smalley, */ + /* * Updated: Trusted Computer Solutions, Inc. + * Support for enhanced MLS infrastructure. + * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc. * - * Support for enhanced MLS infrastructure. - * - * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc. - */ -/* * Updated: Hewlett-Packard - * - * Added support to import/export the MLS label from NetLabel - * - * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 + * Added support to import/export the MLS label from NetLabel + * Copyright (C) Hewlett-Packard Development Company, L.P., 2006 */ #include @@ -52,7 +48,8 @@ int mls_compute_context_len(struct policydb *p, struct context *context) head = -2; prev = -2; e = &context->range.level[l].cat; - ebitmap_for_each_positive_bit(e, node, i) { + ebitmap_for_each_positive_bit(e, node, i) + { if (i - prev > 1) { /* one or more negative bits are skipped */ if (head != prev) { @@ -86,8 +83,7 @@ int mls_compute_context_len(struct policydb *p, struct context *context) * the MLS fields of `context' into the string `*scontext'. * Update `*scontext' to point to the end of the MLS fields. */ -void mls_sid_to_context(struct policydb *p, - struct context *context, +void mls_sid_to_context(struct policydb *p, struct context *context, char **scontext) { char *scontextp, *nm; @@ -112,7 +108,8 @@ void mls_sid_to_context(struct policydb *p, head = -2; prev = -2; e = &context->range.level[l].cat; - ebitmap_for_each_positive_bit(e, node, i) { + ebitmap_for_each_positive_bit(e, node, i) + { if (i - prev > 1) { /* one or more negative bits are skipped */ if (prev != head) { @@ -230,12 +227,8 @@ int mls_context_isvalid(struct policydb *p, struct context *c) * Policy read-lock must be held for sidtab lookup. * */ -int mls_context_to_sid(struct policydb *pol, - char oldc, - char *scontext, - struct context *context, - struct sidtab *s, - u32 def_sid) +int mls_context_to_sid(struct policydb *pol, char oldc, char *scontext, + struct context *context, struct sidtab *s, u32 def_sid) { char *sensitivity, *cur_cat, *next_cat, *rngptr; struct level_datum *levdatum; @@ -333,7 +326,8 @@ int mls_context_to_sid(struct policydb *pol, return -EINVAL; for (i = catdatum->value; i < rngdatum->value; i++) { - rc = ebitmap_set_bit(&context->range.level[l].cat, i, 1); + rc = ebitmap_set_bit( + &context->range.level[l].cat, i, 1); if (rc) return rc; } @@ -371,8 +365,8 @@ int mls_from_string(struct policydb *p, char *str, struct context *context, if (!tmpstr) { rc = -ENOMEM; } else { - rc = mls_context_to_sid(p, ':', tmpstr, context, - NULL, SECSID_NULL); + rc = mls_context_to_sid(p, ':', tmpstr, context, NULL, + SECSID_NULL); kfree(tmpstr); } @@ -382,8 +376,7 @@ int mls_from_string(struct policydb *p, char *str, struct context *context, /* * Copies the MLS range `range' into `context'. */ -int mls_range_set(struct context *context, - struct mls_range *range) +int mls_range_set(struct context *context, struct mls_range *range) { int l, rc = 0; @@ -399,9 +392,8 @@ int mls_range_set(struct context *context, return rc; } -int mls_setup_user_range(struct policydb *p, - struct context *fromcon, struct user_datum *user, - struct context *usercon) +int mls_setup_user_range(struct policydb *p, struct context *fromcon, + struct user_datum *user, struct context *usercon) { if (p->mls_enabled) { struct mls_level *fromcon_sen = &(fromcon->range.level[0]); @@ -444,10 +436,8 @@ int mls_setup_user_range(struct policydb *p, * policy `oldp' to the values specified in the policy `newp', * storing the resulting context in `newc'. */ -int mls_convert_context(struct policydb *oldp, - struct policydb *newp, - struct context *oldc, - struct context *newc) +int mls_convert_context(struct policydb *oldp, struct policydb *newp, + struct context *oldc, struct context *newc) { struct level_datum *levdatum; struct cat_datum *catdatum; @@ -468,8 +458,9 @@ int mls_convert_context(struct policydb *oldp, return -EINVAL; newc->range.level[l].sens = levdatum->level->sens; - ebitmap_for_each_positive_bit(&oldc->range.level[l].cat, - node, i) { + ebitmap_for_each_positive_bit(&oldc->range.level[l].cat, node, + i) + { int rc; catdatum = symtab_search(&newp->p_cats, @@ -486,13 +477,9 @@ int mls_convert_context(struct policydb *oldp, return 0; } -int mls_compute_sid(struct policydb *p, - struct context *scontext, - struct context *tcontext, - u16 tclass, - u32 specified, - struct context *newcontext, - bool sock) +int mls_compute_sid(struct policydb *p, struct context *scontext, + struct context *tcontext, u16 tclass, u32 specified, + struct context *newcontext, bool sock) { struct range_trans rtr; struct mls_range *r; @@ -532,8 +519,8 @@ int mls_compute_sid(struct policydb *p, case DEFAULT_TARGET_LOW_HIGH: return mls_context_cpy(newcontext, tcontext); case DEFAULT_GLBLUB: - return mls_context_glblub(newcontext, - scontext, tcontext); + return mls_context_glblub(newcontext, scontext, + tcontext); } fallthrough; @@ -563,8 +550,7 @@ int mls_compute_sid(struct policydb *p, * NetLabel MLS sensitivity level field. * */ -void mls_export_netlbl_lvl(struct policydb *p, - struct context *context, +void mls_export_netlbl_lvl(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr) { if (!p->mls_enabled) @@ -585,8 +571,7 @@ void mls_export_netlbl_lvl(struct policydb *p, * NetLabel MLS sensitivity level into the context. * */ -void mls_import_netlbl_lvl(struct policydb *p, - struct context *context, +void mls_import_netlbl_lvl(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr) { if (!p->mls_enabled) @@ -607,8 +592,7 @@ void mls_import_netlbl_lvl(struct policydb *p, * MLS category field. Returns zero on success, negative values on failure. * */ -int mls_export_netlbl_cat(struct policydb *p, - struct context *context, +int mls_export_netlbl_cat(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr) { int rc; @@ -637,8 +621,7 @@ int mls_export_netlbl_cat(struct policydb *p, * negative values on failure. * */ -int mls_import_netlbl_cat(struct policydb *p, - struct context *context, +int mls_import_netlbl_cat(struct policydb *p, struct context *context, struct netlbl_lsm_secattr *secattr) { int rc; From patchwork Thu Feb 22 23:52:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568382 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06015140364 for ; Thu, 22 Feb 2024 23:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646389; cv=none; b=nsFSQe/fvC1Gdjuiq3u6DPk0QaTpUydpY1FHK9BZuMLccWXzbMlsGE66sfH3PnGbkF1V6M4eaLa497lQ8i3bQLT2mAMUn5gOGFiiGZpTYo60PxKYnbvMykvRIRJFUMK7UyOD/Zth/HU8fT0UNapLrE6MppJes8TWznmwBkE29o0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646389; c=relaxed/simple; bh=WcWMOGj6EzXlnXxjWOjbIXFHZT51YtOWAmDHFnbMrw4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kqIYhSH7KnTDF5IdlNI2AR4865j6/6tF90hIhoFd9SP+GwIZ4M3RxNG7SO8eDnTe8AFnjhnQvsPEihdz0HqwGPR+U3VGlCMhxvSni3N4iWJD+P5tw/hogsrfmIG6rAO+GuZwiRBImHy4PePgJyFfD3I1lIPyVj4wsa/xyi8XAp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=E/lTGZIv; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="E/lTGZIv" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-68f51ba7043so2484946d6.3 for ; Thu, 22 Feb 2024 15:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646387; x=1709251187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JbjtEbXipWVl4XZCnmkxFTAmBVbWul7Lt80nOFerUuM=; b=E/lTGZIvNpV+moGaXzqChLsiyBHvcHV/1sobmSmQEb1D7As3QnXK9DZZrQJSr3UL5p GSZ+dIWBhKbYu1VQRJeYGuJ7BPEvJ+VZsBsqzBkdC3DnrbWd7K8VxtSmY/6CKNQHXFhG ie9IodNzInMXKxbJfIGp8Q0tgQqizFbqtbdZkjDip9OOAa5vcUL4K0VndQfS60BX2rYr Q9U6l13ow6en8uSxvLGy5s/Ww2RbtxY5Y7O+oYhe7gTw/qRMcx9yNGVEg+pQRjUp2L7v uVvz6MUL1TQjwm1qJhytD2XJ/JDI0c1K6Ccl0GHh+OgbmVyc5ostJCCgDqhKqPO+LX2g mcdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646387; x=1709251187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JbjtEbXipWVl4XZCnmkxFTAmBVbWul7Lt80nOFerUuM=; b=uPks1ZOiczHlg1LImeGulW389mAD7+r0HRPYYOjYyz/tUiGSi9AlGsU93DQEA7d8zU epEw+w9hTqAks8ZUl0JHgx9wySvvQipgKPQ4zui2kQ01JVkHg6D7cJ0scqpdoBMbs2si fe2VgRCD53jsJxixl9PpEIcls5bPUIGGXwpz07Bqd2hRMrHCnRkAL40bfqIEipN3OKVj yZVdUPbGf1dnsv7Xgnp5AXjoXww4gOuGMFLDrZnQ5YWtP89PJdY84OqVc5nttRVAx0MM ctNX6AdAtsFUYxS1VuiUXXOAD7cSnLY8JKVNFUyiIx0JrSWik0Vw/2I7WJbC8hfKTKQw V9GQ== X-Gm-Message-State: AOJu0YzQXJnVPKQS0pdPLy2Tzsi/LX9uMHmHD8ld4aJ9ScAHsoJ96KCt 86ZFaUoJY3exrDklRurgsR6zSxPuQQ46xpZ1JYP6pvE9HNrTQdoBavjVEo1wehLq2rFmjTWJnjI = X-Google-Smtp-Source: AGHT+IFA5+2mvc6EugLdBJwo7w7PJpjIHmXMsCyzehIsrOlrbmqqa/hj4E7MOD6C+5KkozNstjapSA== X-Received: by 2002:ad4:5743:0:b0:68f:22b1:8e24 with SMTP id q3-20020ad45743000000b0068f22b18e24mr886760qvx.28.1708646386601; Thu, 22 Feb 2024 15:59:46 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ld11-20020a056214418b00b00686ac3c9db4sm7478899qvb.98.2024.02.22.15.59.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:46 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 14/21] selinux: fix style issues in security/selinux/ss/mls_types.h Date: Thu, 22 Feb 2024 18:52:32 -0500 Message-ID: <20240222235708.386652-37-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2962; i=paul@paul-moore.com; h=from:subject; bh=WcWMOGj6EzXlnXxjWOjbIXFHZT51YtOWAmDHFnbMrw4=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+puZGruday0MFQyUHWsQQzxbxkr+voStNIC ZBZEDvHbjiJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffqQAKCRDqIPLalzeJ c+AuD/wNSHz3IOM6OtC/7mopxtcJsVglfzcP0tOP0f197N4/bloHWNpNxCDOPp0yrQ+rGhQy8xe A/K3T9zXhUMzeQhdO+pMKp+Q3+FY3pdacBfB6auKEUZuOzhMirylie1NuOs95DfFmgxPmng+nqO MKdGQoCRb8L3DF0fjrG2kL9SSi0Uo4/kmu5Esek+dFlBc1kh6aCkywgICxmCN/IU12QtqZngCcF urECBl0GbqUK7cg7P/OX1qCPb00ZSum+3PsxRdeOYxAnbzqf+PPwDydL59jpqLGTj6eGk/Gitr1 Bi56ttNnJ6/+LQ6ZbPL/KW7JzbZA8QzHSpWm2y87l4j9UoAClORuaa3RvD0wL/qg4S3183Lpa/O jdguuzbnt5ZDQebCg1JvsqLjzaKfHdRpR4TeIv5KyXLuUa4bBHsvL/kxrD/oiGbbS3uACfKoTv6 Wy9GecJp23RQuNWK0t5kdHwjVf7zRUiZldZAV2By6m0CKm/eLPmpfb+ge4AOuPWwgFVXyfDxV2Y mOjEGFPqx5H69Lp/tbjFwhwmddLZVrVArsIobXwUbFa44mAwTYO4wGVUZOmK9dJsOL/B3ZC7Ivf Ijd8l7MrQBfXuidkAMRha/fwlYPuOs2X9EvBWFwXx6rtZmY3l/M8gBsdyW79mIARdqRBTie+COE mBrjM25cG2ioFNQ== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/mls_types.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/security/selinux/ss/mls_types.h b/security/selinux/ss/mls_types.h index f492cf148891..7ef6e8cb0cf4 100644 --- a/security/selinux/ss/mls_types.h +++ b/security/selinux/ss/mls_types.h @@ -4,12 +4,11 @@ * * Author : Stephen Smalley, */ + /* * Updated: Trusted Computer Solutions, Inc. - * - * Support for enhanced MLS infrastructure. - * - * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. + * Support for enhanced MLS infrastructure. + * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. */ #ifndef _SS_MLS_TYPES_H_ @@ -19,34 +18,35 @@ #include "ebitmap.h" struct mls_level { - u32 sens; /* sensitivity */ - struct ebitmap cat; /* category set */ + u32 sens; /* sensitivity */ + struct ebitmap cat; /* category set */ }; struct mls_range { struct mls_level level[2]; /* low == level[0], high == level[1] */ }; -static inline int mls_level_eq(const struct mls_level *l1, const struct mls_level *l2) +static inline int mls_level_eq(const struct mls_level *l1, + const struct mls_level *l2) { - return ((l1->sens == l2->sens) && - ebitmap_cmp(&l1->cat, &l2->cat)); + return ((l1->sens == l2->sens) && ebitmap_cmp(&l1->cat, &l2->cat)); } -static inline int mls_level_dom(const struct mls_level *l1, const struct mls_level *l2) +static inline int mls_level_dom(const struct mls_level *l1, + const struct mls_level *l2) { return ((l1->sens >= l2->sens) && ebitmap_contains(&l1->cat, &l2->cat, 0)); } #define mls_level_incomp(l1, l2) \ -(!mls_level_dom((l1), (l2)) && !mls_level_dom((l2), (l1))) + (!mls_level_dom((l1), (l2)) && !mls_level_dom((l2), (l1))) #define mls_level_between(l1, l2, l3) \ -(mls_level_dom((l1), (l2)) && mls_level_dom((l3), (l1))) + (mls_level_dom((l1), (l2)) && mls_level_dom((l3), (l1))) -#define mls_range_contains(r1, r2) \ -(mls_level_dom(&(r2).level[0], &(r1).level[0]) && \ - mls_level_dom(&(r1).level[1], &(r2).level[1])) +#define mls_range_contains(r1, r2) \ + (mls_level_dom(&(r2).level[0], &(r1).level[0]) && \ + mls_level_dom(&(r1).level[1], &(r2).level[1])) -#endif /* _SS_MLS_TYPES_H_ */ +#endif /* _SS_MLS_TYPES_H_ */ From patchwork Thu Feb 22 23:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568383 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D107A140385 for ; Thu, 22 Feb 2024 23:59:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646390; cv=none; b=ZIv5A9XdqsSOc4f/wtD4nI1p8Z6eoOVaIQWKq/uv89jIjcaj2obYyTjhxRtZjSjSFO3HcjaoFfayKf5sLfH19pQUGq5+8EntWDXCfMUgIN1Jc93qZD/DVuabZdQzvcZRdMnWVw9OFKRwsAT1bmpPDG98qD+lLFAXS8vaGT1g02Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646390; c=relaxed/simple; bh=HRWAc2KELikCNisVhVCM3yHfwPwYkTPNRgp115QKDgg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CLQQ+aRQp0cPXeAIgsNy6bAoxkIL9TLnOYeTkaUmsErlttMH3T0L0+P/5PPj3gdYXwc1Od7YW2tTR3IkVNogrkk5+xddClG9M/0ZSufxEY1e8tw+6dKhwqEftsqlqBHdib2Dwn6oZlS7RRyswmSVps9jQ2QX9xmLNd9r6gDLLo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=EFpES6Hr; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="EFpES6Hr" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-68fb3a3f1c5so2482906d6.3 for ; Thu, 22 Feb 2024 15:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646387; x=1709251187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HO9gYKXdfRljFYpo/GBD95tWyC4dDYclbakKvnKiflQ=; b=EFpES6HrW5BANRE1uSA9N5egqc5nFbV9DbxKZbKWboJTMv0jSHDgcgiWcyYmq8Y/Jo ibc9O5nkeJbZ0oRjAAMMkYlczg1UUbPnKC6abNCdnE5eTX/h0Qku0PXztw9pqG7iLvdS j/XxfK1PpZScXoQSvYOiVRaumovxaBgjj/FCxjx59gVyJSD8KDXXvA0qSdjN/+iT3nx8 EaeIJ4nv6S2qHa2/ZRGjwoRJ6XEHoDOIRVhdr/teoC6Gu23D/4B1gYQ/tanqAc5YSEde w4mmz5HDcy3+6wvM+V+nyMw97P1qKrLl85FyuIGfuRXWQ/ipBlg0JywJGCf6LohkhoRp E78w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646387; x=1709251187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HO9gYKXdfRljFYpo/GBD95tWyC4dDYclbakKvnKiflQ=; b=pD/w0IdtAMJxCf5Skhy3f50K9s0fBQjZ7r1XLTXxg4uc6rgaozZPZeVatc1FnbUN/q 7ViuX9HRlfzmmvXC3f/qemb4dic5Is/RUdbqvg/Nx5afUhG743aP1HV1nQDMecynyJ6D RTLKFPQLVTYEAdv1sYJDZDDcCSwSu6g3VrwqOjD3GF3cQSb+scu6/JVOxvpsGVQoGjax oXX3SNdNQLUmOArFl9/xZgZYRlgZTOvUILdwB4Edj6VqOk4PXWblhHXT1V2RcOkoRc8Y MWIj6BBgCVAAanwcNO/4vHRMjBtj5qO4LWm/FBPulpNyMvkpH3tIGv/VnJrhKD2cGbMQ q6aA== X-Gm-Message-State: AOJu0YxMArxBckYwmWOniBzKyTIcn/aeaP2NYuwEG2idNWNy/DrAh/6n 5w19UARQavBGxTqoqmDVEl5Jk14LSkIUySMsJfebd6hlvPhTlUX13V1bXmxNAyEHnQWU/60eFOM = X-Google-Smtp-Source: AGHT+IE+L3oTb004+d8yBSC/coZ4ElHxLZg0hYzN/OjGboHZKhis42BldK83s74qmNOLWA2F9j6kEg== X-Received: by 2002:a05:6214:c49:b0:68f:2f04:9ce2 with SMTP id r9-20020a0562140c4900b0068f2f049ce2mr842007qvj.8.1708646387520; Thu, 22 Feb 2024 15:59:47 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id d11-20020a0ce44b000000b0068efc28e3d3sm7424704qvm.45.2024.02.22.15.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:47 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 15/21] selinux: fix style issues in security/selinux/ss/policydb.h Date: Thu, 22 Feb 2024 18:52:33 -0500 Message-ID: <20240222235708.386652-38-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=12988; i=paul@paul-moore.com; h=from:subject; bh=HRWAc2KELikCNisVhVCM3yHfwPwYkTPNRgp115QKDgg=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+vLeKCc0TNXMTmOm5LAcX/HrLVNcM91jUew ifhq4ZKVS6JAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffrwAKCRDqIPLalzeJ c+KrEADC3kNBpAB97fF82B+k7HUqVTX54xufgm4ojyeVmISUB8cBPsUl6g+Ywdq9fLPmUGRKA11 +qdZ/SeDHMLRuNzYbwOFzOtoCV97W1+Ym5U9TTrJV0EPBT/L8hC12ojucwyPsl4+e37UN9oMjda 8IhAJ1JoElKbYAgCYWScyQnMgJn03f7Jz23haqOLedtCXkj+BgufLja2xBBm8bIflz3rtGLyO4p cHLV8rPTv5WH8oESUjwhuCpZ9x6oNP0lOpf8BS4fKfvLAka1P4az5fl0gjQJRWehV7iJd22PUD9 nuf3B8fxH9DkRpjrakFz4fv1n78MuSHmIO9Vxjqnsp879aPULphn3Jdw+cJKyIerOCZQzhDkGCo gnboBlB7tygo7Lqppyu5VwqnU1UkFaNNKRZdBYZ8zGXtK7pJ1gt3pssriCEwhXxpgpBCGlmj8+c iwgKAP8033ZfgOs638XnkGTI4qsLqAGGZA8HumN5dbKog2ar5oB3JsO62alB1bn71LswisCLk+V pFSJn98L7ABLydJZh60pTuc4QcjPhSKwDyO0cib8r3wCMdkSIAw9EZ7jLZhlKYsLdEmbstOdun7 1YHUiGDUkWLUw/2S/W/xhamK4cyCVVoeHsgVlgfstTxhbnE+4couftCtrBu3uuMHlQ1UTSNUic9 4i886nR++BcqHKQ== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/policydb.h | 192 ++++++++++++++++----------------- 1 file changed, 95 insertions(+), 97 deletions(-) diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h index b97cda489753..4bba386264a3 100644 --- a/security/selinux/ss/policydb.h +++ b/security/selinux/ss/policydb.h @@ -8,15 +8,13 @@ /* * Updated: Trusted Computer Solutions, Inc. + * Support for enhanced MLS infrastructure. + * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. * - * Support for enhanced MLS infrastructure. - * - * Updated: Frank Mayer and Karl MacMillan - * - * Added conditional policy language extensions - * - * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. - * Copyright (C) 2003 - 2004 Tresys Technology, LLC + * Updated: Frank Mayer and + * Karl MacMillan + * Added conditional policy language extensions + * Copyright (C) 2003-2004 Tresys Technology, LLC */ #ifndef _SS_POLICYDB_H_ @@ -39,104 +37,103 @@ /* Permission attributes */ struct perm_datum { - u32 value; /* permission bit + 1 */ + u32 value; /* permission bit + 1 */ }; /* Attributes of a common prefix for access vectors */ struct common_datum { - u32 value; /* internal common value */ - struct symtab permissions; /* common permissions */ + u32 value; /* internal common value */ + struct symtab permissions; /* common permissions */ }; /* Class attributes */ struct class_datum { - u32 value; /* class value */ - char *comkey; /* common name */ - struct common_datum *comdatum; /* common datum */ - struct symtab permissions; /* class-specific permission symbol table */ - struct constraint_node *constraints; /* constraints on class permissions */ - struct constraint_node *validatetrans; /* special transition rules */ + u32 value; /* class value */ + char *comkey; /* common name */ + struct common_datum *comdatum; /* common datum */ + struct symtab permissions; /* class-specific permission symbol table */ + struct constraint_node *constraints; /* constraints on class perms */ + struct constraint_node *validatetrans; /* special transition rules */ /* Options how a new object user, role, and type should be decided */ -#define DEFAULT_SOURCE 1 -#define DEFAULT_TARGET 2 +#define DEFAULT_SOURCE 1 +#define DEFAULT_TARGET 2 char default_user; char default_role; char default_type; /* Options how a new object range should be decided */ -#define DEFAULT_SOURCE_LOW 1 -#define DEFAULT_SOURCE_HIGH 2 -#define DEFAULT_SOURCE_LOW_HIGH 3 -#define DEFAULT_TARGET_LOW 4 -#define DEFAULT_TARGET_HIGH 5 -#define DEFAULT_TARGET_LOW_HIGH 6 +#define DEFAULT_SOURCE_LOW 1 +#define DEFAULT_SOURCE_HIGH 2 +#define DEFAULT_SOURCE_LOW_HIGH 3 +#define DEFAULT_TARGET_LOW 4 +#define DEFAULT_TARGET_HIGH 5 +#define DEFAULT_TARGET_LOW_HIGH 6 #define DEFAULT_GLBLUB 7 char default_range; }; /* Role attributes */ struct role_datum { - u32 value; /* internal role value */ - u32 bounds; /* boundary of role */ - struct ebitmap dominates; /* set of roles dominated by this role */ - struct ebitmap types; /* set of authorized types for role */ + u32 value; /* internal role value */ + u32 bounds; /* boundary of role */ + struct ebitmap dominates; /* set of roles dominated by this role */ + struct ebitmap types; /* set of authorized types for role */ }; struct role_trans_key { - u32 role; /* current role */ - u32 type; /* program executable type, or new object type */ - u32 tclass; /* process class, or new object class */ + u32 role; /* current role */ + u32 type; /* program executable type, or new object type */ + u32 tclass; /* process class, or new object class */ }; struct role_trans_datum { - u32 new_role; /* new role */ + u32 new_role; /* new role */ }; struct filename_trans_key { - u32 ttype; /* parent dir context */ - u16 tclass; /* class of new object */ - const char *name; /* last path component */ + u32 ttype; /* parent dir context */ + u16 tclass; /* class of new object */ + const char *name; /* last path component */ }; struct filename_trans_datum { - struct ebitmap stypes; /* bitmap of source types for this otype */ - u32 otype; /* resulting type of new object */ - struct filename_trans_datum *next; /* record for next otype*/ + struct ebitmap stypes; /* bitmap of source types for this otype */ + u32 otype; /* resulting type of new object */ + struct filename_trans_datum *next; /* record for next otype*/ }; struct role_allow { - u32 role; /* current role */ - u32 new_role; /* new role */ + u32 role; /* current role */ + u32 new_role; /* new role */ struct role_allow *next; }; /* Type attributes */ struct type_datum { - u32 value; /* internal type value */ - u32 bounds; /* boundary of type */ - unsigned char primary; /* primary name? */ - unsigned char attribute;/* attribute ?*/ + u32 value; /* internal type value */ + u32 bounds; /* boundary of type */ + unsigned char primary; /* primary name? */ + unsigned char attribute; /* attribute ?*/ }; /* User attributes */ struct user_datum { - u32 value; /* internal user value */ - u32 bounds; /* bounds of user */ - struct ebitmap roles; /* set of authorized roles for user */ - struct mls_range range; /* MLS range (min - max) for user */ - struct mls_level dfltlevel; /* default login MLS level for user */ + u32 value; /* internal user value */ + u32 bounds; /* bounds of user */ + struct ebitmap roles; /* set of authorized roles for user */ + struct mls_range range; /* MLS range (min - max) for user */ + struct mls_level dfltlevel; /* default login MLS level for user */ }; - /* Sensitivity attributes */ struct level_datum { - struct mls_level *level; /* sensitivity and associated categories */ - unsigned char isalias; /* is this sensitivity an alias for another? */ + struct mls_level *level; /* sensitivity and associated categories */ + unsigned char isalias; /* is this sensitivity an alias for another? */ }; /* Category attributes */ struct cat_datum { - u32 value; /* internal category bit + 1 */ - unsigned char isalias; /* is this category an alias for another? */ + u32 value; /* internal category bit + 1 */ + unsigned char isalias; /* is this category an alias for another? */ }; struct range_trans { @@ -147,7 +144,7 @@ struct range_trans { /* Boolean data type */ struct cond_bool_datum { - __u32 value; /* internal type value */ + __u32 value; /* internal type value */ int state; }; @@ -173,20 +170,20 @@ struct type_set { */ struct ocontext { union { - char *name; /* name of initial SID, fs, netif, fstype, path */ + char *name; /* name of initial SID, fs, netif, fstype, path */ struct { u8 protocol; u16 low_port; u16 high_port; - } port; /* TCP or UDP port information */ + } port; /* TCP or UDP port information */ struct { u32 addr; u32 mask; - } node; /* node information */ + } node; /* node information */ struct { u32 addr[4]; u32 mask[4]; - } node6; /* IPv6 node information */ + } node6; /* IPv6 node information */ struct { u64 subnet_prefix; u16 low_pkey; @@ -198,11 +195,11 @@ struct ocontext { } ibendport; } u; union { - u32 sclass; /* security class for genfs */ - u32 behavior; /* labeling behavior for fs_use */ + u32 sclass; /* security class for genfs */ + u32 behavior; /* labeling behavior for fs_use */ } v; - struct context context[2]; /* security context(s) */ - u32 sid[2]; /* SID(s) */ + struct context context[2]; /* security context(s) */ + u32 sid[2]; /* SID(s) */ struct ocontext *next; }; @@ -221,19 +218,19 @@ struct genfs { #define SYM_BOOLS 5 #define SYM_LEVELS 6 #define SYM_CATS 7 -#define SYM_NUM 8 +#define SYM_NUM 8 /* object context array indices */ -#define OCON_ISID 0 /* initial SIDs */ -#define OCON_FS 1 /* unlabeled file systems (deprecated) */ -#define OCON_PORT 2 /* TCP and UDP port numbers */ -#define OCON_NETIF 3 /* network interfaces */ -#define OCON_NODE 4 /* nodes */ -#define OCON_FSUSE 5 /* fs_use */ -#define OCON_NODE6 6 /* IPv6 nodes */ -#define OCON_IBPKEY 7 /* Infiniband PKeys */ -#define OCON_IBENDPORT 8 /* Infiniband end ports */ -#define OCON_NUM 9 +#define OCON_ISID 0 /* initial SIDs */ +#define OCON_FS 1 /* unlabeled file systems (deprecated) */ +#define OCON_PORT 2 /* TCP and UDP port numbers */ +#define OCON_NETIF 3 /* network interfaces */ +#define OCON_NODE 4 /* nodes */ +#define OCON_FSUSE 5 /* fs_use */ +#define OCON_NODE6 6 /* IPv6 nodes */ +#define OCON_IBPKEY 7 /* Infiniband PKeys */ +#define OCON_IBENDPORT 8 /* Infiniband end ports */ +#define OCON_NUM 9 /* The policy database */ struct policydb { @@ -243,15 +240,15 @@ struct policydb { struct symtab symtab[SYM_NUM]; #define p_commons symtab[SYM_COMMONS] #define p_classes symtab[SYM_CLASSES] -#define p_roles symtab[SYM_ROLES] -#define p_types symtab[SYM_TYPES] -#define p_users symtab[SYM_USERS] -#define p_bools symtab[SYM_BOOLS] -#define p_levels symtab[SYM_LEVELS] -#define p_cats symtab[SYM_CATS] +#define p_roles symtab[SYM_ROLES] +#define p_types symtab[SYM_TYPES] +#define p_users symtab[SYM_USERS] +#define p_bools symtab[SYM_BOOLS] +#define p_levels symtab[SYM_LEVELS] +#define p_cats symtab[SYM_CATS] /* symbol names indexed by (value - 1) */ - char **sym_val_to_name[SYM_NUM]; + char **sym_val_to_name[SYM_NUM]; /* class, role, and user attributes indexed by (value - 1) */ struct class_datum **class_val_to_struct; @@ -324,25 +321,25 @@ extern int policydb_role_isvalid(struct policydb *p, unsigned int role); extern int policydb_read(struct policydb *p, void *fp); extern int policydb_write(struct policydb *p, void *fp); -extern struct filename_trans_datum *policydb_filenametr_search( - struct policydb *p, struct filename_trans_key *key); +extern struct filename_trans_datum * +policydb_filenametr_search(struct policydb *p, struct filename_trans_key *key); -extern struct mls_range *policydb_rangetr_search( - struct policydb *p, struct range_trans *key); +extern struct mls_range *policydb_rangetr_search(struct policydb *p, + struct range_trans *key); -extern struct role_trans_datum *policydb_roletr_search( - struct policydb *p, struct role_trans_key *key); +extern struct role_trans_datum * +policydb_roletr_search(struct policydb *p, struct role_trans_key *key); -#define POLICYDB_CONFIG_MLS 1 +#define POLICYDB_CONFIG_MLS 1 /* the config flags related to unknown classes/perms are bits 2 and 3 */ -#define REJECT_UNKNOWN 0x00000002 -#define ALLOW_UNKNOWN 0x00000004 +#define REJECT_UNKNOWN 0x00000002 +#define ALLOW_UNKNOWN 0x00000004 -#define OBJECT_R "object_r" +#define OBJECT_R "object_r" #define OBJECT_R_VAL 1 -#define POLICYDB_MAGIC SELINUX_MAGIC +#define POLICYDB_MAGIC SELINUX_MAGIC #define POLICYDB_STRING "SE Linux" struct policy_file { @@ -366,7 +363,8 @@ static inline int next_entry(void *buf, struct policy_file *fp, size_t bytes) return 0; } -static inline int put_entry(const void *buf, size_t bytes, size_t num, struct policy_file *fp) +static inline int put_entry(const void *buf, size_t bytes, size_t num, + struct policy_file *fp) { size_t len; @@ -382,7 +380,8 @@ static inline int put_entry(const void *buf, size_t bytes, size_t num, struct po return 0; } -static inline char *sym_name(struct policydb *p, unsigned int sym_num, unsigned int element_nr) +static inline char *sym_name(struct policydb *p, unsigned int sym_num, + unsigned int element_nr) { return p->sym_val_to_name[sym_num][element_nr]; } @@ -390,5 +389,4 @@ static inline char *sym_name(struct policydb *p, unsigned int sym_num, unsigned extern u16 string_to_security_class(struct policydb *p, const char *name); extern u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name); -#endif /* _SS_POLICYDB_H_ */ - +#endif /* _SS_POLICYDB_H_ */ From patchwork Thu Feb 22 23:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568385 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AD9013BAF8 for ; Thu, 22 Feb 2024 23:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646392; cv=none; b=YxcIKqCHv26mKtYMlZr9wiPABMQiS22qnR+lWkIl2SVgh6qcctk2NUTiXqu+e0afJ+3M2umOHaKlx6nq7sIIT2Q2UnF3o1dirDJAWu09XZb3dRsm8Kb4OdN4CaFqaZwA6VLNESHn+PgWy1GIWS0R49Y67UgMSBXDLtHCEH76PvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646392; c=relaxed/simple; bh=KVOJ2d5yMD1LckI9XHc1d96h3qdrm880a+mK2/nkhEw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qMLrwksvAuGacHJv5lvqAS9zAzO36Z8nv+kV7XSq69SKOdMlLkWYm2WuQLzIgLETmvD0HTmpQHEBLm1hIkHzJzkve8L+uP5JU0OKn3FXVhZ1rkR+5q3ydvJLZwf4n0Bk2jhgKV6ZFR9G9zf8a/jxeQhKGgPfztUBpEdjY8qkUcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=E+/nNU64; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="E+/nNU64" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-787ad74786aso10188685a.1 for ; Thu, 22 Feb 2024 15:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646389; x=1709251189; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zFR6ATjvVTG15zONhsoJKLKIqUHlp7tQ91fN7ZEQQUk=; b=E+/nNU64FTEqvuAz6L7n4YicmX1gXUaa638PRVXdKWXNdx+ar56j1kAlAizinp+MXq lYNIPpwAFDvVy57MWt3Z0Ad6QFv2lnnfAcrhqHMmmxo3l8wus2QaeGhldK+g+kjbp1ho CwTcuJxxGBWkVohKuLegiJM20kgDJkHICjJJXwrv/27zdgHux+SBE8nagJkAQcoPxxjl cCgiQS76MILAflrQSEDBwM9GxioQ7HrYV0BkfFfzzP9ZBdDAXIkfKMNCreXYrchT7Hbv auh7CYNasfrrRtJtPMTdvVNbwuLc2VPhVN7A8qBxzzN2SOC1RTclcaZRjfXMZ7h1wnea 90Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646389; x=1709251189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zFR6ATjvVTG15zONhsoJKLKIqUHlp7tQ91fN7ZEQQUk=; b=OiM6Bj1QwxK1Z8sb5J83hySMW+JBDTrMBsFGdxNGkxC3Z9sXR2mmJhVaPuc63EyZCg U/bHoyq+bXvC7YLBEEeuhtZORSyhVXi3H4RSRvSBV4o7JP7/xsmTT3LMgpFu+0xzAzpJ 4GMQCm+XBEW3KbYINwTymSnlP/cQ8RNOS4FJB06arIS3nPsQY4aUXYonABdXe4zbmWLE fwAFDAUCB8kIBGXhBLvsoiFDphWqa1FagHo7LN2UmppAEplRgkhkFcAUMNjz29T1HbZM hkdKm9BvGVEOkWIzo8CwLg1BtEBSZZSPxMC1MhbgI4KZMW/6aGD21kF4uZuiPg37oq7b Aqsw== X-Gm-Message-State: AOJu0YyWKE8cGJhaUUNOGyu6Fs0zg7ROjijXOtp5aCXGPz3Viaqa/WvL FE00/rQOwCAEodqb5qkaY806RaHo8/J+3Y/XhB/4IzrgZcTAFQa0rcinmR5VNlHpJDe0VH7C9Dw = X-Google-Smtp-Source: AGHT+IFrbiJl6EJriji01s6ucIOY9gAIkz2UtJt0az6qBHvTgzoXMs7d7bORWN9+wlpnyIj+tdYY8w== X-Received: by 2002:a0c:f588:0:b0:68f:709d:a47f with SMTP id k8-20020a0cf588000000b0068f709da47fmr597601qvm.47.1708646388505; Thu, 22 Feb 2024 15:59:48 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id op23-20020a056214459700b0068fcfef2077sm422236qvb.93.2024.02.22.15.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:48 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 16/21] selinux: fix style issues in security/selinux/ss/policydb.c Date: Thu, 22 Feb 2024 18:52:34 -0500 Message-ID: <20240222235708.386652-39-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=33618; i=paul@paul-moore.com; h=from:subject; bh=KVOJ2d5yMD1LckI9XHc1d96h3qdrm880a+mK2/nkhEw=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+2Kk2AwTt09nIfgaeMNjV2Yg5Wb8pu2UeH5 J9kXRdyeh6JAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdfftgAKCRDqIPLalzeJ c/cFD/90WdYat6y4j50riF9qNCfuy80SMGh1VlHcHR4OJdZS2p4GUGSIt1cc/cmYeFsbKF5usmr ZDMrTn8gvwtl2PqdRcVRiS+CWbWlst+NU9aQXvQzr4GNcPs4cAbawa4YD6ID8jCjlQtVJ6/iUsr 6+XpETOJJJD3y1PXcEgBlF5QLDTpwhc9OOGAKqRuSPO2DylKFjtAvQ+t+AuXrG3QKP1ZoGmZJzl nJ0RgQg8HjNM6Va/5eEKwo1fl/DMjhq4eHbFPDcrnD/p5V31OCv8D3qtsSosImaXeATE34DEQwh Ha1EPelRMwaDUD7TrFWcqhwm9XQHsfBIGeiKeM6VeteUpLE7OdUJwHAtJslfLpBUzddqBHGNec0 q4z8F+t+n/T7la4dwDmYJU7KtndeAvlG2lRToqYRJQXV6cK0dDSHE/SnyqczhrBrPvjJwg/+vPc 3bScxaQZ1HrLHdriSNsOHWTYvgtSmV/pu7fpFNzoDmCQo1xaCPzMDCL9S0RCbwnk31cRGx+paBC m5qJwcb2y8CiKQDb4KjqYhuelQCH/MgRCZb9/9TKESfBHtBf721WvAQ4LcRr8jLuzaN0XmbzMuy FfDYMFlwRsVy/84TVB9/DlzUqoXAPK5fV76ov/EbjCSxpPFk5TOy+ycSC2VBuW1qxo1fvfpdJEY Syojh0fDe3PGtOg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/policydb.c | 405 +++++++++++++++++---------------- 1 file changed, 213 insertions(+), 192 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 3b19ad28c922..3d22d5baa829 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -7,25 +7,21 @@ /* * Updated: Trusted Computer Solutions, Inc. + * Support for enhanced MLS infrastructure. + * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. * - * Support for enhanced MLS infrastructure. - * - * Updated: Frank Mayer and Karl MacMillan - * - * Added conditional policy language extensions + * Updated: Frank Mayer and + * Karl MacMillan + * Added conditional policy language extensions + * Copyright (C) 2003-2004 Tresys Technology, LLC * * Updated: Hewlett-Packard - * - * Added support for the policy capability bitmap + * Added support for the policy capability bitmap + * Copyright (C) 2007 Hewlett-Packard Development Company, L.P. * * Update: Mellanox Techonologies - * - * Added Infiniband support - * - * Copyright (C) 2016 Mellanox Techonologies - * Copyright (C) 2007 Hewlett-Packard Development Company, L.P. - * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc. - * Copyright (C) 2003 - 2004 Tresys Technology, LLC + * Added Infiniband support + * Copyright (C) 2016 Mellanox Techonologies */ #include @@ -42,6 +38,7 @@ #include "services.h" #ifdef CONFIG_SECURITY_SELINUX_DEBUG +/* clang-format off */ static const char *const symtab_name[SYM_NUM] = { "common prefixes", "classes", @@ -52,6 +49,7 @@ static const char *const symtab_name[SYM_NUM] = { "levels", "categories", }; +/* clang-format off */ #endif struct policydb_compat_info { @@ -63,103 +61,104 @@ struct policydb_compat_info { /* These need to be updated if SYM_NUM or OCON_NUM changes */ static const struct policydb_compat_info policydb_compat[] = { { - .version = POLICYDB_VERSION_BASE, - .sym_num = SYM_NUM - 3, - .ocon_num = OCON_NUM - 3, + .version = POLICYDB_VERSION_BASE, + .sym_num = SYM_NUM - 3, + .ocon_num = OCON_NUM - 3, }, { - .version = POLICYDB_VERSION_BOOL, - .sym_num = SYM_NUM - 2, - .ocon_num = OCON_NUM - 3, + .version = POLICYDB_VERSION_BOOL, + .sym_num = SYM_NUM - 2, + .ocon_num = OCON_NUM - 3, }, { - .version = POLICYDB_VERSION_IPV6, - .sym_num = SYM_NUM - 2, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_IPV6, + .sym_num = SYM_NUM - 2, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_NLCLASS, - .sym_num = SYM_NUM - 2, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_NLCLASS, + .sym_num = SYM_NUM - 2, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_MLS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_MLS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_AVTAB, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_AVTAB, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_RANGETRANS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_RANGETRANS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_POLCAP, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_POLCAP, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_PERMISSIVE, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_PERMISSIVE, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_BOUNDARY, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_BOUNDARY, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_FILENAME_TRANS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_FILENAME_TRANS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_ROLETRANS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_ROLETRANS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_NEW_OBJECT_DEFAULTS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_NEW_OBJECT_DEFAULTS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_DEFAULT_TYPE, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_DEFAULT_TYPE, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_CONSTRAINT_NAMES, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_CONSTRAINT_NAMES, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_XPERMS_IOCTL, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM - 2, + .version = POLICYDB_VERSION_XPERMS_IOCTL, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM - 2, }, { - .version = POLICYDB_VERSION_INFINIBAND, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM, + .version = POLICYDB_VERSION_INFINIBAND, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM, }, { - .version = POLICYDB_VERSION_GLBLUB, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM, + .version = POLICYDB_VERSION_GLBLUB, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM, }, { - .version = POLICYDB_VERSION_COMP_FTRANS, - .sym_num = SYM_NUM, - .ocon_num = OCON_NUM, + .version = POLICYDB_VERSION_COMP_FTRANS, + .sym_num = SYM_NUM, + .ocon_num = OCON_NUM, }, }; -static const struct policydb_compat_info *policydb_lookup_compat(unsigned int version) +static const struct policydb_compat_info * +policydb_lookup_compat(unsigned int version) { unsigned int i; @@ -312,7 +311,8 @@ static int cat_destroy(void *key, void *datum, void *p) return 0; } -static int (*const destroy_f[SYM_NUM]) (void *key, void *datum, void *datap) = { +/* clang-format off */ +static int (*const destroy_f[SYM_NUM])(void *key, void *datum, void *datap) = { common_destroy, cls_destroy, role_destroy, @@ -322,6 +322,7 @@ static int (*const destroy_f[SYM_NUM]) (void *key, void *datum, void *datap) = { sens_destroy, cat_destroy, }; +/* clang-format on */ static int filenametr_destroy(void *key, void *datum, void *p) { @@ -366,8 +367,8 @@ static void ocontext_destroy(struct ocontext *c, unsigned int i) context_destroy(&c->context[0]); context_destroy(&c->context[1]); - if (i == OCON_ISID || i == OCON_FS || - i == OCON_NETIF || i == OCON_FSUSE) + if (i == OCON_ISID || i == OCON_FS || i == OCON_NETIF || + i == OCON_FSUSE) kfree(c->u.name); kfree(c); } @@ -429,7 +430,6 @@ static int filenametr_cmp(const void *k1, const void *k2) return v; return strcmp(ft1->name, ft2->name); - } static const struct hashtab_key_params filenametr_key_params = { @@ -437,8 +437,8 @@ static const struct hashtab_key_params filenametr_key_params = { .cmp = filenametr_cmp, }; -struct filename_trans_datum *policydb_filenametr_search( - struct policydb *p, struct filename_trans_key *key) +struct filename_trans_datum * +policydb_filenametr_search(struct policydb *p, struct filename_trans_key *key) { return hashtab_search(&p->filename_trans, key, filenametr_key_params); } @@ -448,7 +448,7 @@ static u32 rangetr_hash(const void *k) const struct range_trans *key = k; return key->source_type + (key->target_type << 3) + - (key->target_class << 5); + (key->target_class << 5); } static int rangetr_cmp(const void *k1, const void *k2) @@ -484,7 +484,8 @@ static u32 role_trans_hash(const void *k) { const struct role_trans_key *key = k; - return jhash_3words(key->role, key->type, (u32)key->tclass << 16 | key->tclass, 0); + return jhash_3words(key->role, key->type, + (u32)key->tclass << 16 | key->tclass, 0); } static int role_trans_cmp(const void *k1, const void *k2) @@ -576,9 +577,8 @@ static int role_index(void *key, void *datum, void *datap) role = datum; p = datap; - if (!role->value - || role->value > p->p_roles.nprim - || role->bounds > p->p_roles.nprim) + if (!role->value || role->value > p->p_roles.nprim || + role->bounds > p->p_roles.nprim) return -EINVAL; p->sym_val_to_name[SYM_ROLES][role->value - 1] = key; @@ -595,9 +595,8 @@ static int type_index(void *key, void *datum, void *datap) p = datap; if (typdatum->primary) { - if (!typdatum->value - || typdatum->value > p->p_types.nprim - || typdatum->bounds > p->p_types.nprim) + if (!typdatum->value || typdatum->value > p->p_types.nprim || + typdatum->bounds > p->p_types.nprim) return -EINVAL; p->sym_val_to_name[SYM_TYPES][typdatum->value - 1] = key; p->type_val_to_struct[typdatum->value - 1] = typdatum; @@ -613,9 +612,8 @@ static int user_index(void *key, void *datum, void *datap) usrdatum = datum; p = datap; - if (!usrdatum->value - || usrdatum->value > p->p_users.nprim - || usrdatum->bounds > p->p_users.nprim) + if (!usrdatum->value || usrdatum->value > p->p_users.nprim || + usrdatum->bounds > p->p_users.nprim) return -EINVAL; p->sym_val_to_name[SYM_USERS][usrdatum->value - 1] = key; @@ -660,7 +658,8 @@ static int cat_index(void *key, void *datum, void *datap) return 0; } -static int (*const index_f[SYM_NUM]) (void *key, void *datum, void *datap) = { +/* clang-format off */ +static int (*const index_f[SYM_NUM])(void *key, void *datum, void *datap) = { common_index, class_index, role_index, @@ -670,6 +669,7 @@ static int (*const index_f[SYM_NUM]) (void *key, void *datum, void *datap) = { sens_index, cat_index, }; +/* clang-format on */ #ifdef CONFIG_SECURITY_SELINUX_DEBUG static void hash_eval(struct hashtab *h, const char *hash_name) @@ -677,9 +677,10 @@ static void hash_eval(struct hashtab *h, const char *hash_name) struct hashtab_info info; hashtab_stat(h, &info); - pr_debug("SELinux: %s: %d entries and %d/%d buckets used, longest chain length %d, sum of chain length^2 %llu\n", - hash_name, h->nel, info.slots_used, h->size, - info.max_chain_len, info.chain2_len_sum); + pr_debug( + "SELinux: %s: %d entries and %d/%d buckets used, longest chain length %d, sum of chain length^2 %llu\n", + hash_name, h->nel, info.slots_used, h->size, info.max_chain_len, + info.chain2_len_sum); } static void symtab_hash_eval(struct symtab *s) @@ -710,16 +711,17 @@ static int policydb_index(struct policydb *p) int i, rc; if (p->mls_enabled) - pr_debug("SELinux: %d users, %d roles, %d types, %d bools, %d sens, %d cats\n", - p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, - p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); + pr_debug( + "SELinux: %d users, %d roles, %d types, %d bools, %d sens, %d cats\n", + p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, + p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); else pr_debug("SELinux: %d users, %d roles, %d types, %d bools\n", p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, p->p_bools.nprim); - pr_debug("SELinux: %d classes, %d rules\n", - p->p_classes.nprim, p->te_avtab.nel); + pr_debug("SELinux: %d classes, %d rules\n", p->p_classes.nprim, + p->te_avtab.nel); avtab_hash_eval(&p->te_avtab, "rules"); symtab_hash_eval(p->symtab); @@ -730,21 +732,18 @@ static int policydb_index(struct policydb *p) if (!p->class_val_to_struct) return -ENOMEM; - p->role_val_to_struct = kcalloc(p->p_roles.nprim, - sizeof(*p->role_val_to_struct), - GFP_KERNEL); + p->role_val_to_struct = kcalloc( + p->p_roles.nprim, sizeof(*p->role_val_to_struct), GFP_KERNEL); if (!p->role_val_to_struct) return -ENOMEM; - p->user_val_to_struct = kcalloc(p->p_users.nprim, - sizeof(*p->user_val_to_struct), - GFP_KERNEL); + p->user_val_to_struct = kcalloc( + p->p_users.nprim, sizeof(*p->user_val_to_struct), GFP_KERNEL); if (!p->user_val_to_struct) return -ENOMEM; - p->type_val_to_struct = kvcalloc(p->p_types.nprim, - sizeof(*p->type_val_to_struct), - GFP_KERNEL); + p->type_val_to_struct = kvcalloc( + p->p_types.nprim, sizeof(*p->type_val_to_struct), GFP_KERNEL); if (!p->type_val_to_struct) return -ENOMEM; @@ -754,8 +753,7 @@ static int policydb_index(struct policydb *p) for (i = 0; i < SYM_NUM; i++) { p->sym_val_to_name[i] = kvcalloc(p->symtab[i].nprim, - sizeof(char *), - GFP_KERNEL); + sizeof(char *), GFP_KERNEL); if (!p->sym_val_to_name[i]) return -ENOMEM; @@ -857,8 +855,7 @@ void policydb_destroy(struct policydb *p) int policydb_load_isids(struct policydb *p, struct sidtab *s) { struct ocontext *head, *c; - bool isid_init_supported = ebitmap_get_bit(&p->policycaps, - POLICYDB_CAP_USERSPACE_INITIAL_CONTEXT); + bool isid_init; int rc; rc = sidtab_init(s); @@ -867,6 +864,9 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) return rc; } + isid_init = ebitmap_get_bit(&p->policycaps, + POLICYDB_CAP_USERSPACE_INITIAL_CONTEXT); + head = p->ocontexts[OCON_ISID]; for (c = head; c; c = c->next) { u32 sid = c->sid[0]; @@ -886,7 +886,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) * Also ignore SECINITSID_INIT if the policy doesn't declare * support for it */ - if (sid == SECINITSID_INIT && !isid_init_supported) + if (sid == SECINITSID_INIT && !isid_init) continue; rc = sidtab_set_initial(s, sid, &c->context[0]); @@ -905,8 +905,9 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) * started before policy load would initially get the context * corresponding to SECINITSID_KERNEL. */ - if (sid == SECINITSID_KERNEL && !isid_init_supported) { - rc = sidtab_set_initial(s, SECINITSID_INIT, &c->context[0]); + if (sid == SECINITSID_KERNEL && !isid_init) { + rc = sidtab_set_initial(s, SECINITSID_INIT, + &c->context[0]); if (rc) { pr_err("SELinux: unable to load initial SID %s.\n", name); @@ -1047,8 +1048,7 @@ static int mls_read_range_helper(struct mls_range *r, void *fp) * Read and validate a security context structure * from a policydb binary representation file. */ -static int context_read_and_validate(struct context *c, - struct policydb *p, +static int context_read_and_validate(struct context *c, struct policydb *p, void *fp) { __le32 buf[3]; @@ -1211,10 +1211,8 @@ static int type_set_read(struct type_set *t, void *fp) return 0; } - -static int read_cons_helper(struct policydb *p, - struct constraint_node **nodep, - u32 ncons, int allowxtarget, void *fp) +static int read_cons_helper(struct policydb *p, struct constraint_node **nodep, + u32 ncons, int allowxtarget, void *fp) { struct constraint_node *c, *lc; struct constraint_expr *e, *le; @@ -1284,8 +1282,9 @@ static int read_cons_helper(struct policydb *p, return rc; if (p->policyvers >= POLICYDB_VERSION_CONSTRAINT_NAMES) { - e->type_names = kzalloc(sizeof - (*e->type_names), GFP_KERNEL); + e->type_names = + kzalloc(sizeof(*e->type_names), + GFP_KERNEL); if (!e->type_names) return -ENOMEM; type_set_init(e->type_names); @@ -1319,7 +1318,7 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) if (!cladatum) return -ENOMEM; - rc = next_entry(buf, fp, sizeof(u32)*6); + rc = next_entry(buf, fp, sizeof(u32) * 6); if (rc) goto bad; @@ -1345,8 +1344,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; rc = -EINVAL; - cladatum->comdatum = symtab_search(&p->p_commons, - cladatum->comkey); + cladatum->comdatum = + symtab_search(&p->p_commons, cladatum->comkey); if (!cladatum->comdatum) { pr_err("SELinux: unknown common %s\n", cladatum->comkey); @@ -1369,8 +1368,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) if (rc) goto bad; ncons = le32_to_cpu(buf[0]); - rc = read_cons_helper(p, &cladatum->validatetrans, - ncons, 1, fp); + rc = read_cons_helper(p, &cladatum->validatetrans, ncons, 1, + fp); if (rc) goto bad; } @@ -1507,7 +1506,6 @@ static int type_read(struct policydb *p, struct symtab *s, void *fp) return rc; } - /* * Read a MLS level structure from a policydb binary * representation file. @@ -1659,8 +1657,9 @@ static int cat_read(struct policydb *p, struct symtab *s, void *fp) return rc; } -static int (*const read_f[SYM_NUM]) (struct policydb *p, - struct symtab *s, void *fp) = { +/* clang-format off */ +static int (*const read_f[SYM_NUM])(struct policydb *p, struct symtab *s, + void *fp) = { common_read, class_read, role_read, @@ -1670,6 +1669,7 @@ static int (*const read_f[SYM_NUM]) (struct policydb *p, sens_read, cat_read, }; +/* clang-format on */ static int user_bounds_sanity_check(void *key, void *datum, void *datap) { @@ -1685,12 +1685,13 @@ static int user_bounds_sanity_check(void *key, void *datum, void *datap) if (++depth == POLICYDB_BOUNDS_MAXDEPTH) { pr_err("SELinux: user %s: " "too deep or looped boundary\n", - (char *) key); + (char *)key); return -EINVAL; } upper = p->user_val_to_struct[upper->bounds - 1]; - ebitmap_for_each_positive_bit(&user->roles, node, bit) { + ebitmap_for_each_positive_bit(&user->roles, node, bit) + { if (ebitmap_get_bit(&upper->roles, bit)) continue; @@ -1721,12 +1722,13 @@ static int role_bounds_sanity_check(void *key, void *datum, void *datap) if (++depth == POLICYDB_BOUNDS_MAXDEPTH) { pr_err("SELinux: role %s: " "too deep or looped bounds\n", - (char *) key); + (char *)key); return -EINVAL; } upper = p->role_val_to_struct[upper->bounds - 1]; - ebitmap_for_each_positive_bit(&role->types, node, bit) { + ebitmap_for_each_positive_bit(&role->types, node, bit) + { if (ebitmap_get_bit(&upper->types, bit)) continue; @@ -1754,7 +1756,7 @@ static int type_bounds_sanity_check(void *key, void *datum, void *datap) if (++depth == POLICYDB_BOUNDS_MAXDEPTH) { pr_err("SELinux: type %s: " "too deep or looped boundary\n", - (char *) key); + (char *)key); return -EINVAL; } @@ -1764,7 +1766,7 @@ static int type_bounds_sanity_check(void *key, void *datum, void *datap) if (upper->attribute) { pr_err("SELinux: type %s: " "bounded by attribute %s\n", - (char *) key, + (char *)key, sym_name(p, SYM_TYPES, upper->value - 1)); return -EINVAL; } @@ -1815,7 +1817,7 @@ u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) if (!tclass || tclass > p->p_classes.nprim) return 0; - cladatum = p->class_val_to_struct[tclass-1]; + cladatum = p->class_val_to_struct[tclass - 1]; comdatum = cladatum->comdatum; if (comdatum) perdatum = symtab_search(&comdatum->permissions, name); @@ -1824,7 +1826,7 @@ u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) if (!perdatum) return 0; - return 1U << (perdatum->value-1); + return 1U << (perdatum->value - 1); } static int range_read(struct policydb *p, void *fp) @@ -2192,12 +2194,12 @@ static int genfs_read(struct policydb *p, void *fp) goto out; newc->v.sclass = le32_to_cpu(buf[0]); - rc = context_read_and_validate(&newc->context[0], p, fp); + rc = context_read_and_validate(&newc->context[0], p, + fp); if (rc) goto out; - for (l = NULL, c = genfs->head; c; - l = c, c = c->next) { + for (l = NULL, c = genfs->head; c; l = c, c = c->next) { rc = -EINVAL; if (!strcmp(newc->u.name, c->u.name) && (!c->v.sclass || !newc->v.sclass || @@ -2231,8 +2233,8 @@ static int genfs_read(struct policydb *p, void *fp) return rc; } -static int ocontext_read(struct policydb *p, const struct policydb_compat_info *info, - void *fp) +static int ocontext_read(struct policydb *p, + const struct policydb_compat_info *info, void *fp) { int rc; unsigned int i; @@ -2267,7 +2269,8 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * goto out; c->sid[0] = le32_to_cpu(buf[0]); - rc = context_read_and_validate(&c->context[0], p, fp); + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; break; @@ -2286,21 +2289,24 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * pr_warn("SELinux: void and deprecated fs ocon %s\n", c->u.name); - rc = context_read_and_validate(&c->context[0], p, fp); + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; - rc = context_read_and_validate(&c->context[1], p, fp); + rc = context_read_and_validate(&c->context[1], + p, fp); if (rc) goto out; break; case OCON_PORT: - rc = next_entry(buf, fp, sizeof(u32)*3); + rc = next_entry(buf, fp, sizeof(u32) * 3); if (rc) goto out; c->u.port.protocol = le32_to_cpu(buf[0]); c->u.port.low_port = le32_to_cpu(buf[1]); c->u.port.high_port = le32_to_cpu(buf[2]); - rc = context_read_and_validate(&c->context[0], p, fp); + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; break; @@ -2310,12 +2316,13 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * goto out; c->u.node.addr = nodebuf[0]; /* network order */ c->u.node.mask = nodebuf[1]; /* network order */ - rc = context_read_and_validate(&c->context[0], p, fp); + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; break; case OCON_FSUSE: - rc = next_entry(buf, fp, sizeof(u32)*2); + rc = next_entry(buf, fp, sizeof(u32) * 2); if (rc) goto out; @@ -2332,7 +2339,8 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * if (rc) goto out; - rc = context_read_and_validate(&c->context[0], p, fp); + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; break; @@ -2345,8 +2353,9 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * for (k = 0; k < 4; k++) c->u.node6.addr[k] = nodebuf[k]; for (k = 0; k < 4; k++) - c->u.node6.mask[k] = nodebuf[k+4]; - rc = context_read_and_validate(&c->context[0], p, fp); + c->u.node6.mask[k] = nodebuf[k + 4]; + rc = context_read_and_validate(&c->context[0], + p, fp); if (rc) goto out; break; @@ -2359,7 +2368,8 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * goto out; /* we need to have subnet_prefix in CPU order */ - c->u.ibpkey.subnet_prefix = be64_to_cpu(prefixbuf[0]); + c->u.ibpkey.subnet_prefix = + be64_to_cpu(prefixbuf[0]); rc = next_entry(buf, fp, sizeof(u32) * 2); if (rc) @@ -2373,12 +2383,11 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * goto out; } - c->u.ibpkey.low_pkey = pkey_lo; + c->u.ibpkey.low_pkey = pkey_lo; c->u.ibpkey.high_pkey = pkey_hi; rc = context_read_and_validate(&c->context[0], - p, - fp); + p, fp); if (rc) goto out; break; @@ -2391,7 +2400,8 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * goto out; len = le32_to_cpu(buf[0]); - rc = str_read(&c->u.ibendport.dev_name, GFP_KERNEL, fp, len); + rc = str_read(&c->u.ibendport.dev_name, + GFP_KERNEL, fp, len); if (rc) goto out; @@ -2404,8 +2414,7 @@ static int ocontext_read(struct policydb *p, const struct policydb_compat_info * c->u.ibendport.port = port; rc = context_read_and_validate(&c->context[0], - p, - fp); + p, fp); if (rc) goto out; break; @@ -2462,7 +2471,8 @@ int policydb_read(struct policydb *p, void *fp) policydb_str = kmalloc(len + 1, GFP_KERNEL); if (!policydb_str) { pr_err("SELinux: unable to allocate memory for policydb " - "string of length %d\n", len); + "string of length %d\n", + len); goto bad; } @@ -2477,7 +2487,8 @@ int policydb_read(struct policydb *p, void *fp) policydb_str[len] = '\0'; if (strcmp(policydb_str, POLICYDB_STRING)) { pr_err("SELinux: policydb string %s does not match " - "my string %s\n", policydb_str, POLICYDB_STRING); + "my string %s\n", + policydb_str, POLICYDB_STRING); kfree(policydb_str); goto bad; } @@ -2486,7 +2497,7 @@ int policydb_read(struct policydb *p, void *fp) policydb_str = NULL; /* Read the version and table sizes. */ - rc = next_entry(buf, fp, sizeof(u32)*4); + rc = next_entry(buf, fp, sizeof(u32) * 4); if (rc) goto bad; @@ -2496,7 +2507,8 @@ int policydb_read(struct policydb *p, void *fp) p->policyvers > POLICYDB_VERSION_MAX) { pr_err("SELinux: policydb version %d does not match " "my version range %d-%d\n", - le32_to_cpu(buf[0]), POLICYDB_VERSION_MIN, POLICYDB_VERSION_MAX); + le32_to_cpu(buf[0]), POLICYDB_VERSION_MIN, + POLICYDB_VERSION_MAX); goto bad; } @@ -2506,8 +2518,8 @@ int policydb_read(struct policydb *p, void *fp) rc = -EINVAL; if (p->policyvers < POLICYDB_VERSION_MLS) { pr_err("SELinux: security policydb version %d " - "(MLS) not backwards compatible\n", - p->policyvers); + "(MLS) not backwards compatible\n", + p->policyvers); goto bad; } } @@ -2530,22 +2542,23 @@ int policydb_read(struct policydb *p, void *fp) info = policydb_lookup_compat(p->policyvers); if (!info) { pr_err("SELinux: unable to find policy compat info " - "for version %d\n", p->policyvers); + "for version %d\n", + p->policyvers); goto bad; } rc = -EINVAL; if (le32_to_cpu(buf[2]) != info->sym_num || - le32_to_cpu(buf[3]) != info->ocon_num) { + le32_to_cpu(buf[3]) != info->ocon_num) { pr_err("SELinux: policydb table sizes (%d,%d) do " - "not match mine (%d,%d)\n", le32_to_cpu(buf[2]), - le32_to_cpu(buf[3]), - info->sym_num, info->ocon_num); + "not match mine (%d,%d)\n", + le32_to_cpu(buf[2]), le32_to_cpu(buf[3]), info->sym_num, + info->ocon_num); goto bad; } for (i = 0; i < info->sym_num; i++) { - rc = next_entry(buf, fp, sizeof(u32)*2); + rc = next_entry(buf, fp, sizeof(u32) * 2); if (rc) goto bad; nprim = le32_to_cpu(buf[0]); @@ -2606,7 +2619,7 @@ int policydb_read(struct policydb *p, void *fp) if (!rtd) goto bad; - rc = next_entry(buf, fp, sizeof(u32)*3); + rc = next_entry(buf, fp, sizeof(u32) * 3); if (rc) goto bad; @@ -2650,7 +2663,7 @@ int policydb_read(struct policydb *p, void *fp) lra->next = ra; else p->role_allow = ra; - rc = next_entry(buf, fp, sizeof(u32)*2); + rc = next_entry(buf, fp, sizeof(u32) * 2); if (rc) goto bad; @@ -2698,9 +2711,8 @@ int policydb_read(struct policydb *p, void *fp) goto bad; rc = -ENOMEM; - p->type_attr_map_array = kvcalloc(p->p_types.nprim, - sizeof(*p->type_attr_map_array), - GFP_KERNEL); + p->type_attr_map_array = kvcalloc( + p->p_types.nprim, sizeof(*p->type_attr_map_array), GFP_KERNEL); if (!p->type_attr_map_array) goto bad; @@ -2773,7 +2785,7 @@ static int mls_write_range_helper(struct mls_range *r, void *fp) items = 2; else items = 3; - buf[0] = cpu_to_le32(items-1); + buf[0] = cpu_to_le32(items - 1); buf[1] = cpu_to_le32(r->level[0].sens); if (!eq) buf[2] = cpu_to_le32(r->level[1].sens); @@ -2916,8 +2928,7 @@ static int role_allow_write(struct role_allow *r, void *fp) * Write a security context structure * to a policydb binary representation file. */ -static int context_write(struct policydb *p, struct context *c, - void *fp) +static int context_write(struct policydb *p, struct context *c, void *fp) { int rc; __le32 buf[3]; @@ -3045,7 +3056,7 @@ static int write_cons_helper(struct policydb *p, struct constraint_node *node, if (rc) return rc; if (p->policyvers >= - POLICYDB_VERSION_CONSTRAINT_NAMES) { + POLICYDB_VERSION_CONSTRAINT_NAMES) { rc = type_set_write(e->type_names, fp); if (rc) return rc; @@ -3266,7 +3277,8 @@ static int user_write(void *vkey, void *datum, void *ptr) return 0; } -static int (*const write_f[SYM_NUM]) (void *key, void *datum, void *datap) = { +/* clang-format off */ +static int (*const write_f[SYM_NUM])(void *key, void *datum, void *datap) = { common_write, class_write, role_write, @@ -3276,9 +3288,10 @@ static int (*const write_f[SYM_NUM]) (void *key, void *datum, void *datap) = { sens_write, cat_write, }; +/* clang-format on */ -static int ocontext_write(struct policydb *p, const struct policydb_compat_info *info, - void *fp) +static int ocontext_write(struct policydb *p, + const struct policydb_compat_info *info, void *fp) { unsigned int i, j; int rc; @@ -3360,9 +3373,13 @@ static int ocontext_write(struct policydb *p, const struct policydb_compat_info break; case OCON_NODE6: for (j = 0; j < 4; j++) - nodebuf[j] = c->u.node6.addr[j]; /* network order */ + nodebuf[j] = + c->u.node6.addr + [j]; /* network order */ for (j = 0; j < 4; j++) - nodebuf[j + 4] = c->u.node6.mask[j]; /* network order */ + nodebuf[j + 4] = + c->u.node6.mask + [j]; /* network order */ rc = put_entry(nodebuf, sizeof(u32), 8, fp); if (rc) return rc; @@ -3372,7 +3389,8 @@ static int ocontext_write(struct policydb *p, const struct policydb_compat_info break; case OCON_IBPKEY: /* subnet_prefix is in CPU order */ - prefixbuf[0] = cpu_to_be64(c->u.ibpkey.subnet_prefix); + prefixbuf[0] = + cpu_to_be64(c->u.ibpkey.subnet_prefix); rc = put_entry(prefixbuf, sizeof(u64), 1, fp); if (rc) @@ -3395,7 +3413,8 @@ static int ocontext_write(struct policydb *p, const struct policydb_compat_info rc = put_entry(buf, sizeof(u32), 2, fp); if (rc) return rc; - rc = put_entry(c->u.ibendport.dev_name, 1, len, fp); + rc = put_entry(c->u.ibendport.dev_name, 1, len, + fp); if (rc) return rc; rc = context_write(p, &c->context[0], fp); @@ -3521,7 +3540,8 @@ static int filename_write_helper_compat(void *key, void *data, void *ptr) u32 bit, len = strlen(ft->name); do { - ebitmap_for_each_positive_bit(&datum->stypes, node, bit) { + ebitmap_for_each_positive_bit(&datum->stypes, node, bit) + { buf[0] = cpu_to_le32(len); rc = put_entry(buf, sizeof(u32), 1, fp); if (rc) @@ -3645,8 +3665,8 @@ int policydb_write(struct policydb *p, void *fp) */ if (p->policyvers < POLICYDB_VERSION_AVTAB) { pr_err("SELinux: refusing to write policy version %d." - " Because it is less than version %d\n", p->policyvers, - POLICYDB_VERSION_AVTAB); + " Because it is less than version %d\n", + p->policyvers, POLICYDB_VERSION_AVTAB); return -EINVAL; } @@ -3674,7 +3694,8 @@ int policydb_write(struct policydb *p, void *fp) info = policydb_lookup_compat(p->policyvers); if (!info) { pr_err("SELinux: compatibility lookup failed for policy " - "version %d\n", p->policyvers); + "version %d\n", + p->policyvers); return -EINVAL; } From patchwork Thu Feb 22 23:52:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568384 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C173A13BAF0 for ; Thu, 22 Feb 2024 23:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646392; cv=none; b=Py3aYDHuj29MacP1pJSdsbynExuH0HoI5kkd26l3ybh1n0Y6teK+JAqHhw5M5XMUh1kRYH5aH/U5B2tppCWsFQD0Pna1eCEU6RbvhrV9hN/HFr0s+k/0bofsCiyvJC6h1vA3PW1hEsWwBeENetRyRKrh2kPRBnvGu3InySMMNQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646392; c=relaxed/simple; bh=iGDU1Ht0FP5uWWSc+uR7Qcw4WJO6mgRY36FZ/dsthvY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HtOrRBwtGr5mjetEFzigmjKL5GxxYLcCAMi911lwO7eYd9SX/xZqlHT9qYkOyAMevy+okrHyp0YH5VeYChjtmxLwCoCv6JwSyOyfOQix7Lq+aGdwrZ0EsrWeXFynBGfaPzLt35aiK/anbWs6/h6nrvFAsA6wNq2goLcB+LHvymA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=JCZEy+5w; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="JCZEy+5w" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7872bc61fcbso18415585a.2 for ; Thu, 22 Feb 2024 15:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646389; x=1709251189; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nN6Ex+YZH7SGWlFNwFSFqyDKLnJSvb0fy2hR0kNoheA=; b=JCZEy+5wqmoFNd6pvlEtbZcI8Fa1Apj4U7zfWSqHjhsdz9hA1NkqwPSlGg7NaO0dkB iC7KeyT6YCo3GXG4DJ6qz/UM+mUJlsx6ZImY3FO+MDj46qNqUxnBLYog00l2kR5ISloh bYxq22sT5rjJuwTkc98aVM/fauEcuAOjnAzFrGx14/mh2BpYv6f1bMYZbZBE+Ter2U+K fxePvqflIQWWnZZIz6Va7vHuWR5Qgs26QHzKBEIaWih6mE/fgCa0o9bupyx7lrdgd/Ja UXygRfH5QOXUVyigxM2p/oPDsg/jh7lPqkbUeGhd51wYgIgVwDPGqGJZUqowz9O6ZM5f J1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646389; x=1709251189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nN6Ex+YZH7SGWlFNwFSFqyDKLnJSvb0fy2hR0kNoheA=; b=BXhqhc57VU0qP5yb+6Ml9loH0u+NbVpC1q13JJCal4/W0JIA9MWAfj2a4xMM1/rcjQ 9LFK0bESo9mM85R93yfNsijb4GwiYuwWhOyI7KwFPQqFzUQGzFNnH6Xxd7ZC4X03XABV jEnxCkO1Mv7JWM0zhg16D/w04YpS6yF+AZ+H1DDrPevylAN6yRKdzUktl6qWgW0vhxa3 BusXGAvDZIvpMusgAFplJkPuU37QZOVOLMGvar8a3YGjIKRE4vKWiMqZQgnGQfdWDnhr DPAQ6lOdP2BTJDCl1psttGBDqJIWzkmq+7/n/cVLY0x3qnOc2dE8wpjgzzdy8OVqLRDi 0DyQ== X-Gm-Message-State: AOJu0YzFqpLqk+9Jqfsi7DosgEitQZAiR6Gu/cDqrAVbXROk1loy0+IT ML13ZMePG7BrNVObfbAu2ebBZ1FF+wUvzVbfXGKE/KSW4ogauSnhrW9YeC2paZovh5kKetRZLMc = X-Google-Smtp-Source: AGHT+IHua7vVlwzD6M1494xNpvfCwFfaxJM9Zn4c5BuRpxdofd1+RWX0QF4rDWpM30/vcZYtFxTpKw== X-Received: by 2002:a05:620a:b1a:b0:783:1683:548 with SMTP id t26-20020a05620a0b1a00b0078316830548mr599289qkg.64.1708646389461; Thu, 22 Feb 2024 15:59:49 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id os22-20020a05620a811600b007871bac855fsm5812575qkn.47.2024.02.22.15.59.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:49 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 17/21] selinux: fix style issues in security/selinux/ss/services.h Date: Thu, 22 Feb 2024 18:52:35 -0500 Message-ID: <20240222235708.386652-40-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1196; i=paul@paul-moore.com; h=from:subject; bh=iGDU1Ht0FP5uWWSc+uR7Qcw4WJO6mgRY36FZ/dsthvY=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19+8ZavHIPWBQQfBLQoYb/EV4oR5cLD6dz8a8 xmNcOv9LjKJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffvAAKCRDqIPLalzeJ c9ROD/4vDFej0+/mg8k3T5GCq28QnpAV2V0OliPfEwkOtxe4ref2rqTxkKJRQu8ieGra4H1bUTG /6ggMzxywPufHtQSWEOhnCcjI1KyAAtl4pUQ2lrmELixzyitoBX2cQ4oe/RtgYM3yJacF5luyTP pMVMIVeJJ1kLPvjtjpsIJnrXq2qPOAGruLL14W+4i4FFWeZmtFC+O2embueDOYH1vIpDbLqMdxc SFMBf3VnzHadqGZ+vNc1yx+TFTgtigzAnq3hLjr0IuQ/TcO9XhONzs+S6/gW1N3DZ/wgeD9XH/E ChtFUa9JYMs8or0ORvIAGRp3+JkEfDRXet9RbtohrwsuJf1s6G0u5lel40WGZzfTUzSpG5/2/MG Y7PjTe3woo5Zg9OkjgS6luwJdHaBLjFvtmwcUpZD5RbFnGxP2Uj5MLwO98UI4Ra65XkMod8d2/0 I+g583Fcpp0vxUDheMO8iLuAOmR5p47fgKKgX1qFCLyNsVSkno0fKux5cS+jzkCs/RJQ/qU7sCA inVB0B61SubjUafFmNIFXvWL+Gt8rJT0z400t4vEgnbovseCrQyjyl1+ONWDi865RJvWPWWnINd Io8NtIq9qPWsgQaVEKLUs5yMnIVsEbjE9OzndLThLMrLnQI3hsdebveLd3k5/WoLS8gWjZ0UELr ok+8ZPmuniBLORg== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/services.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/selinux/ss/services.h b/security/selinux/ss/services.h index d24b0a3d198e..93358e7a649c 100644 --- a/security/selinux/ss/services.h +++ b/security/selinux/ss/services.h @@ -4,6 +4,7 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_SERVICES_H_ #define _SS_SERVICES_H_ @@ -43,4 +44,4 @@ int services_convert_context(struct convert_context_args *args, struct context *oldc, struct context *newc, gfp_t gfp_flags); -#endif /* _SS_SERVICES_H_ */ +#endif /* _SS_SERVICES_H_ */ From patchwork Thu Feb 22 23:52:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568386 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A14091C6AB for ; Thu, 22 Feb 2024 23:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646393; cv=none; b=Kjd2AqwM6/n6YAj4YxGVFcPgU7OjEMF6qRnqCe8/qrHBURIqPK+QZlOOkWSSa1uRwogs9EH/VKL/tZXMLAyWXOBy1RfI0N9SMcm+YDCP5uwix8M019up0DLGpQZNHf8X3qwykEnp9QNoHIah7o5RP8bR08cjmwPfNlf657EuAac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646393; c=relaxed/simple; bh=cn4Uyvk024NxtibRVr4efWyEBEkB87HX0nGADdUIA7M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ntvccQs9oHsVaIxMHsNz5oR+rJ1IfmkzwF2Gm+pAzo7eIdJZvToBRgNDpUUSd+uDZxkN375PvlMlc3Jf9a5DEIBIPPCkShTAxlcmp8gZYXZ7M5eokPQQgyDQHUGtrRMihwFQun5H9EmQx8F2PXnqgnh0No5STqrMnB65zahpHPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=FFUdgJtS; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="FFUdgJtS" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-787ac650561so12669785a.3 for ; Thu, 22 Feb 2024 15:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646390; x=1709251190; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4YVKT6CKRc8KsJbHsMGUUZvIeZDdms8RgL4xO8gKMf8=; b=FFUdgJtSbxbGcU4hlpZo27xeJYBRur2SNNieF5Bstw5EWek7uN8TMCRiY/eh/gQYhl sM7soyraOYyjUsoZ40ElRdch5GP0TS+SgLCSO2w5ClrG8C71kTCK2KLoqy7KVrFLz/8d 0qoasPZ6t+2WxZC8sEk9v+VRFIUwi7B5TyIUjsrw7qubYKgoBvZA9LPUzi2yqMTtfMah wRUze0pc9kUOemdjQAM9Ja3z1BmX+1y8LkwqBUyxL03mel4/QOtzDtdYvX19lCvnHdf1 eMjVXyIehHX8vVdqBriL5ln6dg0RUggmz+L9or1VLoMtX01SuVRjb6j35RZIr/QzluPq 3JvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646390; x=1709251190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YVKT6CKRc8KsJbHsMGUUZvIeZDdms8RgL4xO8gKMf8=; b=ORLav+nu030Fiuk88XY374+cpUsdB2/VgisTpGMwGH8LlswJdp6WM6uREjehDATveG G6psSrY6Z58j7QTRKiGGvKL84xR+O0suLUtSmxHGLXY+7nrywxS13kgS+6LI/zU+rPIx /sAfAgltDI4QBupFFE0DSAfJKlxqYIMtJj3ZtmZX0PyQcnUKYVJflQLQQFkQ5ooe8sR1 Zmu8yu35ht++Eofs3YqgWeT5jccEjj9QoUFvnTtocXJes7FIyjvH71EvUvu9k9Vg+G2m ApTmB9zI3KALqA+VQu3PoJXk9J4PfX8LZeYyuELBKu6k62KgbMwF+cVOyQOuR/HPZ+zP XiiA== X-Gm-Message-State: AOJu0YzukzG0QdVkLX8YTjkfM+5wOA7cmM2HsQsB4ou+PPu/ACenkTR8 74muLrYBJO9vaOoiyMPIvK0p/TTMNOsbqy3eJySibaBwrtCYTEShui5E4RxS2P/xA34jO3ce5sk = X-Google-Smtp-Source: AGHT+IFK2BTDXrPduR555qz0Fl7SEa8NrnKKLEun9whw2jVz5DS92oH7DAW+mI6X6bMMCi6p5zt47g== X-Received: by 2002:a05:620a:1714:b0:787:1849:53b1 with SMTP id az20-20020a05620a171400b00787184953b1mr679247qkb.22.1708646390276; Thu, 22 Feb 2024 15:59:50 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id c20-20020a05620a135400b007877f9d9e11sm2564966qkl.119.2024.02.22.15.59.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:49 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 18/21] selinux: fix style issues in security/selinux/ss/sidtab.h Date: Thu, 22 Feb 2024 18:52:36 -0500 Message-ID: <20240222235708.386652-41-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4160; i=paul@paul-moore.com; h=from:subject; bh=cn4Uyvk024NxtibRVr4efWyEBEkB87HX0nGADdUIA7M=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19/DHMsBZ2CIKXcHip9sbmIocM7YbfEvAbqev sxdMQxLW2+JAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffwwAKCRDqIPLalzeJ c2esD/9qFIXv+y2lLRlPdYxuSV+4ukeKgvgrvxZYJzeaSeUdz1Duw+mV6qAnBjZFfz+lvlGcuBH DoO3pojHSqa5wbNLgYcN4uzkM9kTavNTCMk+/HRJ9lQzn8pAOnPfD86eXko/NWrfF2ucdeVoCXf +cJgnhhDGRXER+io2x/h1mrhW/yFGqia958OexNkzV55WMXoW+pddvvCOF3pGSoBM2aMo8K2Q90 ZPYsMdRRBp+sxMzt3u2qjUOD7hUKWRkiiEzf2gcBNb2/nACASu4zqNd0VbmplHtpQUh9AB3xq0N Ws9sddY5v1z1W+hhD+UJP5MmZt21useeccCqpRk/mAHhh9koF2mhQJ2bohFMqwJIo6bnR5CJNHY EB7CJ773rWIGuQztluhQoB02oAGWYhuXvuPmiQCy2o06E5ds6B4E/dhnmpKPaHxXFxvXoS53UYU esojxaAhfPexFQH8SPtlYkREa0AwcEYityFacmQ0dnaBtW5e0fv0hIQcPWB7m2JeIBUqzQhZWmV b19BwoRSZ0q8ZFKcCbypazQP1KMvrC/lg4+JyIzozDpQm2jSovE0UQuFyXvDYqCSeMtB2PiYOYa ag8OeQLbl0M9hMzOAzEmDAJTEbjfryJylATIwCdeiiB9HZ7O0ymaraL0u9gb5cif5b36CxGByww /vOq/zJgI+v8qEQ== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/sidtab.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/security/selinux/ss/sidtab.h b/security/selinux/ss/sidtab.h index 22258201cd14..832c85c70d83 100644 --- a/security/selinux/ss/sidtab.h +++ b/security/selinux/ss/sidtab.h @@ -8,6 +8,7 @@ * * Copyright (C) 2018 Red Hat, Inc. */ + #ifndef _SS_SIDTAB_H_ #define _SS_SIDTAB_H_ @@ -29,25 +30,26 @@ struct sidtab_entry { union sidtab_entry_inner { struct sidtab_node_inner *ptr_inner; - struct sidtab_node_leaf *ptr_leaf; + struct sidtab_node_leaf *ptr_leaf; }; /* align node size to page boundary */ #define SIDTAB_NODE_ALLOC_SHIFT PAGE_SHIFT -#define SIDTAB_NODE_ALLOC_SIZE PAGE_SIZE +#define SIDTAB_NODE_ALLOC_SIZE PAGE_SIZE -#define size_to_shift(size) ((size) == 1 ? 1 : (const_ilog2((size) - 1) + 1)) +#define size_to_shift(size) ((size) == 1 ? 1 : (const_ilog2((size)-1) + 1)) -#define SIDTAB_INNER_SHIFT \ - (SIDTAB_NODE_ALLOC_SHIFT - size_to_shift(sizeof(union sidtab_entry_inner))) +#define SIDTAB_INNER_SHIFT \ + (SIDTAB_NODE_ALLOC_SHIFT - \ + size_to_shift(sizeof(union sidtab_entry_inner))) #define SIDTAB_INNER_ENTRIES ((size_t)1 << SIDTAB_INNER_SHIFT) #define SIDTAB_LEAF_ENTRIES \ (SIDTAB_NODE_ALLOC_SIZE / sizeof(struct sidtab_entry)) #define SIDTAB_MAX_BITS 32 -#define SIDTAB_MAX U32_MAX +#define SIDTAB_MAX U32_MAX /* ensure enough tree levels for SIDTAB_MAX entries */ -#define SIDTAB_MAX_LEVEL \ +#define SIDTAB_MAX_LEVEL \ DIV_ROUND_UP(SIDTAB_MAX_BITS - size_to_shift(SIDTAB_LEAF_ENTRIES), \ SIDTAB_INNER_SHIFT) @@ -69,7 +71,7 @@ struct sidtab_convert_params { struct sidtab *target; }; -#define SIDTAB_HASH_BITS CONFIG_SECURITY_SELINUX_SIDTAB_HASH_BITS +#define SIDTAB_HASH_BITS CONFIG_SECURITY_SELINUX_SIDTAB_HASH_BITS #define SIDTAB_HASH_BUCKETS (1 << SIDTAB_HASH_BITS) struct sidtab { @@ -125,8 +127,10 @@ int sidtab_convert(struct sidtab *s, struct sidtab_convert_params *params); void sidtab_cancel_convert(struct sidtab *s); -void sidtab_freeze_begin(struct sidtab *s, unsigned long *flags) __acquires(&s->lock); -void sidtab_freeze_end(struct sidtab *s, unsigned long *flags) __releases(&s->lock); +void sidtab_freeze_begin(struct sidtab *s, unsigned long *flags) + __acquires(&s->lock); +void sidtab_freeze_end(struct sidtab *s, unsigned long *flags) + __releases(&s->lock); int sidtab_context_to_sid(struct sidtab *s, struct context *context, u32 *sid); @@ -137,8 +141,8 @@ int sidtab_hash_stats(struct sidtab *sidtab, char *page); #if CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE > 0 void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry, const char *str, u32 str_len); -int sidtab_sid2str_get(struct sidtab *s, struct sidtab_entry *entry, - char **out, u32 *out_len); +int sidtab_sid2str_get(struct sidtab *s, struct sidtab_entry *entry, char **out, + u32 *out_len); #else static inline void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry, @@ -146,13 +150,11 @@ static inline void sidtab_sid2str_put(struct sidtab *s, { } static inline int sidtab_sid2str_get(struct sidtab *s, - struct sidtab_entry *entry, - char **out, u32 *out_len) + struct sidtab_entry *entry, char **out, + u32 *out_len) { return -ENOENT; } #endif /* CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE > 0 */ -#endif /* _SS_SIDTAB_H_ */ - - +#endif /* _SS_SIDTAB_H_ */ From patchwork Thu Feb 22 23:52:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568387 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 787D414038D for ; Thu, 22 Feb 2024 23:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646394; cv=none; b=JMSj02UDmjaGM2OyZ3ESKHbMUwdhfeObzvhRA67XXVe4iFP2B6Pkbu4vflyMhjFzU6PuDNmBxzhGNf5cv9KdOD5nETjPbpFq9lKGxkiws0TYI1JVmwhjV5wr9SgKX2R6sYDKmXFYYWcavaE6MGsYTe1BJO8SejbGM1MMyXnFlsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646394; c=relaxed/simple; bh=lJrcmSgC9EMiYe6KkWcngkQRPlbEw0GsWbu7yhus6zQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LEaOrm938n44xxyJ62yCti4yWo2b5IaBxWX8+M5rTARUasEP4EsAHjvFTNYJbCMJB+Kl0v5XhlUePM0e74zKeeZLJFOVS9584AKRUXGIvPvLY9q8ZLbtHL/Jxnds0qICkXQU+Bf5tExN7A37zq5qySMrRkWZ6jjtphdSCUiq884= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=bY/GBC6K; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="bY/GBC6K" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-787aca0b502so8851885a.1 for ; Thu, 22 Feb 2024 15:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646391; x=1709251191; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FPZNPM6ysqdZgtKCmKQMcjHP4qPa7n6/sOYp15wjxLU=; b=bY/GBC6KzDkqswFPxGjnsCbpFTzV0DXeBhOwKLEh8vWdeuga/G2kCk9PU73qzbhc0N jcoi9HPRGkj5SitwnHH7rOZaI6LrWq52mQ+hjvOEVu12EU0rUUkJrdjfgSHZpeXjBGKP 4yjhQTnZjGGiKNgJqkzOUweMg1EzphM9i7nk45jd1yGUaDBQlXvJrskGxAEmeD3Ru8zu Ps2PKwcSDR6LbdvOnRoblqJ32IIKqqO+EU2ihHx87xPJbWeiuCPC/K0CAxImNoWgKZ4w 4/fKVa9fByimoATxa0MPd1VzCObuH3CXZdUi6BxOrAIzFRCO+UsnXNSpxy2I4RRlR2Cj U/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646391; x=1709251191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FPZNPM6ysqdZgtKCmKQMcjHP4qPa7n6/sOYp15wjxLU=; b=VgwlfYtNdA/UzXrIdEC3nfXbP/1TLW1t3turY1KmM/adlmkALTYu8ITJB+amJaAiB5 5XP1xiHMCzhiAF4ETLftuAZmXR/trhX/V2msKRps5kw2toSY2GZkJRrd9HJA+S/MdAOr 03CotsGzu0bUteFzIGjZZNWtG7UnYY2VHW3rxLtb33q2jQXPAOkbF18lyMdNFwGOoSsp 5h2d9OVSTXq8Nn4DBTxK4hh9/UyHtcA80txtF20MVjQ08T4W7yUbzovpSMoWsQvTdR9z j3CTUs88HgNVDManr31YGas66dgvTvM2J7bIiidfbl8JQOszjZH89uwgacjr0ZuRjQoa R6ug== X-Gm-Message-State: AOJu0Ywc36ONZ+wg5F+Z62Iq+Y0HQEGSUWRqMD4UpkQV87C1ePdzppe5 MIT67ThnddiJjRxKDqTWBdl2uOEHKPKvBvU71d1z79XJhd2EcZDtVqbrjSBZE2xNWLBzuBTsg1I = X-Google-Smtp-Source: AGHT+IHrlk4Lgb4qPCTM4CEIKu1dcZqouGmEg85VDnTA57itidnBosAQ93eJJK2ugWr/tQFSiKyWqQ== X-Received: by 2002:a05:620a:2046:b0:787:28cb:5ab8 with SMTP id d6-20020a05620a204600b0078728cb5ab8mr598789qka.41.1708646391156; Thu, 22 Feb 2024 15:59:51 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id l8-20020ae9f008000000b007877add9363sm2814499qkg.103.2024.02.22.15.59.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:50 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 19/21] selinux: fix style issues in security/selinux/ss/sidtab.c Date: Thu, 22 Feb 2024 18:52:37 -0500 Message-ID: <20240222235708.386652-42-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6822; i=paul@paul-moore.com; h=from:subject; bh=lJrcmSgC9EMiYe6KkWcngkQRPlbEw0GsWbu7yhus6zQ=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19/KeeqUZkzfB6/cs3qSJga0M3f4J80MRtvu/ UWGt88v9gyJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdffygAKCRDqIPLalzeJ c+wGD/4x7w0yHIbc/XOCm+EC9wFg+kvhCFYsynNX7Kj8n2nncFMGgOgfDRQvlxCSNKdEf2Ml1+s R4/wqMkKqquzol1T1SXFlUMmylixQkeT6YOUT2RXsbdOz/w5ZbOtBaSzfy2OmrljKETDE043xMc GTg5FCPF5QG6/mgljNKQXZqF+SmsEkXR8mbE8IiFXJHLgW01QMDF1kRK3LVRZDMY6Y7BUB4sUCi zBg4Zh8/2g8i/9E0iMMqDI91n2nhrOiw8iMEyCjsTqI2F7GUdgYGshV5PDA3zerV3EFBW+9WBg7 DJ+uijCBn7NrhNv001YYH7LKuVabMm/ynq9AU4knqluCtsFWeNepClSgUkpnAVjcJ+pCBt99nSj t5n1cjLF4qgrK3WDQitfIxdyLHFHLpJeYNKPCBnoeQsFHQQa/FSdGpbzYnfP0czFZTTpkoGdXO7 V0G1u3ofHLY4OWIwGvS5z41kGWGP2TzB5e8SdpYEWg9w8190n5T3Hg0mOtl8ngMw+1LzX2xjFtl N37HeCoPilsjcU3ivTGZsvfvCdwI3boJn8nsHZ9am3wJPtN/W+/Ft0C9sIw+8JkaJBAsG8g94uT ZY31UKGS1W9bI6qmF23cNrlLqfn28/bSsE+Xi+1EQ0PmwtI5JW9MVGC66TfKhg+SS0uyQNVNYxx 2qUg/hS/ZJrh0Pw== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/sidtab.c | 69 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index 732fd8e22a12..c8848cbba81f 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -7,6 +7,7 @@ * * Copyright (C) 2018 Red Hat, Inc. */ + #include #include #include @@ -29,7 +30,7 @@ struct sidtab_str_cache { }; #define index_to_sid(index) ((index) + SECINITSID_NUM + 1) -#define sid_to_index(sid) ((sid) - (SECINITSID_NUM + 1)) +#define sid_to_index(sid) ((sid) - (SECINITSID_NUM + 1)) int sidtab_init(struct sidtab *s) { @@ -140,9 +141,11 @@ int sidtab_hash_stats(struct sidtab *sidtab, char *page) if (chain_len > max_chain_len) max_chain_len = chain_len; - return scnprintf(page, PAGE_SIZE, "entries: %d\nbuckets used: %d/%d\n" - "longest chain: %d\n", entries, - slots_used, SIDTAB_HASH_BUCKETS, max_chain_len); + return scnprintf(page, PAGE_SIZE, + "entries: %d\nbuckets used: %d/%d\n" + "longest chain: %d\n", + entries, slots_used, SIDTAB_HASH_BUCKETS, + max_chain_len); } static u32 sidtab_level_from_count(u32 count) @@ -162,15 +165,15 @@ static int sidtab_alloc_roots(struct sidtab *s, u32 level) u32 l; if (!s->roots[0].ptr_leaf) { - s->roots[0].ptr_leaf = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_ATOMIC); + s->roots[0].ptr_leaf = + kzalloc(SIDTAB_NODE_ALLOC_SIZE, GFP_ATOMIC); if (!s->roots[0].ptr_leaf) return -ENOMEM; } for (l = 1; l <= level; ++l) if (!s->roots[l].ptr_inner) { - s->roots[l].ptr_inner = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_ATOMIC); + s->roots[l].ptr_inner = + kzalloc(SIDTAB_NODE_ALLOC_SIZE, GFP_ATOMIC); if (!s->roots[l].ptr_inner) return -ENOMEM; s->roots[l].ptr_inner->entries[0] = s->roots[l - 1]; @@ -203,16 +206,16 @@ static struct sidtab_entry *sidtab_do_lookup(struct sidtab *s, u32 index, if (!entry->ptr_inner) { if (alloc) - entry->ptr_inner = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_ATOMIC); + entry->ptr_inner = kzalloc( + SIDTAB_NODE_ALLOC_SIZE, GFP_ATOMIC); if (!entry->ptr_inner) return NULL; } } if (!entry->ptr_leaf) { if (alloc) - entry->ptr_leaf = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_ATOMIC); + entry->ptr_leaf = + kzalloc(SIDTAB_NODE_ALLOC_SIZE, GFP_ATOMIC); if (!entry->ptr_leaf) return NULL; } @@ -262,8 +265,7 @@ struct sidtab_entry *sidtab_search_entry_force(struct sidtab *s, u32 sid) return sidtab_search_core(s, sid, 1); } -int sidtab_context_to_sid(struct sidtab *s, struct context *context, - u32 *sid) +int sidtab_context_to_sid(struct sidtab *s, struct context *context, u32 *sid) { unsigned long flags; u32 count, hash = context_compute_hash(context); @@ -327,8 +329,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context, goto out_unlock; } - rc = services_convert_context(convert->args, - context, &dst_convert->context, + rc = services_convert_context(convert->args, context, + &dst_convert->context, GFP_ATOMIC); if (rc) { context_destroy(&dst->context); @@ -338,8 +340,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context, dst_convert->hash = context_compute_hash(&dst_convert->context); target->count = count + 1; - hash_add_rcu(target->context_to_sid, - &dst_convert->list, dst_convert->hash); + hash_add_rcu(target->context_to_sid, &dst_convert->list, + dst_convert->hash); } if (context->len) @@ -373,8 +375,8 @@ static void sidtab_convert_hashtable(struct sidtab *s, u32 count) } static int sidtab_convert_tree(union sidtab_entry_inner *edst, - union sidtab_entry_inner *esrc, - u32 *pos, u32 count, u32 level, + union sidtab_entry_inner *esrc, u32 *pos, + u32 count, u32 level, struct sidtab_convert_params *convert) { int rc; @@ -382,8 +384,8 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst, if (level != 0) { if (!edst->ptr_inner) { - edst->ptr_inner = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_KERNEL); + edst->ptr_inner = + kzalloc(SIDTAB_NODE_ALLOC_SIZE, GFP_KERNEL); if (!edst->ptr_inner) return -ENOMEM; } @@ -399,17 +401,18 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst, } } else { if (!edst->ptr_leaf) { - edst->ptr_leaf = kzalloc(SIDTAB_NODE_ALLOC_SIZE, - GFP_KERNEL); + edst->ptr_leaf = + kzalloc(SIDTAB_NODE_ALLOC_SIZE, GFP_KERNEL); if (!edst->ptr_leaf) return -ENOMEM; } i = 0; while (i < SIDTAB_LEAF_ENTRIES && *pos < count) { - rc = services_convert_context(convert->args, - &esrc->ptr_leaf->entries[i].context, - &edst->ptr_leaf->entries[i].context, - GFP_KERNEL); + rc = services_convert_context( + convert->args, + &esrc->ptr_leaf->entries[i].context, + &edst->ptr_leaf->entries[i].context, + GFP_KERNEL); if (rc) return rc; (*pos)++; @@ -489,13 +492,15 @@ void sidtab_cancel_convert(struct sidtab *s) spin_unlock_irqrestore(&s->lock, flags); } -void sidtab_freeze_begin(struct sidtab *s, unsigned long *flags) __acquires(&s->lock) +void sidtab_freeze_begin(struct sidtab *s, unsigned long *flags) + __acquires(&s->lock) { spin_lock_irqsave(&s->lock, *flags); s->frozen = true; s->convert = NULL; } -void sidtab_freeze_end(struct sidtab *s, unsigned long *flags) __releases(&s->lock) +void sidtab_freeze_end(struct sidtab *s, unsigned long *flags) + __releases(&s->lock) { spin_unlock_irqrestore(&s->lock, *flags); } @@ -600,8 +605,8 @@ void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry, kfree_rcu(victim, rcu_member); } -int sidtab_sid2str_get(struct sidtab *s, struct sidtab_entry *entry, - char **out, u32 *out_len) +int sidtab_sid2str_get(struct sidtab *s, struct sidtab_entry *entry, char **out, + u32 *out_len) { struct sidtab_str_cache *cache; int rc = 0; From patchwork Thu Feb 22 23:52:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568388 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CF0413BAF8 for ; Thu, 22 Feb 2024 23:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646395; cv=none; b=VAES+7SyUFtLxmjWa+AGWeXUCQwaNtXeJLN0nZZ9JXN1iJ5+TQrKIrcc84i3s8I4oIgDIfJiaG9cTGngW+x3fwhohPkvmmMm1x0661ZEIR4er/6UvEbRfXOaK3xtERS41Xc67mzJn/bScVqj2IM/9JLcLOTAouGSp22ZFC1cWec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646395; c=relaxed/simple; bh=sItb/ePRu45VJMGJcNCchsgSQkrwNAcUqNWJZaT9f9w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=staxu3DDHxaCiFdaPOduxsqYdwArgm2CJ0irLIZrauprVxQVY4p/0FEuOTpZXkoiUK1Xk7NvSC0KllGXsnrbKq7iFA7p3XnjxrxtnzL8jm9cyyRd/nlHG3sEBhxKVClrSLyIwUNDDfxxA+nkV7kU9KQVnH5/UDHSLH6YIKnnyZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=SW6nNLGR; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="SW6nNLGR" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-68fcb96fbc9so2014716d6.2 for ; Thu, 22 Feb 2024 15:59:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646392; x=1709251192; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QDT4N0sZ6Pfgwi8jZAiZ8Ln93adVZzC/jA4W4IZORlo=; b=SW6nNLGRra+5nfCBIm9EajvCg8D28H22CPzhaIGVw3+J6qz3Ax3yggVgI0fub8q9wh iNJLXq5E8xcPW8E8IsDFoyTxidTvXtCi8phoyKA5+tKlq0r+lEQ6SmUwdoNvKRhlPOsZ NsslJKn5IJ3NwaBuqdz75wktPmobsSbYbWXpgI26foSzsv+mMwZjEX5OS3kkYexWOxxY i44r85UGzuc7F57MGPxw4Ndkou+l0Q0kaG7REswYkG/SIMPHgJo3Hgc9J05hZPmXq4HB aaf+q7IgvS+V8cr6btObiJgvCfRzkiQSAfwBfWDhnprOlDWvC5u1W3PdnL3zM+8IJDEa m7HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646392; x=1709251192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QDT4N0sZ6Pfgwi8jZAiZ8Ln93adVZzC/jA4W4IZORlo=; b=nmWup2oZ85qk8i0ftLYzvQm4H3wOEjoCSeV8qIsjLMcU7OV5zk1sKbSz8Oga7ZR4WP C56FdWiS08tgyKUx/BYrffinUEpfyOfUl7UdRz4An17NGVd8EyCu7uGlJTEQkKdT4VAE qHTEQv0K38QxERTvRDAkH1KGVntGGOevkPsHUmDiW5N53+QDYMs0x5/jusVJYXWXr9Yi P87/TspbgICUhDb3FwkXe5W5rx9M0O8b0+5AGtFP89PtWjGOjq6y9uMEvGfvI1gedTi7 vgPXxVfztKn+rskukC3l+tH7ZC/kpH4h/p9b4qFVnam0A37FEgbHgRtgjSmn7nCueKVX 8z9A== X-Gm-Message-State: AOJu0Yzq4FFv/76yP0YfWqfoFa1U/NVYQOymZ/DknliL6hvU3iGliMAs khDxzhIrNV+zPDkMIhbKTGgMPRiTo5M/TkA3nyxRsKu8SQeXa+syClifEjqMqh9CNrQqYnzrEBU = X-Google-Smtp-Source: AGHT+IFggUeauGLz8sFZ4HcTQLz3T0nbgf9WrEAEA6zmQWZB7+d57QPXdU5JrrM0qEKuB502Ca50lA== X-Received: by 2002:a05:6214:5005:b0:68f:6f85:b1d5 with SMTP id jo5-20020a056214500500b0068f6f85b1d5mr942900qvb.9.1708646392084; Thu, 22 Feb 2024 15:59:52 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ma7-20020a0562145b0700b0068f73372424sm5197887qvb.90.2024.02.22.15.59.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:51 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 20/21] selinux: fix style issues in security/selinux/ss/symtab.h Date: Thu, 22 Feb 2024 18:52:38 -0500 Message-ID: <20240222235708.386652-43-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1545; i=paul@paul-moore.com; h=from:subject; bh=sItb/ePRu45VJMGJcNCchsgSQkrwNAcUqNWJZaT9f9w=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19/QEPjNBn1WeGliPgYDrrrzXecIxxYx4Zjlg f/xrt7JieqJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdff0AAKCRDqIPLalzeJ cwvlD/0dhoPIdzI5os57Sh3VlkGQMkrwQDFhOawbihFAuhezapBL7NUNrfr1pVDQ4PCksRPvwLY 8D9y13LILmou2WdHINpJsiFaqV7xlvep8nIWH/xDFMx19mpN9kh+vi7M3TQUecjI3oBVYJKK0Kn gOWRo6STXEoMGV7HkYuBCpjYP9KbpJA1CahiFDC9fVEzIh+zWGFOkH7a9fXgwLLrHe+M6GVxN/e DBf0S/f/2bLJu98IoABtjJ85YKf0hY16Ic43MFxhrrT/kxM3HfHWP+oNrUrY2/bemlCpIEGJ4Ni s2+PuXOwy+Yhc0N4Eb/USUZJ0k0zQ2dxfUxsXpDD7PB/2cxW/X4N/iYNR7LyqHpDtCz6cLWgRrl MAtZKHoH9oR8/yt+vd/6vSyLiF9INWlM1RkM8sHjWcKU/APx1c7RROqfCl2fUBDX9kuOiav4JXS NB9xaKOAz1h9eLclwDWR+LlfLXFUtL+ti6OPJoLe6bMxLpWC4NA6gow3/HeDzE9+GrpC8fX7rAM uErT1XO0/DGXleVUywv35Frx9a3DgLbWQy6haog/3X832sTLodEjh8TFG6Hj/JTy+jII4Rql6BM Y/jcGiZEtf3pka/4ynlJLsa9hOkYNfOGY2MtXwdkOMPU0llx4GvQVn2hmeQTWuaglBEJLJlEA4B 25ml2eHdu0HhY+Q== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/symtab.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/security/selinux/ss/symtab.h b/security/selinux/ss/symtab.h index 0a3b5de79a0f..8e667cdbf38f 100644 --- a/security/selinux/ss/symtab.h +++ b/security/selinux/ss/symtab.h @@ -7,14 +7,15 @@ * * Author : Stephen Smalley, */ + #ifndef _SS_SYMTAB_H_ #define _SS_SYMTAB_H_ #include "hashtab.h" struct symtab { - struct hashtab table; /* hash table (keyed on a string) */ - u32 nprim; /* number of primary names in table */ + struct hashtab table; /* hash table (keyed on a string) */ + u32 nprim; /* number of primary names in table */ }; int symtab_init(struct symtab *s, u32 size); @@ -22,6 +23,4 @@ int symtab_init(struct symtab *s, u32 size); int symtab_insert(struct symtab *s, char *name, void *datum); void *symtab_search(struct symtab *s, const char *name); -#endif /* _SS_SYMTAB_H_ */ - - +#endif /* _SS_SYMTAB_H_ */ From patchwork Thu Feb 22 23:52:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 13568389 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59684140391 for ; Thu, 22 Feb 2024 23:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646395; cv=none; b=H4+i990lQwN/kejJek39JAsF5HuGmPetBF6VfXKVfJDVK9y4FpK3Xu23qcu6nBSkOn3FuKADZyA7ijJjH62tGVcMUY8XS52oL7guLssJnOkPHHJyk1RPGbbm0CwhWttLsKUlcZA4IMC/dYHOhACBvwP5cnGsogcWmHyGZH4YrAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708646395; c=relaxed/simple; bh=LpzIB/M5kt0pFeg/y3NZb7iFfRhgd2jWTZ82m5ZCYvg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfwsOBVXH8RpGHKJU9GUBP0kWIu928nYhKBC5CcQMuhiRjKRfWfaX1BQCnTQyKDH/RNuw1gBq0HIAZEEpuCVz8d2aopogH0/30yDxRWZKaKTq4CzJydBm3vqSJeLvXbe09M6dyKnTCJzWC7y3HC50C9mMrYMq3eD8gI8RSRuLCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=aLTAXoQ6; arc=none smtp.client-ip=209.85.219.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="aLTAXoQ6" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-68facd7ea4aso3688556d6.0 for ; Thu, 22 Feb 2024 15:59:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708646393; x=1709251193; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=A+zoxJPBMxVwgusi5+ZOktMYTJ2nyVr2QNu59xKV8ow=; b=aLTAXoQ6lSjx4UzbYALLwJ2HGnmXtXkDycfNgX9fOp1OEfFZY+8cZmPQ75A+7JaQjP BkkjJ/sH5RNFxxHAV7KvB5n/romc4BurV4SJktMkjvYKaCsCvtzRIz25tcmbhFST6QRk SYqrP0jZxaTqmg7edpz9DpZJhbNd7JM8wd1A38mLj+TzCT1HtVp4n+G+93YJQlFZFUE5 3b5pcix8iEREUFgtlsvc4g70FYGGJXxGttRpt83USS/AbdNaLpu5VRtIYbwqddIy3kq4 1cuN5ZIqmxC4i7Wym0dZXECQiaFAlBNA90Nuy36U4Qq14t9nREosuiYgL25qfU+fnLF0 asxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708646393; x=1709251193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A+zoxJPBMxVwgusi5+ZOktMYTJ2nyVr2QNu59xKV8ow=; b=RiISoP1+a86nhAvGBn3h4mWg2/9YN2wFYU8B1jf9fgpSnURoQDaFHQKS5TjqkCw0vp kHUer0psJq9l6j1l6bkTwWUJqSeL3QC3I9tfSQwW+Cnqgn6Dyp+5sjk/8fPChHSfPZlb h9dzjP3BMyCjeBz+wSpcbz5GNFcelDfTQfJkz7rG04vETEvCAF3553vEjWa2J93zVPS5 0ct44P+1cKV29UsSIvWiaynhMaBxCdDlXlePbjJ0FB7Q0MmhH33EFtcb04OWTF2rKzqO eI4D8TrLvbNMhOvmpW/apNHqdYlAbV7VAoxo8vwjo/yww5sxX98LtRQilyt3GETSsd0S 1erw== X-Gm-Message-State: AOJu0YxiSKPtp/UfnEQ5P7BfMphOQiNLUm/HMVULWL2xaXXsYbtHcbEO jjT4aF+Vp67Cua/Oc1KIvY4tK3i4daalTZ1GsIZI7oUDF2mGipb1rrFLI5ZfRgGYM3a3Dm0en2o = X-Google-Smtp-Source: AGHT+IE/R4HKaLpAzBzbx/wea8NrYnUJNwMYJNwqq3blCCTt32rv9+jsGJ2+WtvEQzz2CAOt3yD3BQ== X-Received: by 2002:a05:6214:d82:b0:68f:42b8:5fb2 with SMTP id e2-20020a0562140d8200b0068f42b85fb2mr971433qve.21.1708646393031; Thu, 22 Feb 2024 15:59:53 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id og15-20020a056214428f00b0068f8a21a065sm4293178qvb.13.2024.02.22.15.59.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:59:52 -0800 (PST) From: Paul Moore To: selinux@vger.kernel.org Subject: [PATCH 21/21] selinux: fix style issues in security/selinux/ss/symtab.c Date: Thu, 22 Feb 2024 18:52:39 -0500 Message-ID: <20240222235708.386652-44-paul@paul-moore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240222235708.386652-23-paul@paul-moore.com> References: <20240222235708.386652-23-paul@paul-moore.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1300; i=paul@paul-moore.com; h=from:subject; bh=LpzIB/M5kt0pFeg/y3NZb7iFfRhgd2jWTZ82m5ZCYvg=; b=owEBbQKS/ZANAwAIAeog8tqXN4lzAcsmYgBl19/WCIAStW31SqmgSzhfahX+JWMqZ1EJSEH5f 0DhaW54SpaJAjMEAAEIAB0WIQRLQqjPB/KZ1VSXfu/qIPLalzeJcwUCZdff1gAKCRDqIPLalzeJ cyW2D/9Mtj0ETvxeu5nCtZ3JI+e8uRvPpQBEK0rnRH7pt9ORbWHxTSjkF3nhTU7m9Lk47il7iyu +4M7Jnig8iDairG7EC93sQYUZYGeHZZbWjkTR9TwKUtTQqnaxe0UWlctCKr07Vvez2A3S9l7vKV kjvjEUTfHflzUnjCyPLxddYHFmN71nZsNzNateabvgVynW29rMmccLuWgseRd6Z1nCgW22sK/E7 f7gef/BSVksE7Qpy/yVkrSX7zEO7z8s1VMIhc2c3AtPqaEMURJNL20BCuAQbQqpZysQPRangLrj dCI29/+dKRQBo/HuTZa4507B7mj+u73/8tWR7J1B/d8MZPIcMpChNKUPz5X2f9Vpb3muTSjbduW q/65q5S89mUmStiFewArDpK3lrU5uVUC8XlXWDFZvyGEnQhLUl/S8nxcNCun/B2XgpelxffJPlD obI49rwRN9hP93Fn7q5VXw43AVyp+9GVBtftff5hip7r2RGpHTqkkQCYKOVxYrzoUdddsFcrJia hXax/fnVw+evFs05GIuKx014QjYuhbLAAeHtGdaEzFYdwNcw8bsruYObnc2cV36RL9MC9hlQI5C QlbxfrQAhAyVsfBvz8FdkrAlLKfJ6LvsiZBHP1J6ltnT5VvVWP6hK0KjrUaGxF5JlcDx2Ilx+zA IR4s/qNE38aJ+rA== X-Developer-Key: i=paul@paul-moore.com; a=openpgp; fpr=7100AADFAE6E6E940D2E0AD655E45A5AE8CA7C8A As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore --- security/selinux/ss/symtab.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security/selinux/ss/symtab.c b/security/selinux/ss/symtab.c index 43d7f0319ccd..c04f8d447873 100644 --- a/security/selinux/ss/symtab.c +++ b/security/selinux/ss/symtab.c @@ -4,6 +4,7 @@ * * Author : Stephen Smalley, */ + #include #include #include @@ -19,7 +20,8 @@ static unsigned int symhash(const void *key) keyp = key; size = strlen(keyp); for (p = keyp; (p - keyp) < size; p++) - val = (val << 4 | (val >> (8*sizeof(unsigned int)-4))) ^ (*p); + val = (val << 4 | (val >> (8 * sizeof(unsigned int) - 4))) ^ + (*p); return val; }