From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Cc: Paul Moore <paul@paul-moore.com>,
Stephen Smalley <stephen.smalley.work@gmail.com>,
Eric Paris <eparis@parisplace.org>,
Ondrej Mosnacek <omosnace@redhat.com>,
"GONG, Ruiqi" <gongruiqi1@huawei.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/7] selinux: update type for number of class permissions in services code
Date: Mon, 7 Aug 2023 19:11:37 +0200 [thread overview]
Message-ID: <20230807171143.208481-2-cgzones@googlemail.com> (raw)
In-Reply-To: <20230807171143.208481-1-cgzones@googlemail.com>
Security classes have only up to 32 permissions, hence using an u16 is
sufficient (while improving padding in struct selinux_mapping).
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v3:
- drop type change of arithmetic variable; it might effect performance
as suggested by David.
- split bogus and corrected cast into separate patch
v2:
update commit description:
- mention struct selinux_mapping in the padding argument
(currently between the first and second member there are 2 bytes
padding)
- mention overflow in the cast argument and the result of setting
no bits due to it
---
security/selinux/ss/services.c | 2 +-
security/selinux/ss/services.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 3ec0bb39c234..dacec2ebdcd7 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -97,7 +97,6 @@ static int selinux_set_mapping(struct policydb *pol,
struct selinux_map *out_map)
{
u16 i, j;
- unsigned k;
bool print_unknown_handle = false;
/* Find number of classes in the input mapping */
@@ -117,6 +116,7 @@ static int selinux_set_mapping(struct policydb *pol,
while (map[j].name) {
const struct security_class_mapping *p_in = map + (j++);
struct selinux_mapping *p_out = out_map->mapping + j;
+ u16 k;
/* An empty class string skips ahead */
if (!strcmp(p_in->name, "")) {
diff --git a/security/selinux/ss/services.h b/security/selinux/ss/services.h
index ed2ee6600467..d24b0a3d198e 100644
--- a/security/selinux/ss/services.h
+++ b/security/selinux/ss/services.h
@@ -12,7 +12,7 @@
/* Mapping for a single class */
struct selinux_mapping {
u16 value; /* policy value for class */
- unsigned int num_perms; /* number of permissions in class */
+ u16 num_perms; /* number of permissions in class */
u32 perms[sizeof(u32) * 8]; /* policy values for permissions */
};
--
2.40.1
next prev parent reply other threads:[~2023-08-07 17:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 17:11 [PATCH v3 2/7] selinux: use u32 as bit type in ebitmap code Christian Göttsche
2023-08-07 17:11 ` Christian Göttsche [this message]
2023-08-09 23:07 ` [PATCH v3 3/7] selinux: update type for number of class permissions in services code Paul Moore
2023-08-07 17:11 ` [PATCH v3 4/7] selinux: make left shifts well defined Christian Göttsche
2023-08-09 23:07 ` Paul Moore
2023-08-07 17:11 ` [PATCH v3 5/7] selinux: avoid implicit conversions in selinuxfs code Christian Göttsche
2023-08-09 23:07 ` Paul Moore
2023-08-07 17:11 ` [PATCH v3 6/7] selinux: avoid implicit conversions in policydb code Christian Göttsche
2023-08-09 23:07 ` Paul Moore
2023-08-07 17:11 ` [PATCH v3 7/7] selinux: use unsigned iterator in nlmsgtab code Christian Göttsche
2023-08-09 23:07 ` Paul Moore
2023-08-07 17:11 ` [PATCH v3 1/7] selinux: avoid implicit conversions in avtab code Christian Göttsche
2023-08-09 23:07 ` Paul Moore
2023-08-09 23:07 ` [PATCH v3 2/7] selinux: use u32 as bit type in ebitmap code Paul Moore
2023-08-16 15:00 ` Christian Göttsche
2023-08-18 13:55 ` Christian Göttsche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230807171143.208481-2-cgzones@googlemail.com \
--to=cgzones@googlemail.com \
--cc=eparis@parisplace.org \
--cc=gongruiqi1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome