Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5089651ybv; Tue, 11 Feb 2020 09:00:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyk2O6e1uH5yyIhO62BdC+JkAAyZ7soEkJhlAsIJA31/QD86Tm4JSNoI62XmnSMwV4vLIa3 X-Received: by 2002:a9d:6289:: with SMTP id x9mr6122956otk.8.1581440442763; Tue, 11 Feb 2020 09:00:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581440442; cv=none; d=google.com; s=arc-20160816; b=IAs+vQ74Y+XN/cyglqxmeDSYSAx/rplxYf7KF/NkAfTor7ce4PIuaF37OR1ZTEbB1q 50Ef7zjcJUu8LmRhQcQx1IQ63kwQz5PZMGxkzdDh1SS4dwmcwsa+iSifydSmtDJyNSB9 hbw7bA2nVmXcGOp7A/jv8ngo7tq2syakNeOVPbna2UU1FvVPvIshl1+ytpLqyYcVwkba AV2ap5GwVulNy3SCdDlLFrNAfArlzTCBzoAWMOlnBX6iZ+NGybeSjxN7rARRbVnOy5UC 7i9JkpGbacKnQ9fRZBawlrtzZjEsp9jViY05Jg5GpvJ/NSKKPaaKL6xnVcJA6u6VwiRD 0H3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=16SLjLXO8g+qbOwDjgyf7x2FsF2pVisv4jB570F5ilM=; b=sgyW2EcV+sX4P/0ZgpB9uXKv2BCODGk6iHga8aiQJmWuiq6GxVcyKz0l16exEfg7PJ QP9WSkcly3EtIs4BHCki+qJ1rvGoC0BlQloCXVc7UIlC0VMLJ9XSultrmJ4xXKOYazAu Ct6UX2Wx2udaQIjvhJIUppQ4ptdt+z01/GtVwgbYWE5Sd21pcASCRt+ACyDgDvyJQWqJ yC08I+l2HVNpObnyOprESYJi9BSw5Kdvn3NetRSIEXn4Nbxbwm+2AQYInNV1uz+ekUTD +ZlFy4h2jg2P9RgE/s+zDWGEN0UvJnceXJkqlKO3qVRsMjfZhyRoa0BvqclK9tlk0WOo DAZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=aSuu2DmL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q124si1965580oig.228.2020.02.11.09.00.29; Tue, 11 Feb 2020 09:00:42 -0800 (PST) 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; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=aSuu2DmL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729210AbgBKPTS (ORCPT + 99 others); Tue, 11 Feb 2020 10:19:18 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38949 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728563AbgBKPTS (ORCPT ); Tue, 11 Feb 2020 10:19:18 -0500 Received: by mail-ed1-f66.google.com with SMTP id m13so5078397edb.6 for ; Tue, 11 Feb 2020 07:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=16SLjLXO8g+qbOwDjgyf7x2FsF2pVisv4jB570F5ilM=; b=aSuu2DmLP5BGoZWIgkKNcdwUhKU6htHEo28BK6My4sj4kupO+Haz8DWn2OJVKhqIO/ SdrQuM5vRc0nDFTBEL+8R8MUhNIUGFrMWJT/BEDG5aIFpN8ffqvbBheaJPJqYQzPbIYG n67kIIUgWE0UkPxGo1Awiw7KRWecWqPJuGG1buEU2AuosK3U9CpDBIQajtQSfeq9aOSu O+bf2+7XrxM/+AWzlli5bcNGowACJ3Jk3RXRtNM5KgjWB2CUwGTL5JHpswlckqjXNVUE HUkGmprWvNphy3WJ64vrFxZQIf+6daO1KpvE06jgb4Y9GqSJsS2Bc9ESCc4O6LTIvT3K bqSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=16SLjLXO8g+qbOwDjgyf7x2FsF2pVisv4jB570F5ilM=; b=TtlFNj8Df7SEr14RNMmBV96n6Z8IU0QMYRuq7NxD2dx0fezMuvJ5NOcZihUm+VTM4j o1Ne3YlwAmZ0lSC9C6r7IoysTk4LLuihErcKGV2z9Ad3HJS8mo8g5fsNRDozrW63KrMh rBCNO08h8Xi1fEtT6RBxcXQ4wGNCxB9asm/pbu/S18CE6sykfv+j0CctHfCqOshs2Dg5 45bgXR7xacfM2+4rOnC3aQ9dBDVNxoTZM51NqEPqrYizppsxiOKGZph7LAbH5nyq+ycv fnPKE+Fdf2cdP+e2mRjCSm2mpB+xz7CiTvpXUup7fu/ongtUylf8TFnDmzqhFW/FX8sf fpgA== X-Gm-Message-State: APjAAAX0Cv1p0WFNXeJIosxnTYSqFVzD/0uK82CrM6chbyOXGyzdK87a gBRcl9Ndu+9XPrcXEFT/HGhoWSfAJSLF3B0Ak0NO X-Received: by 2002:a05:6402:61a:: with SMTP id n26mr5926242edv.135.1581434355583; Tue, 11 Feb 2020 07:19:15 -0800 (PST) MIME-Version: 1.0 References: <20200207180504.4200-1-frextrite@gmail.com> <20200207180504.4200-3-frextrite@gmail.com> In-Reply-To: <20200207180504.4200-3-frextrite@gmail.com> From: Paul Moore Date: Tue, 11 Feb 2020 10:19:04 -0500 Message-ID: Subject: Re: [PATCH 3/3] auditsc: Do not use RCU primitive to read from cred pointer To: Amol Grover Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , James Morris , Thomas Gleixner , Jann Horn , David Howells , Shakeel Butt , "Eric W . Biederman" , Andrew Morton , Eric Paris , linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 7, 2020 at 1:08 PM Amol Grover wrote: > > task_struct::cred is only used task-synchronously and does > not require any RCU locks, hence, rcu_dereference_check is > not required to read from it. > > Suggested-by: Jann Horn > Co-developed-by: Joel Fernandes (Google) > Signed-off-by: Joel Fernandes (Google) > Signed-off-by: Amol Grover > --- > kernel/auditsc.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) Considering the other changes in this patchset this change seems reasonable to me. I'm assuming you were intending this patchset to go in via some tree other than audit? Acked-by: Paul Moore > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > index 4effe01ebbe2..d3510513cdd1 100644 > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -430,24 +430,19 @@ static int audit_field_compare(struct task_struct *tsk, > /* Determine if any context name data matches a rule's watch data */ > /* Compare a task_struct with an audit_rule. Return 1 on match, 0 > * otherwise. > - * > - * If task_creation is true, this is an explicit indication that we are > - * filtering a task rule at task creation time. This and tsk == current are > - * the only situations where tsk->cred may be accessed without an rcu read lock. > */ > static int audit_filter_rules(struct task_struct *tsk, > struct audit_krule *rule, > struct audit_context *ctx, > struct audit_names *name, > - enum audit_state *state, > - bool task_creation) > + enum audit_state *state) > { > const struct cred *cred; > int i, need_sid = 1; > u32 sid; > unsigned int sessionid; > > - cred = rcu_dereference_check(tsk->cred, tsk == current || task_creation); > + cred = tsk->cred; > > for (i = 0; i < rule->field_count; i++) { > struct audit_field *f = &rule->fields[i]; > @@ -745,7 +740,7 @@ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key) > rcu_read_lock(); > list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) { > if (audit_filter_rules(tsk, &e->rule, NULL, NULL, > - &state, true)) { > + &state)) { > if (state == AUDIT_RECORD_CONTEXT) > *key = kstrdup(e->rule.filterkey, GFP_ATOMIC); > rcu_read_unlock(); > @@ -791,7 +786,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, > list_for_each_entry_rcu(e, list, list) { > if (audit_in_mask(&e->rule, ctx->major) && > audit_filter_rules(tsk, &e->rule, ctx, NULL, > - &state, false)) { > + &state)) { > rcu_read_unlock(); > ctx->current_state = state; > return state; > @@ -815,7 +810,7 @@ static int audit_filter_inode_name(struct task_struct *tsk, > > list_for_each_entry_rcu(e, list, list) { > if (audit_in_mask(&e->rule, ctx->major) && > - audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) { > + audit_filter_rules(tsk, &e->rule, ctx, n, &state)) { > ctx->current_state = state; > return 1; > } > -- > 2.24.1 > -- paul moore www.paul-moore.com