Commit c1a7368a authored by wzt.wzt@gmail.com's avatar wzt.wzt@gmail.com Committed by James Morris

Security: Fix coding style in security/

Fix coding style in security/
Signed-off-by: default avatarZhitong Wang <zhitong.wangzt@alibaba-inc.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent e2902eb7
...@@ -503,11 +503,11 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size) ...@@ -503,11 +503,11 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size)
return length; return length;
length = -ENOMEM; length = -ENOMEM;
scon = kzalloc(size+1, GFP_KERNEL); scon = kzalloc(size + 1, GFP_KERNEL);
if (!scon) if (!scon)
return length; return length;
tcon = kzalloc(size+1, GFP_KERNEL); tcon = kzalloc(size + 1, GFP_KERNEL);
if (!tcon) if (!tcon)
goto out; goto out;
...@@ -515,10 +515,10 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size) ...@@ -515,10 +515,10 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size)
if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
goto out2; goto out2;
length = security_context_to_sid(scon, strlen(scon)+1, &ssid); length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
if (length < 0) if (length < 0)
goto out2; goto out2;
length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid); length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
if (length < 0) if (length < 0)
goto out2; goto out2;
...@@ -550,11 +550,11 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size) ...@@ -550,11 +550,11 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
return length; return length;
length = -ENOMEM; length = -ENOMEM;
scon = kzalloc(size+1, GFP_KERNEL); scon = kzalloc(size + 1, GFP_KERNEL);
if (!scon) if (!scon)
return length; return length;
tcon = kzalloc(size+1, GFP_KERNEL); tcon = kzalloc(size + 1, GFP_KERNEL);
if (!tcon) if (!tcon)
goto out; goto out;
...@@ -562,10 +562,10 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size) ...@@ -562,10 +562,10 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
goto out2; goto out2;
length = security_context_to_sid(scon, strlen(scon)+1, &ssid); length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
if (length < 0) if (length < 0)
goto out2; goto out2;
length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid); length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
if (length < 0) if (length < 0)
goto out2; goto out2;
...@@ -609,11 +609,11 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size) ...@@ -609,11 +609,11 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size)
return length; return length;
length = -ENOMEM; length = -ENOMEM;
scon = kzalloc(size+1, GFP_KERNEL); scon = kzalloc(size + 1, GFP_KERNEL);
if (!scon) if (!scon)
return length; return length;
tcon = kzalloc(size+1, GFP_KERNEL); tcon = kzalloc(size + 1, GFP_KERNEL);
if (!tcon) if (!tcon)
goto out; goto out;
...@@ -621,10 +621,10 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size) ...@@ -621,10 +621,10 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size)
if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
goto out2; goto out2;
length = security_context_to_sid(scon, strlen(scon)+1, &ssid); length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
if (length < 0) if (length < 0)
goto out2; goto out2;
length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid); length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
if (length < 0) if (length < 0)
goto out2; goto out2;
...@@ -666,11 +666,11 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size) ...@@ -666,11 +666,11 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
return length; return length;
length = -ENOMEM; length = -ENOMEM;
con = kzalloc(size+1, GFP_KERNEL); con = kzalloc(size + 1, GFP_KERNEL);
if (!con) if (!con)
return length; return length;
user = kzalloc(size+1, GFP_KERNEL); user = kzalloc(size + 1, GFP_KERNEL);
if (!user) if (!user)
goto out; goto out;
...@@ -678,7 +678,7 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size) ...@@ -678,7 +678,7 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
if (sscanf(buf, "%s %s", con, user) != 2) if (sscanf(buf, "%s %s", con, user) != 2)
goto out2; goto out2;
length = security_context_to_sid(con, strlen(con)+1, &sid); length = security_context_to_sid(con, strlen(con) + 1, &sid);
if (length < 0) if (length < 0)
goto out2; goto out2;
...@@ -727,11 +727,11 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size) ...@@ -727,11 +727,11 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
return length; return length;
length = -ENOMEM; length = -ENOMEM;
scon = kzalloc(size+1, GFP_KERNEL); scon = kzalloc(size + 1, GFP_KERNEL);
if (!scon) if (!scon)
return length; return length;
tcon = kzalloc(size+1, GFP_KERNEL); tcon = kzalloc(size + 1, GFP_KERNEL);
if (!tcon) if (!tcon)
goto out; goto out;
...@@ -739,10 +739,10 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size) ...@@ -739,10 +739,10 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
goto out2; goto out2;
length = security_context_to_sid(scon, strlen(scon)+1, &ssid); length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
if (length < 0) if (length < 0)
goto out2; goto out2;
length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid); length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
if (length < 0) if (length < 0)
goto out2; goto out2;
...@@ -1401,7 +1401,7 @@ static int sel_make_perm_files(char *objclass, int classvalue, ...@@ -1401,7 +1401,7 @@ static int sel_make_perm_files(char *objclass, int classvalue,
} }
inode->i_fop = &sel_perm_ops; inode->i_fop = &sel_perm_ops;
/* i+1 since perm values are 1-indexed */ /* i+1 since perm values are 1-indexed */
inode->i_ino = sel_perm_to_ino(classvalue, i+1); inode->i_ino = sel_perm_to_ino(classvalue, i + 1);
d_add(dentry, inode); d_add(dentry, inode);
} }
...@@ -1489,7 +1489,7 @@ static int sel_make_classes(void) ...@@ -1489,7 +1489,7 @@ static int sel_make_classes(void)
goto out; goto out;
/* +2 since classes are 1-indexed */ /* +2 since classes are 1-indexed */
last_class_ino = sel_class_to_ino(nclasses+2); last_class_ino = sel_class_to_ino(nclasses + 2);
for (i = 0; i < nclasses; i++) { for (i = 0; i < nclasses; i++) {
struct dentry *class_name_dir; struct dentry *class_name_dir;
...@@ -1506,7 +1506,7 @@ static int sel_make_classes(void) ...@@ -1506,7 +1506,7 @@ static int sel_make_classes(void)
goto out1; goto out1;
/* i+1 since class values are 1-indexed */ /* i+1 since class values are 1-indexed */
rc = sel_make_class_dir_entries(classes[i], i+1, rc = sel_make_class_dir_entries(classes[i], i + 1,
class_name_dir); class_name_dir);
if (rc) if (rc)
goto out1; goto out1;
......
...@@ -255,7 +255,7 @@ int mls_context_to_sid(struct policydb *pol, ...@@ -255,7 +255,7 @@ int mls_context_to_sid(struct policydb *pol,
if (!pol->mls_enabled) { if (!pol->mls_enabled) {
if (def_sid != SECSID_NULL && oldc) if (def_sid != SECSID_NULL && oldc)
*scontext += strlen(*scontext)+1; *scontext += strlen(*scontext) + 1;
return 0; return 0;
} }
......
...@@ -156,7 +156,7 @@ static int roles_init(struct policydb *p) ...@@ -156,7 +156,7 @@ static int roles_init(struct policydb *p)
rc = -EINVAL; rc = -EINVAL;
goto out_free_role; goto out_free_role;
} }
key = kmalloc(strlen(OBJECT_R)+1, GFP_KERNEL); key = kmalloc(strlen(OBJECT_R) + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free_role; goto out_free_role;
...@@ -2195,7 +2195,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -2195,7 +2195,7 @@ int policydb_read(struct policydb *p, void *fp)
rangetr_hash_eval(p->range_tr); rangetr_hash_eval(p->range_tr);
} }
p->type_attr_map = kmalloc(p->p_types.nprim*sizeof(struct ebitmap), GFP_KERNEL); p->type_attr_map = kmalloc(p->p_types.nprim * sizeof(struct ebitmap), GFP_KERNEL);
if (!p->type_attr_map) if (!p->type_attr_map)
goto bad; goto bad;
......
...@@ -274,15 +274,15 @@ static int constraint_expr_eval(struct context *scontext, ...@@ -274,15 +274,15 @@ static int constraint_expr_eval(struct context *scontext,
case CEXPR_AND: case CEXPR_AND:
BUG_ON(sp < 1); BUG_ON(sp < 1);
sp--; sp--;
s[sp] &= s[sp+1]; s[sp] &= s[sp + 1];
break; break;
case CEXPR_OR: case CEXPR_OR:
BUG_ON(sp < 1); BUG_ON(sp < 1);
sp--; sp--;
s[sp] |= s[sp+1]; s[sp] |= s[sp + 1];
break; break;
case CEXPR_ATTR: case CEXPR_ATTR:
if (sp == (CEXPR_MAXDEPTH-1)) if (sp == (CEXPR_MAXDEPTH - 1))
return 0; return 0;
switch (e->attr) { switch (e->attr) {
case CEXPR_USER: case CEXPR_USER:
...@@ -1216,7 +1216,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len, ...@@ -1216,7 +1216,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
*sid = SECSID_NULL; *sid = SECSID_NULL;
/* Copy the string so that we can modify the copy as we parse it. */ /* Copy the string so that we can modify the copy as we parse it. */
scontext2 = kmalloc(scontext_len+1, gfp_flags); scontext2 = kmalloc(scontext_len + 1, gfp_flags);
if (!scontext2) if (!scontext2)
return -ENOMEM; return -ENOMEM;
memcpy(scontext2, scontext, scontext_len); memcpy(scontext2, scontext, scontext_len);
...@@ -2101,9 +2101,9 @@ int security_get_user_sids(u32 fromsid, ...@@ -2101,9 +2101,9 @@ int security_get_user_sids(u32 fromsid,
ebitmap_for_each_positive_bit(&user->roles, rnode, i) { ebitmap_for_each_positive_bit(&user->roles, rnode, i) {
role = policydb.role_val_to_struct[i]; role = policydb.role_val_to_struct[i];
usercon.role = i+1; usercon.role = i + 1;
ebitmap_for_each_positive_bit(&role->types, tnode, j) { ebitmap_for_each_positive_bit(&role->types, tnode, j) {
usercon.type = j+1; usercon.type = j + 1;
if (mls_setup_user_range(fromcon, user, &usercon)) if (mls_setup_user_range(fromcon, user, &usercon))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment