From patchwork Wed May 12 14:45:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 435565 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4943608jao; Wed, 12 May 2021 08:40:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWuYnA0M3B8n1JxTAyt9M48SJfBMB3APW71C/v/LnYLkgzbk3O54QkzLcI7/DMkN5TN7n2 X-Received: by 2002:a2e:3c07:: with SMTP id j7mr30731971lja.307.1620834010370; Wed, 12 May 2021 08:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834010; cv=none; d=google.com; s=arc-20160816; b=0T0B4jgDimAJB61u48iIg5sp1cSHQrPfsh24pVwTR41j1OpE3LhssO8ATIY5mfqOog ZhGbt1/7fcV+TL/ZDdkl4wcOA0IJfi88TMBuZyzWCkSfwXmmYcHNOtb2uiKBvi1dg1hX YNSel9B/TGTAuD6npQCFpADy3iCzRVFLmFGts2lGjsT92F6Ykp9OMWp2Uish1xhrWOGv RNE4H41qvrTJZ1qgFIqt3Akbb3qIAaaFpt1OD2RNbulrxm1hFYbB28RVbeWeYdlwrIzM eoev6k4ttG0sxDptnkn7ep9TTAnAHAS1sxFvMsGJP9jxa7Xpm09scJirjRtWCSBla8f9 ueUQ== 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=8x4Jc3kRfqn3ZKx7wTvf/HZd/MHoN4RWHsh4gs6KUmY=; b=MTjtnIrJhDlozGDNsppzyH/hQmO+IMjpUgeyanql46cIBgZH8ePc0sJguJcygz3Lri 95ZpfdYplk93SWkDOd00TJQiZtGZ254jBd5JQ/qAoGGroLk8l5VweQSqabYBk7bEN9qs m0ItqXGEZ5crv+7nwnSYv43uGjI1aF1wLYG25/Z1mAZLx9OJQgeuEqmvRcgf3y9c5X21 GI6mv5HxwUiJq9tdt8mB1bUOwrXkAqlC7NGHdIaRbHzNUMF8G0TqrBW6QAzJSNKXFRNd T5JlxVKD02EEoT14TUP/L6lEDU4hXWtT+MEFt1XXMvF47fUEXN+6sKP2zSxeZixoJGlA b5Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MTJNME39; 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 m20si100438lji.284.2021.05.12.08.40.10; Wed, 12 May 2021 08:40:10 -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=MTJNME39; 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 S234023AbhELPcB (ORCPT + 12 others); Wed, 12 May 2021 11:32:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:40490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235458AbhELP2E (ORCPT ); Wed, 12 May 2021 11:28:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAB6961C20; Wed, 12 May 2021 15:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832381; bh=Vzc7tGSAr1z6+iSgLvZ/TNMDpea323OpeKIft7ZbDag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MTJNME39jxYonNGoJ1xgZAM+AHdGLX3RnbEORo4GS2Gu041vmmspgjSs9V3LOO1T7 xugk2U8YXQfa94fDALnwUMFntKHJk/6VBZj3cJQeVASkPsh89r28BRb4OpsUpn4M6q DLuss/IcEvCXvSzhAocEOW+zue6nQC/K0VfWNAi8= 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 5.10 222/530] soc: qcom: mdt_loader: Detect truncated read of segments Date: Wed, 12 May 2021 16:45:32 +0200 Message-Id: <20210512144827.128000067@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 2ddaee5ef9cc..eba7f76f9d61 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -261,6 +261,15 @@ static 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); }