Re: [PATCH RFC 11/20] selinux: avc: avoid implicit conversions

From: Paul Moore
Date: Tue Jul 18 2023 - 18:02:05 EST


On Jul 6, 2023 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@xxxxxxxxxxxxxx> wrote:
>
> Use a consistent type of u32 for sequence numbers.
>
> Use a non-negative and input parameter matching type for the hash
> result.
>
> Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
> ---
> security/selinux/avc.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)

...

> diff --git a/security/selinux/avc.c b/security/selinux/avc.c
> index 1074db66e5ff..cd55479cce25 100644
> --- a/security/selinux/avc.c
> +++ b/security/selinux/avc.c
> @@ -654,9 +654,9 @@ static void avc_audit_pre_callback(struct audit_buffer *ab, void *a)
> {
> struct common_audit_data *ad = a;
> struct selinux_audit_data *sad = ad->selinux_audit_data;
> - u32 av = sad->audited;
> + u32 av = sad->audited, perm;
> const char *const *perms;
> - int i, perm;
> + u32 i;

Technically the perm type change doesn't fit with the description, but
it's minor enough that it shouldn't be an issue.

Merged into selinux/next.

> audit_log_format(ab, "avc: %s ", sad->denied ? "denied" : "granted");
>
> @@ -833,7 +833,8 @@ static int avc_update_node(u32 event, u32 perms, u8 driver, u8 xperm, u32 ssid,
> struct extended_perms_decision *xpd,
> u32 flags)
> {
> - int hvalue, rc = 0;
> + u32 hvalue;
> + int rc = 0;
> unsigned long flag;
> struct avc_node *pos, *node, *orig = NULL;
> struct hlist_head *head;
> --
> 2.40.1

--
paul-moore.com