From patchwork Thu Mar 28 20:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 784607 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0116F13A250; Thu, 28 Mar 2024 20:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659083; cv=none; b=eHb3ptQ755f5+BnUHp/kVfsXZse6EGLkER5MXdc45Zn/JBm9pnzsKH2Lf2eEqwCAeu7tY1Fa3aBFKofzEUcsWuMN8Eti/jUxbSYxMYi7LL8n0fqDRHorVdxrc9oc4/WJBsbzKgqxgQCcrlRgXazHkMPd47X10Z6iI67E+X6jtDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659083; c=relaxed/simple; bh=kEP8nmkOk4QJmLgse+4tccjONBlM45t9m0YZSjoDuGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgOdXsVoyZUJ8szNk7Hpi2YRYDsGYK9fqIpTlAD/dRtuBp5JjQiypN1XvPgPlD+eVrrayBopxbZxWzvvJTjb1MhNgoixZbWf3sck7qqsIQODjCnD/jPwQuODkEYIhWoa6Xkzf/ugrE5G2CvOGN9J5DPwJuOLHOUTpLNk0QLH8nA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b=Sgaaa3RK; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b="Sgaaa3RK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711659061; x=1712263861; i=timschumi@gmx.de; bh=HJHQk3LZIdKlpZNpET9Lr1IlYEfzNZsX8njffaK3JXs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Sgaaa3RKB2SPP3FiuDghk9nZ9/qZ0oXxK055369YgkIonrSCvwHNVuaOJP/5IuZO /+suq0pdlJhVW6tdfwa+1b/stJh2C5UNCQsOpjgw6+lVc8X9kQtwN9+X0AJPE3GYy Z/VIWnJeg9r8Vq8IlsfUQ6bN2WIfrditCeDEqmksBr/rBm45yM/OJ1bXRppGkt0VY fsOu1GzVZuaWQpxZZMlrTDbHxMViqbag1/TOyIM4K6S4MVk7Y9BwQEs+UjpKqwWrG ditb8ulPoEpbwGpnQGJKlCvitMgBA7ln/bvf9SPQIeFm4tedpg/XBfKqjH9xDEyVC Z0RkMrxzASAWrPT+pg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([93.218.98.241]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MAwbp-1s0hHI1C01-00BLok; Thu, 28 Mar 2024 21:51:01 +0100 From: Tim Schumacher To: linux-efi@vger.kernel.org Cc: Tim Schumacher , Ard Biesheuvel , linux-hardening@vger.kernel.org, Kees Cook , Tony Luck , "Guilherme G. Piccoli" Subject: [PATCH v2 1/4] efi: pstore: Request at most 512 bytes for variable names Date: Thu, 28 Mar 2024 21:50:30 +0100 Message-ID: <20240328205041.76812-1-timschumi@gmx.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240315002616.422802-1-timschumi@gmx.de> References: <20240315002616.422802-1-timschumi@gmx.de> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:F1wxBJQKy4dnK5cIOi8lgWEi4TGqi9qGOVLBCK8sYoCD1nUQ4uE DuNt93KLDs4rSSeGOcUZigEytD/dTHBDKN06qQou9PUUFswfxyB8b4wYSshfxbjl4PnYEnS RudB5zriVpRpncv1MFfkRYrh2fDLarPrDlMPJVCog+awg4uoVB+BO5wsbCq6tIOirZdWwJt QG9oNfeb8qAYaoS0dzFOw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:LpIuViflScA=;LHZQv8hTCInRamLh3u9+E4LIQLA 8NaHLDXxZf1fr7uNiDOwNBPvAO3lumKbpoo7/XvY+JcfEbaMEhhyuUDiJoe+F8o6K9fcHAwVW ClJB9Qf3KedfGLH5xoKkCLDdjCiD3WQTnVVLHkeoRBrom2X+1oyDKQ9PHt7qe3CgQ/fq6dL6m SZ6Cx/z+ps8+OmhlYZPu/ngT0LI3DYCN9J9DGdqBxj9eIQUMMsZ+h1h6OcnmhsrWVcDuS5eAa lfHKLU+8SMO2UKpaEvQYF2rVmGwXJNqFpTuei/MZ+RdAD5sYpqFvZ5nuHPr/P0qMmrf2ovuQt lmHg+U+1cdKwdSSZwrLWaG7PJ5Qo15/1YKlAFpHeArqwA8iqG+TZMUnBzD2ScPUEEvQuHtHDY kL6MedULDyLZSd2DdPePjBdxEor2noPwlVx2OFWCQKWYl7vQtGs/P7VDTWPiQRnjDD6xhMEtz Hf3tjQw0B/132uNRotR7JCrfsQkKYm5mc0zlk0TB043WIS5RChyORqpxLEOqQxyF8gtRenvwU fDMeUT0vjz9QzYtd96CBM1AupH/zkeytRdtldMmksRblSPJjI+n7GAiu9ApmnzYKxqSL8R2bD BJ4YfEf9nC/O95TYfpXGHQdIjbFoQOego0+CzMJnwhwTKiYrlhb1GkCnaYaoQq7fXmO04suuu JWTAuytwDkxfw3ByvlA4iVuLtKCG4S+MEKYq69TGjLV/DDB27TB3RLHPI08bLir6Xuc/1Z8lh Kbwo9RQRGLVmWzlpxopNlBKhn4l+MbmKLcNAgw8B07IMSJdvZA3MTug3oO9Rjimo4J39XwBap w5yZZ/kxSeHDeyQ5y123XkHZ3A3ODb5h1xwd3gNtwBCnU= Work around a quirk in a few old (2011-ish) UEFI implementations, where a call to `GetNextVariableName` with a buffer size larger than 512 bytes will always return EFI_INVALID_PARAMETER. This was already done to efivarfs in commit f45812cc23fb ("efivarfs: Request at most 512 bytes for variable names"), but the second copy of the variable iteration implementation was overlooked. Signed-off-by: Tim Schumacher --- Changes from v1: - None, resubmitted as a part of a chain. --- drivers/firmware/efi/efi-pstore.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.44.0 diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index 833cbb995dd3f..5b9dc26e6bcb9 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c @@ -162,7 +162,15 @@ static ssize_t efi_pstore_read(struct pstore_record *record) efi_status_t status; for (;;) { - varname_size = 1024; + /* + * A small set of old UEFI implementations reject sizes + * above a certain threshold, the lowest seen in the wild + * is 512. + * + * TODO: Commonize with the iteration implementation in + * fs/efivarfs to keep all the quirks in one place. + */ + varname_size = 512; /* * If this is the first read() call in the pstore enumeration, From patchwork Thu Mar 28 20:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 783736 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E8F713A27E for ; Thu, 28 Mar 2024 20:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659085; cv=none; b=bbp8bTdXJr4vPndd9S1Jm2lwvy08wJX75XLBQCwqQJHHABOqjpm5Ff4UD4oAFIYy1IUk0OFx9PEde+wL0ehmfpKit686L6epctc+5T3/bFa4cvavXKdem+dn4UGog3hfiqMt6bCuOeGHcB9o8iM2cWO/ftAWTuiaDbflz2Yqnfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659085; c=relaxed/simple; bh=1S9JeLCHVSjVrLgAE1vonQqbGgqf78z5W9p1qhuQcaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nkWhTeL3SS7M/bNzByqRFwGMbAt29twrgVLBqTyvp0Tt0N6n/9tk044Pk/p7TpYaLAExiifaeCWEQfaeXeahhVhMqu8PitUpadZLNjtFlP6wPIGVvXZSvDz7gzlpIVgUkI/HMWnURh5CavhUM7cZKAFKjH2anDghONXdjdSRqXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b=iuys5Y7Q; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b="iuys5Y7Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711659074; x=1712263874; i=timschumi@gmx.de; bh=5+oNQ+p8GCTcBKXD9M5Ra/nvzQpHz9iGUYNbkgoiVX0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=iuys5Y7Q78F6bJO11+AgNc6ZoYiQoOZW/ccNpyX0ZiLwtfgx/opDHn8HjfjaMov2 MEPE8gQTe+jDT/nUE49TZF25IJAEN0mRh5oWcww+CX2JG2fVnyDRI7y8A5vQKdyZc rAFXs4Q7Zj14zSJ5gDfiVcpyOZ/CwSGlWrujufKfr3mEYztIduc7DALEAPRSPrFhR vGZkKNk7xQUB+DkiFENffrqu/OqQZ0PL2FvyXW1qahk6Ycmblrc3y/VMnfxwUGBYB 87sp285UzBFqdq8vx8/I9pvLlcoCHkksWCTzKvOsJ4rlaDdmtEM55ecZEEKYRUxVb mBAkgkaX1Fb+CfgTUQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([93.218.98.241]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MybKf-1slk0V0bkb-00yyNG; Thu, 28 Mar 2024 21:51:14 +0100 From: Tim Schumacher To: linux-efi@vger.kernel.org Cc: Tim Schumacher , Ard Biesheuvel , Jeremy Kerr Subject: [PATCH v2 2/4] Documentation: Mark the 'efivars' sysfs interface as removed Date: Thu, 28 Mar 2024 21:50:31 +0100 Message-ID: <20240328205041.76812-2-timschumi@gmx.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240328205041.76812-1-timschumi@gmx.de> References: <20240315002616.422802-1-timschumi@gmx.de> <20240328205041.76812-1-timschumi@gmx.de> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:As64rDX3CpnNkHIx1BhVzW2Rm291+CFPd6FNoYGNp5qOg2n6OUy zOmEWvCI1Whet2q+spMeESPd6PX7Bsobud1x1vjyztwpolWWb4UrgsBdrS2/VaUEBXpMEaq Qzk5aDfYxypv0F1GXg7OZxFBb5tQ66Xn6lQW8LRh5NeFpAVRXc8vW5vmDA7KGi30v2AtAyf vLviVyBhVERuIgrkEptzg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:CpoGR+z7kno=;M9G9H5TKlWaofYrZ7OeGQw0ki5e zr7WRJW3qhjHBUQ8LzEg4JYPliJpok1Iszc/qxa8OHb+y1d0vFder1gMX9KO+8pO45CxeGesQ F3fVaUy4RiXvHg9aPRurCIaf+ufs0LUgE3k73QlEMrIhjL4Y/tPwbTBpUdo0QQO1wLlg2CkJl ZxD2n7oviaz/KRl6BJRhpFyTS7jCEeecKMLtQ+ksz9dBxUB3fIE2ifSFKxxE5qD/1Gi73yHoM 96rQg7xJY/TjrKluXaLWXzFKZmw/kXJrMkMxPT+io2z6/Pc5fT4CX5JEQuahMzSak/lD6ZpM6 p74zUKLOG9Nc069eibh6ICj0oeNNCQ8Je64J6+qhs9bg5WkZ9EhG2zpUaE++02oPz3G6ByvbP 1cy7yTtO8YuePhioKXCvUT8qH3ifLFtSHi8WH7agb8HvAAIdUeD73L+EvvrahnT/zRi+qYdPS wNf+pBw3haLyCezdsJiJoDKQTRRwLEF4ygHe4+wISJAbLgi51F6UA17wd3IWf5bvgu0PjVmYJ 5h6nR4yN5CMPCM7tTxWZi47ooLGBXEHA4doxLMrX0bhUbfHgxzuBy6pnZT9FGyda2MU6LIztI 3nAS7NinOsW1H+RUBOMVCAjCRumJwJUmN5HJN1AThag4aEM2L1xKYIqFQHCIZFTzg+YfpdVLY PAgtSJDXGuMd5svJgvV/vDBgPBtzZkCaH34qhi5Cio/8i7B60j7NS0mIEzgFNz+d5elnoHe/j 8ete81dGtvOO0Jrf6kJ/R6Kk/ZrGYzeiDOfyKFMM63APLRymzLcYSSLI1FXnL4fN1XvK4QS3b zDBPxdA2xWghkHiM8kihJjFCN7fclv1i9Jui4wDrXrZ28= The 'efivars' sysfs interface was removed in commit 0f5b2c69a4cb ("efi: vars: Remove deprecated 'efivars' sysfs interface"), but the ABI documentation was not updated properly. Strip down the documentation file for /sys/firmware/efi/vars to a very basic description of what the interface was about, add a section about the rough removal timeline, and inform the reader about the intended replacement. Signed-off-by: Tim Schumacher --- Changes from v1 (semi-non-existing): - Removed large parts of the now unneeded description, as well as the contact. - Added a short documentation about the deprecation, removal, and replacement. - Split out into separate patch as per request, part of a patch chain. --- .../ABI/removed/sysfs-firmware-efi-vars | 12 +++ .../ABI/stable/sysfs-firmware-efi-vars | 79 ------------------- 2 files changed, 12 insertions(+), 79 deletions(-) create mode 100644 Documentation/ABI/removed/sysfs-firmware-efi-vars delete mode 100644 Documentation/ABI/stable/sysfs-firmware-efi-vars -- 2.44.0 diff --git a/Documentation/ABI/removed/sysfs-firmware-efi-vars b/Documentation/ABI/removed/sysfs-firmware-efi-vars new file mode 100644 index 0000000000000..8d97368b149bb --- /dev/null +++ b/Documentation/ABI/removed/sysfs-firmware-efi-vars @@ -0,0 +1,12 @@ +What: /sys/firmware/efi/vars +Date: April 2004, removed March 2023 +Description: + This directory exposed interfaces for interacting with + EFI variables. For more information on EFI variables, + see 'Variable Services' in the UEFI specification + (section 7.2 in specification version 2.3 Errata D). + + The 'efivars' sysfs interface was removed in March of 2023, + after being considered deprecated no later than September + of 2020. Its functionality has been replaced by the + 'efivarfs' filesystem. diff --git a/Documentation/ABI/stable/sysfs-firmware-efi-vars b/Documentation/ABI/stable/sysfs-firmware-efi-vars deleted file mode 100644 index 46ccd233e3594..0000000000000 --- a/Documentation/ABI/stable/sysfs-firmware-efi-vars +++ /dev/null @@ -1,79 +0,0 @@ -What: /sys/firmware/efi/vars -Date: April 2004 -Contact: Matt Domsch -Description: - This directory exposes interfaces for interactive with - EFI variables. For more information on EFI variables, - see 'Variable Services' in the UEFI specification - (section 7.2 in specification version 2.3 Errata D). - - In summary, EFI variables are named, and are classified - into separate namespaces through the use of a vendor - GUID. They also have an arbitrary binary value - associated with them. - - The efivars module enumerates these variables and - creates a separate directory for each one found. Each - directory has a name of the form "-" - and contains the following files: - - =============== ======================================== - attributes: A read-only text file enumerating the - EFI variable flags. Potential values - include: - - EFI_VARIABLE_NON_VOLATILE - EFI_VARIABLE_BOOTSERVICE_ACCESS - EFI_VARIABLE_RUNTIME_ACCESS - EFI_VARIABLE_HARDWARE_ERROR_RECORD - EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS - - See the EFI documentation for an - explanation of each of these variables. - - data: A read-only binary file that can be read - to attain the value of the EFI variable - - guid: The vendor GUID of the variable. This - should always match the GUID in the - variable's name. - - raw_var: A binary file that can be read to obtain - a structure that contains everything - there is to know about the variable. - For structure definition see "struct - efi_variable" in the kernel sources. - - This file can also be written to in - order to update the value of a variable. - For this to work however, all fields of - the "struct efi_variable" passed must - match byte for byte with the structure - read out of the file, save for the value - portion. - - **Note** the efi_variable structure - read/written with this file contains a - 'long' type that may change widths - depending on your underlying - architecture. - - size: As ASCII representation of the size of - the variable's value. - =============== ======================================== - - - In addition, two other magic binary files are provided - in the top-level directory and are used for adding and - removing variables: - - =============== ======================================== - new_var: Takes a "struct efi_variable" and - instructs the EFI firmware to create a - new variable. - - del_var: Takes a "struct efi_variable" and - instructs the EFI firmware to remove any - variable that has a matching vendor GUID - and variable key name. - =============== ======================================== From patchwork Thu Mar 28 20:50:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 783737 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E8945B1E3 for ; Thu, 28 Mar 2024 20:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659083; cv=none; b=Le4cRDM6qZN+Uq3HQNL0c8yjz3mrzbt3Ym6bx7IHUDuIBIDOPpRJkOPqjsd9aUalpSIx1ThniM3ctXXGztmRNHKPydtqgbrChUZye/1FUy1rUIFPLs3r8L6eX3kLRbnWeBzE3maZjBQw5q5SWFAfnQr6SXAWea3plUle6EowFrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659083; c=relaxed/simple; bh=lpeBQuTy/n7G1PDmBoR6r/SOsg1Hx4nhKJ7MYvcK7po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dWWmTD5aXovuwU69dnXw7Zw4Ko3TVhjElO8Tbj7MeSyFrhzV+jY1nz9elbXeBCCF1BC4YCIlTPFc/MGOB4hOgtGRhWfSkN0Ybg8K2cv98MRIp0jz/ZHZr3KU4HV7QamwdH/C4+ckrIGL2jO8Iur0jbXUXJhXzZBxkm+XEcLb9Eg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b=kq/vpyOS; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b="kq/vpyOS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711659074; x=1712263874; i=timschumi@gmx.de; bh=ocf3r+xuAv1V4gpB+2uQ1yuwyHV5GwdmOQTUSDdBqaI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=kq/vpyOSvJ0PGqY1gWBde50Oj0UgRvZwI6oWQin/XjOo3YId941FcnKLt9pAhk6G qRvzvur1NcE4nSIQR5aTk2UiSNegsbCNl9yMIxaMN8P6r+8GfIqobb9MoFe3yituC L+2d64VE46X5J/EAoVcLO+Fil6YPUw0JloxJUC5NHeLOBonGlG+9yZSCS7VIzKLZr v6MYHI4FBVFBQrSeeWwQyb6Sjl0E4pg7eRaiv01CsJKMHHuGrX2lzB/OtoA76Iphj n7QJvWnlQfPtKN5Zl7vNMgUFfnZHeWagCIBDaN3Bj7MGeq/C9xe+fwguv0U2KvfZk PghuOyhTL4/uLaGLaw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([93.218.98.241]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6ll8-1rvybE1k5u-008NxB; Thu, 28 Mar 2024 21:51:14 +0100 From: Tim Schumacher To: linux-efi@vger.kernel.org Cc: Tim Schumacher , Ard Biesheuvel , Jeremy Kerr Subject: [PATCH v2 3/4] efivarfs: Remove unused internal struct members Date: Thu, 28 Mar 2024 21:50:32 +0100 Message-ID: <20240328205041.76812-3-timschumi@gmx.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240328205041.76812-1-timschumi@gmx.de> References: <20240315002616.422802-1-timschumi@gmx.de> <20240328205041.76812-1-timschumi@gmx.de> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:ItkpeyJ6Rxpa1YIZvGFi77vz8A8GeXblehSbGxbzZk+jR8gqaOG fpYSuUSR80inh3V1IjjqMLtWI1xOpCnpWXuIHSfknrNcC/laC/WDEP1gKslUtItsPULJKf8 ujcfWpr0UnBhicjJTfBNffnMUGPoIFxL1USLlOKBl9uOgSxeV8zmK+CkDEFDw/+5Nt0GYPM g2ioDB+ifJ0QovVU3ar9A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:py2i4mptt6Q=;iAieYc3rm6UfvOCBIliZDhUdZfA iUgAROoF2rukiswHOQciAhwNRrcCcwofFX3HVXSCkRGeP5jCg5bPwZy1y8QSGMOL3X/rvjBBu OKxhSy8SAXlGL0c+Ao2y5NdgbQ69zEN6ySXAGe8xYBuozC3tk5/8K5mJR7KGMCNqw5vYRPG6J RvFOOUjoBVyxr6cdan3x28s2DJnBPfYSC2snXBXCnEmNj+Z5n6GSKrPWIn9nIrH7jCuBgR7Ql 3M7ORTESJJFmxmFwbeOq54grq31t/udMyYlfVsUe4iWEA6eBO66KYtnv+b/6ZtdA6TpccR8YY MVYg3bhZu81DrGNTrcy9oVyPH/D4gTUPl1r++NHSOmH0IE5svdoponse/NmPF1bkK8Bp+DqVJ s/wyLfGdE0iI4H2sZpyq/UbMbhHFUkd02h4aGJ82kYX4CWEvZ+kmJdlgCmQCtzkCWatWhHEhM 3qkJOAJ5smFUtg1JK6N3LELB4E4g3c1Am4z+kj2T7MVunbOHjMmHiRaG3LUkVytJckCwMj9n9 anS/fdHTlfvBHZb493fgR2NJCZ8N5mBWCkiW11GhsBNDuZwH3B0iPVo6v8K7fvGsa+CwJK1DL EkdLJG6OP6LMLvCFE4pXxtsddX1PSIWLSImvMTbgnUZ6H0QP6CGIH4SK/UtU1IejBsZI5OsA2 51xo3FjAmPqu6in0w4PaitYIYoHlXYxZkhyZu98BXeYfASx/4Dhys4PKaKkaYT+4VREdi1MTz +e77wFFk6JZmDpTdz3hpDx2AZ9xrnsnCmuOaFuH6vfQzIB0f0orA6UZyKNcn8YQPBNN52KI+O vfqBqEJh2hUZKeshRXOxeNr8fwu1yS24VRWyrOtbxhwM4= The structure was moved to the efivarfs internals in commit 2d82e6227ea1 ("efi: vars: Move efivar caching layer into efivarfs") after previously being used as the data ABI for efivars until its removal in commit 0f5b2c69a4cb ("efi: vars: Remove deprecated 'efivars' sysfs interface"). As efivarfs only uses the structure for the variable name caching layer, the data-related members were never in use. Remove them to avoid implying that efivarfs is bound by the same restrictions that efivars once had. While at it, remove the packed attribute, since we no longer have to guarantee a stable layout. Signed-off-by: Tim Schumacher --- Changes from v1: - Split out documentation changes into a separate patch - Remove the packed attribute of the struct --- fs/efivarfs/internal.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.44.0 diff --git a/fs/efivarfs/internal.h b/fs/efivarfs/internal.h index f7206158ee813..d71d2e08422f0 100644 --- a/fs/efivarfs/internal.h +++ b/fs/efivarfs/internal.h @@ -24,11 +24,8 @@ struct efivarfs_fs_info { struct efi_variable { efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)]; efi_guid_t VendorGuid; - unsigned long DataSize; - __u8 Data[1024]; - efi_status_t Status; __u32 Attributes; -} __attribute__((packed)); +}; struct efivar_entry { struct efi_variable var; From patchwork Thu Mar 28 20:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 784606 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CD0C13A3E7 for ; Thu, 28 Mar 2024 20:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659084; cv=none; b=rPXBrpCl75UQTXeTKM0jOCHtc+NBppjGKdNQZgy8tMl+TCucA9ZETGb2MmWZPR5HAG9cXF8VcIbEFL5m6Es16aknJpOtCakfoiWZ6yGbrBevf0bBn/Oe4tIW6cTLAZSjeRFfXmnS1L8tKGCr6ILReGvD2Mt372e3cKgPW/HjgvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659084; c=relaxed/simple; bh=4mysez7lD1vKLQufVGQpeVDXY3KNZoEL5k6rpwnJG5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jh/ljUO9BVdkd78QGSWuLLyMU7DdAtjbZWk2yP6IGyW/gH8YGvwcmIW/Mi/9ugyHXiPSuBlHrClnghgrqxoDSgggjQ6lDtqokl4rk2mBHlWQPqMJZvWXJaeeQokUuTzj77Lk1heWhwJtGBeoeL1fU5AEjd5Bbh2+pcwAxXaJRn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b=XWbG/r8m; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=timschumi@gmx.de header.b="XWbG/r8m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711659074; x=1712263874; i=timschumi@gmx.de; bh=6ORMjfkr+xilT0cm/WbOy99GHRbCruCTXAGNKgYCQX0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=XWbG/r8mWNw3uJpUhrTu8uwPTUy+cKxfQQM7VdiELk102Giux/GuKHVQAOGtw+OQ tG9JUxSYUNnkLEEgSLdAbCgRUA+n5FXikFPeTfMKoErRXa1nFJuBC5mjdqs5OghbE LE4tw/SnJs8CDLoL7PtzVp9taVLWJg5XC78+bFnmyIfcMOxUQtTJub9BT//zOI+rF MKga/KM3BAGpEZtsQjc96+9nkI/RUz3RoYwAyPuOsSq0OYeHovBMg04jAX1keGe3e Ew5KS94CIg3Lz4xA+h+oF3LJ3yKjNLQuPY0zbsnlTrBW3Gu42rIPt5kA8Sscpa2JA jBrXmtHETADkop4MVw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([93.218.98.241]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M3DNt-1rqlfL2sDV-003gqw; Thu, 28 Mar 2024 21:51:14 +0100 From: Tim Schumacher To: linux-efi@vger.kernel.org Cc: Tim Schumacher , Ard Biesheuvel , Jeremy Kerr Subject: [PATCH v2 4/4] efi: Clear up misconceptions about a maximum variable name size Date: Thu, 28 Mar 2024 21:50:33 +0100 Message-ID: <20240328205041.76812-4-timschumi@gmx.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240328205041.76812-1-timschumi@gmx.de> References: <20240315002616.422802-1-timschumi@gmx.de> <20240328205041.76812-1-timschumi@gmx.de> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:ik1jGDY/Ziu7GHg5hW3aufW0oiC6PQlztnSZVGMPDwxfHTW6xZU ZD5hNciPDMdiC/1fasAMSfmN8dGXmLcIVLcNMzwTbrVSxxAQP5+BgKanzm1GsluuGeFzJz9 dT45QbaYXfVOMDvnivXT/gSQ7HlaXQWUPWlvkqPAB2PF3Bqoe6kOeHd5SEG/26xUNR0ZtXz exwmVnvWUGvsHApngBd/Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:+1xIh9xekeM=;a5XdEGhUcgJzCJNhWh1hZd+8GKb ornTuxVubP8Q+HKBZagLYAp5rbHsfLl9wBGwfOwQuWPY+OaZfE8LSStXM8yoFBVYaFIZVLnbN 1BstD0ZOdXmydvrCMfmZIYOIfLjui48DF5lqJV9V1+85GTmv10h0J1Qr9phVGK1fUcvUUo57O fGM+OBNoYxv81E97FFcn7QrVmgauYjaD9BF+/nklHYPf7zqhwg3gMIbe9841h844ANhtdGigJ IoCQVvygKVWB+DrKbB2/atrElr9r6BkuSZUYkpiQrYjUqkzFHDY4BxC0Vh1lOLPsRe37Ll/Mc zqXzzZ6g4biBoPeRJQp1nx0qDGls7EQPHUkn3uIZxYFEXp5VGJAp/tdGqpcYeYjJDmT5bcDNp sEeT3emRD9h7kHKDe3I3qgeKJMDvB89tsihdQvNtnCFLqVFag/fDD6ptofHph7M0PjjFAwxbv T+PhumAFQ7eBYQgkqUKDHbSdcVENe0Zr7oh6JjUfNDkqAk6mzzqNQuNpErptsnmp2m3zC7v/Z 0JmjFI1W+v98IB2DnlGApis7zv2LyK553Txb0gg/xGwOc51y98kKI605X3gGhxgE1jhBe3XrI haxba9SrDiyVkFz+WwlRvvtElHXvYIRn6WapRNTN+RfLMOXkMRudkUnyxyIfbFEKOgDE8bU6a Gl7qyMOUXJH9dQgkmXQLzCyN2rkWuWlHYsLQYCjmh2dnuPDz45MQWbhfd395t8pDJ2bYrbvVd HLDedqp7wWxc217eRozz4+YIJp5BeS61cykcSEXUksHNXb6k5cgO2M1l0MIoCcY3JN9WyCejl 5tzmllGe0yykO0W3YMY6rw0JsQBWauv0kLJnFvFqQ5VE0= The UEFI specification does not make any mention of a maximum variable name size, so the headers and implementation shouldn't claim that one exists either. Comments referring to this limit have been removed or rewritten, as this is an implementation detail local to the Linux kernel. Where appropriate, the magic value of 1024 has been replaced with EFI_VAR_NAME_LEN, as this is used for the efi_variable struct definition. This in itself does not change any behavior, but should serve as points of interest when making future changes in the same area. A related build-time check has been added to ensure that the special 512 byte sized buffer will not overflow with a potentially decreased EFI_VAR_NAME_LEN. Signed-off-by: Tim Schumacher --- Changes from v1: - None, resubmitted as part of a patch chain --- drivers/firmware/efi/vars.c | 2 +- fs/efivarfs/vars.c | 5 +++-- include/linux/efi.h | 9 ++++----- 3 files changed, 8 insertions(+), 8 deletions(-) -- 2.44.0 diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index f654e6f6af873..4056ba7f34408 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -215,7 +215,7 @@ efi_status_t efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor, if (data_size > 0) { status = check_var_size(nonblocking, attr, - data_size + ucs2_strsize(name, 1024)); + data_size + ucs2_strsize(name, EFI_VAR_NAME_LEN)); if (status != EFI_SUCCESS) return status; } diff --git a/fs/efivarfs/vars.c b/fs/efivarfs/vars.c index 4d722af1014f2..3cc89bb624f07 100644 --- a/fs/efivarfs/vars.c +++ b/fs/efivarfs/vars.c @@ -295,9 +295,9 @@ static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, unsigned long strsize1, strsize2; bool found = false; - strsize1 = ucs2_strsize(variable_name, 1024); + strsize1 = ucs2_strsize(variable_name, EFI_VAR_NAME_LEN); list_for_each_entry_safe(entry, n, head, list) { - strsize2 = ucs2_strsize(entry->var.VariableName, 1024); + strsize2 = ucs2_strsize(entry->var.VariableName, EFI_VAR_NAME_LEN); if (strsize1 == strsize2 && !memcmp(variable_name, &(entry->var.VariableName), strsize2) && @@ -396,6 +396,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, do { variable_name_size = 512; + BUILD_BUG_ON(EFI_VAR_NAME_LEN < 512); status = efivar_get_next_variable(&variable_name_size, variable_name, diff --git a/include/linux/efi.h b/include/linux/efi.h index d59b0947fba08..418e555459da7 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1072,12 +1072,11 @@ static inline u64 efivar_reserved_space(void) { return 0; } #endif /* - * The maximum size of VariableName + Data = 1024 - * Therefore, it's reasonable to save that much - * space in each part of the structure, - * and we use a page for reading/writing. + * There is no actual upper limit specified for the variable name size. + * + * This limit exists only for practical purposes, since name conversions + * are bounds-checked and name data is occasionally stored in-line. */ - #define EFI_VAR_NAME_LEN 1024 int efivars_register(struct efivars *efivars,