ima: add gid support
Subsystems (4)
PATCH v2 1/1 ima: add gid support
From: Curtis Veit <[email protected]>
IMA currently supports the concept of rules based on uid where the rule is based on the uid of the file owner or the uid of the user accessing the file. It is useful to have similar rules based on gid. This patch provides that ability.
---
v2: Trivial changes that Mimi requested
--- Documentation/ABI/testing/ima_policy | 8 +- security/integrity/ima/ima_policy.c | 201 +++++++++++++++++++++++---- 2 files changed, 180 insertions(+), 29 deletions(-)
Documentation/ABI/testing/ima_policy +6 -2
@@ -22,8 +22,9 @@ Description: action: measure | dont_measure | appraise | dont_appraise | audit | hash | dont_hash condition:= base | lsm [option] - base: [[func=] [mask=] [fsmagic=] [fsuuid=] [uid=] - [euid=] [fowner=] [fsname=]] + base: [[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=] + [uid=] [euid=] [gid=] [egid=] + [fowner=] [fgroup=]] lsm: [[subj_user=] [subj_role=] [subj_type=] [obj_user=] [obj_role=] [obj_type=]] option: [[appraise_type=]] [template=] [permit_directio]
@@ -40,7 +41,10 @@ Description: fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6) uid:= decimal value euid:= decimal value + gid:= decimal value + egid:= decimal value fowner:= decimal value + fgroup:= decimal value lsm: are LSM specific option: appraise_type:= [imasig] [imasig|modsig]
security/integrity/ima/ima_policy.c +174 -27
354 lines not on this page · raw message
Signature · 1 line
2.33.0
Mimi Zohar
maintainerHi Alex,
Quoted 7 lines · Alex Henrie
From: Curtis Veit <[email protected]>
IMA currently supports the concept of rules based on uid where the rule is based on the uid of the file owner or the uid of the user accessing the file. It is useful to have similar rules based on gid. This patch provides that ability.
Quoted 5 lines
Signed-off-by Curtis Veit <[email protected]>Co-developed-by Alex Henrie <[email protected]>Signed-off-by Alex Henrie <[email protected]>---
v2: Trivial changes that Mimi requested
Sorry, scripts/check-patch.pl reported some warnings. Two more trivial changes.
Quoted 10 lines
--- Documentation/ABI/testing/ima_policy | 8 +- security/integrity/ima/ima_policy.c | 201 +++++++++++++++++++++++---- 2 files changed, 180 insertions(+), 29 deletions(-)Documentation/ABI/testing/ima_policy +0
-1--- a/Documentation/ABI/testing/ima_policy
Documentation/ABI/testing/ima_policy struct ima_rule_entry { · line 90
Quoted 10 lines
Documentation/ABI/testing/ima_policy +4
-0@@ -78,9 +81,13 @@ struct ima_rule_entry { unsigned long fsmagic; uuid_t fsuuid; kuid_t uid; + kgid_t gid; kuid_t fowner; + kgid_t fgroup; bool (*uid_op)(kuid_t, kuid_t); /* Handlers for operators */ + bool (*gid_op)(kgid_t, kgid_t); bool (*fowner_op)(kuid_t, kuid_t); /* uid_eq(), uid_gt(), uid_lt() */ + bool (*fgroup_op)(kgid_t, kgid_t); /* gid_eq(), gid_gt(), gid_lt() */
scripts/checkpatch.pl complains about missing variables.
Documentation/ABI/testing/ima_policy static bool ima_match_rules(struct ima_rule_entry *rule, · line 593
Quoted 10 lines
Documentation/ABI/testing/ima_policy +1
-1int pcr; unsigned int allowed_algos; /* bitfield of allowed hash algorithms */ struct {@@ -582,10 +590,23 @@ static bool ima_match_rules(struct ima_rule_entry *rule, } else if (!rule->uid_op(cred->euid, rule->uid)) return false; } - + if ((rule->flags & IMA_GID) && !rule->gid_op(rule->gid, cred->gid))
All of uid_op/gid_op calls in ima_match_rules() pass the "cred->xxxx,rule->xxx" except here, where it is rule->gid, cred->rule. Reversing
the parameters here will help with addressing the checkpatch.pl warning.
thanks,
Mimi
Petr Vorel
Reviewed-byHi Alex, Mimi,
Quoted 27 lines
Hi Alex,
Quoted 7 lines · Alex Henrie
From: Curtis Veit <[email protected]>
IMA currently supports the concept of rules based on uid where the rule is based on the uid of the file owner or the uid of the user accessing the file. It is useful to have similar rules based on gid. This patch provides that ability.
Quoted 5 lines
Signed-off-by Curtis Veit <[email protected]>Co-developed-by Alex Henrie <[email protected]>Signed-off-by Alex Henrie <[email protected]>---
v2: Trivial changes that Mimi requestedSorry,
scripts/check-patch.plreported some warnings. Two more trivial changes.Quoted 8 lines
--- Documentation/ABI/testing/ima_policy | 8 +- security/integrity/ima/ima_policy.c | 201 +++++++++++++++++++++++---- 2 files changed, 180 insertions(+), 29 deletions(-)Documentation/ABI/testing/ima_policy +0
-1--- a/Documentation/ABI/testing/ima_policy
Quoted 13 lines
Documentation/ABI/testing/ima_policy struct ima_rule_entry { · line 90
Quoted 11 lines
Documentation/ABI/testing/ima_policy +4
-0@@ -78,9 +81,13 @@ struct ima_rule_entry { unsigned long fsmagic; uuid_t fsuuid; kuid_t uid; + kgid_t gid; kuid_t fowner; + kgid_t fgroup; bool (*uid_op)(kuid_t, kuid_t); /* Handlers for operators */ + bool (*gid_op)(kgid_t, kgid_t); bool (*fowner_op)(kuid_t, kuid_t); /* uid_eq(), uid_gt(), uid_lt() */ + bool (*fgroup_op)(kgid_t, kgid_t); /* gid_eq(), gid_gt(), gid_lt() */
scripts/checkpatch.plcomplains about missing variables.
+1
Quoted 4 lines
Quoted 3 lines
Documentation/ABI/testing/ima_policy +0
-0int pcr; unsigned int allowed_algos; /* bitfield of allowed hash algorithms */ struct {
Quoted 11 lines
Documentation/ABI/testing/ima_policy static bool ima_match_rules(struct ima_rule_entry *rule, · line 593
Quoted 6 lines
Documentation/ABI/testing/ima_policy +1
-1@@ -582,10 +590,23 @@ static bool ima_match_rules(struct ima_rule_entry *rule, } else if (!rule->uid_op(cred->euid, rule->uid)) return false; } - + if ((rule->flags & IMA_GID) && !rule->gid_op(rule->gid, cred->gid))All of uid_op/gid_op calls in
ima_match_rules()pass the "cred->xxxx,rule->xxx" except here, where it isrule->gid,cred->rule. Reversing
the parameters here will help with addressing the checkpatch.pl warning.
+1
Apart from those checkpatch issues patch LGTM.
Kind regards,
Petr
Quoted 3 lines
thanks,
Mimi
Quoted 14 lines · On Wed, 06 Oct 2021 15:49:58 -0400 Mimi Zohar <[email protected]> wrote:
security/integrity/ima/ima_policy.c struct ima_rule_entry { · line 90
Quoted 11 lines · Alex Henrie
security/integrity/ima/ima_policy.c +4
-0@@ -78,9 +81,13 @@ struct ima_rule_entry {unsigned long fsmagic;uuid_t fsuuid;kuid_t uid; +kgid_t gid;kuid_t fowner; +kgid_t fgroup;bool (*uid_op)(kuid_t ,kuid_t );/* Handlers for operators */ +bool (*gid_op)(kgid_t ,kgid_t );bool (*fowner_op)(kuid_t ,kuid_t );/* uid_eq(), uid_gt(), uid_lt() */ +bool (*fgroup_op)(kgid_t ,kgid_t );/* gid_eq(), gid_gt(), gid_lt() */
scripts/checkpatch.plcomplains about missing variables.
I'll resend with a new patch that fixes the existing style problems with the UID code before adding GID support.
Quoted 11 lines
security/integrity/ima/ima_policy.c static bool ima_match_rules(struct ima_rule_entry *rule, · line 593
Quoted 6 lines
security/integrity/ima/ima_policy.c +1
-1@@ -582,10 +590,23 @@ static bool ima_match_rules(struct ima_rule_entry *rule, }else if (!rule->uid_op (cred->euid, rule->uid))return false; } - +if ((rule->flags &IMA_GID ) && !rule->gid_op (rule->gid, cred->gid))All of uid_op/gid_op calls in
ima_match_rules()pass the "cred->xxxx,rule->xxx" except here, where it isrule->gid,cred->rule. Reversing
the parameters here will help with addressing the checkpatch.pl warning.
Good catch, thanks.
-Alex