Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp535162rwn; Thu, 8 Sep 2022 05:32:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4bxDrQ5aLGGSU2OPqOE9zHIrwZaFTQJHWkLmLPkqgGwn1l7b8iV6yKyxNqK/oxufKCudw4 X-Received: by 2002:a17:907:6da4:b0:76f:4e07:f735 with SMTP id sb36-20020a1709076da400b0076f4e07f735mr5763940ejc.246.1662640374007; Thu, 08 Sep 2022 05:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662640374; cv=none; d=google.com; s=arc-20160816; b=Mixdl1Vkw8rjXzdj+ya+hXx6WfDHyiK3Z0pIDamd1ouoD1S5L2QpoKwuvS6uAIuBpD cvzrFH8A6DaehLdvqxnlEZUqVvTDnelqD6dVspIuqCHjEmZieXYC9EnuAYPbX+n9ZKN6 M+mm1+5mR/2qeYrRkNcJrT1zOxO0t/stKCS61brk+hZrQGyjM3rBkoo79R0du+XXxSnz IP0qiw1oD5Kn6lRO+38R7qYaASPNZdWffJWz8UDOjsTI5BDlAGRBL2H9Y2GI7MykG574 +8l5MzcApfbgmk6Po3HWw+aFkzvxbH63y7s+RVRWoIamysNtGyfdkcv9cNrSCkP2N3fk zJ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/TwRgIpCKm5u0ZTDcwzqWSdJMwk2jlf9YHn/ZMEjcYw=; b=mAJZ5EKIFFzryQaIPcKEf2HfUSZTUJ85n2PXWkGpnArR4bmJwC8kzC8+XM6Q/MVoj5 vo4qr2Jry0dZK687sgZ+zUdXJYHDAtLxEIcbiNEHRhx5MmfKatYcTP4qx488eyeLjoqW X41BTf89PkuCMT15X+XSPMfOg1VmKhnIpZMkr/4Ru55DLRvBRvaR/YI8opQ+MpOUm3AW NUGA93HsjYAijTCCO/efv/I84ADJ4bT2B05UMH44NchlX5G1EvLRM/Yaf0F6oSxjvpIU F/iUtVzb1XFpfcdxC7Uy7eCRIwKYF9iuqA2BUKf7GUwT5avsEQcyeGI4U+drKrPvBwC3 SBJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/B3/7aQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a0564020f1a00b0044f2fb68fe6si2230653eda.495.2022.09.08.05.32.26; Thu, 08 Sep 2022 05:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/B3/7aQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbiIHMWb (ORCPT + 99 others); Thu, 8 Sep 2022 08:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbiIHMWZ (ORCPT ); Thu, 8 Sep 2022 08:22:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D1C64D9; Thu, 8 Sep 2022 05:22:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A53D061C99; Thu, 8 Sep 2022 12:22:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A976C433D6; Thu, 8 Sep 2022 12:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662639743; bh=c865XJLe4Z2ZkQVpfIUa6NvVVbhj/DHk8R5Iswb7/6M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X/B3/7aQ1H23MpMbYOEAHsluM/ebsaOP4LrfJ7XKXwjf1NzoAKOPAndPh/In2tlkt ebeFZS7zjnMeFSz/5+4qcQhXuGe4zRMUpVS73l+JkhyphP/ep0SoFwhiyhXhAJ9gOx W7RVone1Ma83uzslTrBWwAXX9IKRDFOtJvwGPVj4jEebb02TTUZShuPIXDn8Vouka9 a4vLscqy9qtW1Xw6GnXMNCai8U7QAv1FVnGw2Z8JgxgmXfjjZ0yEv9KkvfOE8RTRDA axW/PvmWAHYAOdJOOcd9IqT5h+lCaV2DPl7ptgyVHsElEUhXCsd2l1yXf0z14TfJ/p VO5vmUyqDJVEg== Date: Thu, 8 Sep 2022 13:22:16 +0100 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Hauke Mehrtens , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , llvm@lists.linux.dev, kernel test robot , Tom Rix , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] MIPS: BCM47XX: Cast memcmp() of function to (void *) Message-ID: References: <20220907230556.73536-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220907230556.73536-1-keescook@chromium.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 07, 2022 at 04:05:56PM -0700, Kees Cook wrote: > Clang is especially sensitive about argument type matching when using > __overloaded functions (like memcmp(), etc). Help it see that function > pointers are just "void *". Avoids this error: > > arch/mips/bcm47xx/prom.c:89:8: error: no matching function for call to 'memcmp' > if (!memcmp(prom_init, prom_init + mem, 32)) > ^~~~~~ > include/linux/string.h:156:12: note: candidate function not viable: no known conversion from 'void (void)' to 'const void *' for 1st argument extern int memcmp(const void *,const void *,__kernel_size_t); > Don't we have the same problem at line 162? (next-20220908)arch/mips/bcm47xx/prom.c: 161 for (extmem = 128 << 20; extmem < 512 << 20; extmem <<= 1) { 162 if (!memcmp(prom_init, (void *)(off + extmem), 16)) 163 break; 164 } -- Gustavo > Cc: Hauke Mehrtens > Cc: "Rafał Miłecki" > Cc: Thomas Bogendoerfer > Cc: linux-mips@vger.kernel.org > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: llvm@lists.linux.dev > Reported-by: kernel test robot > Link: https://lore.kernel.org/lkml/202209080652.sz2d68e5-lkp@intel.com > Signed-off-by: Kees Cook > --- > arch/mips/bcm47xx/prom.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c > index ab203e66ba0d..eb5c04a24531 100644 > --- a/arch/mips/bcm47xx/prom.c > +++ b/arch/mips/bcm47xx/prom.c > @@ -86,7 +86,7 @@ static __init void prom_init_mem(void) > pr_debug("Assume 128MB RAM\n"); > break; > } > - if (!memcmp(prom_init, prom_init + mem, 32)) > + if (!memcmp((void *)prom_init, (void *)prom_init + mem, 32)) > break; > } > lowmem = mem; > -- > 2.34.1 >