Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jEfHq-0003iN-6L for mharc-grub-devel@gnu.org; Wed, 18 Mar 2020 16:27:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58350) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEfHn-0003b7-1X for grub-devel@gnu.org; Wed, 18 Mar 2020 16:27:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEfHl-0006Ip-JJ for grub-devel@gnu.org; Wed, 18 Mar 2020 16:27:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEfHl-0006Bo-A6 for grub-devel@gnu.org; Wed, 18 Mar 2020 16:27:29 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IK3bUG114338; Wed, 18 Mar 2020 16:27:27 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yu8bs06hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 16:27:27 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02IK53of032491; Wed, 18 Mar 2020 20:27:26 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 2yrpw6uwu6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 20:27:26 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02IKRPGa46399800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Mar 2020 20:27:25 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84BBFBE053; Wed, 18 Mar 2020 20:27:25 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 514BFBE04F; Wed, 18 Mar 2020 20:27:25 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 18 Mar 2020 20:27:25 +0000 (GMT) Subject: Re: Verifier running out of memory on ieee1275/powerpc64 From: Stefan Berger To: The development of GNU GRUB , Simon Hardy Reply-To: The development of GNU GRUB References: <20200318155906.GC2186@itdev.co.uk> <7ba9fa0c-75ad-e3c7-77ab-08b983ccae30@linux.ibm.com> Message-ID: <8066faa6-3879-91a2-80c6-c5ca6c753a7b@linux.ibm.com> Date: Wed, 18 Mar 2020 16:27:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <7ba9fa0c-75ad-e3c7-77ab-08b983ccae30@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_07:2020-03-18, 2020-03-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003180087 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id 02IK3bUG114338 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 20:27:32 -0000 On 3/18/20 3:32 PM, Stefan Berger wrote: > On 3/18/20 11:59 AM, Simon Hardy wrote: >> The 2020/03/17 13:15, Stefan Berger wrote: >>> =C2=A0=C2=A0I trying to add (v)TPM support for the ieee1275/powerpc64= platform=20 >>> to grub. >>> The issue I have been running into is that the verifier runs out of=20 >>> memory. >>> At that point it has loaded the (~ 32MB) Linux kernel and now the=20 >>> verifier >>> is invoked to load the file. Unfortunately it cannot load the file=20 >>> since it >>> doesn't have enough memory to grub_malloc. I have played with=20 >>> increasing >>> heap size(es) but it still doesn't work. The kernel and initramfs=20 >>> files on >>> ppc64 can be rather big, thus we do not a lot of memory. The rescue >>> initramfs here is for example 78MB, a regular initramfs from Fedora=20 >>> 31 is >>> ~34MB. The kernel sizes on my system are 32MB, though a colleague=20 >>> was using >>> an unstripped kernel of 127MB, so lots of (unfragmented) memory=20 >>> needs to be >>> available to run verifiers. >> The verifiers framework has a flag, GRUB_VERIFY_FLAGS_SINGLE_CHUNK,=20 >> that is >> used by the platform-independent TPM module. This could be deferred=20 >> to the >> platform-specific TPM file (see point 3 below). With this flag unset=20 >> for your >> platform, you could verify the files in small chunks. This requires=20 >> three >> further elements: >> >> 1. You will need to implement the chunk-by-chunk behaviour in >> verifiers.c, it doesn't exist yet. >> >> 2. You will need to add functionality to calculate a hash from=20 >> chunks, or >> require that the crypto module is built into the core. >> >> 3. The firmware interface needs to support HashLogExtend with a user=20 >> supplied >> hash instead of a memory buffer. For example the PC Conventional BIOS=20 >> API has >> this, but the UEFI API does not. > > Simon, thanks a lot for your reply. > > TPM 2's logging behavior is different than that of a TPM 1.2 and it's=20 > not clear whether hashing in grub will produce the right hash or=20 > hashes (for different PCR banks) as needed by the firmware. I would=20 > rather leave the hashing entirely up to the firmware because it knows=20 > which PCR banks are activate and what hashes it wants to use for=20 > logging and PCR extending. > > I was wondering whether it would not be possible to load the raw file=20 > into memory, pass it to the firmware for hashing (and logging) via the=20 > verifier, and if we do not trust that the firmware treated the file=20 > data as a read-only array, load the file again into the same array=20 > right after. This way we wouldn't need more memory. [*] However, I am=20 > not sure how it fits into the architecture with the verifiers or=20 > whether the TPM verifier would have to take on a special role=20 > (possibly with a flag) then. > > You didn't pick up on the idea of a bigger heap. Is there a problem=20 > with the heap size somehow? My machine has GBs of memory, so it really=20 > shouldn't be a problem to get memory. I think that's the problem to solve, at least for this platform, since=20 none of the verifiers will work due to the memory exhaustion issue. =C2=A0=C2=A0 Stefan