From patchwork Wed Apr 28 08:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 428592 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp366974jao; Wed, 28 Apr 2021 00:43:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ/xFvkTeEM4oYYf3U2rPkPMLAK+P8NWhhx/ubE7mcRX9IVvnwblCVXfOefFHUKlGFN+B0 X-Received: by 2002:a17:906:6d50:: with SMTP id a16mr27575008ejt.31.1619595801750; Wed, 28 Apr 2021 00:43:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1619595801; cv=pass; d=google.com; s=arc-20160816; b=tXTD3iKX9GkSgqF9Nkk8Cpv9sIIB0ahpJ2E3ThDpeXYZbzj8W9kOcuyT3B4t1m1UeZ wnxQySN48vvCShKSNUB0H3vvEwVAqA6HLYjbKJXQLGv9rRJRsDh6YApTQaMwVpL9j68R vXl/EsoVQyTtCcVwf1WKLJRFHEFJfcXXDe38exqjTkJsIbhAa1gRF1K4tVW4oymcmlDj R67yLIdpT51ThmhSIAM82uRG2HgdZzaGaFlCNxPcvl5H4dKfzHy+GfyFRCbk2r0e2wZd E2xCu5kyLaNxMNRYxoOsWC1xHTo0+wUca0UcJrf92qKLdevak9gdiGcFLW85gPwlD4AP uu7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:message-id:date:subject:cc:to:from :dkim-signature; bh=02KCRJIuavlmEm+A3xDzYjjM0TCmlouDjszVF0315qU=; b=vFzOgB89mXStoqw6zIsAYeadnyfdWKBMd7xGkfD5MdnCnqTIZELgqe6MCW7tHK8XA4 Hgh611P2XwHZcXNzfj+uXdtwAtRFxYlrREVngpiPgspX4pQQ6AiIziwb+jbO+nS+dX9M fOIzG2TrNlm4bw+ZD9qrNXF3z0DSJn7qT1t495yHtfUR6Z3uUo9X3IXa8CovfoF3LgTh 1jlmA64XpEnYLHiQ+gZb6FHwJtn7YqbvZtRjyVHu8delVxSXx/9yqCCgzPsD9LNPNehq qd0Hi5XKWMaIupk9V6wPF2tC7ZN6/ss6ultwKm2KT58SHck/XvwKA7tQry5//VBYEXLB B4bg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=IsrtF5eX; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id n17si2268587ejs.363.2021.04.28.00.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:43:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=IsrtF5eX; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22A2F80EC1; Wed, 28 Apr 2021 09:43:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.com 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=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="IsrtF5eX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A172C81692; Wed, 28 Apr 2021 09:43:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on0610.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5E31A8021C for ; Wed, 28 Apr 2021 09:43:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@oss.nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tl07LzV2PcY+G0uFt4cZA0cMUVtOrZ0qTej3JL6yT5oXVx49ngkc7/7drpaTQ0tftueUvHFG6fc8QGmBkLUxeSE/fe6Oj30OWHtJ/1iyHtMC6eCyliBZ+Wg7V+L2iAlxJmMle3ZFoPqiaqV6bZhEWNxj6/bhsKlhqbc91nxlLzQgAhH60LYjPEhb+xbbw9CaGXZ2rIyPIf/77aTG8qSdhh9Izk3uNmOq1yO8F1sGcr4BbLTS6JZtB3G59FqkfNzJam+Db4RtykK4Y2OqrjDcKYeiFM75dUm9ZT+QkPUU6eVA0jkLWDLu45/0ptmtPach79+aWRRJz/nlQ/4dOHpXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=02KCRJIuavlmEm+A3xDzYjjM0TCmlouDjszVF0315qU=; b=P+D36Gbthc4EFM7exAwvunkvzE5Dyq4gPxUtzv9P98pq+JZmGrB7+aaVKZDa8KSgQFJyvPexGFJLUs3GNGHI6k+AwlwPGACzlFgPJZN+5wVDvtGiHYBXBXuJtKjhlrdbK6ucj+9PJ8Cb/T5HhFkQAqMaucqVvX1/HLPba5Qw/3EqXI5szCKjJt0cTGeWFLrXSHenfZhsFXg7pynz2a5uDL2gHTIGdbcuk28xX7EHqctu5CjojwX3avqhwHzqk/d1B0SRMVQqJ2RAmp7nqnK2cBIabWqp6UcnClI/dTir4tdS9T3YJv7eKbXMCP7T2LIzhdIzAuLXUO8ZxoRwVZ0prA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=02KCRJIuavlmEm+A3xDzYjjM0TCmlouDjszVF0315qU=; b=IsrtF5eXrnlZ5or9bpqdvQ4z+xIN95G22eTYYrdv4iryzGvOrYhP2iOu6Kb5DmD0f9L1VxCHjrEkWZ7VCl4SagJ7Z8I6ZDjMJe2lTIRqRT/iFKlgJ4CxnXyvnHm1nTwfkDWXjQUDrPF1V2MNcD1klvKw+auYgxeB5XPqquFDsaI= Authentication-Results: gmx.de; dkim=none (message not signed) header.d=none; gmx.de; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR0402MB2756.eurprd04.prod.outlook.com (2603:10a6:203:99::22) by AS8PR04MB7735.eurprd04.prod.outlook.com (2603:10a6:20b:2a5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.20; Wed, 28 Apr 2021 07:43:04 +0000 Received: from AM5PR0402MB2756.eurprd04.prod.outlook.com ([fe80::b158:2ae5:f2d1:7142]) by AM5PR0402MB2756.eurprd04.prod.outlook.com ([fe80::b158:2ae5:f2d1:7142%9]) with mapi id 15.20.4065.027; Wed, 28 Apr 2021 07:43:04 +0000 From: "Peng Fan (OSS)" To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: u-boot@lists.denx.de, pbrobinson@redhat.com, grant.likely@arm.com, Peng Fan , =?utf-8?q?Stefan_S=C3=B8rensen?= Subject: [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int Date: Wed, 28 Apr 2021 16:15:12 +0800 Message-Id: <20210428081512.25890-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK0PR01CA0067.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::31) To AM5PR0402MB2756.eurprd04.prod.outlook.com (2603:10a6:203:99::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by HK0PR01CA0067.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Wed, 28 Apr 2021 07:43:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b29bc5cf-524d-4bed-32eb-08d90a194180 X-MS-TrafficTypeDiagnostic: AS8PR04MB7735: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CZL47D7hPz+r7WfBq2CgSgdqxNAAK2tXZ3IK0VFzUPcbn665RGS3TAV7rpMIlpH5W9cRdQWzkYkBbzR2GwMZTbsD5KW2MvG7h+t8qRaPtgSIXKf2e/1vwJYZ89L+SBy4nIMmpsaYBnNlQ7YMUqQfUv3H10gW0v7whfb335eZsFlVcNWf5eb4K5iFVQ57g2mTGEq7EJG/zu1yZO9UTY4ueBHf3r3Uqqsw8wSDYTUF96ar3qb1OEmbylVhFW7oVXm3PGXCozXmMDRAROxhVCZ0M97cy01Sd6T1yLtxXve0yAZS4inntVYTjB/Uj3iZlL1eFB9hONY6+p+HwEeBXFn+5lVJhUFCPx+XQcDEt51cJSIf0Yj5ttquteyu6W1x6mvZ76he96nW+U0rhpuKlDFq24c8xJHensfEt0s4S51Y4hea34B90CQroZ1btX4a/mbT1peE6q3Tcswk00btrKT6C60P36Kxtdgwgu1H5NVZP9PX9CusmT23d3V9FIJ9FOcB+MBn52Ee43W0e7odpg9I7SkmwsdMvok6UTJNmkcZwqvFBfTnrgXy89cgX6REORGJ2cLb+hep9QaYnhTEASYkth3PQcJoifOTMz5zM2MCkMgp9ow+r0hJHu+FjS6P9lSvxyPIimbFPbhHjsNs8ZJYsD1VDdOIqDW1JGDDf/u+kw1850WAM0LCVUpZfzJmB21SyBzktghx28SA0e46hpgY75nFrpqdZVX8+9/GjyyIUp8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0402MB2756.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(346002)(39860400002)(396003)(376002)(66946007)(66556008)(6486002)(26005)(6512007)(66476007)(4326008)(83380400001)(966005)(316002)(6666004)(54906003)(86362001)(956004)(2616005)(1076003)(38350700002)(16526019)(38100700002)(2906002)(186003)(8676002)(66574015)(5660300002)(52116002)(6506007)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?Y3f4F/FPwOCym5wLLq34ojPYM9k?= =?utf-8?q?pe5msFnRV9ecyK2kHGw3HwzR5RVEe6kPANjKpakowzXIEVhADS1+xS1L?= =?utf-8?q?QEt5CjscbTh0hlw7e36VGrLq+UJ+Q/KCMs/T0tk97GK9OWmciO2dnGCo?= =?utf-8?q?8WM1uf8L1+RyLjxHMP+qLBeR5q7IB2ZmyP6zyGcb0g6GwsyMr1ZAFeCY?= =?utf-8?q?pl79pZciAEcu+QzAjvWKPkPGI7aiQtrNqyrxHJuFCzcXDMKmJdRWU2KH?= =?utf-8?q?lrNvOZmSWqNRg4tjuqDoIPJQxsGBKf3YGVOdx1SSu4Jdite6hjXmOtza?= =?utf-8?q?xK577vacbKMx+SDXU2+mJYceffYbWIcLKv2ceZzySn9myHt3GuP3kJ3J?= =?utf-8?q?c1nYRovEC8Ou6Z7EbIpuwB1b02R4PDBMSbKl2OU6MRYc6Yv4KVA3N3eD?= =?utf-8?q?EdpjKz0a1n9mE3HCslb/rBk+7i+6iyec5Ov6iC5uHEGp6pWgE4m3qfsQ?= =?utf-8?q?XwrlGg9p+ykMwRnFk1d7dIwKmUu2D8FgexSYZOln4cwLqK4jFn19Mns2?= =?utf-8?q?RuoCiTDxEhNlKCXqs1/apZTdD0h8StOPBU0NDKvR7OlF8cx4MLKbFzzR?= =?utf-8?q?5Urub/YszkgkKqlkL/V0sGcIMEDzO62C/IixJtnNsZWrWPNA06PwVqkc?= =?utf-8?q?gE7Sj4uYuzvRRBSTeE5/7IIcBwbO/EJT7/iuzQJ7Bi+Ojz0IlYnZXQGa?= =?utf-8?q?kT7IRjldVt4Q0IISUUhYnfDbcjqpC4Af9Z5mKAHSVAMbfxCyTTCA9Z12?= =?utf-8?q?5XT+pZaz5Go0dV5ucBzQONtXffBuKf/E2L109kkYp/V24coewFs1iqXU?= =?utf-8?q?zdtZYEwBo1mtAFl7e6tOYjZ6BpzTO6ItLAWWxhjkjzkjIbrsaUNU3Cl0?= =?utf-8?q?JM+XJpinqlG4j+/aIp/a3eaXemyrYGuFs8VipJdKb5XBzj+ddaVOR9z8?= =?utf-8?q?KPLWlfKLCtXYrmLLl08vKR/EC2FS/btHl8y/RiMVxrjORvVrc+JL2Odr?= =?utf-8?q?3b54rHFue4eTdxIk3T+kDZjvUng74mO2lqEXD+tzfjxyWTWXapZjXMkP?= =?utf-8?q?xYjicahr+d3tCIGUKhmuRMWTpmXpP6ehyRDiP6pgKYhyrsuZO+Vm2haX?= =?utf-8?q?HI5718J2bhqsbXdz448E/jc0x6qGNjAscnnJqbexDLmjDSxBVMFZShyk?= =?utf-8?q?fgip01pb9GmMA2d64/TK+reRGbz+5OV5JC+7A9cWbDH0qjCYBcnorIH8?= =?utf-8?q?rWcVVar0Lj++q+kPVb2hMFzwqS/MtNstiVEsqcJajWKFoaFbu0Dn5qaX?= =?utf-8?q?yLKoZVr4Z0MAE3N2zumRJJxjTLYTJOLCAuNU+IK+/3dgRs3k1I5Qkamf?= =?utf-8?q?gxzYLgFbo+kzqcTXRu22awSaJLy2e?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b29bc5cf-524d-4bed-32eb-08d90a194180 X-MS-Exchange-CrossTenant-AuthSource: AM5PR0402MB2756.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2021 07:43:04.3564 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GPtAr8z263bVO5oe40QmYan0BDG8kd5iEuGTzEwG7H2taf5JMXSHb+J+umEdx6iWnZnikDavYREaaMQi8W8ZWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7735 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Peng Fan This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817, but that fix was wrongly partial reverted. To Fedora shim loader, when buffer is NULL, a use-case is to call efi_file_read with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read. Otherwise, we always met "Could not read \EFI\: Invalid Parameter" Fixes: db12f518edb0("efi_loader: implement non-blocking file services") Signed-off-by: Peng Fan Cc: Heinrich Schuchardt Cc: Stefan Sørensen --- lib/efi_loader/efi_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.0 Tested-by: Peter Robinson diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 204105e25a..6b3f5962be 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this, efi_status_t ret = EFI_SUCCESS; u64 bs; - if (!this || !buffer_size || !buffer) + if (!this || !buffer_size) return EFI_INVALID_PARAMETER; bs = *buffer_size;