Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp540310ybz; Wed, 15 Apr 2020 13:36:31 -0700 (PDT) X-Google-Smtp-Source: APiQypJW90PTcU9ZwJJ90lFV1VLx1VgoiN41kVAL9YgEdM2rHAau1vJx6SuMNn7MA9zkm7m0xzFw X-Received: by 2002:a17:906:5918:: with SMTP id h24mr6824088ejq.210.1586982990960; Wed, 15 Apr 2020 13:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586982990; cv=none; d=google.com; s=arc-20160816; b=JKvsV6ZpSG2vHVzHa+28HFoOMGrVUcqb/HN742tw6XdsvAk7kHszzKIiD7KW6uWw/1 HUfzWy3MlcMtWvxr0/LWRWTCzihYNOdx4WNfYu06MkdzGOCNCAGrZjLHbwVo32f7g3/x YehdinKAE7jouPS+HWontbF384KOveS/w4ev71MpNjI0oPQgeh6NKl6tSZndYFAz6Fl3 UpCVfRPv7VcYMemBVlO6yJBjRUt3bksPalAa/pM2TyaU1hasyOZrBfGXmGzkAZyn0JlD MeIDnNbALdHO3U92bbUy7phrd4R4AYd98DpfEm50+mELzU+XntnOV+Y72vglpAqhcY0n P8HA== 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=P2OGTzezbmsxNz77OvfmRSX4UFTzK4abvmGcUFpwe58=; b=LX7XsBrFEp04Nh12SwAIS2qngaPACJScPj8pr5FL1oH6TlBp5VJN1ZtHUkyBfUjknP 0+FObAdKMssOW197cWdKSdYgc8HkKVhbXaW4XPkx6dF8NHpcaG3+VLIUMrJDioF5ikbQ JBcky1O2BGeqvZ+KlgBue4ythE8GYm7GYUJ08OhtY6J7IUxcypo9MnPkDaB6MHO5Vr0F QeQY9H7PxM0r6uvqhn5nu6npi3ZsvsQn0P13F4Uthe3hAU7ffP2I3tKVeJ4eSZ0qUdSV dWGWb3kzXcenPCe753lRhv3VOHrC8xqyiffqKzZzaUiPLXrO2kLuUKfZmoGiOkIiqR8a 3WYg== 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 u24si6567459edy.567.2020.04.15.13.36.07; Wed, 15 Apr 2020 13:36:30 -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 S2438385AbgDNKdy (ORCPT + 99 others); Tue, 14 Apr 2020 06:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2438344AbgDNKb6 (ORCPT ); Tue, 14 Apr 2020 06:31:58 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06A40C061A0E for ; Tue, 14 Apr 2020 03:31:54 -0700 (PDT) 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 1jOIrA-00078x-0v; Tue, 14 Apr 2020 12:31:52 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1jOIr9-0000Ib-9D; Tue, 14 Apr 2020 12:31:51 +0200 Date: Tue, 14 Apr 2020 12:31:51 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Peng Fan Cc: "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "jassisinghbrar@gmail.com" , "o.rempel@pengutronix.de" , Leonard Crestez , Aisheng Dong , Anson Huang , "linux-kernel@vger.kernel.org" , dl-linux-imx , "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: <20200414103151.mm6w5gkgrdvt6z2b@pengutronix.de> References: <1586851826-16596-1-git-send-email-peng.fan@nxp.com> <20200414082635.jo5yljonh5xgnujd@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 08:40:19AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH] mailbox: imx-mailbox: fix scu msg header size check > > > > 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. > > */ > > V2 will have the update. > > > > > > /* > > > * 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? > > ok. Will change to msg->hdr.size << 2 keeping sizeof(*msg). > > > And I suggesting specifying the unit in the error message. > > Is this ok to you? > dev_err(priv->dev, "Exceed max msg size (%zu) on TX, got: %i, > msg->hdr.size: %i\n", sizeof(*msg), msg->hdr.size << 2, msg->hdr.size); I'd prefer: dev_err(priv->dev, "Maximal message size (%zu bytes) exceeded on TX; got: %i bytes\n" . Duplicating the value doesn't add much value. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |