Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4598813pxj; Wed, 12 May 2021 08:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq+D/r7Isylzmnxb5xPX0Z9EWSdV6hkzm4vvZBthLtESAHmCwRo8WEsZCVEcQk/9sY/Hhr X-Received: by 2002:a4a:b1c2:: with SMTP id j2mr17081591ooo.78.1620835181624; Wed, 12 May 2021 08:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835181; cv=none; d=google.com; s=arc-20160816; b=I9sVjWbRg3ofeVfrkysxoCbmXCye8qZGD2uY5BhxWxIoPg8NEn329vmAKqUAApbXjm kd8T9hw09OMprzAn+zJhlMMd1piENeDJ0lglJ58eLDm6vrBIXLFcY4t97mWv6eSyjbTf 9zAfihaOzO51JBZQp2jxA8SoMJbEUQhiquP8AnmWKk8GSd8MVn9pixFPvc+GFts88UhH LTFAUMWjZsRh7bYW+N5bLJ1i6qfRdZclSQnnsytigNrjHtwpUqsHXS2AkZfGcvkq7Qyr FxI5MIWcO9VLJUj5dnN2QH1OQ/KEEKcCt8oB8R2PrLRb/oH285DWYknM4GPTWGP8ibDY zG+A== 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=ODkHwEFQb8cHm6EBBLUvRzrJNQnVbyx8OjVs/0/vEhO96T39bHJ7XjLqe7VsS4HrRU /xmnLmqyoX17wK+tGt2fHrC/cRUaYGw7ZeeJKlYoFympie82FCb2wAHLSlGBbMNYQbKm LbRsV6tMcXwqXD8L3RB4nLkVXUa5CZuU2gnpZyXXxdgfWc0Q/O47bp+b1DJGRbsn+G4d xW0Do9iZQYvI5gAnAvqrBgB4i+97iTswc5kMyAyTL2Si5U6i1EUShxAhQr2BY8NngviC 2qb9Yf3HvXWkBlR0RGdI5xUkoQbmSYvIKTFzAKOin/Ljt5TuO9rbmIzvcuIb3FeVMZNs ExQw== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 v11si162581oor.49.2021.05.12.08.59.27; Wed, 12 May 2021 08:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S234258AbhELP6H (ORCPT + 99 others); Wed, 12 May 2021 11:58:07 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(+) 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); } -- 2.30.2