Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3352445pxb; Mon, 4 Apr 2022 14:23:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaYEzf/J2P4wGcDJ6poo88BdW/wXqr1+FG5SwabRHPkFJvLS3Ew42WzimywilaDiaPGwUS X-Received: by 2002:a05:6a00:2908:b0:4fa:9297:f631 with SMTP id cg8-20020a056a00290800b004fa9297f631mr150225pfb.3.1649107412713; Mon, 04 Apr 2022 14:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649107412; cv=none; d=google.com; s=arc-20160816; b=UWDNXWOyK/8xTV80DY3mL4vygCkbJeEj6giKGsyBiGi9agrSEdx72endjLte2MWta5 RvpwkwOf2ARZbqavAMoviP8p4KmtSSdRf6sIjnWuy36emJp7PvpL6Shr9mfPV8JsKp+l 96i3wt6CWb8JOWHbh9c/3Lj7zxsmThgU1DSVHQzJ9QzQBGGPjWB9/8f/9Jyij8949Vlv rBfHRddsnvqlHcShPxhXEVBLXju3agTTjTTVk6XOgiesmInJY7Ez/ajVDhaqH8D2DTtL neQ/k0wYebF+DaG8Ho4VdbNsYqN6OGw7nKvU/Ax3P24FtSRM/IwgnbaD1NI9Vgx8GmdT I6CQ== 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=TpRKn7SJqJk10dOIDt+TAhE5hOf2Y79WpsicE+YX85k=; b=ecR3SFHOVNy01/k3Ey+gaozoERvmpVe2cxNLTg5w/7uvi6H/V1eVZbGfdRrck4muL3 GXH4iYXKtM0YZAqf7xtbgwVl26/FS4eK49gjrt6SmmXEC63+rJrpMTHTttBc1jtSrMz5 +lDHIBwk61G+vz+V/1zROwOpnwiFnvZd4ej7c3BQ464UNUJ8FENWf5ifRMgPgItmSOGj KVEzZiT8vUjrfwEdb0C3CYeYjufKXRYyZyeyyXH7wXPqrYwbw0Ur7xZ/WOPkuIYvv3/T On7Vq0WyMJL4qnyoaRH6kQyo6uGg2dwxLR/KJqcCWGdvpaYB2T+jI3HvFA0JZv9VSapB gShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PHtC2Xm8; 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 d7-20020a056a00244700b004fa3a8dff8fsi11731597pfj.70.2022.04.04.14.23.18; Mon, 04 Apr 2022 14:23:32 -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=@infradead.org header.s=casper.20170209 header.b=PHtC2Xm8; 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 S1346174AbiDANO1 (ORCPT + 99 others); Fri, 1 Apr 2022 09:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244872AbiDANOX (ORCPT ); Fri, 1 Apr 2022 09:14:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD5A1D66DE; Fri, 1 Apr 2022 06:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=TpRKn7SJqJk10dOIDt+TAhE5hOf2Y79WpsicE+YX85k=; b=PHtC2Xm86gFfykvKt6TEThyM7M Of9YUNDCIcLsjkG/E3JJi26aThQnEy3e2XeE1Ze1NDD5eVAK8t/lmr3JbkTS7ejKWUGrlDekcrscT zxNnM8A4j6wafn7bBTbzDasdq+0Sq4n/LSwOc/lZeB7aWqsRa0wT/baok6J9nRtoIb0zWmgcosrXz 0LTQtqFKW1oAW4ApN1crtiuseHp/po4kZye4sHM7kI/8lkPQIVBQIwJjQMmnSp6vyDzkJ0IlanT2K 36IncTVI3qDFnRSjgm3ye3+xOylL8xomBBjF1Zc6VoOC16bhLYh90wsVZoJyyhqXM/kNI7Oz3IOBl OIZYMNwQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1naH4g-003DMW-V2; Fri, 01 Apr 2022 13:12:23 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 77FFD30027B; Fri, 1 Apr 2022 15:12:22 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5C6182008B7BF; Fri, 1 Apr 2022 15:12:22 +0200 (CEST) Date: Fri, 1 Apr 2022 15:12:22 +0200 From: Peter Zijlstra To: "Gustavo A. R. Silva" Cc: Dave Hansen , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] x86/mm/pgtable: Fix Wstringop-overflow warnings Message-ID: References: <20220401005834.GA182932@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220401005834.GA182932@embeddedor> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Thu, Mar 31, 2022 at 07:58:34PM -0500, Gustavo A. R. Silva wrote: > Fix the following -Wstringop-overflow warnings when building with GCC-11: > > .arch/x86/mm/pgtable.c: In function ‘pgd_alloc’: > arch/x86/mm/pgtable.c:437:13: warning: ‘preallocate_pmds.constprop’ accessing 8 bytes in a region of size 0 [-Wstringop-overflow=] > 437 | if (preallocate_pmds(mm, pmds, PREALLOCATED_PMDS) != 0) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:437:13: note: referencing argument 2 of type ‘pmd_t **’ > arch/x86/mm/pgtable.c:225:12: note: in a call to function ‘preallocate_pmds.constprop’ > 225 | static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[], int count) > | ^~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:440:13: warning: ‘preallocate_pmds.constprop’ accessing 8 bytes in a region of size 0 [-Wstringop-overflow=] > 440 | if (preallocate_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS) != 0) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:440:13: note: referencing argument 2 of type ‘pmd_t **’ > arch/x86/mm/pgtable.c:225:12: note: in a call to function ‘preallocate_pmds.constprop’ > 225 | static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[], int count) > | ^~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:462:9: warning: ‘free_pmds.constprop’ accessing 8 bytes in a region of size 0 [-Wstringop-overflow=] > 462 | free_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:462:9: note: referencing argument 2 of type ‘pmd_t **’ > arch/x86/mm/pgtable.c:213:13: note: in a call to function ‘free_pmds.constprop’ > 213 | static void free_pmds(struct mm_struct *mm, pmd_t *pmds[], int count) > | ^~~~~~~~~ > arch/x86/mm/pgtable.c:455:9: warning: ‘pgd_prepopulate_user_pmd’ accessing 8 bytes in a region of size 0 [-Wstringop-overflow=] > 455 | pgd_prepopulate_user_pmd(mm, pgd, u_pmds); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:455:9: note: referencing argument 3 of type ‘pmd_t **’ > arch/x86/mm/pgtable.c:320:13: note: in a call to function ‘pgd_prepopulate_user_pmd’ > 320 | static void pgd_prepopulate_user_pmd(struct mm_struct *mm, > | ^~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:464:9: warning: ‘free_pmds.constprop’ accessing 8 bytes in a region of size 0 [-Wstringop-overflow=] > 464 | free_pmds(mm, pmds, PREALLOCATED_PMDS); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/mm/pgtable.c:464:9: note: referencing argument 2 of type ‘pmd_t **’ > arch/x86/mm/pgtable.c:213:13: note: in a call to function ‘free_pmds.constprop’ > 213 | static void free_pmds(struct mm_struct *mm, pmd_t *pmds[], int count) > | ^~~~~~~~~ > > by using pointer notation instead of array notation as a workaround for > the above GCC warnings. 'Workaround' implies the warning is on crack... > This helps with the ongoing efforts to globally enable > -Wstringop-overflow. which puts to question this endeavour, why are you wanting to have this if its crap?