Skip to content

Commit c92cdeb

Browse files
rgbriggseparis
authored andcommitted
audit: convert PPIDs to the inital PID namespace.
sys_getppid() returns the parent pid of the current process in its own pid namespace. Since audit filters are based in the init pid namespace, a process could avoid a filter or trigger an unintended one by being in an alternate pid namespace or log meaningless information. Switch to task_ppid_nr() for PPIDs to anchor all audit filters in the init_pid_ns. (informed by ebiederman's 6c621b7e) Cc: stable@vger.kernel.org Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
1 parent ad36d28 commit c92cdeb

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎kernel/audit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,10 +1819,10 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
18191819
spin_unlock_irq(&tsk->sighand->siglock);
18201820

18211821
audit_log_format(ab,
1822-
" ppid=%ld pid=%d auid=%u uid=%u gid=%u"
1822+
" ppid=%d pid=%d auid=%u uid=%u gid=%u"
18231823
" euid=%u suid=%u fsuid=%u"
18241824
" egid=%u sgid=%u fsgid=%u tty=%s ses=%u",
1825-
sys_getppid(),
1825+
task_ppid_nr(tsk),
18261826
tsk->pid,
18271827
from_kuid(&init_user_ns, audit_get_loginuid(tsk)),
18281828
from_kuid(&init_user_ns, cred->uid),

‎kernel/auditsc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int audit_filter_rules(struct task_struct *tsk,
465465
case AUDIT_PPID:
466466
if (ctx) {
467467
if (!ctx->ppid)
468-
ctx->ppid = sys_getppid();
468+
ctx->ppid = task_ppid_nr(tsk);
469469
result = audit_comparator(ctx->ppid, f->op, f->val);
470470
}
471471
break;

0 commit comments

Comments
 (0)