Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1940923ybz; Thu, 30 Apr 2020 08:07:39 -0700 (PDT) X-Google-Smtp-Source: APiQypIY7mnxTFmAkj/SeAbY14+9qAhb8RJREJKXBlBiPk/20aUhM/hVQY3mYG836C+LVbKHM0cu X-Received: by 2002:a05:6402:759:: with SMTP id p25mr3228975edy.102.1588259259230; Thu, 30 Apr 2020 08:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588259259; cv=none; d=google.com; s=arc-20160816; b=Ikfxfv7juYtS39ziUuAQOzvKiK4q/g0fQKFeRDZ7U/EPwin4W6t9D/ylRO8160lO/d ah2sOtE4NVZ7g8LIbWLI0fCioLbgd7dai+xlG0GCWuOyDlPjNovt/SJ64zBs30MedZVU hWz2FTuZTcJQAKVNp4KxocJn5fCydGNpqVuDCX9MEOg85igNiICUUPfVhSf0gR8SF9T3 QVLj7Oh8/DUaY/A9p9U2Ofk7aUwoKYdt9RZvYVx2zIiaoLrFmE4auzo4t0+31bjPsJpl ox4MsOVYwVmuOiQFW6tmbCB1eas6Rjjkw3aFIwqS5y18vNLHEFMpIk/0U/xV1qQvbNz2 PeDA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=jhdlQT2vqv3qEZdgFhTq6+MiNtZ4KjJ/qRTV4AVufrM=; b=Qoc1fl4/IzzvctQj9kIRKOmH+K7jZXRaJfbSpu8IUi2qWX7zEREwQBqCOyoHDgHAZ0 XabW9bEv4bPOltuXRu10KbDPXFyimGmLJv02pDRuJehBbBCh4IEUJAUJLv1BvS40UzJO PSsdbfjAww74juTOSNetZSpkfp7PYgYmEtOhw9bRaiXnq8A+yU/kkH00hm+NrvqnNyo+ xJSrgo20f3veWqpfkyTGj4Qkl6UnXs9MoW8RtUepg2qrdBJR8lYUgbs6IdAXxvs8lVId YxuqpFqFwQd34Bpc7oBXUCc33I75Kre64QmVMC3N4ZSg0B9fgTQCnMXd4MKxoFlsSop/ ZGRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=lmwJzH8i; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si5380519ejk.157.2020.04.30.08.07.01; Thu, 30 Apr 2020 08:07: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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=lmwJzH8i; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbgD3PDQ (ORCPT + 99 others); Thu, 30 Apr 2020 11:03:16 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:34936 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgD3PDQ (ORCPT ); Thu, 30 Apr 2020 11:03:16 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1588258995; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=jhdlQT2vqv3qEZdgFhTq6+MiNtZ4KjJ/qRTV4AVufrM=; b=lmwJzH8iMSNrWRPZL91WFb/Emw8U5ZXwyAgRFkUr1Qg6SnDqD3Qv8qnIWTswQeedpZVhf197 QnqHbImmiFUx6lH/QBBWvivd9CuKjP4DO3O8860kIeGwnpU8/3hrSUsgf/HwK59rfspdkB/Z C1uNFIF6VjQsXpywXXbewCu7e84= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5eaae87e.7f91e6aa95e0-smtp-out-n04; Thu, 30 Apr 2020 15:02:22 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 49D2FC433D2; Thu, 30 Apr 2020 15:02:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=ham autolearn_force=no version=3.4.0 Received: from [10.226.58.28] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jhugo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7CE8EC433CB; Thu, 30 Apr 2020 15:02:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7CE8EC433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=jhugo@codeaurora.org Subject: Re: [PATCH v3 6/9] bus: mhi: core: WARN_ON for malformed vector table To: Bhaumik Bhatt , mani@kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, hemantk@codeaurora.org References: <1588193551-31439-1-git-send-email-bbhatt@codeaurora.org> <1588193551-31439-7-git-send-email-bbhatt@codeaurora.org> From: Jeffrey Hugo Message-ID: <15f88b7a-a3cb-ac19-bffe-247f2e99d894@codeaurora.org> Date: Thu, 30 Apr 2020 09:02:19 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1588193551-31439-7-git-send-email-bbhatt@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/29/2020 2:52 PM, Bhaumik Bhatt wrote: > Add a bounds check in the firmware copy routine to exit if a malformed > vector table is found while attempting to load the firmware in to the > BHIe vector table. > > Signed-off-by: Bhaumik Bhatt > --- > drivers/bus/mhi/core/boot.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c > index 17c636b..bc70edc 100644 > --- a/drivers/bus/mhi/core/boot.c > +++ b/drivers/bus/mhi/core/boot.c > @@ -362,8 +362,14 @@ static void mhi_firmware_copy(struct mhi_controller *mhi_cntrl, > int i = 0; > struct mhi_buf *mhi_buf = img_info->mhi_buf; > struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; > + struct device *dev = &mhi_cntrl->mhi_dev->dev; > > while (remainder) { > + if (WARN_ON(i >= img_info->entries)) { > + dev_err(dev, "Malformed vector table\n"); I feel like this message needs more detail. At a minimum, I think it should indicate what vector table (BHIe). I think if you can identify what file, etc the the glitch is in, that would be better. Maybe some detail about i and img_info->entries. If I see this error message, I should have enough information to immediately debug the issue. If it tells enough to go directly into the firmware file and have a look at entry X to see what might be corrupt about it, that makes my debugging very efficient. If I have to go back to the code to figure out what "Malformed vector table" means, and then maybe apply a patch to get more data about the error - the error message is not as useful as it should be. > + return; > + } > + > to_cpy = min(remainder, mhi_buf->len); > memcpy(mhi_buf->buf, buf, to_cpy); > bhi_vec->dma_addr = mhi_buf->dma_addr; > -- Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.