Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93A6CC0015E for ; Thu, 27 Jul 2023 03:02:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 40443867EA; Thu, 27 Jul 2023 05:02:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iy24sr7P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BA8F8674E; Thu, 27 Jul 2023 05:01:48 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C9AAC8679B for ; Thu, 27 Jul 2023 05:01:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3460815fde5so1534115ab.2 for ; Wed, 26 Jul 2023 20:01:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690426904; x=1691031704; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=En9nERjZf5QTibPqV5mRUTHDBuIjv60aX/HCIp3V2Q4=; b=iy24sr7PUwjtpRxapSiiikV14tGsObZy/fca6Y8wcSkCilXvL9q22O/LI2mWEDPt3+ 5yETPavHlrBHjjzW/L8YFH1OG1VPPXxyEOoDPrIDIhY9/1tIqvmpBPag0wgFxQPQJ3Tg mp5DfoUttiWC9D7bGTgnA2u86IE75d9wiOgJs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690426904; x=1691031704; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=En9nERjZf5QTibPqV5mRUTHDBuIjv60aX/HCIp3V2Q4=; b=B6fcxuQJwqzJq2XSiMQGCZRVY712UJk70GhaaPrgLK0+PV2VhxQKc0AByDhDJqfque AH/iScjuVKMpdr0H97q7PnKOtr8NqvppiJfq+/KkRY/kJaya1rtMSdYf/5w7XBQB8NAv JVUAVL6XcbixSa+EPaGZiGgmZ54FFfSAXXV8mqqv7gKfxOEl6YC4dyUiwdLRAKpDy9uP wI+J2I9HDIJcoBJDSal/4HjEW65AHtq3M6M9qjf504mQt3d5a+IZ/qIO8USfC5gXL75h H3od4r4wekfVxng+2vzPPFRIzPnCieV7ZQymS2JBzJYDMe6ltv6sUgc1oSizYSJQbqCV 11xg== X-Gm-Message-State: ABy/qLYo1Nf0FdMDsHfhU/tZ2DAoxJrjwpQFdj05uBuwpQ578G4/h8Ub bHYAE4FnwTQ4wp1vlWWqmYP1cMvHgnKRgqfXYHw= X-Google-Smtp-Source: APBJJlEjwU5P3em3Zn+aU96BSqthcx1f/xAezhu+HCIxVS1kCuF7ybS++NTHe+tRksDsFGF6PTKrtw== X-Received: by 2002:a05:6e02:1568:b0:345:c77a:b5eb with SMTP id k8-20020a056e02156800b00345c77ab5ebmr4614955ilu.18.1690426904345; Wed, 26 Jul 2023 20:01:44 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id a14-20020a92d58e000000b00348d41ffd13sm207539iln.85.2023.07.26.20.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 20:01:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH 4/5] bootstd: Init the size before reading the devicetree Date: Wed, 26 Jul 2023 21:01:24 -0600 Message-ID: <20230727030128.459760-5-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230727030128.459760-1-sjg@chromium.org> References: <20230727030128.459760-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The implementation in distro_efi_try_bootflow_files() does not pass a valid size to bootmeth_common_read_file(), so this can fail if the uninted value happens to be too small. Fix this. This was reported by someone but I cannot now find the email. Signed-off-by: Simon Glass --- boot/bootmeth_efi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index bceec0d12ef3..1c9f2b1e2fe4 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -21,6 +21,7 @@ #include #include #include +#include #define EFI_DIRNAME "efi/boot/" @@ -281,9 +282,12 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq); if (ret == -EALREADY) bflow->flags = BOOTFLOWF_USE_PRIOR_FDT; - if (!ret) + if (!ret) { + /* Limit FDT files to 4MB */ + size = SZ_4M; ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr, &size); + } } if (*fname) { -- 2.41.0.487.g6d72f3e995-goog