Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp443491pxj; Thu, 20 May 2021 13:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpfKC5/LgtzIA3mp8exrHD6dRFktUB7RofzsCHg32uNWjTnY1b8cLfHQoMJgqLZ0lzl4Ak X-Received: by 2002:a17:907:98a9:: with SMTP id ju9mr6295889ejc.257.1621541024874; Thu, 20 May 2021 13:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621541024; cv=none; d=google.com; s=arc-20160816; b=r1hk/sacEAPFtp40rY8tZuhd/LdAioheD7/edfCNRfyaJ4nA91tzkzR9zQ0K2ieXxi HESpOFH8BvFOm0QIz+OS8jd8LA0iYkMEShR0YfHFNk5qQJXJubZ3n5nzKduPFTdg0F0H yDesezL4k33CJO09BeSiT8+VlZ/lwaONNK7b7joR0lD2tnNc/zq48klkKAw9gIB82SOB H/BJuFC7LQej6pgzH1I5f48i/Tef4uCSZLfWxhfXpLKHsRUvIzmIW64qo+eUtUCH4tcn oiCrSCw95ZwhMU75cYfCaZz/uILbPSIeqPV/bvaDgZuWW69UzvGvU12fgxhWA/CO1x1l 2b6g== 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=UotOZsYpqWpMG2ZVewUav8g+LjFwlnjVp2sW/h2RZ4g8dSohYK/wI8iMEw/EwuAxWx C2D9LvBpkvx9onkkHXWYDNeH0jxJWhvO06DxkrePoBwuR86qWAwvGKej0k57UtsBWHtZ XrTQ0KLAfLZbROoSsryVOnhrgOEGE9GVve5Ircb3FEwEdz/Yj0BVR5ej6MARV4w+bt6U UWz9rEUen7k+26K5LEzSNJ9k0apXGpmcBz4Icn+Wv2milaB7aVVBI6JdWpdwn4ZrCyY9 qbS6usYfiAIFbt3k3cIZgndUvpd4btu/M9cPZY9/n8oHnXtqPXM/78gymTEVr3cmkdJb 8B2w== 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 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 cr15si4453181ejc.676.2021.05.20.13.03.21; Thu, 20 May 2021 13:03:44 -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=AQdvjTbB; 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 S237640AbhETKpy (ORCPT + 99 others); Thu, 20 May 2021 06:45:54 -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 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 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); } -- 2.30.2