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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CC935C433EF for ; Tue, 31 May 2022 11:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=4r/Bv9KDxVlYYXcqWY0r+QFrXNGTO74ktGzH4SzXAvU=; b=cbQ3Fzkz9qQR5x sOlWZOpNj3bW4+XI3WE6sHXQAJg+VVpr0aXPXTDuAxyoZa3746VBfMqQHxp2tMif/288dMOLgf9AT WUEpwcddr+Uib4Wnyy5mw9x/mwErosth2fPKMTAXUH7hrLf6EfWs6fsgk5Jlcm8y5ESxz12jGjKUg QdRhkOZaJbRHcoWFIfE1vQi8crytBEP75O9qp0ojeiky04H+1a51aIDGfe4tljBRsN6d0Sz17m1y6 BPQVO1y+UMFHPRCOf5p2jbs1+xxP0iVz8XOYdwIn5eHsVUvMY2868VYi4kTE9ONhSmfEt4U/TFNpd tDTlVFECbqMlAmn+Vxug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw0Ab-00AXIK-VU; Tue, 31 May 2022 11:36:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw0AZ-00AXHH-6h for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2022 11:36:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F1F6B23A; Tue, 31 May 2022 04:36:13 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B8793F73D; Tue, 31 May 2022 04:36:13 -0700 (PDT) Date: Tue, 31 May 2022 12:36:07 +0100 From: Cristian Marussi To: Robin Murphy Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla Subject: Re: [PATCH 2/2] firmware: arm_scmi: Fix pointers arithmetic in Base protocol Message-ID: References: <20220530115237.277077-1-cristian.marussi@arm.com> <20220530115237.277077-2-cristian.marussi@arm.com> <1cdf5131-a67b-7297-ad75-49b53f2da293@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1cdf5131-a67b-7297-ad75-49b53f2da293@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220531_043615_331812_6536246B X-CRM114-Status: GOOD ( 19.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, May 31, 2022 at 12:02:53PM +0100, Robin Murphy wrote: > On 2022-05-30 12:52, Cristian Marussi wrote: > > Fix a possible undefined behaviour involving pointer arithmetic in Base > > protocol scmi_base_implementation_list_get(). > > > > cppcheck complains with: > > > > drivers/firmware/arm_scmi/base.c:190:19: warning: 't->rx.buf' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] > > list = t->rx.buf + sizeof(*num_ret); > > Except we use GNU C, where it is well-defined[1]. We use void pointer > arithmetic *all over* Linux, so there really isn't any valid argument that > it could be problematic. If this was a common SCMI library intended to be > portable then the patch would seem more reasonable, but in Linux-specific > driver code it's just pointless churn. > Hi Robin, thanks for the correction, I'll drop this. Thanks, Cristian > Cheers, > Robin. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html > > > Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol") > > Cc: Sudeep Holla > > Signed-off-by: Cristian Marussi > > --- > > drivers/firmware/arm_scmi/base.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c > > index 20fba7370f4e..6d6214d9e68c 100644 > > --- a/drivers/firmware/arm_scmi/base.c > > +++ b/drivers/firmware/arm_scmi/base.c > > @@ -187,7 +187,7 @@ scmi_base_implementation_list_get(const struct scmi_protocol_handle *ph, > > num_skip = t->tx.buf; > > num_ret = t->rx.buf; > > - list = t->rx.buf + sizeof(*num_ret); > > + list = ((u8 *)t->rx.buf) + sizeof(*num_ret); > > do { > > size_t real_list_sz; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel