From patchwork Wed May 12 14:45:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 435603 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp5016019jao; Wed, 12 May 2021 10:06:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQXpabwzPeOC0TGAvj71bNq6XAHwS2LIxFWFMeZCbZH8NpL4s0d3ZDrW1QWCyu/e6S6S2/ X-Received: by 2002:a02:cf32:: with SMTP id s18mr4607908jar.31.1620839168969; Wed, 12 May 2021 10:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620839168; cv=none; d=google.com; s=arc-20160816; b=GWDwYbFzylDzgbRvIUwlA3e4wurfaK3U3FxTcw3loLGvza4aWPkpncc4uM1vuwPOGm RHpIKqIJPjspMVIILBf5679cRf7cA0ufG/KTp9w7eIhlNg7n8hrN1yycTya2nO/isvW3 95vc16R0yvMAC0spWNw9UAQf4c/f2FciyvtnenNmyoSlLDvhKvomP87Sr2CjgPjYgYW+ 0YfHpE9Cl8Dw4cnjBGoHZb2O6ALvDzzY6uMMkzewXdpMFETc4qD5877LfQiUqLzcdRJ6 LOL9SpoE2z+vhldzXspE8+oFnhtBHqPWp7o5ifLdv3MJKC6aY8kHbAHJ28VlxmuWYMOn Z4ng== 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=wtvhwKxBt6l3KQydlzrbCl/Fqw0VcKAZFMLGZLPigAh2akXlLH6+pdwwUz4aLdpPO7 kvzlQxSI9ePcd+cY2wYCkuJtKCz9dAfJYoa54f/4p3c3Cav8VnSjaZa1VaFCW7Efm8mK yRbjwboZE5zQLZGFC8PDrDIQVYqmrUututN0guDNDuIaEndTJngDE8rbG+q2oY8RKdSu TNfkMhwOTwRAG96oVZEJtl2n8lbOykC4bgae8XxWkwRil7QFYYOC190BI6z5vyQkbSF/ Yc97JB4Ptsb3t5fcEDk30F1LFijgp/TZnfrijPwgIReQJa2VsTqCTNERA+SGZJudUE6h TGhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QLCzUHhN; 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 q8si330223ior.12.2021.05.12.10.06.07; Wed, 12 May 2021 10:06:08 -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=QLCzUHhN; 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 S237926AbhELQOv (ORCPT + 12 others); Wed, 12 May 2021 12:14:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:58912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239193AbhELQHe (ORCPT ); Wed, 12 May 2021 12:07:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B7B66198C; Wed, 12 May 2021 15:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833812; bh=Vzc7tGSAr1z6+iSgLvZ/TNMDpea323OpeKIft7ZbDag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLCzUHhNYaq6HEuqXiyMqBNZ0N5lbFJ9rhOzqV97K6hG5d0m1eZVXzy2uzZjBRTf9 Qmt9e6yiM0u6CYA7+rmExPQTPY11O7yC6NH3aAxOBzo6AkBys3cR7tyq2U5/6ZGiq6 beOLQ9KQjhMRF+NPatBV1gDCYZDyVaSsXpOnzG6s= 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.11 253/601] soc: qcom: mdt_loader: Detect truncated read of segments Date: Wed, 12 May 2021 16:45:30 +0200 Message-Id: <20210512144836.156157602@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@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); }