Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp300002ybz; Tue, 21 Apr 2020 21:25:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLauE+eZT7DfG0TRToOIP9eqyuqTwcg5N9JC6dXc0cu3mL8Bcv+XCBMOMed96S8qbXgBG1O X-Received: by 2002:a17:906:6992:: with SMTP id i18mr23360629ejr.293.1587529506874; Tue, 21 Apr 2020 21:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587529506; cv=none; d=google.com; s=arc-20160816; b=jeZDR1bGvFuusXstboJ7G3gUu5sE9wkyaB4LgFICwtE/XWgY7tmA3YJgSqr32U5FLZ 7kSAOTC2WX+j6RWtTbCP5venHlazUUrrO0vjHl/644z8FRJxUfBfcrHjS9oJl0Scj/Wn e0/WWf9zzLS4qOkD6tABFvAqYCPWstf3omY5V7yYWBCGi45QkApkl4SZw5kFRv/KAIHt N91BlE/E7BC2WLyqbUK4sUBcYl6ndsEknlQ517TiW3DFtGamZ403BYrwgqCgTprmvHow /eCzodTU3/KHoGNMHbmWqgksTsxgWjOx/Z2adDOvZGy7OhAM9mXEYjy59kzJa5xnrrM9 dH5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=kvpym/R0LUwgL8lADSrB9TScxJz6XxGUYe6UV96jMZQ=; b=Se7bxx1KpEfkaJrahwbDj4dwfzgOBq2Rho8jiWZcjycyCTOEEkane8rLFTrGYf3Wyf viExyhVnkowU7t3KEimUcyI5Bzikz/kMdBU3YGIQ5vzb+n/scaNIOzeBcm6jRscMXIBJ SlkXI+FY89ade+QjLEA3ABcPvZ1QBKU78cFVZqReotxSYyKJSZX/ixFG1rUyXYjrG300 NKLqgJCZMwt6Wg3Fjr7gbv2jCoqFDp0HI+rUrjtToAukJuhLha4gAUg+aUA70V+55wiX Yh/YLjFB0XAQSMABN0Tf2ddLLu97+MtwyKtO796K0WZ96+7fge+6iNyq+9aKeLm2tnzT f/Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=B4gD7WAd; 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 a24si2671605eds.168.2020.04.21.21.24.44; Tue, 21 Apr 2020 21:25:06 -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=B4gD7WAd; 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 S1726008AbgDVETz (ORCPT + 99 others); Wed, 22 Apr 2020 00:19:55 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:64155 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgDVETz (ORCPT ); Wed, 22 Apr 2020 00:19:55 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587529194; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=kvpym/R0LUwgL8lADSrB9TScxJz6XxGUYe6UV96jMZQ=; b=B4gD7WAdHKKiMzR9XryAnaEIx867Fy0KcjLba8hGz9QPocxt5PWVrB1xgzVuhhLh+6nLcIiO WMcjBoebPXqWumC6Ma/x8a3KUVNZCrHjHApQ6ebAKtFdFfsEbaxUTyALUcFQIuB2SSQkhKWk Cc3k7gdwsYaY2bJf373qYWZvUgs= 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 5e9fc5e6.7fe203ca6538-smtp-out-n02; Wed, 22 Apr 2020 04:19:50 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 84D90C43637; Wed, 22 Apr 2020 04:19:50 +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 bbhatt-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bbhatt) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1B40DC433BA; Wed, 22 Apr 2020 04:19:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1B40DC433BA 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=bbhatt@codeaurora.org From: Bhaumik Bhatt To: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Hemant Kumar Subject: [PATCH v1 2/8] bus: mhi: core: Add range check for channel id received in event ring Date: Tue, 21 Apr 2020 21:19:29 -0700 Message-Id: <1587529175-27778-3-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> References: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/bus/mhi/core/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 23154f1..ba8afa7 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)) + continue; + mhi_chan = &mhi_cntrl->mhi_chan[chan]; if (likely(type == MHI_PKT_TYPE_TX_EVENT)) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project