From patchwork Fri Mar 15 00:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 780623 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 C52E7635; Fri, 15 Mar 2024 00:27:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710462449; cv=none; b=JOoEx0tFWlb99FyjT9L9T8NcTEhwnsI9uN1TY759E8DigR2ytUYdutQ+lqxGbGjWb4QhIsTw8poSqutfgF+2YhMwJeTiCd5juzP8q/F4LP/SWDDxiYe/CMsxjE8n/6FweE3n2oThO6/ENrnMi2eFcn9n0tVRrCcM5h/m7KpdEsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710462449; c=relaxed/simple; bh=f8E8aUsLYhx+wLVyVfWO0R+ZhEJFEDlP2NW5WWjxZjo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qZwjF/KopP4tXVk+GC2oPIr5gaGV6vfgSSDc5mfK7KJ3X8wnKDW2fwO1aqFTQq4K34fjMLwgjsMr+PkzKf7bIgR7Fpwb/wKTHtflG7FhUWEqgXorerh3lbaZqi9s31dtlc3FRZiI9t+EDhYrobM5R4RyOAbbdBZmNTSsnvGGd2I= 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=N8MKBEZv; arc=none smtp.client-ip=212.227.15.19 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="N8MKBEZv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1710462429; x=1711067229; i=timschumi@gmx.de; bh=B52cazKgtP+V6ttkF6KV1d6LbmJl83GGXxXlPh901dI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=N8MKBEZvdC4W5nNstoYGkCyuOmxOJdZgM5b1WznJH0flqyCuaDj3ZTg0+o1eLSgf sLlphXSEcjXv49bqP8urm4QaI8t0aYpeEZMDXC7muIQeYIfbPKBeCV0DOswQpDYuN QmQxb2hdle4n00W4zvDaazJBusiD3j7Vs+XPB3tjz+0ht27tL7KK8J5+hPApqBWk0 XhgFs8tHLoJn2gteeK5U1/ygc7gwqTuuf8ynALBu0kXcr9DtpmDjod+X0yeTT2zIM wX50ADp1RokSbAYVOggN1E3BZBCOG2SNR76/AVQUNad9x1PHREqI3iC8phPFaFy+p yYEMkbC4bC0ig7Hh8g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([93.218.98.241]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MpDJd-1r0t5W0CdT-00qhX4; Fri, 15 Mar 2024 01:27:09 +0100 From: Tim Schumacher To: linux-efi@vger.kernel.org Cc: Tim Schumacher , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Ard Biesheuvel , linux-hardening@vger.kernel.org Subject: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names Date: Fri, 15 Mar 2024 01:25:58 +0100 Message-ID: <20240315002616.422802-1-timschumi@gmx.de> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Prov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CsUMfN/pQUjq12Yy6Olc6N03xxeT3dIsrEpnuKplsiiJhGUTYgCXbB wAoSgA4IeDkadqh1nzWli6rveHHXDnGPuAUocLSCXJvVk= 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 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 --- I CC'd the pstore people and linux-hardening mailing list because get_maintainer.pl suggested to do so. Apologies in case this was the incorrect decision, this is a very non-pstore-specific patch after all. I have taken the liberty of adding a TODO for the future, the actual refactor can follow at some point down the line. --- drivers/firmware/efi/efi-pstore.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.44.0 diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index e7b9ec6f8a86..f0ceb5702d21 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c @@ -135,7 +135,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,