From patchwork Thu May 20 09:19:32 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: 443191 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2129828jac; Thu, 20 May 2021 02:54:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0aDK4qEOGyR356VUvw9Tym9xX5ciHVDbfodlWn7RWB2IYeQUEir32x5Woz/tXTPU1rkDo X-Received: by 2002:a05:6e02:1b0f:: with SMTP id i15mr3751707ilv.164.1621504490012; Thu, 20 May 2021 02:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621504490; cv=none; d=google.com; s=arc-20160816; b=zhnQz55iuuiV8kYwwygzw0bMFLG9GtVP4NgMwI9dYZASX0uw4rm+KTUspsCjawOKwN vpwvQt0UgCeRRO04n65X+bzg4PN4EfmeZowDVoi0yDvkOpD9YjZvtTFMr/GAb/H0qgQV Z+B/szIpuj5CNTeTO7i5tfYqad7HQ6wR4YdL5dvmPIlR4V1zkD/VkLXQOVODzmicpNBW qZkY20cvnHtT8rH/rhRy1YJe/nzNlmNqTbJblLglEdH6XZf/+1grH5UswrHFfg1EivE9 w7VWrM8n8Pe6fHDs4jHojaQnKuppmwnbty+IQ0Uckkz3lw/GE0IgLwyZOUx/PDOw5WQN nvkg== 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=9XXHYTa0Uwwq4umReK+3ujbGf7eIckkAU2W7EDZXDpo=; b=xsvFfz3zlTpXQi6wOcQ6Djbmoo0xac/SQQdG9NofNYK1wMw/4yAjWhDPmK3UBbS58B qZmFvoZsFTmy3g+OzRvBTMfWjWEp/Ehu4Do27mczlwFeMl08+Dwev79eJMtvxSqNTQts 0zrSORjGRymVqKkKRRPLutIF7sPu2Kdn0izDW7BMsCYhsnM6xcg4n3RUIvwQWKIkkVVu 7SWGYp6QmT9JJ7mmfUiaqt2/Jx97gkzN/h8GV2X5W+o5lqM5Dw4Rzb6raRPpq0IFX8w4 +/16+l4UxFKmaM1h51nL81W/Y3QTqtiMgz1QweKPPXfoOOmdEc1rWGfk75+TWUtpahPg k1+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FRY6hxwo; 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 w36si1802867jal.44.2021.05.20.02.54.49; Thu, 20 May 2021 02:54:50 -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=FRY6hxwo; 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 S234391AbhETJ4H (ORCPT + 12 others); Thu, 20 May 2021 05:56:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbhETJxt (ORCPT ); Thu, 20 May 2021 05:53:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38A7A60FF3; Thu, 20 May 2021 09:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503398; bh=DfdOwyS7EFK7TW++18nDfcmXVvmmrXzU1SsNLwFnNhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRY6hxwoywVaD5+oSmIU8a0K0+NLlaDirhFgCQLe/oA8sw49ICffy4csfaBhhtF+c KQzZv7p0cbF3Bpnzam52E6ElABoQxncAYcP0BwBTVfw2behC0As70bKnljqo07YnLo nT40sceMMgSnGrr9spThxN+rgWLZTrDB7qIZ0Lbg= 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.19 203/425] soc: qcom: mdt_loader: Detect truncated read of segments Date: Thu, 20 May 2021 11:19:32 +0200 Message-Id: <20210520092138.085430213@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 7584b81d06a1..47dffe7736ff 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -187,6 +187,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); }