linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] x86/mm/pgtable: Fix Wstringop-overflow warnings
Date: Fri, 1 Apr 2022 15:12:22 +0200	[thread overview]
Message-ID: <Ykb6Nv80LJomLDsO@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220401005834.GA182932@embeddedor>

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?


      reply	other threads:[~2022-04-01 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01  0:58 [PATCH][next] x86/mm/pgtable: Fix Wstringop-overflow warnings Gustavo A. R. Silva
2022-04-01 13:12 ` Peter Zijlstra [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ykb6Nv80LJomLDsO@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gustavoars@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).