From patchwork Tue May 22 14:06:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petko Manolov X-Patchwork-Id: 10418699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F69D6032A for ; Tue, 22 May 2018 14:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF3028CD3 for ; Tue, 22 May 2018 14:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 308CA28CD5; Tue, 22 May 2018 14:07:02 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 83E8628CF5 for ; Tue, 22 May 2018 14:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751229AbeEVOHA (ORCPT ); Tue, 22 May 2018 10:07:00 -0400 Received: from lan.nucleusys.com ([92.247.61.126]:57674 "EHLO zztop.nucleusys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751196AbeEVOG7 (ORCPT ); Tue, 22 May 2018 10:06:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nucleusys.com; s=x; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BfjfXEn8V62+0o2TeeYrbKxKnm6udMlsmLqUWmuuaO4=; b=bhjV6bh41pMbFB3HH/UgyVjmvv oyqm+iQZCFN+K1X6CJLuPHdpHMS4L8TZxzOunX9ajjlCt2vnnOChlInBtFguOV1PrsWATDSVVP5Mr XwKxK6IdWyGEelu8Tt5rBjHt07kAoe87F1Cp+STJWP1OF+JARrISOt5HF0XgIpXGvVKQ=; Received: from 78-83-78-119.spectrumnet.bg ([78.83.78.119] helo=carbon) by zztop.nucleusys.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fL7wF-0008Or-8b; Tue, 22 May 2018 17:06:55 +0300 Date: Tue, 22 May 2018 17:06:55 +0300 From: Petko Manolov To: Mimi Zohar Cc: Linux Integrity Subject: [PATCH] IMA: use list_splice_tail_init_rcu() instead of its open coded variant Message-ID: <20180522140655.GA5794@carbon> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Mimi, Please review and consider this patch for mainlining if it looks OK to you. I've tested it on v4.17.0-rc6 and seems to be working fine. Petko --- From e5cb36d4470cf64af2087fba4615ee8539385c98 Mon Sep 17 00:00:00 2001 From: Petko Manolov Date: Fri, 18 May 2018 14:10:57 +0300 Subject: [PATCH] Replace the open coded version with list_splice_tail_init_rcu() Signed-off-by: Petko Manolov --- security/integrity/ima/ima_policy.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index d89bebf85421..722466f843ef 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -509,22 +509,9 @@ int ima_check_policy(void) */ void ima_update_policy(void) { - struct list_head *first, *last, *policy; + struct list_head *policy = &ima_policy_rules; - /* append current policy with the new rules */ - first = (&ima_temp_rules)->next; - last = (&ima_temp_rules)->prev; - policy = &ima_policy_rules; - - synchronize_rcu(); - - last->next = policy; - rcu_assign_pointer(list_next_rcu(policy->prev), first); - first->prev = policy->prev; - policy->prev = last; - - /* prepare for the next policy rules addition */ - INIT_LIST_HEAD(&ima_temp_rules); + list_splice_tail_init_rcu(&ima_temp_rules, policy, synchronize_rcu); if (ima_rules != policy) { ima_policy_flag = 0;