Message ID | 20240131094253.20384-1-quic_audityab@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1775162dyb; Wed, 31 Jan 2024 01:43:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFecDWMaSQFdvwiBtVGJwUPGn+49+Qz0JqatgN26D+hjMZE3N7rXrwtVz8w2MFYd5xKsydn X-Received: by 2002:a05:620a:12c4:b0:783:fd95:d37b with SMTP id e4-20020a05620a12c400b00783fd95d37bmr973119qkl.16.1706694204576; Wed, 31 Jan 2024 01:43:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706694204; cv=pass; d=google.com; s=arc-20160816; b=vaBUZjTWrY8Wp2jAycJlV9rST736N51d92vPW1R0QjKp7mvnR6b9FCmsgt4wqKPf2O o4vJormz0gorF1C/22KFIzCHj/MUNCQB5+Sf+KcW71RMxYkKlPyorciAsNpiMjBlje/u CxobUMLMRiYQdWfeUuLbaTN3InbRUFZF7xUS22ixje6Zby6NrfM6JiXyXV+iDoIh7H7Z 1jpr7G3K1xW5agbZiX13GhwNOjGkWtnVl15zdjI64UTUn31Bip5aOcWnk/3UkFseCdPT BCyvS4fo1oKeW8lv/irSM1FMVO3R+p5Rn9q0eizkoIPPmt1yW3Y3021JqWScObojr8B7 1LXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=TN8sUvXkG9tan3zwgK4OGu5R676NcyPOdYBP/KAfGds=; fh=S6+yOdkVLKxSh+mv2kzsrp5cYVrj9QqgI2mnFAMTzk0=; b=ndyMqIkP6RDAWJ4XldrADvM3/z653ijfx4SmMohy9yXeVj09gR4COggp5NgyWBog5H TlCA93hSQRCmQgeEXMzfUaVgip72kdGMbqBFg83YFtoTSWnAQubh7jt8VmHxynr6ApGa 0KHoDR3RXflFlyystNlrrmGFQsAwA5ba7aVeEwL2l6E1MkNA309qEkTSSDrgv1FPU+7S lIxK3tbgnM8k1NpfIeLwIKnfEr07vSsxIPb6XQGWC5LpfCrMre9NrkHcEYS2o+CICn21 rh6p3GOFaFcFbBLTISJgbv8ngJCbkinPT2n6hr2fdbq++Ah168yxRtpd4c4QL4FXUoyx fJ1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Bq1S3GYN; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCV+yl4jrFCnK8PxckYgtN/U8/J+fBR/EEwga04T7Yu1U7sxHBdwfOOSRe/lLGTp9n2s2hp0sQVhysjtIsGVGdTzlEOA6g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h7-20020a05620a21c700b0078408def5e0si3769689qka.419.2024.01.31.01.43.24 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:43:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Bq1S3GYN; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46155-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5E6D01C2163F for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 09:43:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E41DF6994B; Wed, 31 Jan 2024 09:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Bq1S3GYN" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A0CB67A16; Wed, 31 Jan 2024 09:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706694186; cv=none; b=JbYzvTwLBSLmSXX9T4JrBs/eAc7CdbbZ5qHZgpzX6Dqv08JIeZPlH/Z7gx19A4NVxGjDjo4rua9OYDyqevZ/CS88Qf2E3ab/Ku9zNSdQQNQon4HgZ3PsoX3yqdXKGioDCze4XL49tomSbQLBMJ+Vxe16TxFnvQrRyYQ6cYrK4Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706694186; c=relaxed/simple; bh=+3j16HGIZAY4J4ZI60uEGjVzbBn8FpbNDoy1EDVdFHo=; h=From:To:Cc:Subject:Date:Message-Id; b=n5DwC1I0tYuUttP+oN1VPS++PEeDBqO+vAl0aaSyRMQttDr6b77wil4tAGZuO2C6YcP1Ts/tDVI5RTRAdkEluOeh7BxG6IcQrp4X4rG6KlBFFz0M9Mqv2RtKDqsKiQX/15+VrLMjjhwJyf/cyuXs/uQN4d7n3tIFG5SThJCiI+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Bq1S3GYN; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V80efM016875; Wed, 31 Jan 2024 09:43:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id; s=qcppdkim1; bh=TN8sUvXkG9ta n3zwgK4OGu5R676NcyPOdYBP/KAfGds=; b=Bq1S3GYNNIHG9pXoyO22im1PE6mf JkqGXNMrMJ5cEyJhukntcsP78Zni8m0NMENIQl+VX5SLmBltHpVOe69PhxkYX4oM OTTywGkylxW66kbfrKXKDfXQXNcZU7UKg88BR9JASZwJGO/4fb5cE0e8BPQhZlNf xkxUXf3lUN4SVkSdvEjabRmKs0AsREH+boyjpQmNnItx3lbwB2VSRv92qLv0toCs 1lEIRdiiwT5FJ2h2TAXZa4gUGPXQTEm00WUzxO9+i50TPz53ZjNt4XhheZF1Avg/ pGOlw+ufkTO5jn6MWUFSyfLOF+pjSjBoYQn+OGnQkOohjJzx15yHQW4V6g== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyjas084k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 09:43:00 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 40V9guWa008461; Wed, 31 Jan 2024 09:42:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 3vvtwmc41r-1; Wed, 31 Jan 2024 09:42:56 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40V9gu4s008455; Wed, 31 Jan 2024 09:42:56 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-audityab-hyd.qualcomm.com [10.147.244.159]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 40V9guun008454; Wed, 31 Jan 2024 09:42:56 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 207879) id 876B35001C2; Wed, 31 Jan 2024 15:12:55 +0530 (+0530) From: Auditya Bhattaram <quic_audityab@quicinc.com> To: andersson@kernel.org, konrad.dybcio@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Auditya Bhattaram <quic_audityab@quicinc.com> Subject: [PATCH] soc: qcom: mdt_loader: Add Upperbounds check for program header access Date: Wed, 31 Jan 2024 15:12:53 +0530 Message-Id: <20240131094253.20384-1-quic_audityab@quicinc.com> X-Mailer: git-send-email 2.17.1 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: KjhyxFA81mRL8g4Csd0T608oga8KSAz5 X-Proofpoint-ORIG-GUID: KjhyxFA81mRL8g4Csd0T608oga8KSAz5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_03,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 clxscore=1011 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310073 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789598582533607898 X-GMAIL-MSGID: 1789598582533607898 |
Series |
soc: qcom: mdt_loader: Add Upperbounds check for program header access
|
|
Commit Message
Auditya Bhattaram
Jan. 31, 2024, 9:42 a.m. UTC
hash_index is evaluated by looping phdrs till QCOM_MDT_TYPE_HASH
is found. Add an upperbound check to phdrs to access within elf size.
Signed-off-by: Auditya Bhattaram <quic_audityab@quicinc.com>
---
drivers/soc/qcom/mdt_loader.c | 3 +++
1 file changed, 3 insertions(+)
--
2.17.1
Comments
On 31.01.2024 10:42, Auditya Bhattaram wrote: > hash_index is evaluated by looping phdrs till QCOM_MDT_TYPE_HASH > is found. Add an upperbound check to phdrs to access within elf size. > > Signed-off-by: Auditya Bhattaram <quic_audityab@quicinc.com> > --- Could you print an error when this happens? There's a lot of EINVALs in the MDT loader codepaths, but you never know which one fired.. Konrad
On 2/1/2024 8:20 PM, Konrad Dybcio wrote: > On 31.01.2024 10:42, Auditya Bhattaram wrote: >> hash_index is evaluated by looping phdrs till QCOM_MDT_TYPE_HASH >> is found. Add an upperbound check to phdrs to access within elf size. >> >> Signed-off-by: Auditya Bhattaram <quic_audityab@quicinc.com> >> --- > > Could you print an error when this happens? There's a lot of EINVALs > in the MDT loader codepaths, but you never know which one fired.. > > Konrad Sure, will add error prints
diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 6f177e46fa0f..fee86317ad83 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -145,6 +145,9 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len, if (phdrs[0].p_type == PT_LOAD) return ERR_PTR(-EINVAL); + if (((size_t)(phdrs + ehdr->e_phnum)) > ((size_t)ehdr + fw->size)) + return ERR_PTR(-EINVAL); + for (i = 1; i < ehdr->e_phnum; i++) { if ((phdrs[i].p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) { hash_segment = i;