Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1102240pxa; Thu, 20 Aug 2020 02:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRViC6bEYnCOjTEZdZxi8Edzbcl8qOt1RvovyUSPzIAkYHCGA2MXOvH7tTnIfzaqskx/aF X-Received: by 2002:a17:906:c34e:: with SMTP id ci14mr2485156ejb.335.1597915839884; Thu, 20 Aug 2020 02:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597915839; cv=none; d=google.com; s=arc-20160816; b=hRMKku40idZ1xCd19BzrxXmFUND+2FKgqiZ4GIK43vJoleWZ5u4sSqHldCt067t6Sq YPA3HSB+iXsOHOGCWtd3weKy25NT7d6GiBJ1UUmru6bzUwbwfVvOM16mszEtfb9az2Ay pdhI/fXDQKvmgaBGqn6/BfaWgLuVcmrK2i+PWLBxvhd0XkFs4bbSaWLQjP3g+s+KloAj NHKZ5k3DDs5ffz8fwTrf1lmGjyJpae7a3YQn2BvYZPaZikH5rNejSaTfd/w4WXT5B1Cr twxy96qQDdk/bwC/5O14a+p5nv5AIvGxai3lKSABgnQq0ele4MA6R5VqrSZylluAGyUb MqGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nn7Zi/mP06XV4XSvD/OPIK5uf9zCA/l6t7TaIEZVjYg=; b=cbKcg0fD5kKlv7B5O3Y1ppLGF9tFSdLKoWj7cAU1sTPC4T1vvNa1FBIlNJ024kAjgr c6SyrO6WLFl8s4/YpSqkzwshGrnYk203FB+8WcZCShvCiBRHlvtBQ/D6Ic20cLdwcUPN u/T32USp+CCZOuiYnL5Q40ttBUYEYitf8MyScYgo6nnvhviwbt3KaEPrNUCS90v9k7c8 Z5pybW5XUPl/3v3qCRryS8wK5l40HEkKxMZ5Bw5DH1VmO/DTLvdq34rbeCdK2CVMTE41 rW18SQjDQIXCXWm3Xo5MEe/zYmmqmCABE6iz4TV1/gW9DuHV95Xh+WbFESvhekkxxt92 /CAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="d/qw8mR5"; 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=fail (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 g12si836056ejr.622.2020.08.20.02.30.16; Thu, 20 Aug 2020 02:30:39 -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=@kernel.org header.s=default header.b="d/qw8mR5"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbgHTJ3n (ORCPT + 99 others); Thu, 20 Aug 2020 05:29:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:37472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgHTJ2g (ORCPT ); Thu, 20 Aug 2020 05:28:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 514C922BEB; Thu, 20 Aug 2020 09:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915715; bh=OomzG7dA9asi6NfL/AWCE0vsBRX8+YD2MqecWk4xYYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/qw8mR5sG8S/BpNrKuVXG46wAizXGNexolQ4PfzpMX3rYimvm7fGBRAv5hBHq2GD l9RlhuCCxU1vVHpTE/+G4wqYuoQBitN27W9cNKQZT1DB4/mYhoEPRoBp6hRdaJ8YnQ tWDVzdsaHpoXDas6abCSHs3ny9Xi8sQ2vbUMov7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Sibi Sankar Subject: [PATCH 5.8 110/232] remoteproc: qcom_q6v5_mss: Validate modem blob firmware size before load Date: Thu, 20 Aug 2020 11:19:21 +0200 Message-Id: <20200820091618.150272569@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sibi Sankar commit 135b9e8d1cd8ba5ac9ad9bcf24b464b7b052e5b8 upstream. The following mem abort is observed when one of the modem blob firmware size exceeds the allocated mpss region. Fix this by restricting the copy size to segment size using request_firmware_into_buf before load. Err Logs: Unable to handle kernel paging request at virtual address Mem abort info: ... Call trace: __memcpy+0x110/0x180 rproc_start+0xd0/0x190 rproc_boot+0x404/0x550 state_store+0x54/0xf8 dev_attr_store+0x44/0x60 sysfs_kf_write+0x58/0x80 kernfs_fop_write+0x140/0x230 vfs_write+0xc4/0x208 ksys_write+0x74/0xf8 ... Reviewed-by: Bjorn Andersson Fixes: 051fb70fd4ea4 ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5") Cc: stable@vger.kernel.org Signed-off-by: Sibi Sankar Link: https://lore.kernel.org/r/20200722201047.12975-3-sibis@codeaurora.org Signed-off-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman --- drivers/remoteproc/qcom_q6v5_mss.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1144,15 +1144,14 @@ static int q6v5_mpss_load(struct q6v5 *q } else if (phdr->p_filesz) { /* Replace "xxx.xxx" with "xxx.bxx" */ sprintf(fw_name + fw_name_len - 3, "b%02d", i); - ret = request_firmware(&seg_fw, fw_name, qproc->dev); + ret = request_firmware_into_buf(&seg_fw, fw_name, qproc->dev, + ptr, phdr->p_filesz); if (ret) { dev_err(qproc->dev, "failed to load %s\n", fw_name); iounmap(ptr); goto release_firmware; } - memcpy(ptr, seg_fw->data, seg_fw->size); - release_firmware(seg_fw); }