Commit 3eea57c2 authored by John Johansen's avatar John Johansen

apparmor: fix setprocattr arg processing for onexec

the exec file isn't processing its command arg. It should only set be
responding to a command of exec.

Also cleanup setprocattr some more while we are at it.
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 214beaca
...@@ -529,6 +529,8 @@ static int apparmor_getprocattr(struct task_struct *task, char *name, ...@@ -529,6 +529,8 @@ static int apparmor_getprocattr(struct task_struct *task, char *name,
static int apparmor_setprocattr(struct task_struct *task, char *name, static int apparmor_setprocattr(struct task_struct *task, char *name,
void *value, size_t size) void *value, size_t size)
{ {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
char *command, *args = value; char *command, *args = value;
size_t arg_size; size_t arg_size;
int error; int error;
...@@ -572,28 +574,31 @@ static int apparmor_setprocattr(struct task_struct *task, char *name, ...@@ -572,28 +574,31 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
} else if (strcmp(command, "permprofile") == 0) { } else if (strcmp(command, "permprofile") == 0) {
error = aa_setprocattr_changeprofile(args, !AA_ONEXEC, error = aa_setprocattr_changeprofile(args, !AA_ONEXEC,
AA_DO_TEST); AA_DO_TEST);
} else { } else
struct common_audit_data sa; goto fail;
struct apparmor_audit_data aad = {0,};
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_SETPROCATTR;
aad.info = name;
aad.error = -EINVAL;
return aa_audit(AUDIT_APPARMOR_DENIED,
__aa_current_profile(), GFP_KERNEL,
&sa, NULL);
}
} else if (strcmp(name, "exec") == 0) { } else if (strcmp(name, "exec") == 0) {
error = aa_setprocattr_changeprofile(args, AA_ONEXEC, if (strcmp(command, "exec") == 0)
!AA_DO_TEST); error = aa_setprocattr_changeprofile(args, AA_ONEXEC,
} else { !AA_DO_TEST);
else
goto fail;
} else
/* only support the "current" and "exec" process attributes */ /* only support the "current" and "exec" process attributes */
return -EINVAL; return -EINVAL;
}
if (!error) if (!error)
error = size; error = size;
return error; return error;
fail:
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.profile = aa_current_profile();
aad.op = OP_SETPROCATTR;
aad.info = name;
aad.error = -EINVAL;
aa_audit_msg(AUDIT_APPARMOR_DENIED, &sa, NULL);
return -EINVAL;
} }
static int apparmor_task_setrlimit(struct task_struct *task, static int apparmor_task_setrlimit(struct task_struct *task,
......
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