aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity
diff options
context:
space:
mode:
authorDmitry Kasatkin <d.kasatkin@samsung.com>2014-08-22 02:43:55 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2014-09-09 10:28:47 -0400
commitf68c05f4d2d4e19c40f4ac1e769cc0a2f9f544a0 (patch)
tree07370f5d985fbb1235044660937b27d9b04a4a8c /security/integrity
parent65d98f3be25f7ee96af655f97e153d3d8d3d8ef9 (diff)
ima: simplify conditional statement to improve performance
Precede bit testing before string comparison makes code faster. Also refactor statement as a single line pointer assignment. Logic is following: we set 'xattr_ptr' to read xattr value when we will do appraisal or in any case when measurement template is other than 'ima'. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity')
-rw-r--r--security/integrity/ima/ima_main.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index f82cf9b8e92b..f7b85bf0eaf3 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -206,10 +206,8 @@ static int process_measurement(struct file *file, const char *filename,
206 } 206 }
207 207
208 template_desc = ima_template_desc_current(); 208 template_desc = ima_template_desc_current();
209 if (strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) == 0) { 209 if ((action & IMA_APPRAISE_SUBMASK) ||
210 if (action & IMA_APPRAISE_SUBMASK) 210 strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) != 0)
211 xattr_ptr = &xattr_value;
212 } else
213 xattr_ptr = &xattr_value; 211 xattr_ptr = &xattr_value;
214 212
215 rc = ima_collect_measurement(iint, file, xattr_ptr, &xattr_len); 213 rc = ima_collect_measurement(iint, file, xattr_ptr, &xattr_len);