From patchwork Thu May 20 09:20:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 443208 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2156735jac; Thu, 20 May 2021 03:30:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuNanUwjAYwEQhZsZ7P6F0m6b1S06C1VVWGwWW7ay+unSnWsLKlNpbCUETTc0vQJXgUzLS X-Received: by 2002:a05:6638:b14:: with SMTP id a20mr5089799jab.132.1621506629127; Thu, 20 May 2021 03:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506629; cv=none; d=google.com; s=arc-20160816; b=mSq2YneF+WJtBckHHNHNxrArLSGlgOwM35yHvzqd6tVBUsbDBWmqRnwXQ+wdlo9x+a 1qVCIlswEY+61Kjfz0jSXB7caZp1X2lrhRxhS8L49cqJXIz3U9p6tquKxdaG33K0N33y pYkK4Wr2n1Myfu3sUBkz8htcIRGS0V/MM+w+PGpzOzbwbiaXQM3jzMh50rfIlHvkGt6+ oknVeeqbUpfYJoCoxc7CRdXaK7aysNO7Z2UB6ou5eWaeoIWxAf5Kc3HDnJw7bNYmgFMw IKUeIvXRww68FPZ91KBy6g6tIQLDxGQ9Oh04SCMpuReM94dIsEVfp5MdiP19hyvGP0v4 Vaag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=axOBIFUYKZGMX7fs51JPFBCyJrx6M0HiEotH5nUciIU=; b=WYgUJInESojnjz1R5paOvZSqnzJ9e197PQW5Ati49VgGrkbHkF2sRm6vECoxSIOIwd r5aVQLn+8tjgjhnI66ybWPBlibttXdxQW3liab2YJjKTHCF9YsiY3/5GN8kjCIrNS7bU MFu/vZnjbZydw+ntWXujkMgFysvDNXryCauVmqOKI4CnohU+H20i48CeJa/tXvA4Rncl eFR1M+t/cmfZD1jvXhvG72KEmLmfDROYAG0alxCoSeVwOt3i1Yhdm/77Jnbfu1A8UYye ypDuhmvveh/DuDGLRH+mGoj7hjBSWCOWRUInT/3IPytSAew0aXaLECi5N6WIMNu7+OJv SJxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AQdvjTbB; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m14si2193789ili.85.2021.05.20.03.30.28; Thu, 20 May 2021 03:30:29 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AQdvjTbB; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234948AbhETKbr (ORCPT + 12 others); Thu, 20 May 2021 06:31:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:60752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236002AbhETK3q (ORCPT ); Thu, 20 May 2021 06:29:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13DC7611C2; Thu, 20 May 2021 09:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504303; bh=X77CZ2mhBpvbf24kDthnI68hyzl0G4DvTeW/MrSqEqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQdvjTbBH2+tRQ+7LvOrUO46D6YapsJYUPMRreyxmDvyj8O95ANHf5cl55k1p/bcA ODUTOp4JjWe/kf04PYS5sKFvoPPFFA+6dFoXw/2401bWcN+cFSf1Ok8M61XLB2ndKv muHaMg/7KovMuzLQ1qvsNJgWhD3toKd6YyrDPXsE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sibi Sankar , Bjorn Andersson , Sasha Levin Subject: [PATCH 4.14 167/323] soc: qcom: mdt_loader: Detect truncated read of segments Date: Thu, 20 May 2021 11:20:59 +0200 Message-Id: <20210520092125.830445780@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjorn Andersson [ Upstream commit 0648c55e3a21ccd816e99b6600d6199fbf39d23a ] Given that no validation of how much data the firmware loader read in for a given segment truncated segment files would best case result in a hash verification failure, without any indication of what went wrong. Improve this by validating that the firmware loader did return the amount of data requested. Fixes: 445c2410a449 ("soc: qcom: mdt_loader: Use request_firmware_into_buf()") Reviewed-by: Sibi Sankar Link: https://lore.kernel.org/r/20210107232526.716989-1-bjorn.andersson@linaro.org Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/soc/qcom/mdt_loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.30.2 diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 17cba12cdf61..9155b1c75cfb 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -193,6 +193,15 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, break; } + if (seg_fw->size != phdr->p_filesz) { + dev_err(dev, + "failed to load segment %d from truncated file %s\n", + i, fw_name); + release_firmware(seg_fw); + ret = -EINVAL; + break; + } + release_firmware(seg_fw); }