123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #include <linux/gfp.h>
- #include <linux/ptrace.h>
- #include "include/audit.h"
- #include "include/capability.h"
- #include "include/context.h"
- #include "include/policy.h"
- #include "include/ipc.h"
- static void audit_cb(struct audit_buffer *ab, void *va)
- {
- struct common_audit_data *sa = va;
- audit_log_format(ab, " target=");
- audit_log_untrustedstring(ab, sa->aad->target);
- }
- static int aa_audit_ptrace(struct aa_profile *profile,
- struct aa_profile *target, int error)
- {
- struct common_audit_data sa;
- struct apparmor_audit_data aad = {0,};
- sa.type = LSM_AUDIT_DATA_NONE;
- sa.aad = &aad;
- aad.op = OP_PTRACE;
- aad.target = target;
- aad.error = error;
- return aa_audit(AUDIT_APPARMOR_AUTO, profile, GFP_ATOMIC, &sa,
- audit_cb);
- }
- int aa_may_ptrace(struct aa_profile *tracer, struct aa_profile *tracee,
- unsigned int mode)
- {
-
- if (unconfined(tracer) || tracer == tracee)
- return 0;
-
- return aa_capable(tracer, CAP_SYS_PTRACE, 1);
- }
- int aa_ptrace(struct task_struct *tracer, struct task_struct *tracee,
- unsigned int mode)
- {
-
- struct aa_profile *tracer_p = aa_get_task_profile(tracer);
- int error = 0;
- if (!unconfined(tracer_p)) {
- struct aa_profile *tracee_p = aa_get_task_profile(tracee);
- error = aa_may_ptrace(tracer_p, tracee_p, mode);
- error = aa_audit_ptrace(tracer_p, tracee_p, error);
- aa_put_profile(tracee_p);
- }
- aa_put_profile(tracer_p);
- return error;
- }
|