Received: by 10.192.165.148 with SMTP id m20csp499148imm; Fri, 4 May 2018 13:57:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrUC82hnjBYP0PjgW4Rpu2XV/75aFqT/oPzLlJbFOeuTxolsW2WfClYvB00KgeNLM3+gjR8 X-Received: by 10.98.64.79 with SMTP id n76mr5051801pfa.185.1525467434774; Fri, 04 May 2018 13:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525467434; cv=none; d=google.com; s=arc-20160816; b=QkUB4yHfdZ80pKPEt2BrJZl0bqVIqFvMHFvOzkzk/6/IO4tk3C1OIbHH0V2qZ3JFFx 9j6FyOfU9wZ3Xc/MREUpJLPqESlmTwJQ8zyjXCRYrIpiWQhnZK9S21fe+3v8M2YPcT6M d0u0q8+yaUX1jDFgmvd13YVUKc8rfaoBXcOvxG94dCZobrM5n/u9DTpELc8GXgCGCiJI 0IzVcOI9Kr5KhM12RvuiIIyqDIu1XhbNOUd525i88mM6ipRmWh87BvseiKdl/AutGAgi getRdJLR1UFnYwIFXuP98YtcL759YCjAAlasJQWzOwCWR1SBSknHJnztmVl34v9bVSCA 5rVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pUWbkmg6FdvY/9dkvS0KrIqUVuLr2eZVZbpD69eB9u8=; b=I6NP6nDOSMRXTz5cTyW+ucZoIDsVNTEs09Gx+zWlNTUiGdeiksZiQiO3PH0Hxerl2c 4pNGGgwT6uNwk6VneIGSc2p+2cNxsyOgjVwcRN5msLyhAmX3qAA/aaorJvykXoFtBGqZ hwh8jD11+RM4Gb6F6VJBMlRRdlyWHVEvD1Sh1ml3u/yo69PjOjKlnJg8Z3iI0/ISolYe qsIrUuFC2IxKr+Rxa6mSovYgLlCGn9i9C7T3PlLiHNPvWaP/LXPs8cz3Q3S00O9htPy/ VVNSX04zqKCFJMLRGVY7u3BjDeUW8Qq50aBjuNVwXjbeVuBx3PK4cGr2wbI20MCDrjj9 tC6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si13942940pln.437.2018.05.04.13.57.00; Fri, 04 May 2018 13:57:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbeEDU40 (ORCPT + 99 others); Fri, 4 May 2018 16:56:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751558AbeEDUz1 (ORCPT ); Fri, 4 May 2018 16:55:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E91D81A88AD; Fri, 4 May 2018 20:55:27 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3859215CDA7; Fri, 4 May 2018 20:55:24 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML , Linux NetDev Upstream Mailing List , Netfilter Devel List , Linux Security Module list , Integrity Measurement Architecture , SElinux list Cc: Eric Paris , Paul Moore , Steve Grubb , Ingo Molnar , David Howells , Richard Guy Briggs Subject: [PATCH ghak81 RFC V1 4/5] audit: use inline function to set audit context Date: Fri, 4 May 2018 16:54:37 -0400 Message-Id: <2f0566af8ccafdaf400a3d002cb4aef9b80e44cf.1525466167.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 04 May 2018 20:55:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 04 May 2018 20:55:27 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recognizing that the audit context is an internal audit value, use an access function to set the audit context pointer for the task rather than reaching directly into the task struct to set it. Signed-off-by: Richard Guy Briggs --- include/linux/audit.h | 8 ++++++++ kernel/auditsc.c | 6 +++--- kernel/fork.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 93e4c61..dba0d45 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -235,6 +235,10 @@ extern void __audit_inode_child(struct inode *parent, extern void __audit_seccomp(unsigned long syscall, long signr, int code); extern void __audit_ptrace(struct task_struct *t); +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) +{ + task->audit_context = ctx; +} static inline struct audit_context *audit_context(struct task_struct *task) { return task->audit_context; @@ -472,6 +476,10 @@ static inline bool audit_dummy_context(void) { return true; } +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) +{ + task->audit_context = ctx; +} static inline struct audit_context *audit_context(struct task_struct *task) { return NULL; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index a4bbdcc..f294e4a 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -865,7 +865,7 @@ static inline struct audit_context *audit_take_context(struct task_struct *tsk, audit_filter_inodes(tsk, context); } - tsk->audit_context = NULL; + audit_set_context(tsk, NULL); return context; } @@ -952,7 +952,7 @@ int audit_alloc(struct task_struct *tsk) } context->filterkey = key; - tsk->audit_context = context; + audit_set_context(tsk, context); set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT); return 0; } @@ -1590,7 +1590,7 @@ void __audit_syscall_exit(int success, long return_code) kfree(context->filterkey); context->filterkey = NULL; } - tsk->audit_context = context; + audit_set_context(tsk, context); } static inline void handle_one(const struct inode *inode) diff --git a/kernel/fork.c b/kernel/fork.c index 242c8c9..cd18448 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1713,7 +1713,7 @@ static __latent_entropy struct task_struct *copy_process( p->start_time = ktime_get_ns(); p->real_start_time = ktime_get_boot_ns(); p->io_context = NULL; - p->audit_context = NULL; + audit_set_context(p, NULL); cgroup_fork(p); #ifdef CONFIG_NUMA p->mempolicy = mpol_dup(p->mempolicy); -- 1.8.3.1