mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
apparmor: constify aa_perms parameters that are read-only
Several functions take a struct aa_perms * argument that is only ever read from and never modified through the pointer. Mark those parameters const struct aa_perms * to document intent and let the compiler enforce that the permission set is not mutated. The converted functions are: - aa_check_perms() - aa_do_perms() - do_perms() (af_inet) - match_label() (af_unix) - verify_perm() - aa_perms_accum() / aa_perms_accum_raw() (@addend only) No functional change. Signed-off-by: John Johansen <john.johansen@canonical.com> Assisted-by: Claude:claude-opus-4.8
This commit is contained in:
parent
ecafacef16
commit
e3bc982007
|
|
@ -173,7 +173,7 @@ static aa_state_t match_to_peer(struct aa_policydb *policy, aa_state_t state,
|
|||
static aa_state_t match_label(struct aa_profile *profile,
|
||||
struct aa_ruleset *rule, aa_state_t state,
|
||||
u32 request, struct aa_profile *peer,
|
||||
struct aa_perms *p,
|
||||
const struct aa_perms *p,
|
||||
struct apparmor_audit_data *ad)
|
||||
{
|
||||
AA_BUG(!profile);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ extern struct aa_sfs_entry aa_sfs_entry_network[];
|
|||
extern struct aa_sfs_entry aa_sfs_entry_networkv9[];
|
||||
|
||||
int aa_do_perms(struct aa_profile *profile, struct aa_policydb *policy,
|
||||
aa_state_t state, u32 request, struct aa_perms *p,
|
||||
aa_state_t state, u32 request, const struct aa_perms *p,
|
||||
struct apparmor_audit_data *ad);
|
||||
/* passing in state returned by XXX_mediates_AF() */
|
||||
aa_state_t aa_match_to_prot(struct aa_policydb *policy, aa_state_t state,
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ extern const struct aa_perms allperms;
|
|||
* @addend: perms struct to add to @accum
|
||||
*/
|
||||
static inline void aa_perms_accum_raw(struct aa_perms *accum,
|
||||
struct aa_perms *addend)
|
||||
const struct aa_perms *addend)
|
||||
{
|
||||
accum->deny |= addend->deny;
|
||||
accum->allow &= addend->allow & ~addend->deny;
|
||||
|
|
@ -132,7 +132,7 @@ static inline void aa_perms_accum_raw(struct aa_perms *accum,
|
|||
* @addend: perms struct to add to @accum
|
||||
*/
|
||||
static inline void aa_perms_accum(struct aa_perms *accum,
|
||||
struct aa_perms *addend)
|
||||
const struct aa_perms *addend)
|
||||
{
|
||||
accum->deny |= addend->deny;
|
||||
accum->allow &= addend->allow & ~accum->deny;
|
||||
|
|
@ -208,12 +208,13 @@ void aa_audit_perm_mask(struct audit_buffer *ab, u32 mask, const char *chrs,
|
|||
u32 chrsmask, const char * const *names, u32 namesmask);
|
||||
void aa_apply_modes_to_perms(struct aa_profile *profile,
|
||||
struct aa_perms *perms);
|
||||
void aa_perms_accum(struct aa_perms *accum, struct aa_perms *addend);
|
||||
void aa_perms_accum_raw(struct aa_perms *accum, struct aa_perms *addend);
|
||||
void aa_perms_accum(struct aa_perms *accum, const struct aa_perms *addend);
|
||||
void aa_perms_accum_raw(struct aa_perms *accum, const struct aa_perms *addend);
|
||||
void aa_profile_match_label(struct aa_profile *profile,
|
||||
struct aa_ruleset *rules, struct aa_label *label,
|
||||
int type, u32 request, struct aa_perms *perms);
|
||||
int aa_check_perms(struct aa_profile *profile, struct aa_perms *perms,
|
||||
int aa_check_perms(struct aa_profile *profile, const struct aa_perms *perms,
|
||||
u32 request, struct apparmor_audit_data *ad,
|
||||
void (*cb)(struct audit_buffer *, void *));
|
||||
#endif /* __AA_PERM_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ void aa_profile_match_label(struct aa_profile *profile,
|
|||
* error code will indicate whether there was an explicit deny
|
||||
* with a positive value.
|
||||
*/
|
||||
int aa_check_perms(struct aa_profile *profile, struct aa_perms *perms,
|
||||
int aa_check_perms(struct aa_profile *profile, const struct aa_perms *perms,
|
||||
u32 request, struct apparmor_audit_data *ad,
|
||||
void (*cb)(struct audit_buffer *, void *))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ void audit_net_cb(struct audit_buffer *ab, void *va)
|
|||
/* standard permission lookup pattern - supports early bailout */
|
||||
int aa_do_perms(struct aa_profile *profile, struct aa_policydb *policy,
|
||||
aa_state_t state, u32 request,
|
||||
struct aa_perms *p, struct apparmor_audit_data *ad)
|
||||
const struct aa_perms *p, struct apparmor_audit_data *ad)
|
||||
{
|
||||
struct aa_perms perms;
|
||||
|
||||
|
|
|
|||
|
|
@ -1493,7 +1493,7 @@ static bool verify_dfa_accept_index(struct aa_dfa *dfa, int table_size)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool verify_perm(struct aa_perms *perm)
|
||||
static bool verify_perm(const struct aa_perms *perm)
|
||||
{
|
||||
/* TODO: allow option to just force the perms into a valid state */
|
||||
if (perm->allow & perm->deny)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user