From patchwork Wed Apr 28 13:54:01 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: 428607 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp608904jao; Wed, 28 Apr 2021 06:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+knYO3cwOfmqR5g/T//OLON4Bf4sk0YBzG1i/67aZccwpk2JSES4IhUWLm5UZyrtcgPdn X-Received: by 2002:a17:906:d145:: with SMTP id br5mr4000176ejb.452.1619616125416; Wed, 28 Apr 2021 06:22:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1619616125; cv=pass; d=google.com; s=arc-20160816; b=C8PL9Bo5Nt3iMyBInYt8YrL6Wo+khmAXXJzLsn8jMYEWQrbFfBWJ4aeb6nHe1RoSa9 ncCxK4sekRbM2Ro8+rPcxcIsht2RbB3eldX+RnNmFbbAELH8M8+4O1sz2dJqLV3d+mb4 8skX+gHZGhmnJOXUTUsVu+k3yPf3t3Q1PRYuNGSw/DJxwsWS28voojehU/VS9wPeJi2R 0u8V7qMNStKm7B4FpBdo5LM+ljFkmGHAvqHp0pySRvWcZvrxzdYbYJNNvq728tKL2LP9 TGRhzTOBPehdlNIcfUu4yZo+zKKQe3wEVnYN+q8n9AdR5DyZy4UOh4cl3SX+PqudYbD3 zySQ== 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=Jvu1xYFUKJO/uJlsI76lQFrPlpRTiU+rjukLralExi8=; b=omZL1mkiAG/cPMcKJ1z/qq+3wMXdSmPblaGUnNW1R5ufhUyYAzVsHt6xoUxmAZEXvN v5rPIYyFF+n/o9OvQP/ExzHgyFSSANK7Gg1QWpKBRpLszLpfRIFFWmSU+OVVlxIdQFnM Au/JZxt3mdsDEila57/86vlEzPyEPNOY4IeRR76/nQ5AoDShQYLxNgPxdI6Vn4Immivk 5E+Oxe8PFtsp2paS7ltW6G9NwQ3wc2V03PDH6slse+sk6cGDKjdqa8krcr34OWX9yG9M m9yuGVdvAsHqYoERpjyp/7wjElrrZpm0Iczga3Ejl93FtsBWxixC5dSIJW7csEIsTwwV IxsQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Y9LhgRit; 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 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id mp1si2943585ejc.457.2021.04.28.06.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 06:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Y9LhgRit; 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 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 0143180EC0; Wed, 28 Apr 2021 15:22:01 +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="Y9LhgRit"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11DCC80EC0; Wed, 28 Apr 2021 15:22:00 +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 EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20614.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::614]) (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 BF2AE82BB2 for ; Wed, 28 Apr 2021 15:21:56 +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=Ykl/b+bOscXPccjkBLrnNZ64DLu+6jcykHxXg6zp1iRDn9PjYn5sAB9UzpDwBH/KBFvrw3JDaJE3H5KE1MYt/qTuXtPsUxfuHlok2cGYHW9QtYf5hVHXeWQ2CEuFUsTXn0wkc/UWBAqubidQx/AHfKQCT2TtJgSzsiaS+s0Q4xEfkByM49AF5KbOQ9dfEBqQgcpjjCPO5870sdVmZGUbHH2Alvo3NxlPP1gWLM0yVNN33b5BUxMiBgkiycAt1eN1V5lqmhkzB2i8LrKv8X+8P9n41oowUuqt0Qaai6eYOhg+bhNaZbrEUdcI47KRm5hpg1pk0sYYw+IeXo4P9EmhGg== 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=Jvu1xYFUKJO/uJlsI76lQFrPlpRTiU+rjukLralExi8=; b=fZLxEM4upa8xSPDRUr7ha1FAI2UY44OO4z3vEc15uhQcMMwddhIvqbEAMyJ9CfOjnAN3K8FzmE8uZAb5U7qqT9NqOlK0sVsPLb6rXRAIlj2lDUoPPwQ0LAzKA1A8ADxTEGJZhcy+s60JQ2mmPMgg8wf7ybi3YOHnV972Ai8EJT0dCJeEMbWJ2CjRtWZqpLyDujovr8w82q2vXpFPXMp/krwklqtTdlGxgKP9ZMU+2n0SGvqBTcXts/cE+XxraFrOTth/rdLrqKtKXGjbGGN9bW0cNJWzmYMFBwR8oU27Ygr0FZ7GFqW7pGdPaGkfjsbkqvS+8P9/4qBo208dUryMZg== 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=Jvu1xYFUKJO/uJlsI76lQFrPlpRTiU+rjukLralExi8=; b=Y9LhgRit5KPyFtT5AVfHzHnlc9O6Ssk9T3mI7BThr15G7JYL8xyLUH1Yx3UmVl57Rvgz1z8yMTCtLyhHB3Xbw82ysiOO8JpHAM1U20AXO2mAew0td3xOPWJ7aDBS2NBdGmkM4PG9WfYlpl8TzsMDJNfjpNWiID6ykA2/FGS3Krg= 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 AM6PR0402MB3525.eurprd04.prod.outlook.com (2603:10a6:209:4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25; Wed, 28 Apr 2021 13:21:55 +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 13:21:55 +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?= , Peter Robinson Subject: [PATCH V2] efi_loader: loosen buffer parameter check in efi_file_read_int Date: Wed, 28 Apr 2021 21:54:01 +0800 Message-Id: <20210428135401.22365-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0302CA0020.apcprd03.prod.outlook.com (2603:1096:202::30) 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 HK2PR0302CA0020.apcprd03.prod.outlook.com (2603:1096:202::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.16 via Frontend Transport; Wed, 28 Apr 2021 13:21:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d16d4712-33ca-4f2f-49cf-08d90a489784 X-MS-TrafficTypeDiagnostic: AM6PR0402MB3525: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R8IIzR87BJ9qITheAW0/6SscIznIBDQntrQKYiITRtr3RZNBHPGuiexfqYuAABypLYa20Kpjk8qwFtkVl5Wv9zswD2NHqy5w+BU9PNQDIw5/spSSuSNZKUBD9L1rsFxNX+pluafaP2yEzJ09OmA1rGVbLC8uc0VtwPFvuyXoPYvMI8nbxEuX8eVVs8oz6i8qTLMzAKJS7PgYVwBQQjkqPEAwfnkSibtgFyy2rBjeD18PGmRSKqwkNWkO7w3bBkj/7Zor9h/8j8w07q+Iq/ZU1Mlbm8USlj2VCmhqkJddRE7/Jj0NMfQLQJ3zZABeONnYzgAUfyXXQb4sxuuM+nqRwyW/oASjsumXU4sApadRppYdLqA2uxrvM7HduDA16u1YIOc7exaHsHSuZm3p0jnKSbUkDWki3YwYZYKuOSAhwVnxIFzdFO331d/JoJnvCPulh43Bf2ndcJ+Fi6UK/BPtUCHjzSvXm5SWO2YlsNW6EAQf/teSOpYzo6jQT3QLS5InHcfHTUBcF7z7679ht2IGrNZZc2gq/Z5eCppzp33pHTx+R+wqWt+vDU8+iho2jR4+UoTTC2VanZ8dprckWpPXxgtPq6ZbkmFKjdql5ZZWwMfKu/0DaKI+T0Qcrgo5BUNETfCuDu48gBkMrs+ewk5JWR4u9Dwgq605ea1ydic2+X7SoTc/ZQ1mnr+P5IBaTsdJxE4rLVKGAo5HZcS7X6t2b9RSQz2CTskNOlg9t+2XE0zvDc19T8CF6rTS8DkG4yQa 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)(136003)(39860400002)(376002)(366004)(396003)(346002)(38100700002)(38350700002)(478600001)(5660300002)(6506007)(6666004)(66574015)(26005)(6486002)(86362001)(956004)(66476007)(2906002)(16526019)(83380400001)(6512007)(1076003)(8676002)(966005)(54906003)(186003)(52116002)(66556008)(66946007)(4326008)(316002)(2616005)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?mYfVlOJMJVsoKYMLc92rFnaCTR+?= =?utf-8?q?XLQNE9Fknv0C/Xkfupn634/z0PDINPn1vwI7UBh2GXDundoV+tDpV3/J?= =?utf-8?q?9Ao+ZaklGBv/35YvbogOLThhUOpbrxM2+PmyMASh2BwZQm4j3DtGuxer?= =?utf-8?q?W2benG82zAGjtAJ70va+RfdHJfMOIDL+Oxkvqa8F1tiAWyVebMmTb9Lv?= =?utf-8?q?ZQdnkJtClzsGEsN7JuXzN5zAG9JnDkptt4s0xR8Tngwj+0ktYv/WIYfW?= =?utf-8?q?byVRKt2cGY+IbfGzOgHeeR/6msyKEXY6EKxdrGpddqp/uOGuH2BlhbQt?= =?utf-8?q?qWthQJBCUI+HaR7mZgiEJctgT+rWAgDrZMTtvzQT/2TTs+4LPqu1h8tK?= =?utf-8?q?SW3diXo+rqN1splk5PQ0rbM9pPZECBGS/9KWkqZOCtKtGQWbDf1N4t/t?= =?utf-8?q?XjJ+JS/eOy0dBvhEmZ6tbCB5HpkLj/GbwlXsIm6aJbCXmd7hGzt+B9av?= =?utf-8?q?Rbm6uYmrHxxMBLr/kYUvivhGCUqFEuApHEUlG6yVU6rFPTtzXtE9aYWl?= =?utf-8?q?sF+IFI0YAUfgmi5X3c4fvpdyhxyz0g5S58VT2SXLiBxvhwRX/5stsFvK?= =?utf-8?q?urZjoTi5m7GkFJlzD3JpY5tikAgxS48dfUkcZRBLJKtpJln7kGQ4yCyu?= =?utf-8?q?xkJfyN+4VDmIEUQgWmSGwo0Z77B/A1lYejj+poC8BhkvFUTynlVzcft9?= =?utf-8?q?BNfW3rQaTOoNFmU3wiIqRxDzWZfkL3tZroLTZJnDN6KOrK2xERgFeiIt?= =?utf-8?q?x0xafXIOmUEnPoWUY1jtqv7qdVGy2HyJ6Us3tI8KNIL/Ezl9Cl9Wm8FR?= =?utf-8?q?h/qZG13p7g11rt+6Bue1jxVckObYlnLPUzuAa2ZzqB1gZjXKKXDgS9eS?= =?utf-8?q?sr+1aDjv0MZCYmHZIBgmkKI0oNiqOWuzYI3T3ofJ2RT1TKthFErEJu0d?= =?utf-8?q?ZAZH1O2YxGlEpXKzHeahQ8Zr/xhS85QykeKLXr+XKvURNH/yiY4KETT/?= =?utf-8?q?kTq5BXPjIDIHtKaa3UnE8DTaewaqy7YoDaolXatDKpuLa9E9CwRbrN2D?= =?utf-8?q?38XwteMWDd5zCLvLZ+g7+pUjtqyoHs5lXbvTqb2DmK8tr3nMHzx5370Z?= =?utf-8?q?V+bfbKvyqEECHE+AyXyb94GtEQaYgatdcI61SuVO82ZWimQgBtq9BAdY?= =?utf-8?q?ABcHPMBpe4BuiQZRO2VdwtaUrLAZc4xyFTPnrnqM0ajr5/9bMQ4QdAr+?= =?utf-8?q?eZL4d88AuBRbax/JmKGSxLCxUVyAjXtrcEnoibNf1yLZlcgAp8kEaK1m?= =?utf-8?q?MOh2B7UflHobGwDKQKgP5I34mBssnm96TCDU6t+rHhProt6OgOKQPoQ5?= =?utf-8?q?gmKvQx5CBsVuTA03gJ4gCfW4myFky?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d16d4712-33ca-4f2f-49cf-08d90a489784 X-MS-Exchange-CrossTenant-AuthSource: AM5PR0402MB2756.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2021 13:21:54.9886 (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: kJtC/i3wLmUtXCoTbf/Jg1qhdz4MvWusai7Piwigv6OEGOknbKvDpIUrRwJMUXhNsSApid+ni8lC5sO+x5y30w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3525 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. When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read. So remove the check only for directory reading, file reading already do the check by itself. Fixes: db12f518edb0("efi_loader: implement non-blocking file services") Cc: Heinrich Schuchardt Cc: Stefan Sørensen Tested-by: Peter Robinson Signed-off-by: Peng Fan --- V2: Update commit log Per Heinrich's comments. Add T-b tag lib/efi_loader/efi_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.0 Reviewed-by: Heinrich Schuchardt Tested-by: Michal Simek 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;