From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nHARS-0002Lk-O4 for mharc-grub-devel@gnu.org; Mon, 07 Feb 2022 15:16:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHARQ-0002La-R8 for grub-devel@gnu.org; Mon, 07 Feb 2022 15:16:52 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23080 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHARN-0000uv-1l for grub-devel@gnu.org; Mon, 07 Feb 2022 15:16:52 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 217JQ86c011424; Mon, 7 Feb 2022 20:16:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : reply-to : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=LgPFGU7ejf6f2VfBDPsZ6TE8q9oE7vXYm/whmwYz9Ts=; b=saCDksUKHR/E1ObbkPWWzwsK5rWM60YWPV8xU35BCJm6W+Y1VVH1G2RotLeoZg++3QLl 0n2AQs/+ADWi6ZNQAekNeWmQAkmMi5qzkwJDK+foEuz+xIu8e0AJp1F4BKV4ktT059xb qihA6oDGbq0uIqfqtX7sG9HQMIfVVk0hyRfTkPmGm6YaSB+tNArVw2E2TNCSUyHSBzwt P0lWbVmYaBYs4u3hAYpuzbfhM8oudc59TEbJZuDUmpuYwEBlsjshQSkwTlNd16sw6fk4 9XI8hK4nxeCENq73LCoXnbsbzuT3VVvs2eTNUYnYYuxJmGhKrGViNDMDCWr0oK9Zq56B gA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e22nkdsw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Feb 2022 20:16:42 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 217Jxoqn031136; Mon, 7 Feb 2022 20:16:42 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e22nkdsvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Feb 2022 20:16:42 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 217JvfGT018202; Mon, 7 Feb 2022 20:16:41 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01wdc.us.ibm.com with ESMTP id 3e1gv9w267-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Feb 2022 20:16:41 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 217KGbE016319018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Feb 2022 20:16:37 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FB027805C; Mon, 7 Feb 2022 20:16:37 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6161978063; Mon, 7 Feb 2022 20:16:35 +0000 (GMT) Received: from jarvis.int.hansenpartnership.com (unknown [9.211.78.81]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 7 Feb 2022 20:16:35 +0000 (GMT) Message-ID: <7a34c9c29c0bb8aae8a5ca4fc9063690df9b8464.camel@linux.ibm.com> Subject: Re: [PATCH v4 2/2] efi: Add API for retrieving the EFI secret for cryptodisk From: James Bottomley Reply-To: jejb@linux.ibm.com To: The development of GNU GRUB Cc: thomas.lendacky@amd.com, ashish.kalra@amd.com, brijesh.singh@amd.com, david.kaplan@amd.com, jon.grimm@amd.com, tobin@ibm.com, frankeh@us.ibm.com, dovmurik@linux.vnet.ibm.com, Dov.Murik1@il.ibm.com, Javier Martinez Canillas , GNUtoo@cyberdimension.org, ps@pks.im, development@efficientek.com, Daniel Kiper Date: Mon, 07 Feb 2022 15:16:34 -0500 In-Reply-To: References: <20220207152944.27183-1-jejb@linux.ibm.com> <20220207152944.27183-3-jejb@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8juKw6CcJwxU1-j889GGn6gQzTse5GqL X-Proofpoint-ORIG-GUID: 8QhLCavgg2Cn6A6HixXKnbtLNTXGXwLn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-07_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202070118 Received-SPF: pass client-ip=148.163.158.5; envelope-from=jejb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Feb 2022 20:16:53 -0000 On Mon, 2022-02-07 at 17:00 +0000, Dr. David Alan Gilbert wrote: > * James Bottomley (jejb@linux.ibm.com) wrote: [...] > > +static grub_err_t > > +grub_efi_secret_put (const char *arg __attribute__((unused)), int > > have_it, > > + grub_uint8_t **ptr) > > +{ > > + struct secret_entry *e = (struct secret_entry *)(*ptr - > > (long)&((struct secret_entry *)0)->data); > > use offsetof ? Yes, Dov suggested that as well. I don't really find either form more or less readable, but I can certainly change it. [...] > > +static grub_err_t > > +grub_efi_secret_find (struct efi_secret *s, grub_uint8_t > > **secret_ptr) > > +{ > > + int len; > > + struct secret_header *h; > > + struct secret_entry *e; > > + unsigned char *ptr = (unsigned char *)(unsigned long)s->base; > > + > > + /* the area must be big enough for a guid and a u32 length */ > > + if (s->size < sizeof (*h)) > > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "EFI secret area is > > too small"); > > + > > + h = (struct secret_header *)ptr; > > + if (grub_memcmp(&h->guid, &tableheader_guid, sizeof (h->guid))) > > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "EFI secret area > > does not start with correct guid\n"); > > + if (h->len < sizeof (*h)) > > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "EFI secret area is > > too small\n"); > > These grub_error calls (and a couple later) are terminated using a \n > which I don't think you want. That does seem to be consistent with the rest. I note I didn't see an extra \n in testing, but I bet something in grub eats it. James