Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2978056imw; Sun, 17 Jul 2022 22:36:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sxewUXsQ1kQiY0skSWM52SUcCWZe3a1v6lrQv+62c2umNyRF1LwlqjMYl6/W0xPd1xfcYC X-Received: by 2002:a05:6a00:8c5:b0:510:6eae:6fa1 with SMTP id s5-20020a056a0008c500b005106eae6fa1mr27351787pfu.12.1658122593414; Sun, 17 Jul 2022 22:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658122593; cv=none; d=google.com; s=arc-20160816; b=eHUdt6cRaA6gMFs8iD3hUguW/Ey0S1xe/oK7339AVKZl0TyAOpylZt/Ov7an1HegP1 2TKXyvlo0E8QSbPba86vndqXw3ffx8OuAl4cK05DA/RfJM+WDVFSv2gsz8R9NLGN/fe9 +8LLpdlCm2A+Vrx9aKnNgkCdSLaXUuoa/4wqGvm008QEOA5W3pw4HagFUbzT1I9aXWEA LeimvQmNxw2SyCsZoNa8lrog91GI+yeK7B73ZP9wE/Y0R0n1KQnQ6oLuikEw6IVA6Ai1 gkN1YiMSd8CpTqCAP2RK6SH8PiUiFhBxxUrQnmygqFvaolPk4zUX9NVBZYAXXkGlTvfj H0zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=HfoMlxVHe2GNGL+Z3nwT14HwbjZ1aAk2Dtdo9PNK1VQ=; b=nOaXss4q9+QskVpT8iIepIaSHGlGlnOW2Khkf48Y03ezgLQ2X4TIVj56jEV3FaS6eB Kujl36Yw6DbF7FmI95zK6AP38iAq3tK/EltnU22EodmR5AdrxKr49mbt8ZfVZCiQLcvY yrD5EB5Zm72p08L4PJYgFhuRYSGGEdbbGs81LEu8i2lQzt4cMFuQy8JN49KMsI1RWJWo N1sCnbmV2FHMgTUr/N0VfNk9V2CFNGrTjK86jIcW9Joj7bWlrz2QHUPZgfEX6Q3J1Ltq 7KmkMh4NU9ANp5qWSvztMmrgWifwxXkS2WcyxnybbelIQU+biUztoLE6/Oc6TLdVBv9Q BD7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=CHSSgVtr; 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 u21-20020a63ef15000000b004160a244062si6152724pgh.311.2022.07.17.22.36.17; Sun, 17 Jul 2022 22:36:33 -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=@ellerman.id.au header.s=201909 header.b=CHSSgVtr; 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 S231515AbiGRElg (ORCPT + 99 others); Mon, 18 Jul 2022 00:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiGREle (ORCPT ); Mon, 18 Jul 2022 00:41:34 -0400 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2F5910551; Sun, 17 Jul 2022 21:41:32 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LmTnN1vs1z4xhn; Mon, 18 Jul 2022 14:41:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658119288; bh=HfoMlxVHe2GNGL+Z3nwT14HwbjZ1aAk2Dtdo9PNK1VQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CHSSgVtrop/Y7cdYxGnGHQMtrhKN6M4mfFF179p31b8WbnOsj/tE+V4NpwgwwMx6Z lAxnw5V0oEwFWQHxLcv1B6bI5z1F/0jZJUZF8lOXvvdrW2gdzcmjD82sB1YUESQ6/p UdxgKYYEzGQkBFqlT4kEHzSkxqzJLL2NY/5jd5D81xFH+s7tK6VFrwLGcSjuYuCBFx qkWjqmqY6wfvZ2SaiuOOFLRcPhrliuW3A25gQvyztz/W7IdV3Qxi05NsHd07cIIRHj eGjTRoqhbkPIhrlFr2oWYWmlUqM2BZYAWGLTPf8St8pzZX16L+C1KxjYFfSRV9COaQ bJo7pdgo4/H+w== From: Michael Ellerman To: Sudip Mukherjee , Benjamin Herrenschmidt , Paul Mackerras , Kees Cook Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel , linux-hardening@vger.kernel.org, Linus Torvalds Subject: Re: mainline build failure of powerpc allmodconfig for prom_init_check In-Reply-To: References: Date: Mon, 18 Jul 2022 14:41:23 +1000 Message-ID: <87cze3docs.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS 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 Sudip Mukherjee writes: > On Thu, Jul 14, 2022 at 9:55 AM Sudip Mukherjee (Codethink) > wrote: >> >> Hi All, >> >> Not sure if it has been reported before but the latest mainline kernel >> branch fails to build for powerpc allmodconfig with gcc-12 and the error is: >> >> Error: External symbol 'memset' referenced from prom_init.c >> make[2]: *** [arch/powerpc/kernel/Makefile:204: arch/powerpc/kernel/prom_init_check] Error 1 > > I was trying to check it. With gcc-11 the assembly code generated is > not using memset, but using __memset. > But with gcc-12, I can see the assembly code is using memset. One > example from the assembly: > > call_prom: > .quad .call_prom,.TOC.@tocbase,0 > .previous > .size call_prom,24 > .type .call_prom,@function > .call_prom: > mflr 0 #, > std 29,-24(1) #, > std 30,-16(1) #, > std 31,-8(1) #, > mr 29,3 # tmp166, service > mr 31,4 # nargs, tmp167 > mr 30,5 # tmp168, nret > # arch/powerpc/kernel/prom_init.c:396: struct prom_args args; > li 4,254 #, Here we load 254 into r4, which is the 2nd parameter to memset (c). > li 5,52 #, This is r5, the 3rd parameter (n), ie. the size of the structure. That tells us we're memsetting the entire structure, ie. the 10 x 4 bytes of args.args plus 3 x 4 bytes for the other members. > # arch/powerpc/kernel/prom_init.c:394: { > std 0,16(1) #, > stdu 1,-208(1) #,, > # arch/powerpc/kernel/prom_init.c:396: struct prom_args args; > addi 3,1,112 # tmp174,, Here we load (calculate) the address of "args" into r3, the first parameter to memset. > # arch/powerpc/kernel/prom_init.c:394: { > std 9,304(1) #, > std 10,312(1) #, > std 6,280(1) #, > std 7,288(1) #, > std 8,296(1) #, > # arch/powerpc/kernel/prom_init.c:396: struct prom_args args; > bl .memset # So we're memsetting all of args to 254, not zero. That's happening because allmodconfig with gcc 12 enables CONFIG_INIT_STACK_ALL_PATTERN, whereas gcc 11 doesn't. I think the simplest fix in the short term is to just disable stack initialisation for prom_init.c. It only runs at boot so there's no real security impact to disabling it. cheers