Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions kernel/selinux/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int get_object(char *buf, char __user *user_object, size_t buf_sz,
}

if (strncpy_from_user(buf, user_object, buf_sz) < 0) {
return -1;
return -EINVAL;
}

*object = buf;
Expand Down Expand Up @@ -192,7 +192,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
struct policydb *db;

if (!arg4) {
return -1;
return -EINVAL;
}

if (!getenforce()) {
Expand All @@ -202,7 +202,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
struct sepol_data data;
if (copy_from_user(&data, arg4, sizeof(struct sepol_data))) {
pr_err("sepol: copy sepol_data failed.\n");
return -1;
return -EINVAL;
}

u32 cmd = data.cmd;
Expand All @@ -212,7 +212,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)

db = get_policydb();

int ret = -1;
int ret = -EINVAL;
if (cmd == CMD_NORMAL_PERM) {
char src_buf[MAX_SEPOL_LEN];
char tgt_buf[MAX_SEPOL_LEN];
Expand Down Expand Up @@ -253,7 +253,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
} else {
pr_err("sepol: unknown subcmd: %d\n", subcmd);
}
ret = success ? 0 : -1;
ret = success ? 0 : -EINVAL;

} else if (cmd == CMD_XPERM) {
char src_buf[MAX_SEPOL_LEN];
Expand Down Expand Up @@ -298,7 +298,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
} else {
pr_err("sepol: unknown subcmd: %d\n", subcmd);
}
ret = success ? 0 : -1;
ret = success ? 0 : -EINVAL;
} else if (cmd == CMD_TYPE_STATE) {
char src[MAX_SEPOL_LEN];

Expand Down
6 changes: 3 additions & 3 deletions userspace/ksud/src/sepolicy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ fn apply_one_rule<'a>(statement: &'a PolicyStatement<'a>, strict: bool) -> Resul
cmd: 0,
arg: &ffi_policy as *const _ as u64,
};
if crate::ksucalls::set_sepolicy(&cmd).is_err() {
log::warn!("apply rule: {statement:?} failed.");
if let Err(e) = crate::ksucalls::set_sepolicy(&cmd) {
log::warn!("apply rule {:?} failed: {}", statement, e);
if strict {
return Err(anyhow::anyhow!("apply rule {:?} failed.", statement));
return Err(anyhow::anyhow!("apply rule {:?} failed: {}", statement, e));
}
}
}
Expand Down