Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p2BB4-0001aX-2i for mharc-grub-devel@gnu.org; Mon, 05 Dec 2022 08:06:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2BB1-0001Zr-HC for grub-devel@gnu.org; Mon, 05 Dec 2022 08:06:31 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2BAz-0003FB-TB for grub-devel@gnu.org; Mon, 05 Dec 2022 08:06:31 -0500 Received: by mail-pl1-x62d.google.com with SMTP id g10so10713926plo.11 for ; Mon, 05 Dec 2022 05:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/Y6tTPnyXVUjr34qxDvZrSMxJ2cdPj9t4cj7D/Nzce8=; b=PHm9/4+x4wcD6tBsd0oVtGLRQbwfJRQmh9zjd7yoW8ZWEAJvThO4NiyyzefoxJCBBs DdFvYx2bS1dTr1zxZBoXNspLoRtxw95XE9evCNZYz9No/3APHcpXZ5phalRT8UlLFwjE nWUoPCiMrNiHE3SuH78Ng/XssEInzoh6Gw9NZKVuN+p18htrxt/NGvXADCz4j9+lDz0C VygnECUywdklaIw8LUYgJ5t3UYQbjdHgG3FYe2Q9pzD/Go7F1sd6JpTmkUyRbqq2AoK+ xh2NWhhEigqGHt8wsNO6Tcm30waZyh0E9XkYK4Vh+WWhthzFWgy/u69sxdRUMR2ukiIf /VrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Y6tTPnyXVUjr34qxDvZrSMxJ2cdPj9t4cj7D/Nzce8=; b=fBn3IT4TNgt/LI37S0Eg1KJjsxC9ybSi2YRr0naGpaw9C7nzcEpB1pt/ZTjd2cDdt+ 6eThyjRHxRnK9qU+mGLu44OT3wh/08940gYDzV5vwTAnlEuMNrI1KGDRWpiLW6AO7FHW SJz3d2DvZqLoOFMx4EyazhWl6fPrhfivCHLA4g7hRmazt8j6aCSr6dXsd10VOrnY11nD 3tZ5HuZl2GC/5ExADnfLuYYdUms0hTBaJgZlII/+aCvcpWRuwJQLlZkWReBmoYHSgiI+ scFa28lOCGAqUVQzfEMQcYE9rv97g3CM9lARnKcUaqGvNKnv+U573S43ogvvder1VEaR JDlg== X-Gm-Message-State: ANoB5plj7CiZF5T6Bws/m4JpicJdj6ZPWnavlUUauIH4saHL9HIYa49E AyYoqf+Z2tM9P617N7EH+624QLPQthk= X-Google-Smtp-Source: AA0mqf6GtXMOwdTjIPENR5H2IpRmT84opX9Nb2JnBpZl6AMJ/aQ3D56rq52aaN42IXZuLmpho9300w== X-Received: by 2002:a17:902:cecf:b0:189:c02f:c418 with SMTP id d15-20020a170902cecf00b00189c02fc418mr13889866plg.131.1670245585312; Mon, 05 Dec 2022 05:06:25 -0800 (PST) Received: from localhost.localdomain (ec2-13-113-80-70.ap-northeast-1.compute.amazonaws.com. [13.113.80.70]) by smtp.gmail.com with ESMTPSA id ij27-20020a170902ab5b00b00188f7ad561asm10522441plb.249.2022.12.05.05.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 05:06:24 -0800 (PST) From: Zhang Boyang To: grub-devel@gnu.org Cc: steve@einval.com, rharwood@redhat.com, mchang@suse.com Subject: [RFC PATCH 0/4] Wrap font files into PE files Date: Mon, 5 Dec 2022 21:06:01 +0800 Message-Id: <20221205130605.250715-1-zhangboyang.id@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=zhangboyang.id@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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, 05 Dec 2022 13:06:32 -0000 Hi, This patchset introduces a utility: grub-wrap. It can wrap a non-PE file as a PE file, which can be subsequently digitally signed (and verified by shim). The wrapped file will be unwrapped at runtime automatically and transparently by the unwrap filter. With grub-wrap, a PF2 font file can be wrapped and digitally signed. The name of PE section must be .GRUBpf2, to clearly identifies such PE file is a wrapper of a PF2 font file. Example usage: # generate a MOK key for signing pesign --certficate 'MyKey' --export-cert MyKey.crt # import the new MOK key mokutil --import MyKey.crt reboot # wrap unicode.pf2 as unicode.pf2.dll grub-wrap --input unicode.pf2 --output unicode.pf2.dll --name .GRUBpf2 -O x86_64-efi # sign the wrapper with MOK key pesign --in unicode.pf2.dll --out /boot/grub/fonts/unicode.pf2 --force --certficate 'MyKey' --sign There is one problem: those wrappers mustn't be accepted by other PE loaders. To distinguish these wrappers from normal EFI applications, I decided to make these wrappers looks like plain Windows resource-only DLLs (no entry point, and subsystem tag is set to Windows GUI instead of EFI Application). Currently, shim, tianocore, and my patched GRUB will reject these wrappers while trying to use them as executables. However, I'm not sure whether in-market UEFI firmwares will reject them. So I think the best workaround is to forbid keys available in firmware from signing these wrappers, and only use keys in shim to sign wrappers (this seems like exactly what we are doing for GRUB itself). Best Regards, Zhang Boyang