Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp326209ybl; Thu, 12 Dec 2019 19:14:52 -0800 (PST) X-Google-Smtp-Source: APXvYqybaIn4NS6hp2fQ1sL3sHsjdUsK/XMRduY/bYlirnjpYKArXHTUE3Lk59iYB3n/9WZQP0vU X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr12513808oto.30.1576206892034; Thu, 12 Dec 2019 19:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576206892; cv=none; d=google.com; s=arc-20160816; b=mkMqpk76735uSD44wc4vz07JVoMAQJZI/T+pN1otsntClcTtq/Dg2VN2xQ747D9Jcs radxzdbBbOivO83y9087hDoBS4PxxAwHBJnuYj6UrYtditUioRVaozpOWuOK0+OgSaLs /lNBioEpUbUCqNV7IUnBQgbgCt5T/DkkDubIza3dMo0p8GwxTFCbfSE55LidQ4agdxkK 8Yu4UQ8tUAjGzGhqUeXqFDsMi+A+/YDnphCc9rfLUQmEbw5vOY1GoD+xSFabP/KyOt7O CMTOP9nVJZpTXP6mplwBuHShNP2zLEISwvg4qVrvNybnw/AJ/w+OlDUYNN4RpcVPr7KG nn5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=YxXTmKallgLBW7/eDWy6Lx19SJtawJZqEYTFJolyfhY=; b=U05ThSADSCYC/dOJQIF1px30sPIbO5petOvUEQ6lu180ExPsL0Fqzk70OZOIbPAhzi w5tjhdwMPB9ACuTGiO0JORRYXoEPhWxqWtYwP+kKAgVgoPT4HnBoX3xiGhT/tD0vGc0M 2wVNMnF//XvzxSttOBJhZhJTWVPqoOKm5yL+um04JL1jq7mfg2r5qnKFux4cbJLeezgU 9ILNt16Via4lovMWomiM8glYUqD5LmXKlidKO5gKuxQeP+qT0FHiwy3uNOeKPYRTCyWv sH4Pb6WvUct/z+a9sCwMB2G+O1xwKp3Qg7ziYuXpno7695vsnGZ2J3evncp5aoRReRZp LS2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=CNuTiTMq; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si4765148otq.144.2019.12.12.19.14.39; Thu, 12 Dec 2019 19:14:52 -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=@linux.microsoft.com header.s=default header.b=CNuTiTMq; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731897AbfLMB7Q (ORCPT + 99 others); Thu, 12 Dec 2019 20:59:16 -0500 Received: from linux.microsoft.com ([13.77.154.182]:48632 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbfLMB7Q (ORCPT ); Thu, 12 Dec 2019 20:59:16 -0500 Received: from [10.137.112.108] (unknown [131.107.174.108]) by linux.microsoft.com (Postfix) with ESMTPSA id 61D2F20B7187; Thu, 12 Dec 2019 17:59:15 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 61D2F20B7187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1576202355; bh=YxXTmKallgLBW7/eDWy6Lx19SJtawJZqEYTFJolyfhY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=CNuTiTMqkeQ2MswdQVXysPfvcdmZ2cNrJnYYqac+2rU02Wh60moR8u+XAW6oERWIe v2fUa6G0XMEN6ITGO38tGW8Vl6yhrvEshMCKRT4PYPb6zoMhiQ3eEZbGWXgU6IIiQk dXAYW0MEXYLtWnF6XiHmz0Dw4ImpveaIdcZU597w= Subject: Re: [PATCH v3 1/2] IMA: Define workqueue for early boot "key" measurements To: Mimi Zohar , 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: <20191213004250.21132-1-nramas@linux.microsoft.com> <20191213004250.21132-2-nramas@linux.microsoft.com> <1576202134.4579.189.camel@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: <6e0dad33-66f9-4807-d08d-ff30396cec5e@linux.microsoft.com> Date: Thu, 12 Dec 2019 17:59:11 -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: <1576202134.4579.189.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/12/19 5:55 PM, Mimi Zohar wrote: >> +/* >> + * ima_process_queued_keys() - process keys queued for measurement >> + * >> + * This function sets ima_process_keys to true and processes queued keys. >> + * From here on keys will be processed right away (not queued). >> + */ >> +void ima_process_queued_keys(void) >> +{ >> + struct ima_key_entry *entry, *tmp; >> + LIST_HEAD(temp_ima_keys); >> + >> + if (ima_process_keys) >> + return; >> + >> + /* >> + * To avoid holding the mutex when processing queued keys, >> + * transfer the queued keys with the mutex held to a temp list, >> + * release the mutex, and then process the queued keys from >> + * the temp list. >> + * >> + * Since ima_process_keys is set to true, any new key will be >> + * processed immediately and not be queued. >> + */ >> + INIT_LIST_HEAD(&temp_ima_keys); >> + >> + mutex_lock(&ima_keys_mutex); > > Don't you need a test here, before setting ima_process_keys? > > if (ima_process_keys) > return; > > Mimi That check is done before the comment - at the start of ima_process_queued_keys(). +void ima_process_queued_keys(void) +{ + struct ima_key_entry *entry, *tmp; + LIST_HEAD(temp_ima_keys); + + if (ima_process_keys) + return; thanks, -lakshmi