From patchwork Thu Jul 4 12:46:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 810490 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60E641ABC33 for ; Thu, 4 Jul 2024 12:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720097187; cv=none; b=HB1C1bQ1K74AS9F3EqJlyqzGnvnKBBbyq3qdIzGSe86T2I1v5PSrJgaWg1XbyR6MdZCPijfX5xEjFkZRLzp2HeDm6jHgHvI28EpVSqX/tRdCQFx8qmeDYymYymmVaYCMmPhl48hK7QQNOB7yqJhqcv9CAYipf2yHom1WB4i8O+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720097187; c=relaxed/simple; bh=auu0d3/fL1iL/Q7mC7JwLFZ0Ab3Q9PoxsgV+c2FkV4A=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uIGmbUn/YN3pr9+/pvh9xLsrcFoekahOOK41ecSp1TYq+cpB4Oa//lyNpaIPIFb11F7/hZbS+JfUvShFzjwvLNmeCqIazdayz2IhS3noEMukWS4xKdZcFo1/wXf22leTS1s4foBmFXI/hPXSdLoUApjH/Q7onrqaaypvsYSuSDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LBlr5G1B; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LBlr5G1B" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4256718144dso6110785e9.1 for ; Thu, 04 Jul 2024 05:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720097185; x=1720701985; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=X3PzPgOQAWXsVCGBV/l/dD+372MMLzVOKKWoVsNAuxM=; b=LBlr5G1BHEVrMTTO8PjoPZwMIPfKMZ0mfOPyqvmQbGpecALhhibW64ba3O+difmp/J Xd3SrExEPPp55zL4RRIOK5ySsvHPxDJGBMkqFtM36XYvoD6/bd6vy+jgLbGXi6yRNkHO M9TP2lGj8Z0hYsrpsdRr2X4yN/RqJl+r0Jf3ZSIOx0ShY5pSdAXPYXdYDAhtVZoXVoWD e5b+f6yUeyn1TmexgJ0svtWqSx7JD59ziIezChcZNL8DQxozF4UOaNv8o+ibfxqzQZf1 BQmMhanRLzeTOQySMqe4GAc1PoSSZC4pWoFjwE/M3BusLfXllsbWYTS3me/cKFA3CzVc okXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720097185; x=1720701985; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=X3PzPgOQAWXsVCGBV/l/dD+372MMLzVOKKWoVsNAuxM=; b=rRD75Hg7Qw/l+lGkeb9qV9xBwU93sYEdVQsnHjf/AQLwoVUwMQJYlLB3dTk/mM+7DV 3d7LLid7YQeFB9Cejq+48Uc36KG6PHV07Qm/7OwgOiz3eIMeQoHOzwhgeC7SY79tnqwY d/WW1+7uq3e8LJ7P39oYYav1GGDlrstcfBSZ3usQwx9aO/AeqKmcOjWeCpptEU4DrC0B 20cofWMWsACr3ZfidwyQNpDj1sfID/r9/YAsOj0Z8l47CVQUpo2PWpTziUMuK2oKr1RC N8hNuwmXIZP3RHiixHum1HWaqoJeg5U+cD0FAgGkGYpMFNT9DzddMdP1+1FujkqGCD9r A6FA== X-Gm-Message-State: AOJu0YxQb8RicubC6nQFOdxJ8g1qg0L9xdTJHrTdLgnEBxDriF7ccgOS 6MFQOAz3Ph+8aL5RBxX8QyvT6nKkzWTVs1kOFBGQF9uscmCX7Kr6PQMU9bK6OPnGNdVIL6JOVJH 2sy0OfXVZhb0LqojmBAEdk+wgiYjpWyBx02E5Me3M4ACJZ9tkM9De/1V+cTE0WGYrIMGy84CXnq 6aVwLzko1J0cU6bU9QzBFZsS8Byg== X-Google-Smtp-Source: AGHT+IFINreKUktWhBlOrgCHaphfERCXvxePBsBuBhEhd+V/HSoqoRk5pIa+/vuX/aHn4ywCZ0dJhZ5a X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:600c:1d24:b0:425:8cbb:6eb with SMTP id 5b1f17b1804b1-4264eab8615mr575e9.7.1720097184366; Thu, 04 Jul 2024 05:46:24 -0700 (PDT) Date: Thu, 4 Jul 2024 14:46:20 +0200 Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1199; i=ardb@kernel.org; h=from:subject; bh=SeLgbYfl7PyH676mYz7TJcDFUcEjco1H488xhZCkCBY=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIa1t5pz6bs7qDRWyK1bWGDPxaS258ptRS6HM7Sx/+5lzN 1/o1f/vKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABP5Ysjwv2rOIa25z2pdrtzY 3id7XexrCEdaGPNzZwMuQ3vFKa5/zzD8TxN65LY13IFrBc9GP4HajbN/bFvk7NQlvM6yYTVbgdt ELgA= X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog Message-ID: <20240704124619.373578-3-ardb+git@google.com> Subject: [PATCH 1/2] x86/efistub: Avoid returning EFI_SUCCESS on error From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel From: Ard Biesheuvel The fail label is only used in a situation where the previous EFI API call succeeded, and so status will be set to EFI_SUCCESS. Fix this, by dropping the goto entirely, and call efi_exit() with the correct error code. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/x86-stub.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 51b7185f8707..a4d0164ba35e 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -566,16 +566,13 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, /* Convert unicode cmdline to ascii */ cmdline_ptr = efi_convert_cmdline(image, &options_size); if (!cmdline_ptr) - goto fail; + efi_exit(handle, EFI_OUT_OF_RESOURCES); efi_set_u64_split((unsigned long)cmdline_ptr, &hdr->cmd_line_ptr, &boot_params.ext_cmd_line_ptr); efi_stub_entry(handle, sys_table_arg, &boot_params); /* not reached */ - -fail: - efi_exit(handle, status); } static void add_e820ext(struct boot_params *params, From patchwork Thu Jul 4 12:46:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 810112 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 274261AB51B for ; Thu, 4 Jul 2024 12:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720097189; cv=none; b=TeQ11hOpicMxfGZRZGFodp9/ujmBCvSf7ge6YNfrUcBTZZnNaWs4UluDxyjMHegt4Dr9JR53O7cOmK/9DQMcAsigy2APObRcbPgDt1fOizU/Vx9G3DPCw78Q/FFb2u3KssDt+8qGz3rXPZx8O5di99uw7PHfBtcLTqpPvoiNXUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720097189; c=relaxed/simple; bh=HU6IGe2+cbS5qwz6Ym2l9BvqhzrUzAKPLu9XEKmlQ+Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Aa+5QQB9IgOp4cgYEqoW9DMiXbl0h6gTEseEAWCWajkw+chEIR6xkOgnon7RG3VLSKtRPqV3K6868tAACaXxeiuthRPuaxZ5v1fZktBRw0tjATkkba2IBdogW4vSSMkS6Ej2fFciy7bAUJUsb7tBANo1ZBd5Eo1OIfb9xu6oYnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uIHOU8u3; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uIHOU8u3" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-651e54bb41bso11272537b3.1 for ; Thu, 04 Jul 2024 05:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720097187; x=1720701987; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kp9mB2z9fkkSnWzx2SaeHdTtcLUq5enQshYr4vg0rNY=; b=uIHOU8u3Jpqg3i0q6lrQ8XRpWH2n1oVSRF/pXgpAAo8ruLfw720UI4KdKMSo9wQIL5 qcSbfQ3Pqs7jFisO8JGVHUBkj7JPWhVFSTZio1z5WGqD13t7wzqUoRqjn0wTZrV7lvEm EwkbfKfUlT9bNvz0DMPk6TCO+8aV7dOidXvFEIUic1HGHKfee6qqTDupxqssHj8pnkE3 77rV6Q2Q3RwN5SopHeDsrRiThG6NJGzuSWT1DzoygjtD7Dmd745lo/J3rdBOhS2va0dO Wrmomg5nkxgEY+Km517rCJWLUzoUFmyzwMceLqgbIfbey1BzNU7hWOXDHS1eRFbMQVE2 xVdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720097187; x=1720701987; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kp9mB2z9fkkSnWzx2SaeHdTtcLUq5enQshYr4vg0rNY=; b=KWFT/AWnVpDXLz7MOd3a+8XSm/bySj4V7ZTvvFuXF99jaDiDwhq3mhd7QfrfkhvUDW qvnBC5UPM0eZ5jfExBUOqCd1ZLO5wdy1g+Xnrdohsxzd+xa7Lm4rz9ePdye4fULDeQi8 md8Ff4sBEFoiiHyOB61iVMz9kyMfqbJkfloORnAr+tP0k/qOlBg5zoQ/P5u7MgIYAI3K J0UPblYlbmV6dzf0e0TWTqYRCcHFwbTC0POfr6tTosBe9CkieRx93hZICYhXhhAVYWzM zOeNJpfCU2x+ifP7SMm4cngN4Emw/fQ/x1kGU0YsNErIIUadkNPxvCq/zfLxT1uXOFrN aH+Q== X-Gm-Message-State: AOJu0Yzx0YeBzKuMF9g3GTIw+7zZVAJzoF8IphsxzqkAyjnbclvKiuH1 ILVe5yCd7SL+ZsMDvRyoy1a+JH5S4EY9KoVAPRcO0UTeMwcEUQX2NrqKy5ir5yJV7mUpBOKouqW 1rtGAcfIiQwl4NwPjbJASepbS5zJIdsjvT2jxkYAGa0QSPxbsPLSyQeockxqq4WfmIOpSbrrVGE 8xRo8W5hvwlY2tVRz3xMefEUWnsg== X-Google-Smtp-Source: AGHT+IEFexQ1gfl9M3yUIoeAkncyveegIvy4gbGUtxLCPHxflGYlviUjFkAKOYuQbcZkOkppaZLCSCec X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:690c:4d82:b0:630:e8a:8a15 with SMTP id 00721157ae682-652d2809e31mr186297b3.0.1720097186894; Thu, 04 Jul 2024 05:46:26 -0700 (PDT) Date: Thu, 4 Jul 2024 14:46:21 +0200 In-Reply-To: <20240704124619.373578-3-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240704124619.373578-3-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1221; i=ardb@kernel.org; h=from:subject; bh=wbypBLS4acZUXPbYk30a96QrEw+Gpc5WvloZv82Jpew=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIa1t5pyoWOG8ALc1KzqvPeh8PFk2V0Hyw7Hnrk9uVG9QE jbv39XcUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACYiaMvwP2RZQ5HozLae0wYb 2bmeCEwpXzbfW0Jm65fS+JkhalYCOowMh+p+LJl7iP/KeZY4qQe7pE5siV/S/fRTYFDHxeuV2mF VvAA= X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog Message-ID: <20240704124619.373578-4-ardb+git@google.com> Subject: [PATCH 2/2] x86/efistub: Drop redundant clearing of BSS From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel From: Ard Biesheuvel As it turns out, clearing the BSS was not the right fix for the issue that was ultimately fixed by commit decd347c2a75 ("x86/efistub: Reinstate soft limit for initrd loading"), and given that the Windows EFI loader becomes very unhappy when entered with garbage in BSS, this is one thing that x86 PC EFI implementations can be expected to get right. So drop it from the pure PE entrypoint. The handover protocol entrypoint still needs this - it is used by the flaky distro bootloaders that barely implement PE/COFF at all. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/x86-stub.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index a4d0164ba35e..1ed94b251c58 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -541,9 +541,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, efi_status_t status; char *cmdline_ptr; - if (efi_is_native()) - memset(_bss, 0, _ebss - _bss); - efi_system_table = sys_table_arg; /* Check if we were booted by the EFI firmware */