Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp917728ybb; Fri, 3 Apr 2020 14:23:32 -0700 (PDT) X-Google-Smtp-Source: APiQypI+Rka0hUYFA2/iCkAvabTM8i9QUiUwFMQoFYhptYhwTZie3Jt/OXtvSAZKqOkJgSxRurWt X-Received: by 2002:a9d:6e02:: with SMTP id e2mr8245731otr.317.1585949012259; Fri, 03 Apr 2020 14:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585949012; cv=none; d=google.com; s=arc-20160816; b=hd0/0KoQ261QWuZf+Vpmex6BFZGE5f/arbM8cw1osbQv4iOAOolQFNhauqwP5yp/RB EhPunT23nZHcSV2M89HgIwmbyLptE3R/W2LJkDfrikd/fDehblBbwY+uFqI7I9fNk8Au G4JmaYFdqQ3CooabvLPS2Cm9E8rjGKbsmq6x9RBZ7O6L7h0ZSw2+oSi3NclfFGwQecLP jcirA14WbBk4h4bLLZFpESLXnO5uNB/TSa1KmF4r6J18fpOh8pr2LJfA5E6cl3ebiRpn mr9r5ChtTn3pgy3ip2lILuIIOOuwy3gcuzITYj9B0q17lytejrQ8szXwKBzIAZIekWf6 Xjlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lPxdH1JXe7h2gPkmS5oPinAisRrZCpEB3AZHI2P5ejM=; b=AkSukKx7VJkrSKzMZT4L2JVejoxvBDuUHcYBczNJdkXt3TU/LtkHYJvxnTC4EkfFeb glZNH5eeIX91UFIL6HGQALLV0oo4EEXtLijZAPQTe/ClrTER3QUhoSpXNL3wy8Vp/oRg P97dE2f4eNpSCTSntBxSoqqf6OG2UjYmko6V3m5gixL8ks9MVlsBv/bX+rNe/RjN/7FO 3cp1W2rVKy/XdoML1ItZ/OHpdnXCV2Y3FGN6CkWLYzTHcBkeftLuLqsVIonW2tc18EL7 7TXJuEnH5CAKZAJ7H4uLV7kXsJm4WZyJJVs2WFaDG8uHSf3PES2o8+mnPVVV37FxdNpx ZwCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uyr9ebEV; 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=pass (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 a185si4180115oii.252.2020.04.03.14.23.10; Fri, 03 Apr 2020 14:23:32 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uyr9ebEV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbgDCVWH (ORCPT + 99 others); Fri, 3 Apr 2020 17:22:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24712 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727958AbgDCVWH (ORCPT ); Fri, 3 Apr 2020 17:22:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585948926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lPxdH1JXe7h2gPkmS5oPinAisRrZCpEB3AZHI2P5ejM=; b=Uyr9ebEVXj09NjtzZU2ORoisaWWFTREneW7C+yB21bE5TNu+CcTASTJWTynk8ulS374sev /m/uW5eFkpgJ73CsaSxBr9jxfGqb5PJPrwFV4b8nhbr2i2rt03rZCMaH98D0brijXG3x0m 0NfDow8QUTOq0LGkLZ/yrY6IS4X6OOY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-eunYrKpcOoiRPxIDITrryw-1; Fri, 03 Apr 2020 17:21:59 -0400 X-MC-Unique: eunYrKpcOoiRPxIDITrryw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A54211005509; Fri, 3 Apr 2020 21:21:54 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.3.128.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 363DD26DF1; Fri, 3 Apr 2020 21:21:41 +0000 (UTC) Date: Fri, 3 Apr 2020 17:21:38 -0400 From: Richard Guy Briggs To: Amol Grover Cc: Paul Moore , Juri Lelli , Peter Zijlstra , David Howells , Joel Fernandes , Vincent Guittot , James Morris , Madhuparna Bhowmik , Ingo Molnar , Mel Gorman , linux-kernel-mentees@lists.linuxfoundation.org, "Paul E . McKenney" , Jann Horn , Steven Rostedt , Shakeel Butt , Thomas Gleixner , Dietmar Eggemann , Ben Segall , linux-kernel@vger.kernel.org, linux-audit@redhat.com, "Eric W . Biederman" , Andrew Morton Subject: Re: [PATCH 3/3 RESEND] auditsc: Do not use RCU primitive to read from cred pointer Message-ID: <20200403212138.kr72jr57ppzsv6rm@madcap2.tricolour.ca> References: <20200402055640.6677-1-frextrite@gmail.com> <20200402055640.6677-3-frextrite@gmail.com> <20200403075613.GA2788@workstation-portable> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200403075613.GA2788@workstation-portable> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-03 13:26, Amol Grover wrote: > On Thu, Apr 02, 2020 at 08:56:36AM -0400, Paul Moore wrote: > > On Thu, Apr 2, 2020 at 1:57 AM 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(-) > > > > This is the exact same patch I ACK'd back in February, yes? > > > > https://lore.kernel.org/linux-audit/CAHC9VhQCbg1V290bYEZM+izDPRpr=XYXakohnDaMphkBBFgUaA@mail.gmail.com > > > > Hi Paul, > > That's correct. I've resend the series out of the fear that the first 2 > patches might've gotten lost as it's been almost a month since I last > sent them. Could you please ack this again, and if you don't mind could > you please go through the other 2 patches and ack them aswell? Via who's tree are you expecting this will make it upstream? > Thanks > Amol > > > > 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 - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635