Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3110416pxj; Sun, 23 May 2021 22:00:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+EuRmf4h1rxzqKauDKpn5Ywlmmhde/mpth8pFCp3twU8hdwXF/MAlTEXmO5L39b1GC5nj X-Received: by 2002:aa7:d844:: with SMTP id f4mr23004482eds.203.1621832437035; Sun, 23 May 2021 22:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621832437; cv=none; d=google.com; s=arc-20160816; b=Kn4buTQmLQmjItYIuDA1Cy7gcREriyqF0+VXCsQW6n/vN/RuYTnKO6MmhHwJmk8TXs FMJ3bbYxaJ9jTHNqjUkD4TReHOB+ki+1igR5VOscWA0kxyqa3DMaQDQXszfTK3S0tOnF fPX85raTsj2RgxwR/7tHYGfajEh2afvD/ELrajMJh9Z5/eAXf5M2FzcYApgUJZCMKGwW ecc7rAqWvQEY96S8WgYQ3tGxkmS1KuQWuWGmSDw7hdoMboUpsle7j8BUNqwe8CzQgkRx IA+ouIkIRkjGeNsuCjVOtVzZuOQ2cmtzqN8okvIfx6SPcPrnBjXLOmtXszQ9lfHz6Ie9 AXtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1ZYaJzg8EfGTG1YeFB1KyajqSUT6MB2q2X9Re4Ft+nw=; b=MPeyyCvbGxueb9sAMzjS1KewMmawrn3ksLU7jq1XYofR8Hi10nb6ZPhuRAvit1yZlO zxr9r8fONfH7n7T8WG1BLOZ5Drl2aTck9GBZzXFjj/Q9HgId6p124/quOII4Try+EBVq lMmjTHvbm4IvISrWnVvyRm1JBRp2lB9/T03c0WhcU5r/VRA5EPVqQWqdDSifNwANXFka R3xE4I5qu01w4jMVSDMICcRliBIu51Eh8iulPh5HZy3x2hldxU8EkAo19T0wX1nDbmWs LQ3/oOeq2RKwfJU8f1+P2OF76ds+hJGqZQkzNL9ZtLkw9lyPkKiyAUOU7e/r0pm/nU6x HF8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QpGnnJc2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si12424112eds.113.2021.05.23.22.00.13; Sun, 23 May 2021 22:00:37 -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=@linaro.org header.s=google header.b=QpGnnJc2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbhEXE77 (ORCPT + 99 others); Mon, 24 May 2021 00:59:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbhEXE76 (ORCPT ); Mon, 24 May 2021 00:59:58 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF515C061756 for ; Sun, 23 May 2021 21:58:29 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d78so18979202pfd.10 for ; Sun, 23 May 2021 21:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1ZYaJzg8EfGTG1YeFB1KyajqSUT6MB2q2X9Re4Ft+nw=; b=QpGnnJc2Tb1UEE7G3EnRIds1WFTSQS/3IYFhN5NB1mCThWYLnzHZRMsvpQS8FOV1iP oQBCNXR/jLpzVqr6JKVKe+R8B9fa5zy4t2pQQId55UfuG04FlZAKIgjy4dDvJXkmyU2N dirg1foJ3iYCVhR0yU2o7NIb+9wViqBNjdUPyU2VxRe1LFE/lfkmRZ3lU/bN9rDs/dwL 2FkJVaDfL2wMisoaA5zBIfTuNLreUtmP/UVBVU56l83eg9albvBN816TBp3sukmjPISM K4V5tLlpVYfBa4hXez4xPDwTfABLoK2kdSQ4U9vOAhtr8Nur+q0PyEy3WGb5Uh/nbyRN eKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1ZYaJzg8EfGTG1YeFB1KyajqSUT6MB2q2X9Re4Ft+nw=; b=Z2IuzJh5hglUejPA/8riBILiPjah0Wc4GuimYjPdKtZfvqE3Ybg/4lV7DviD6OAnZC XfvRRDxkRZIsOlqT0BwxaAyMhsWJuncbTCrUarL8C7iwERHs9NebzoNtIyAvOL/TOnIW cAM/bn2mg6A3r54vkTmmOlKsHBQTdAKB79cW79mQDiUrgi47ORmWfCCfwiKhyZk9bqNV Mo/xFZ8+lyS0qLCGfluYV4CoO2NThJ8gDt9pkSSX1AZNs2F34fjQRdnifazU9R9HYxAg J70/FxlpHcjGlov65nG3dOFHRK9xLm6yF3WSvyyNU98stxpj8nj7L1yOBTTbIQcS9IvH Cdzg== X-Gm-Message-State: AOAM531ct68SWlGpHzXWs7EN98hi8ScyI1ZcGzyDX5y6/DDJm2VNKR3+ v4MTse32+bDzb6jOeMNpTV03Vm/FIw0C X-Received: by 2002:a62:384c:0:b029:2dd:423b:6e49 with SMTP id f73-20020a62384c0000b02902dd423b6e49mr23220503pfa.9.1621832309175; Sun, 23 May 2021 21:58:29 -0700 (PDT) Received: from work ([120.138.12.48]) by smtp.gmail.com with ESMTPSA id w2sm9341621pjq.5.2021.05.23.21.58.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 May 2021 21:58:28 -0700 (PDT) Date: Mon, 24 May 2021 10:28:25 +0530 From: Manivannan Sadhasivam To: Bhaumik Bhatt Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, loic.poulain@linaro.org Subject: Re: [PATCH] bus: mhi: core: Validate channel ID when processing command completions Message-ID: <20210524045825.GE8823@work> References: <1619481538-4435-1-git-send-email-bbhatt@codeaurora.org> <20210524044228.GD8823@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210524044228.GD8823@work> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 24, 2021 at 10:12:28AM +0530, Manivannan Sadhasivam wrote: > On Mon, Apr 26, 2021 at 04:58:58PM -0700, Bhaumik Bhatt wrote: > > MHI reads the channel ID from the event ring element sent by the > > device which can be any value between 0 and 255. In order to > > prevent any out of bound accesses, add a check against the maximum > > number of channels supported by the controller and those channels > > not configured yet so as to skip processing of that event ring > > element. > > > > Fixes: 1d3173a3bae7 ("bus: mhi: core: Add support for processing events from client device") > > Signed-off-by: Bhaumik Bhatt > > Applied to mhi-next! > Sorry this has been applied to mhi-next! Thanks, Mani > Thanks, > Mani > > > --- > > drivers/bus/mhi/core/main.c | 15 ++++++++++----- > > 1 file changed, 10 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c > > index 22acde1..ed07421 100644 > > --- a/drivers/bus/mhi/core/main.c > > +++ b/drivers/bus/mhi/core/main.c > > @@ -773,11 +773,16 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl, > > cmd_pkt = mhi_to_virtual(mhi_ring, ptr); > > > > chan = MHI_TRE_GET_CMD_CHID(cmd_pkt); > > - mhi_chan = &mhi_cntrl->mhi_chan[chan]; > > - write_lock_bh(&mhi_chan->lock); > > - mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); > > - complete(&mhi_chan->completion); > > - write_unlock_bh(&mhi_chan->lock); > > + WARN_ON(chan >= mhi_cntrl->max_chan); > > + > > + if (chan < mhi_cntrl->max_chan && > > + mhi_cntrl->mhi_chan[chan].configured) { > > + mhi_chan = &mhi_cntrl->mhi_chan[chan]; > > + write_lock_bh(&mhi_chan->lock); > > + mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); > > + complete(&mhi_chan->completion); > > + write_unlock_bh(&mhi_chan->lock); > > + } > > > > mhi_del_ring_element(mhi_cntrl, mhi_ring); > > } > > -- > > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > > a Linux Foundation Collaborative Project > >