Re: mm/mprotect.c:700:43: sparse: sparse: cast to non-scalar

From: Lorenzo Stoakes

Date: Mon Jun 22 2026 - 09:52:16 EST


On Mon, Jun 22, 2026 at 06:02:20PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: ef0c9f75a19532d7675384708fc8621e10850104
> commit: 3a6455d56bd7c4cfb1ea35ddae052943065e338e mm: convert do_brk_flags() to use vma_flags_t
> date: 3 months ago
> config: alpha-randconfig-r111-20260618 (https://download.01.org/0day-ci/archive/20260622/202606221720.CGRCyQ8e-lkp@xxxxxxxxx/config)
> compiler: alpha-linux-gcc (GCC) 10.5.0
> sparse: v0.6.5-rc1
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260622/202606221720.CGRCyQ8e-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Fixes: 3a6455d56bd7 ("mm: convert do_brk_flags() to use vma_flags_t")
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202606221720.CGRCyQ8e-lkp@xxxxxxxxx/
>
> sparse warnings: (new ones prefixed by >>)
> >> mm/mprotect.c:700:43: sparse: sparse: cast to non-scalar
> >> mm/mprotect.c:700:43: sparse: sparse: cast from non-scalar
> mm/mprotect.c: note: in included file (through include/linux/mm.h, include/linux/pagewalk.h):
> include/linux/pgtable.h:461:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast from non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast from non-scalar
> mm/mprotect.c: note: in included file (through include/linux/pgtable.h, include/linux/mm.h, include/linux/pagewalk.h):
> arch/alpha/include/asm/pgtable.h:272:21: sparse: sparse: cast to non-scalar
> arch/alpha/include/asm/pgtable.h:272:21: sparse: sparse: cast from non-scalar
> arch/alpha/include/asm/pgtable.h:272:21: sparse: sparse: cast to non-scalar
> arch/alpha/include/asm/pgtable.h:272:21: sparse: sparse: cast from non-scalar
> mm/mprotect.c: note: in included file (through include/linux/mm.h, include/linux/pagewalk.h):
> include/linux/pgtable.h:475:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:475:16: sparse: sparse: cast from non-scalar
> include/linux/pgtable.h:468:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:468:16: sparse: sparse: cast from non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast from non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast to non-scalar
> include/linux/pgtable.h:461:16: sparse: sparse: cast from non-scalar
>
> vim +700 mm/mprotect.c
>
> 693
> 694 int
> 695 mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
> 696 struct vm_area_struct *vma, struct vm_area_struct **pprev,
> 697 unsigned long start, unsigned long end, vm_flags_t newflags)
> 698 {
> 699 struct mm_struct *mm = vma->vm_mm;
> > 700 const vma_flags_t old_vma_flags = READ_ONCE(vma->flags);

Ah yeah... this works right now but is actually sketchy, as we need to copy not assign.

Will come up with a fix for this, but I think it needn't be backported as this
all works correctly right now.

Thanks, Lorenzo