From patchwork Tue Sep 4 16:06:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10587577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8682714BD for ; Tue, 4 Sep 2018 16:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 831C3294B2 for ; Tue, 4 Sep 2018 16:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76BBC29DC7; Tue, 4 Sep 2018 16:06:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B8C8294B2 for ; Tue, 4 Sep 2018 16:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbeIDUcc (ORCPT ); Tue, 4 Sep 2018 16:32:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:54688 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727793AbeIDUcb (ORCPT ); Tue, 4 Sep 2018 16:32:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CE98DB0C4; Tue, 4 Sep 2018 16:06:42 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4626D1E3619; Tue, 4 Sep 2018 18:06:41 +0200 (CEST) From: Jan Kara To: Paul Moore Cc: Al Viro , linux-audit@redhat.com, , rgb@redhat.com, Amir Goldstein , Jan Kara Subject: [PATCH 08/11] audit: Provide helper for dropping mark's chunk reference Date: Tue, 4 Sep 2018 18:06:28 +0200 Message-Id: <20180904160632.21210-9-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180904160632.21210-1-jack@suse.cz> References: <20180904160632.21210-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Provide a helper function audit_mark_put_chunk() for dropping mark's reference (which has to happen only after RCU grace period expires). Currently that happens only from a single place but in later patches we introduce more callers. Signed-off-by: Jan Kara --- kernel/audit_tree.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index af91b0d33478..0cd08b3581f1 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c @@ -132,10 +132,20 @@ static void __put_chunk(struct rcu_head *rcu) audit_put_chunk(chunk); } +/* + * Drop reference to the chunk that was held by the mark. This is the reference + * that gets dropped after we've removed the chunk from the hash table and we + * use it to make sure chunk cannot be freed before RCU grace period expires. + */ +static void audit_mark_put_chunk(struct audit_chunk *chunk) +{ + call_rcu(&chunk->head, __put_chunk); +} + static void audit_tree_destroy_watch(struct fsnotify_mark *entry) { struct audit_chunk *chunk = container_of(entry, struct audit_chunk, mark); - call_rcu(&chunk->head, __put_chunk); + audit_mark_put_chunk(chunk); } static struct audit_chunk *alloc_chunk(int count)