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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9054EB64DC for ; Tue, 11 Jul 2023 17:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjGKR7M (ORCPT ); Tue, 11 Jul 2023 13:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbjGKR7L (ORCPT ); Tue, 11 Jul 2023 13:59:11 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A75F810EF for ; Tue, 11 Jul 2023 10:59:10 -0700 (PDT) Received: from [192.168.87.36] (c-98-237-170-177.hsd1.wa.comcast.net [98.237.170.177]) by linux.microsoft.com (Postfix) with ESMTPSA id F14F721C3A86; Tue, 11 Jul 2023 10:59:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F14F721C3A86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1689098350; bh=WSjxDjeKuh5YC4rclUlKkaHpQJmUGwQ/LPglD0lAajY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OOLpHPQ74J0/O6dlN6YUBT8yhJPxTahq8fK6vLAO9dDTS1LS0aF8OdHH7LDA+8Xxi 4KHrLIK+f/81HZ29Bxx/pu1wHQ8aN/iM+tTXV7rdqTgdWmx6fJsb/qvFIc2Hmhhpke wShAU6RiKyaBW34uQRPtE1cHbaMIBA8stWK+3E2w= Message-ID: <31eb2a9c-7410-b655-43d2-3b2966d2d3da@linux.microsoft.com> Date: Tue, 11 Jul 2023 10:59:07 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 01/10] ima: implement function to allocate buffer at kexec load Content-Language: en-US To: Mimi Zohar , noodles@fb.com, bauermann@kolabnow.com, kexec@lists.infradead.org, linux-integrity@vger.kernel.org Cc: code@tyhicks.com, nramas@linux.microsoft.com, paul@paul-moore.com, Eric Biederman References: <20230703215709.1195644-1-tusharsu@linux.microsoft.com> <20230703215709.1195644-2-tusharsu@linux.microsoft.com> <494dffc6cc7cfb8c6ca78f3bae442d57362a8857.camel@linux.ibm.com> From: Tushar Sugandhi In-Reply-To: <494dffc6cc7cfb8c6ca78f3bae442d57362a8857.camel@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Adding Eric to cc. On 7/7/23 06:00, Mimi Zohar wrote: > Hi Tushar, > > On Mon, 2023-07-03 at 14:57 -0700, Tushar Sugandhi wrote: >> IMA does not provide a mechanism to allocate memory for IMA log storage >> during kexec operation. > The IMA measurement list is currently being carried across kexec, so > obviously a buffer is being allocated for it. IMA not allocating > memory for the measurment list is not the problem statement. Please > concisely provide the problem statement, explaining why IMA needs to > allocate the buffer. > I meant IMA does not provide separate functions to allocate buffer and populate measurements.  Both operations are wrapped in an atomic ima_dump_measurement_list(). As I mentioned in the comment in the cover letter, if there is no such technical limitation to allocate the buffer and copy the measurements at kexec ‘execute’ – I will make the necessary code changes and update the above line in the patch description accordingly. >> The function should handle the scenario where >> the kexec load is called multiple times. > Currently the buffer is being freed with the kexec 'unload'. With this > patch IMA is allocating a buffer for the measurement list, which needs > to be freed independently of the kexec 'unload'. If we end up allocating the buffer at kexec ‘execute’ (which results in soft boot to next Kernel) – is it technically possible that kexec ‘unload’ being called after calling kexec ‘execute’? If not, should I still free the buffer at kexec ‘unload’ in this scenario? ~Tushar >> Implement a function to allocate buffer of size kexec_segment_size at >> kexec load. If the buffer was already allocated, free that buffer and >> reallocate. Finally, initialihze ima_khdr struct. >> >> The patch operates under the assumption that the segment size does not >> change between kexec load and execute. >> >> Signed-off-by: Tushar Sugandhi 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA9D7EB64DC for ; Tue, 11 Jul 2023 17:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bFOmis62PzWQ96ZWjqac+GEkkULZOWhGsiC628B5fc0=; b=B4rbRe/R8ru1a6 f67opJUUJzw4V50PcgKYRidJrPKNwQQmhhbCvSi7gm6ZJD987liNN5mLzM21qcE5t2zmtotS/otSJ 3vF4Qy9K9pB7Opty3gnyhFcgTbsyJkhJ3u4SOrahHnqwDHvvWF/5SRpO2KfGPQiB+BCIRnneMluAW fQQyQpEnHnnXNApkwQHETPb+Fte6FD/vBMOR5LwSOMqTeGMPJeqLKvIew3sAToLfDJhEps2xGudfy 4BghnwvYJMTp/VL2O1R7+czgKc3hJSZ0pAnvUE1oQDDMQAQOwdT8uLDce4CwyTKCh7BbfW5JqkyIC +CqA31vz/VfDGysZnh9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJHdp-00FbdX-1b; Tue, 11 Jul 2023 17:59:13 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJHdn-00Fbcx-0J for kexec@lists.infradead.org; Tue, 11 Jul 2023 17:59:12 +0000 Received: from [192.168.87.36] (c-98-237-170-177.hsd1.wa.comcast.net [98.237.170.177]) by linux.microsoft.com (Postfix) with ESMTPSA id F14F721C3A86; Tue, 11 Jul 2023 10:59:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F14F721C3A86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1689098350; bh=WSjxDjeKuh5YC4rclUlKkaHpQJmUGwQ/LPglD0lAajY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OOLpHPQ74J0/O6dlN6YUBT8yhJPxTahq8fK6vLAO9dDTS1LS0aF8OdHH7LDA+8Xxi 4KHrLIK+f/81HZ29Bxx/pu1wHQ8aN/iM+tTXV7rdqTgdWmx6fJsb/qvFIc2Hmhhpke wShAU6RiKyaBW34uQRPtE1cHbaMIBA8stWK+3E2w= Message-ID: <31eb2a9c-7410-b655-43d2-3b2966d2d3da@linux.microsoft.com> Date: Tue, 11 Jul 2023 10:59:07 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 01/10] ima: implement function to allocate buffer at kexec load Content-Language: en-US To: Mimi Zohar , noodles@fb.com, bauermann@kolabnow.com, kexec@lists.infradead.org, linux-integrity@vger.kernel.org Cc: code@tyhicks.com, nramas@linux.microsoft.com, paul@paul-moore.com, Eric Biederman References: <20230703215709.1195644-1-tusharsu@linux.microsoft.com> <20230703215709.1195644-2-tusharsu@linux.microsoft.com> <494dffc6cc7cfb8c6ca78f3bae442d57362a8857.camel@linux.ibm.com> From: Tushar Sugandhi In-Reply-To: <494dffc6cc7cfb8c6ca78f3bae442d57362a8857.camel@linux.ibm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230711_105911_158362_08F67648 X-CRM114-Status: GOOD ( 18.04 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org QWRkaW5nIEVyaWMgdG8gY2MuCgpPbiA3LzcvMjMgMDY6MDAsIE1pbWkgWm9oYXIgd3JvdGU6Cj4g SGkgVHVzaGFyLAo+Cj4gT24gTW9uLCAyMDIzLTA3LTAzIGF0IDE0OjU3IC0wNzAwLCBUdXNoYXIg U3VnYW5kaGkgd3JvdGU6Cj4+IElNQSBkb2VzIG5vdCBwcm92aWRlIGEgbWVjaGFuaXNtIHRvIGFs bG9jYXRlIG1lbW9yeSBmb3IgSU1BIGxvZyBzdG9yYWdlCj4+IGR1cmluZyBrZXhlYyBvcGVyYXRp b24uCj4gVGhlIElNQSBtZWFzdXJlbWVudCBsaXN0IGlzIGN1cnJlbnRseSBiZWluZyBjYXJyaWVk IGFjcm9zcyBrZXhlYywgc28KPiBvYnZpb3VzbHkgYSBidWZmZXIgaXMgYmVpbmcgYWxsb2NhdGVk IGZvciBpdC4gIElNQSBub3QgYWxsb2NhdGluZwo+IG1lbW9yeSBmb3IgdGhlIG1lYXN1cm1lbnQg bGlzdCBpcyBub3QgdGhlIHByb2JsZW0gc3RhdGVtZW50LiAgUGxlYXNlCj4gY29uY2lzZWx5IHBy b3ZpZGUgdGhlIHByb2JsZW0gc3RhdGVtZW50LCBleHBsYWluaW5nIHdoeSBJTUEgbmVlZHMgdG8K PiBhbGxvY2F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