Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2648231rwb; Mon, 19 Sep 2022 08:02:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GQdHGutc8QKOMw7W7JPoLyvaQok6AWCAtYGHNisvP7Tu5gKRGm0Kaj0DuGHaDwE1lzIZw X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr15735599edb.410.1663599779763; Mon, 19 Sep 2022 08:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663599779; cv=none; d=google.com; s=arc-20160816; b=JCwsXTS1tyOrcKpf5MGo2+grxnTZAeYPW8vazuTWh5UudIPRmJ1AQsQS9DOICgwbMd 91sD6zzIKrk8IJlzhG5e5ljEjcecFhEwiSs9wWSurIu34pkAHL20cFH0v3xUj11+yBe9 NJND7K+535ZiG9h0Qy/817klkWOh9tqVYlZWUj5UT+BJ9UUwOR3hfWD5n45hVfBCnGU8 kKLLDHiCIazW0VIDLtHAJvmy98CD3OcTkB1J6hpBwmtMdPhsryJ1VLCFtm8DJrvkSU+2 Yp0fktUiPj8UG1VdmBHdp+LEcbu25OD1t1pqcaQ0qTlN/YckaWmbnAgnubwpBk27Og1M yVZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Qq+KYlXd/KRzSK6FKd7wyC9sCJjKi+BWXGGcJiM5Gvw=; b=yfugqvOrmlGLjq1vfPnxsUzG8N6kI5yGOky1EOdwquTmhyb//ubp3s8sAAU2wMDGPi jJ2x42H0dpfFKW08pfFymBxjr7y4UiRJRO789q50TXJCV+7vQGWilJZ9HnYr/HEYBwl/ CfL94ZZzC+KPKdBq6+WVwD1hToYYnvG9pPVHkUlGufovplhAoEstD0sacWtNMgyMuw37 Ih9F9+ufw+eXL/RNDahArLoe4cuBU2MYmLCap0kXh0/mLWYZWPMboRcrMCt+y6Zi95u3 hBEFaqVk+xPHen9EX45NlYPgYyx3swzUHvDPXFcJTCZXfcxs9CiC1kBdedrmWT3w4lkb eIhg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a056402348500b0043ccb3ed80asi12097261edc.18.2022.09.19.08.02.28; Mon, 19 Sep 2022 08:02:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbiISOve (ORCPT + 99 others); Mon, 19 Sep 2022 10:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiISOvI (ORCPT ); Mon, 19 Sep 2022 10:51:08 -0400 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C97C810FDD; Mon, 19 Sep 2022 07:51:02 -0700 (PDT) Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1oaI6u-0005ft-05; Mon, 19 Sep 2022 16:51:00 +0200 Received: by alpha.franken.de (Postfix, from userid 1000) id BAE67C12F2; Mon, 19 Sep 2022 16:49:36 +0200 (CEST) Date: Mon, 19 Sep 2022 16:49:36 +0200 From: Thomas Bogendoerfer To: Kees Cook Cc: Hauke Mehrtens , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , 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: <20220919144936.GE7674@alpha.franken.de> 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> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE 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); > > 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 applied to mips-next with the second memcmp(prom_init changed as well. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]