From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C79D1C2D0D1 for ; Thu, 19 Dec 2019 16:55:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91D762146E for ; Thu, 19 Dec 2019 16:55:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="qLPJLn14" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726964AbfLSQzn (ORCPT ); Thu, 19 Dec 2019 11:55:43 -0500 Received: from linux.microsoft.com ([13.77.154.182]:36414 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbfLSQzn (ORCPT ); Thu, 19 Dec 2019 11:55:43 -0500 Received: from [10.137.112.108] (unknown [131.107.174.108]) by linux.microsoft.com (Postfix) with ESMTPSA id 9CC722010C1D; Thu, 19 Dec 2019 08:55:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9CC722010C1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1576774542; bh=so8Lx2f9qiSk/E4NI0zuLpTEaSOcPtfK6N+bkOqOOB4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=qLPJLn14e7anO0rCxRsxhWetAEhf5ceGYmYUiNFt/vFImvPItk4dDaGbMUKp+W5TT j62KZcJFE9Rz5VOdwEttZ2tvSN7r5472TJCbWOL8P4QGMYSO4hzccTjNJdZkOM0JTE U2tzdpO+LfCoT4TfP5gYn/zMKw9ll+d9xrfGHCvU= Subject: Re: [PATCH v5 1/2] IMA: Define workqueue for early boot "key" measurements To: Mimi Zohar , James.Bottomley@HansenPartnership.com, linux-integrity@vger.kernel.org Cc: eric.snowberg@oracle.com, dhowells@redhat.com, mathew.j.martineau@linux.intel.com, matthewgarrett@google.com, sashal@kernel.org, jamorris@linux.microsoft.com, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org References: <20191218164434.2877-1-nramas@linux.microsoft.com> <20191218164434.2877-2-nramas@linux.microsoft.com> <1576761104.4579.426.camel@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: <503845c9-beeb-b520-ec3f-af5fa7d2b91f@linux.microsoft.com> Date: Thu, 19 Dec 2019 08:55:38 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <1576761104.4579.426.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/19/19 5:11 AM, Mimi Zohar wrote: > > Getting rid of the temporary list is definitely a big improvement.  As > James suggested, using test_and_set_bit() and test_bit() would improve > this code even more.  I think, James correct me if I'm wrong, you > would be able to get rid of both the mutex and "process". > > Mimi I am not sure if the mutex can be removed. In ima_queue_key() we need to test the flag and add the key to the list as an atomic operation: if (!test_bit()) insert_key_to_list Suppose the if condition is true, but before we could insert the key to the list, ima_process_queued_keys() runs and processes queued keys we'll add the key to the list and never process it. Is there an API in the kernel to test and add an entry to a list atomically? thanks, -lakshmi