From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B87C3567B for ; Mon, 24 Feb 2020 06:49:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7D2920661 for ; Mon, 24 Feb 2020 06:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dD730qFs"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="sPT3ZFIV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7D2920661 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V/zlQmxPRjTy8nHj9VLAD85eMBWMEnfzVBgDQBxWIIk=; b=dD730qFs4kxr3j ThdiHp587MSrAZYAUKS8PqTIpdGI5FQ3+aoo5/8pNnlgk+tflyK7DIwZvDvKgbTGP58Z0ZEjMp1wW 0r1qkDA/cw8NDIm/mcul7k1gR94cV/YH8LApIJKiWXIupyHnyXhWppMGyhiQElyqvjyEJOiSpkeQJ o/MUJMIyo21ktWxvMW+r4o1mdZIf85A3ABeb0CnymT2BP/ID9WSrle0HJTRINDbQuKcDpQzEoTFfM a3dFu18nqb7W+hVZyV54PgkQfXjF+eSfQS+HzhUyJnvqCuILK7FPkQWWvHyOpaMoqU6N6zgxZlUbV Lhba2MWDKVuyd6blAIbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j67YI-0004Mm-1g; Mon, 24 Feb 2020 06:49:14 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j67YE-0004MT-JF for linux-arm-kernel@lists.infradead.org; Mon, 24 Feb 2020 06:49:12 +0000 Received: from dragon (80.251.214.228.16clouds.com [80.251.214.228]) (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 D782F20661; Mon, 24 Feb 2020 06:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582526950; bh=fTou/t6Toy7plljj7+N7mWKQn3888V8JTKmo35a07jI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sPT3ZFIVKprGq8oPF95m5UZYZ1ZXiO5d7MjVA+D0jKUBg/S5Gz8zFNMIWWd2xd7eR CyBGDMPXhrDlSn14kdppX3YoIlCQOgr6WR9ceujxFu5/v3UOa6aco5oeS7ICpO7DT3 X99wKAhoYUMjoeJnQWBkgWRUGRW2FtL1kD7MXXnI= Date: Mon, 24 Feb 2020 14:49:05 +0800 From: Shawn Guo To: Leonard Crestez Subject: Re: [PATCH] firmware: imx: scu: Fix corruption of header Message-ID: <20200224064904.GP27688@dragon> References: <4389d4185aabbb94dfcbe79a9d0937fb57182335.1582215013.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4389d4185aabbb94dfcbe79a9d0937fb57182335.1582215013.git.leonard.crestez@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200223_224911_294820_C374DF66 X-CRM114-Status: GOOD ( 23.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Franck LENORMAND , linux-imx@nxp.com, kernel@pengutronix.de, Fabio Estevam , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 20, 2020 at 06:12:22PM +0200, Leonard Crestez wrote: > From: Franck LENORMAND > > The header of the message to send can be changed if the > response is longer than the request: > - 1st word, the header is sent > - the remaining words of the message are sent > - the response is received asynchronously during the > execution of the loop, changing the size field in > the header > - the for loop test the termination condition using > the corrupted header > > It is the case for the API build_info which has just a > header as request but 3 words in response. > > This issue is fixed by storing the header locally instead of > using a pointer on it. > > Fixes: edbee095fafb (firmware: imx: add SCU firmware driver support) > Signed-off-by: Franck LENORMAND > Reviewed-by: Leonard Crestez When you forward a patch from someone else, it should have your SoB. Shawn > Cc: stable@vger.kernel.org > --- > drivers/firmware/imx/imx-scu.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > This can manifest as random crashes so Cc: stable > > diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c > index 03b43b7a6d1d..2cf09f8a075c 100644 > --- a/drivers/firmware/imx/imx-scu.c > +++ b/drivers/firmware/imx/imx-scu.c > @@ -132,24 +132,24 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg) > complete(&sc_ipc->done); > } > > static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) > { > - struct imx_sc_rpc_msg *hdr = msg; > + struct imx_sc_rpc_msg hdr = *(struct imx_sc_rpc_msg *)msg; > struct imx_sc_chan *sc_chan; > u32 *data = msg; > int ret; > int i; > > /* Check size */ > - if (hdr->size > IMX_SC_RPC_MAX_MSG) > + if (hdr.size > IMX_SC_RPC_MAX_MSG) > return -EINVAL; > > - dev_dbg(sc_ipc->dev, "RPC SVC %u FUNC %u SIZE %u\n", hdr->svc, > - hdr->func, hdr->size); > + dev_dbg(sc_ipc->dev, "RPC SVC %u FUNC %u SIZE %u\n", hdr.svc, > + hdr.func, hdr.size); > > - for (i = 0; i < hdr->size; i++) { > + for (i = 0; i < hdr.size; i++) { > sc_chan = &sc_ipc->chans[i % 4]; > ret = mbox_send_message(sc_chan->ch, &data[i]); > if (ret < 0) > return ret; > } > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel