ksud, kernel: fix sepolicy patch hint (#2872)

This commit is contained in:
Ylarod
2025-11-06 10:14:54 +08:00
committed by ShirkNeko
parent a8302120c4
commit 699852009c

View File

@@ -178,7 +178,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) { if (strncpy_from_user(buf, user_object, buf_sz) < 0) {
return -1; return -EINVAL;
} }
*object = buf; *object = buf;
@@ -208,7 +208,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
struct policydb *db; struct policydb *db;
if (!arg4) { if (!arg4) {
return -1; return -EINVAL;
} }
if (!getenforce()) { if (!getenforce()) {
@@ -222,7 +222,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
struct sepol_data data = { 0 }; struct sepol_data data = { 0 };
if (copy_from_user(&data, arg4, sizeof(struct sepol_data))) { if (copy_from_user(&data, arg4, sizeof(struct sepol_data))) {
pr_err("sepol: copy sepol_data failed.\n"); pr_err("sepol: copy sepol_data failed.\n");
return -1; return -EINVAL;
} }
sepol1 = (char __user *)data.field_sepol1; sepol1 = (char __user *)data.field_sepol1;
@@ -239,7 +239,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
db = get_policydb(); db = get_policydb();
int ret = -1; int ret = -EINVAL;
if (cmd == CMD_NORMAL_PERM) { if (cmd == CMD_NORMAL_PERM) {
char src_buf[MAX_SEPOL_LEN]; char src_buf[MAX_SEPOL_LEN];
char tgt_buf[MAX_SEPOL_LEN]; char tgt_buf[MAX_SEPOL_LEN];
@@ -279,7 +279,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
} else { } else {
pr_err("sepol: unknown subcmd: %d\n", subcmd); pr_err("sepol: unknown subcmd: %d\n", subcmd);
} }
ret = success ? 0 : -1; ret = success ? 0 : -EINVAL;
} else if (cmd == CMD_XPERM) { } else if (cmd == CMD_XPERM) {
char src_buf[MAX_SEPOL_LEN]; char src_buf[MAX_SEPOL_LEN];
@@ -323,7 +323,7 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
} else { } else {
pr_err("sepol: unknown subcmd: %d\n", subcmd); pr_err("sepol: unknown subcmd: %d\n", subcmd);
} }
ret = success ? 0 : -1; ret = success ? 0 : -EINVAL;
} else if (cmd == CMD_TYPE_STATE) { } else if (cmd == CMD_TYPE_STATE) {
char src[MAX_SEPOL_LEN]; char src[MAX_SEPOL_LEN];