llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [jfern:mm/mremap-pmd-warning-2 1/1] mm/mremap.c:809:18: error: use of undeclared identifier 'old_addr'; did you mean 'new_addr'?
@ 2023-04-22 16:48 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-04-22 16:48 UTC (permalink / raw)
  To: Joel Fernandes (Google); +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git mm/mremap-pmd-warning-2
head:   5cacbf1f3489c227cb2e78e0b9ef454a9363d680
commit: 5cacbf1f3489c227cb2e78e0b9ef454a9363d680 [1/1] mremap: Allow backward overlapping moves
config: riscv-randconfig-r042-20230421 (https://download.01.org/0day-ci/archive/20230423/202304230008.dleNKiqY-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 437b7602e4a998220871de78afcb020b9c14a661)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git/commit/?id=5cacbf1f3489c227cb2e78e0b9ef454a9363d680
        git remote add jfern https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git
        git fetch --no-tags jfern mm/mremap-pmd-warning-2
        git checkout 5cacbf1f3489c227cb2e78e0b9ef454a9363d680
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304230008.dleNKiqY-lkp@intel.com/

All errors (new ones prefixed by >>):

>> mm/mremap.c:809:18: error: use of undeclared identifier 'old_addr'; did you mean 'new_addr'?
           if ((new_addr > old_addr) &&
                           ^~~~~~~~
                           new_addr
   mm/mremap.c:788:17: note: 'new_addr' declared here
                   unsigned long new_addr, unsigned long new_len, bool *locked,
                                 ^
   1 error generated.


vim +809 mm/mremap.c

   786	
   787	static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
   788			unsigned long new_addr, unsigned long new_len, bool *locked,
   789			unsigned long flags, struct vm_userfaultfd_ctx *uf,
   790			struct list_head *uf_unmap_early,
   791			struct list_head *uf_unmap)
   792	{
   793		struct mm_struct *mm = current->mm;
   794		struct vm_area_struct *vma;
   795		unsigned long ret = -EINVAL;
   796		unsigned long map_flags = 0;
   797	
   798		if (offset_in_page(new_addr))
   799			goto out;
   800	
   801		if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
   802			goto out;
   803	
   804		/*
   805		 * Ensure the old/new locations do not overlap for forward moves.
   806		 * Backward overlapping moves are still OK as we do them for the stack
   807		 * during execve() anyway.
   808		 */
 > 809		if ((new_addr > old_addr) &&
   810		    (addr + old_len > new_addr && new_addr + new_len > addr))
   811			goto out;
   812	
   813		/*
   814		 * move_vma() need us to stay 4 maps below the threshold, otherwise
   815		 * it will bail out at the very beginning.
   816		 * That is a problem if we have already unmaped the regions here
   817		 * (new_addr, and old_addr), because userspace will not know the
   818		 * state of the vma's after it gets -ENOMEM.
   819		 * So, to avoid such scenario we can pre-compute if the whole
   820		 * operation has high chances to success map-wise.
   821		 * Worst-scenario case is when both vma's (new_addr and old_addr) get
   822		 * split in 3 before unmapping it.
   823		 * That means 2 more maps (1 for each) to the ones we already hold.
   824		 * Check whether current map count plus 2 still leads us to 4 maps below
   825		 * the threshold, otherwise return -ENOMEM here to be more safe.
   826		 */
   827		if ((mm->map_count + 2) >= sysctl_max_map_count - 3)
   828			return -ENOMEM;
   829	
   830		if (flags & MREMAP_FIXED) {
   831			ret = do_munmap(mm, new_addr, new_len, uf_unmap_early);
   832			if (ret)
   833				goto out;
   834		}
   835	
   836		if (old_len > new_len) {
   837			ret = do_munmap(mm, addr+new_len, old_len - new_len, uf_unmap);
   838			if (ret)
   839				goto out;
   840			old_len = new_len;
   841		}
   842	
   843		vma = vma_to_resize(addr, old_len, new_len, flags);
   844		if (IS_ERR(vma)) {
   845			ret = PTR_ERR(vma);
   846			goto out;
   847		}
   848	
   849		/* MREMAP_DONTUNMAP expands by old_len since old_len == new_len */
   850		if (flags & MREMAP_DONTUNMAP &&
   851			!may_expand_vm(mm, vma->vm_flags, old_len >> PAGE_SHIFT)) {
   852			ret = -ENOMEM;
   853			goto out;
   854		}
   855	
   856		if (flags & MREMAP_FIXED)
   857			map_flags |= MAP_FIXED;
   858	
   859		if (vma->vm_flags & VM_MAYSHARE)
   860			map_flags |= MAP_SHARED;
   861	
   862		ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
   863					((addr - vma->vm_start) >> PAGE_SHIFT),
   864					map_flags);
   865		if (IS_ERR_VALUE(ret))
   866			goto out;
   867	
   868		/* We got a new mapping */
   869		if (!(flags & MREMAP_FIXED))
   870			new_addr = ret;
   871	
   872		ret = move_vma(vma, addr, old_len, new_len, new_addr, locked, flags, uf,
   873			       uf_unmap);
   874	
   875	out:
   876		return ret;
   877	}
   878	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-22 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-22 16:48 [jfern:mm/mremap-pmd-warning-2 1/1] mm/mremap.c:809:18: error: use of undeclared identifier 'old_addr'; did you mean 'new_addr'? kernel test robot

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).