apparmor: Remove redundant assignments
Subsystems (8)
PATCH 1/5 apparmor: Remove redundant assignments
Get rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
--- security/apparmor/domain.c | 3 +-- security/apparmor/label.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
security/apparmor/domain.c +1 -2
@@ -627,7 +627,6 @@ static struct aa_label *profile_transition(struct aa_profile *profile, {struct aa_label *new =NULL ;const char *info =NULL , *name =NULL , *target =NULL ; -unsigned int state = profile->file.start;struct aa_perms perms = {};bool nonewprivs = false;int error =0 ;
@@ -661,7 +660,7 @@ static struct aa_label *profile_transition(struct aa_profile *profile, }/* find exec permissions for name */ - state =aa_str_perms (profile->file.dfa, state, name, cond, &perms); +aa_str_perms (profile->file.dfa, profile->file.start, name, cond, &perms);if (perms.allow &MAY_EXEC ) {/* exec permission determine how to transition */ new = x_to_label(profile, bprm, name, perms.xindex, &target,
security/apparmor/label.c +1 -1
@@ -807,7 +807,7 @@ bool aa_label_replace(struct aa_label *old, struct aa_label *new)struct aa_labelset *ls =labels_set (old);write_lock_irqsave (&ls->lock, flags); - res =__label_remove (old, new); +__label_remove (old, new);if (labels_ns (old) !=labels_ns (new)) {write_unlock_irqrestore (&ls->lock, flags); ls =labels_set (new);
Signature · 1 line
2.25.1
PATCH 2/5 integrity: Remove redundant assignments
Get rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
--- security/integrity/ima/ima_main.c | 2 +- security/integrity/ima/ima_modsig.c | 2 +- security/integrity/ima/ima_policy.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
security/integrity/ima/ima_main.c +1 -1
@@ -432,7 +432,7 @@ int ima_file_mmap(struct file *file, unsigned long prot)int ima_file_mprotect (struct vm_area_struct *vma,unsigned long prot) {struct ima_template_desc *template =NULL ; -struct file *file = vma->vm_file; +struct file *file;char filename[NAME_MAX ];char *pathbuf =NULL ;const char *pathname =NULL ;
security/integrity/ima/ima_modsig.c +1 -1
@@ -109,7 +109,7 @@ void ima_collect_modsig(struct modsig *modsig, const void *buf, loff_t size)return ;/* Ask the PKCS7 code to calculate the file hash. */ - rc =pkcs7_get_digest (modsig->pkcs7_msg, &modsig->digest, +pkcs7_get_digest (modsig->pkcs7_msg, &modsig->digest, &modsig->digest_size, &modsig->hash_algo); }
security/integrity/ima/ima_policy.c +1 -1
@@ -869,7 +869,7 @@ static int __init ima_init_arch_policy(void)char rule[255 ];int result; - result =strscpy (rule, *rules,sizeof (rule)); +strscpy (rule, *rules,sizeof (rule));INIT_LIST_HEAD (&arch_policy_entry[i].list); result =ima_parse_rule (rule, &arch_policy_entry[i]);
Signature · 1 line
2.25.1
PATCH 3/5 keys: Remove redundant assignments
In reply to Michal OrzelGet rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
--- security/keys/process_keys.c | 1 - security/keys/request_key.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-)
security/keys/process_keys.c +0 -1
@@ -92,7 +92,6 @@ int look_up_user_keyrings(struct key **_user_keyring,return PTR_ERR (reg_keyring);down_write (&user_ns->keyring_sem); - ret =0 ;/* Get the user keyring. Note that there may be one in existence * already as it may have been pinned by a session, but the user_struct
security/keys/request_key.c +2 -4
@@ -116,7 +116,7 @@ static int call_sbin_request_key(struct key *authkey, void *aux) {static char const request_key[] ="/sbin/request-key" ;struct request_key_auth *rka =get_request_key_auth (authkey); -const struct cred *cred =current_cred (); +const struct cred *cred;key_serial_t prkey, sskey;struct key *key = rka->target_key, *keyring, *session, *user_session;char *argv[9 ], *envp[3 ], uid_str[12 ], gid_str[12 ];
@@ -506,9 +506,7 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,kdebug ("cons failed" ); goto construction_failed; } - }else if (ret == -EINPROGRESS ) { - ret =0 ; - }else { + }else if (ret != -EINPROGRESS ) { goto error_put_dest_keyring; }
Signature · 1 line
2.25.1
Re: [PATCH 3/5] keys: Remove redundant assignments
Quoted 50 lines · Michal Orzel
Get rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
Signed-off-by Michal Orzel <[email protected]>--- security/keys/process_keys.c | 1 - security/keys/request_key.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-)security/keys/process_keys.c +0
-1@@ -92,7 +92,6 @@ int look_up_user_keyrings(struct key **_user_keyring,return PTR_ERR (reg_keyring);down_write (&user_ns->keyring_sem); - ret =0 ;/* Get the user keyring. Note that there may be one in existence * already as it may have been pinned by a session, but the user_struct security/keys/request_key.c +2
-4@@ -116,7 +116,7 @@ static int call_sbin_request_key(struct key *authkey, void *aux) {static char const request_key[] ="/sbin/request-key" ;struct request_key_auth *rka =get_request_key_auth (authkey); -const struct cred *cred =current_cred (); +const struct cred *cred;key_serial_t prkey, sskey;struct key *key = rka->target_key, *keyring, *session, *user_session;char *argv[9 ], *envp[3 ], uid_str[12 ], gid_str[12 ];@@ -506,9 +506,7 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,kdebug ("cons failed" ); goto construction_failed; } - }else if (ret == -EINPROGRESS ) { - ret =0 ; - }else { + }else if (ret != -EINPROGRESS ) { goto error_put_dest_keyring; }Signature · 1 line
2.25.1
David: can you pick this?
BR, Jarkko
PATCH 4/5 selinux: Remove redundant assignments
In reply to Michal OrzelGet rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
--- security/selinux/avc.c | 4 ++-- security/selinux/hooks.c | 1 - security/selinux/ss/services.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-)
security/selinux/avc.c +2 -2
@@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state, node =avc_lookup (state->avc, ssid, tsid, tclass);if (unlikely (!node)) { - node =avc_compute_av (state, ssid, tsid, tclass, &avd, xp_node); +avc_compute_av (state, ssid, tsid, tclass, &avd, xp_node); }else {memcpy (&avd, &node->ae.avd,sizeof (avd)); xp_node = node->ae.xp_node;
@@ -1151,7 +1151,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state, node =avc_lookup (state->avc, ssid, tsid, tclass);if (unlikely (!node)) - node =avc_compute_av (state, ssid, tsid, tclass, avd, &xp_node); +avc_compute_av (state, ssid, tsid, tclass, avd, &xp_node);else memcpy (avd, &node->ae.avd,sizeof (*avd));
security/selinux/hooks.c +0 -1
@@ -6487,7 +6487,6 @@ static int selinux_setprocattr(const char *name, void *value, size_t size) goto abort_change;/* Only allow single threaded processes to change context */ - error = -EPERM ;if (!current_is_single_threaded ()) { error =security_bounded_transition (&selinux_state, tsec->sid, sid);
security/selinux/ss/services.c +0 -1
@@ -2980,7 +2980,6 @@ int security_fs_use(struct selinux_state *state, struct super_block *sb) } retry: - rc =0 ;rcu_read_lock (); policy =rcu_dereference (state->policy); policydb = &policy->policydb;
Signature · 1 line
2.25.1
PATCH 5/5 smack: Remove redundant assignments
In reply to Michal OrzelGet rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
--- security/smack/smackfs.c | 1 - 1 file changed, 1 deletion(-)
security/smack/smackfs.c +0 -1
@@ -1192,7 +1192,6 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf, rc = -EINVAL ; goto free_out; } - m =BEBITS ; masks =32 ; }if (masks >BEBITS ) {
Signature · 1 line
2.25.1
Casey Schaufler
maintainerRe: [PATCH 5/5] smack: Remove redundant assignments
Quoted 6 lines · Michal Orzel
Get rid of redundant assignments which end up in values not being read either because they are overwritten or the function ends.
Reported by clang-tidy [deadcode.DeadStores]
Signed-off-by Michal Orzel <[email protected]>
Thank you. I will take this via the Smack tree.
Quoted 16 lines
--- security/smack/smackfs.c | 1 - 1 file changed, 1 deletion(-)security/smack/smackfs.c +0
-1@@ -1192,7 +1192,6 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf, rc = -EINVAL ; goto free_out; } - m =BEBITS ; masks =32 ; }if (masks >BEBITS ) {