Re: [PATCH] mm: do not bug_on on incorrect lenght in __mm_populate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michal,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.18-rc3 next-20180705]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Michal-Hocko/mm-do-not-bug_on-on-incorrect-lenght-in-__mm_populate/20180706-134850
config: x86_64-randconfig-x015-201826 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   mm/mmap.c: In function 'do_brk_flags':
>> mm/mmap.c:2936:16: error: 'len' redeclared as different kind of symbol
     unsigned long len;
                   ^~~
   mm/mmap.c:2932:59: note: previous definition of 'len' was here
    static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long flags, struct list_head *uf)
                                                              ^~~

vim +/len +2936 mm/mmap.c

^1da177e4 Linus Torvalds        2005-04-16  2926  
^1da177e4 Linus Torvalds        2005-04-16  2927  /*
^1da177e4 Linus Torvalds        2005-04-16  2928   *  this is really a simplified "do_mmap".  it only handles
^1da177e4 Linus Torvalds        2005-04-16  2929   *  anonymous maps.  eventually we may be able to do some
^1da177e4 Linus Torvalds        2005-04-16  2930   *  brk-specific accounting here.
^1da177e4 Linus Torvalds        2005-04-16  2931   */
e3049e198 Michal Hocko          2018-07-06  2932  static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long flags, struct list_head *uf)
^1da177e4 Linus Torvalds        2005-04-16  2933  {
^1da177e4 Linus Torvalds        2005-04-16  2934  	struct mm_struct *mm = current->mm;
^1da177e4 Linus Torvalds        2005-04-16  2935  	struct vm_area_struct *vma, *prev;
16e72e9b3 Denys Vlasenko        2017-02-22 @2936  	unsigned long len;
^1da177e4 Linus Torvalds        2005-04-16  2937  	struct rb_node **rb_link, *rb_parent;
^1da177e4 Linus Torvalds        2005-04-16  2938  	pgoff_t pgoff = addr >> PAGE_SHIFT;
3a4597568 Kirill Korotaev       2006-09-07  2939  	int error;
^1da177e4 Linus Torvalds        2005-04-16  2940  
16e72e9b3 Denys Vlasenko        2017-02-22  2941  	/* Until we need other flags, refuse anything except VM_EXEC. */
16e72e9b3 Denys Vlasenko        2017-02-22  2942  	if ((flags & (~VM_EXEC)) != 0)
16e72e9b3 Denys Vlasenko        2017-02-22  2943  		return -EINVAL;
16e72e9b3 Denys Vlasenko        2017-02-22  2944  	flags |= VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
3a4597568 Kirill Korotaev       2006-09-07  2945  
2c6a10161 Al Viro               2009-12-03  2946  	error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
de1741a13 Alexander Kuleshov    2015-11-05  2947  	if (offset_in_page(error))
3a4597568 Kirill Korotaev       2006-09-07  2948  		return error;
3a4597568 Kirill Korotaev       2006-09-07  2949  
363ee17f0 Davidlohr Bueso       2014-01-21  2950  	error = mlock_future_check(mm, mm->def_flags, len);
363ee17f0 Davidlohr Bueso       2014-01-21  2951  	if (error)
363ee17f0 Davidlohr Bueso       2014-01-21  2952  		return error;
^1da177e4 Linus Torvalds        2005-04-16  2953  
^1da177e4 Linus Torvalds        2005-04-16  2954  	/*
^1da177e4 Linus Torvalds        2005-04-16  2955  	 * mm->mmap_sem is required to protect against another thread
^1da177e4 Linus Torvalds        2005-04-16  2956  	 * changing the mappings in case we sleep.
^1da177e4 Linus Torvalds        2005-04-16  2957  	 */
^1da177e4 Linus Torvalds        2005-04-16  2958  	verify_mm_writelocked(mm);
^1da177e4 Linus Torvalds        2005-04-16  2959  
^1da177e4 Linus Torvalds        2005-04-16  2960  	/*
^1da177e4 Linus Torvalds        2005-04-16  2961  	 * Clear old maps.  this also does some error checking for us
^1da177e4 Linus Torvalds        2005-04-16  2962  	 */
9fcd14571 Rasmus Villemoes      2015-04-15  2963  	while (find_vma_links(mm, addr, addr + len, &prev, &rb_link,
9fcd14571 Rasmus Villemoes      2015-04-15  2964  			      &rb_parent)) {
897ab3e0c Mike Rapoport         2017-02-24  2965  		if (do_munmap(mm, addr, len, uf))
^1da177e4 Linus Torvalds        2005-04-16  2966  			return -ENOMEM;
^1da177e4 Linus Torvalds        2005-04-16  2967  	}
^1da177e4 Linus Torvalds        2005-04-16  2968  
^1da177e4 Linus Torvalds        2005-04-16  2969  	/* Check against address space limits *after* clearing old maps... */
846383359 Konstantin Khlebnikov 2016-01-14  2970  	if (!may_expand_vm(mm, flags, len >> PAGE_SHIFT))
^1da177e4 Linus Torvalds        2005-04-16  2971  		return -ENOMEM;
^1da177e4 Linus Torvalds        2005-04-16  2972  
^1da177e4 Linus Torvalds        2005-04-16  2973  	if (mm->map_count > sysctl_max_map_count)
^1da177e4 Linus Torvalds        2005-04-16  2974  		return -ENOMEM;
^1da177e4 Linus Torvalds        2005-04-16  2975  
191c54244 Al Viro               2012-02-13  2976  	if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
^1da177e4 Linus Torvalds        2005-04-16  2977  		return -ENOMEM;
^1da177e4 Linus Torvalds        2005-04-16  2978  
^1da177e4 Linus Torvalds        2005-04-16  2979  	/* Can we just expand an old private anonymous mapping? */
ba470de43 Rik van Riel          2008-10-18  2980  	vma = vma_merge(mm, prev, addr, addr + len, flags,
19a809afe Andrea Arcangeli      2015-09-04  2981  			NULL, NULL, pgoff, NULL, NULL_VM_UFFD_CTX);
ba470de43 Rik van Riel          2008-10-18  2982  	if (vma)
^1da177e4 Linus Torvalds        2005-04-16  2983  		goto out;
^1da177e4 Linus Torvalds        2005-04-16  2984  
^1da177e4 Linus Torvalds        2005-04-16  2985  	/*
^1da177e4 Linus Torvalds        2005-04-16  2986  	 * create a vma struct for an anonymous mapping
^1da177e4 Linus Torvalds        2005-04-16  2987  	 */
c5e3b83e9 Pekka Enberg          2006-03-25  2988  	vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
^1da177e4 Linus Torvalds        2005-04-16  2989  	if (!vma) {
^1da177e4 Linus Torvalds        2005-04-16  2990  		vm_unacct_memory(len >> PAGE_SHIFT);
^1da177e4 Linus Torvalds        2005-04-16  2991  		return -ENOMEM;
^1da177e4 Linus Torvalds        2005-04-16  2992  	}
^1da177e4 Linus Torvalds        2005-04-16  2993  
5beb49305 Rik van Riel          2010-03-05  2994  	INIT_LIST_HEAD(&vma->anon_vma_chain);
^1da177e4 Linus Torvalds        2005-04-16  2995  	vma->vm_mm = mm;
^1da177e4 Linus Torvalds        2005-04-16  2996  	vma->vm_start = addr;
^1da177e4 Linus Torvalds        2005-04-16  2997  	vma->vm_end = addr + len;
^1da177e4 Linus Torvalds        2005-04-16  2998  	vma->vm_pgoff = pgoff;
^1da177e4 Linus Torvalds        2005-04-16  2999  	vma->vm_flags = flags;
3ed75eb8f Coly Li               2007-10-18  3000  	vma->vm_page_prot = vm_get_page_prot(flags);
^1da177e4 Linus Torvalds        2005-04-16  3001  	vma_link(mm, vma, prev, rb_link, rb_parent);
^1da177e4 Linus Torvalds        2005-04-16  3002  out:
3af9e8592 Eric B Munson         2010-05-18  3003  	perf_event_mmap(vma);
^1da177e4 Linus Torvalds        2005-04-16  3004  	mm->total_vm += len >> PAGE_SHIFT;
846383359 Konstantin Khlebnikov 2016-01-14  3005  	mm->data_vm += len >> PAGE_SHIFT;
128557ffe Michel Lespinasse     2013-02-22  3006  	if (flags & VM_LOCKED)
ba470de43 Rik van Riel          2008-10-18  3007  		mm->locked_vm += (len >> PAGE_SHIFT);
d9104d1ca Cyrill Gorcunov       2013-09-11  3008  	vma->vm_flags |= VM_SOFTDIRTY;
5d22fc25d Linus Torvalds        2016-05-27  3009  	return 0;
^1da177e4 Linus Torvalds        2005-04-16  3010  }
^1da177e4 Linus Torvalds        2005-04-16  3011  

:::::: The code at line 2936 was first introduced by commit
:::::: 16e72e9b30986ee15f17fbb68189ca842c32af58 powerpc: do not make the entire heap executable

:::::: TO: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux