Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp504495ybz; Wed, 15 Apr 2020 12:55:19 -0700 (PDT) X-Google-Smtp-Source: APiQypKjAGGJGvrrqNOQLEMCCHTDFgqHvzs3d5Iyle8itWsFa+biiaQgxNxz0W+AfeGNO8KsiPbx X-Received: by 2002:a50:9a04:: with SMTP id o4mr457562edb.289.1586980518982; Wed, 15 Apr 2020 12:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586980518; cv=none; d=google.com; s=arc-20160816; b=OQH0RjNdOnGo/mRMWK9Vd3BM1aiC2DcuHjgjYjsVOFTSW7yJomOugLwUa6OxcBtz6c XOOeKQ2uuLRUGz8EcvlV1hbpjxfRPKhqTnMgk9742+j6rXztGx5j1B2nmWDZn+wlB+m6 2X+jdq7d4i2rm2+zXQZn9m4thHmSlhCSYL1fcuMyMpL+Gi88EndF0KIJzVcDXnsKD4/H d65L0yXjAT/5QQ+4E64ItLBQWxvqd3GtoImmxb/I3uOHjv3nplPZrxHFtr+VJkPXkopt xJBHG5/W3OtYbejrAn9iMhVXCNqlhkw6PGGzZBrZaSc0LW6/RUZe0y91XgUUJpd3+7FX tl1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=d7GmvUX0rXkVWOJeUCczE/Jyl5N5QxQuc6Ba+1CkPAs=; b=Jzaw5L4BTPGWFrX7R3zOSmte+Tx5FNmH9J1vyoP35EsxvwMw3aIp0agDYHQK1oAnqr izGJd6cMbR75S5YquXYkK9yaPWoz5f8+Y2OApmBOtUmHIt/6QwO3BHsjzkvOnCl37dDw Kq/8Ycs/+ZQwHv8Dzy9eT5S6jiieH9lrf4tBSkdimeJjQ6vYKaA5ZPoYbbyybh+AJ9EE Z9tu/a4oIjWUJwlVWRiVr1PExC6fFn0h4570OoWMiakZZ4pBdGniIp5VQn/qAhHyw3Np VhMjRo4qtCn7vvOK+SNwka9aFt2Um8JY+ulTxdxPoDnvWK8e/3BBqQ8QzCWgbZ/pnnOX +U5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for 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 u19si12291097edr.598.2020.04.15.12.54.55; Wed, 15 Apr 2020 12:55:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; spf=pass (google.com: best guess record for 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 S2436767AbgDNI0v (ORCPT + 99 others); Tue, 14 Apr 2020 04:26:51 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39633 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436780AbgDNI0j (ORCPT ); Tue, 14 Apr 2020 04:26:39 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOGtw-0007Pr-8X; Tue, 14 Apr 2020 10:26:36 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1jOGtv-0000m7-JI; Tue, 14 Apr 2020 10:26:35 +0200 Date: Tue, 14 Apr 2020 10:26:35 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: peng.fan@nxp.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, jassisinghbrar@gmail.com, o.rempel@pengutronix.de, leonard.crestez@nxp.com, aisheng.dong@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] mailbox: imx-mailbox: fix scu msg header size check Message-ID: <20200414082635.jo5yljonh5xgnujd@pengutronix.de> References: <1586851826-16596-1-git-send-email-peng.fan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1586851826-16596-1-git-send-email-peng.fan@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 14, 2020 at 04:10:26PM +0800, peng.fan@nxp.com wrote: > From: Peng Fan > > The i.MX8 SCU message header size is the number of "u32" elements, > not "u8", so fix the check. > > Reported-by: coverity-bot > Addresses-Coverity-ID: 1461658 ("Memory - corruptions") > Signed-off-by: Peng Fan > --- > > V2: > I not include the fixes tag, since this patch still in next tree. > > drivers/mailbox/imx-mailbox.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c > index 7906624a731c..c2398cb63ea0 100644 > --- a/drivers/mailbox/imx-mailbox.c > +++ b/drivers/mailbox/imx-mailbox.c > @@ -154,12 +154,12 @@ static int imx_mu_scu_tx(struct imx_mu_priv *priv, > > switch (cp->type) { > case IMX_MU_TYPE_TX: > - if (msg->hdr.size > sizeof(*msg)) { > + if (msg->hdr.size > (sizeof(*msg) / 4)) { No need for the parenthesis. Maybe a comment would be helpful here, something like: /* * msg->hdr.size specifies the number of u32 words while sizeof * yields bytes. */ > /* > * The real message size can be different to > * struct imx_sc_rpc_msg_max size > */ > - dev_err(priv->dev, "Exceed max msg size (%zu) on TX, got: %i\n", sizeof(*msg), msg->hdr.size); > + dev_err(priv->dev, "Exceed max msg size (%zu) on TX, got: %i\n", sizeof(*msg) / 4, msg->hdr.size); The unit here is also "number of u32 words", maybe bytes is more natural? And I suggesting specifying the unit in the error message. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |