Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp854393ybz; Wed, 29 Apr 2020 10:32:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIX9fU44lh5qFETpkfLkC8QFolQ9WX4UjxO8cwzncy641r2lCKZJSmFO1FvzeMi0ZsIdoRU X-Received: by 2002:a17:906:1a06:: with SMTP id i6mr3664611ejf.90.1588181544647; Wed, 29 Apr 2020 10:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588181544; cv=none; d=google.com; s=arc-20160816; b=aH2DyGZb4Ey+OJl4aYzfejSKcUr2UHFJgf1UVTvZOW3riJH/e/w8S6eYx8s/Mjh/vG P3PdW3bRP2MndSUBn2+l2FkKVSP8dPbW0wv5dsDAu+m5w2IQS/3Y5AY8wFpGIQHS++9R B/NtCAirfOj1SXkQR9BYX6eXcVn6H/5WtpxFLulngnSuOgk3kuHAWKWNhjvx8x6pql// lAQrcOq1woKxOmKpcWZGHCywEEuG1aV5qU7s8xeICFGeqJPagPF5MElUHsZJyAl2LSTw qSvo15swA9Jl1cSYjrGDTmCkjKtVFlW8FF31vsa03ZFRqbFSVPfxxckPA77gcmB05U/K sLMA== 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=Xp/0lr40wfL33pzbo6BAF3q5KzIJcGKl6bxJ0pSGH3E=; b=vR6MQPqQE7g5fe4KtD9uhSfR1H7QE/tWFsCBdVGwegiJx/GpDpq/W2Rsj90s84Z12M PQnQUxWT+hc6bUN5gH7XhRkUPOC6kwTHGQnT0HMQNrmr/YlCmE+24yB9dvwR4fe0eZBS JgBbM0Kpk6ljP+SWJ8g94jEXLwBJ5ev1FlwvVmU5DmcYWEAdGUK8/11+EoeRPwq1LJGF J8XUlobunn5/FKzM2kAAKx6jdLRPBAOKwwsUl4Deo3uizzOKI5UhI91eNSx31Xo4hGt/ 77norWxPWpl6fZ8fniz/ZWJepte/EnUHvmqJAspe1FtZLmKMQdxgF2dtxgeOzyf5nmJs Lf+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=HZyYwtb2; 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 s13si4029128ejr.484.2020.04.29.10.31.51; Wed, 29 Apr 2020 10:32:24 -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=HZyYwtb2; 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 S1726822AbgD2R3h (ORCPT + 99 others); Wed, 29 Apr 2020 13:29:37 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:12045 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbgD2R3g (ORCPT ); Wed, 29 Apr 2020 13:29:36 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1588181376; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=Xp/0lr40wfL33pzbo6BAF3q5KzIJcGKl6bxJ0pSGH3E=; b=HZyYwtb2+83fvX9Rhv8igus7NqBL+fHXBN1IE9R4zSmhzeqybvcyYk25RPMO+4G9IHkQPeD5 Txx+Dvk2Uut47nNo2bVDz4fyUc9oK+tPh6runj50meKrb/+n7ZvRxyH4lwPXZ8j8hwBqs92S 1y1yNgeemJe9nSvdkSRvOJfPrHk= 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 5ea9b97f.7f04b832e298-smtp-out-n04; Wed, 29 Apr 2020 17:29:35 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 716BCC433D2; Wed, 29 Apr 2020 17:29:34 +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, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from [10.46.162.249] (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: hemantk) by smtp.codeaurora.org (Postfix) with ESMTPSA id CE65CC433CB; Wed, 29 Apr 2020 17:29:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CE65CC433CB 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=hemantk@codeaurora.org Subject: Re: [PATCH v2 2/8] bus: mhi: core: Add range check for channel id received in event ring To: Jeffrey Hugo , Bhaumik Bhatt , mani@kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1588042766-17496-1-git-send-email-bbhatt@codeaurora.org> <1588042766-17496-3-git-send-email-bbhatt@codeaurora.org> <5dfa3617-644c-42c3-0dfe-4f9f4a6d5ded@codeaurora.org> From: Hemant Kumar Message-ID: <0e889174-4264-5911-ce6f-d2b6084a22a8@codeaurora.org> Date: Wed, 29 Apr 2020 10:29:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <5dfa3617-644c-42c3-0dfe-4f9f4a6d5ded@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jeff On 4/28/20 7:44 AM, Jeffrey Hugo wrote: > On 4/27/2020 8:59 PM, Bhaumik Bhatt wrote: >> From: Hemant Kumar >> >> MHI data completion handler function reads channel id from event >> ring element. Value is under the control of MHI devices and can be >> any value between 0 and 255. In order to prevent out of bound access >> add a bound check against the max channel supported by controller >> and skip processing of that event ring element. >> >> Signed-off-by: Hemant Kumar >> Signed-off-by: Bhaumik Bhatt >> --- >>   drivers/bus/mhi/core/main.c | 4 ++++ >>   1 file changed, 4 insertions(+) >> >> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c >> index 23154f1..1ccd4cc 100644 >> --- a/drivers/bus/mhi/core/main.c >> +++ b/drivers/bus/mhi/core/main.c >> @@ -827,6 +827,9 @@ int mhi_process_data_event_ring(struct >> mhi_controller *mhi_cntrl, >>           enum mhi_pkt_type type = MHI_TRE_GET_EV_TYPE(local_rp); >>           chan = MHI_TRE_GET_EV_CHID(local_rp); >> +        if (WARN_ON(chan >= mhi_cntrl->max_chan)) >> +            goto next_event; >> + >>           mhi_chan = &mhi_cntrl->mhi_chan[chan]; >>           if (likely(type == MHI_PKT_TYPE_TX_EVENT)) { >> @@ -837,6 +840,7 @@ int mhi_process_data_event_ring(struct >> mhi_controller *mhi_cntrl, >>               event_quota--; >>           } >> +next_event: >>           mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); >>           local_rp = ev_ring->rp; >>           dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); >> > > It looks like the same issue exists in mhi_process_ctrl_ev_ring(), and > thus some form of this solution needs to be applied there as well. Would > you please fix that too? > As discussed with you off line, spec allows to have just event ring to be used for both data and control. Updating this in V3. -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project