KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
81 stars 5 forks source link

Fix -Wstringop-overflow warnings in arch/x86/mm/pgtable.c (GCC-11) #203

Closed GustavoARSilva closed 1 year ago

GustavoARSilva commented 1 year ago

We need to address the following warnings in arch/x86/mm/pgtable.c before we can enable -Wstriongop-overflow globally:

  CC      arch/x86/mm/pgtable.o
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)
      |             ^~~~~~~~~
GustavoARSilva commented 1 year ago

Patch for this: https://lore.kernel.org/linux-hardening/Yytb67xvrnctxnEe@work/