linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Jann Horn <jannh@google.com>, Andrew Morton <akpm@linux-foundation.org>
Cc: oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>,
	Hugh Dickins <hughd@google.com>, Oleg Nesterov <oleg@redhat.com>,
	Michal Hocko <mhocko@suse.com>, Helge Deller <deller@gmx.de>,
	Vlastimil Babka <vbabka@suse.cz>, Ben Hutchings <bwh@kernel.org>,
	Willy Tarreau <w@1wt.eu>, Rik van Riel <riel@redhat.com>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Jann Horn <jannh@google.com>
Subject: Re: [PATCH] mm: Enforce a minimal stack gap even against inaccessible VMAs
Date: Wed, 9 Oct 2024 06:45:08 +0800	[thread overview]
Message-ID: <202410090632.brLG8w0b-lkp@intel.com> (raw)
In-Reply-To: <20241008-stack-gap-inaccessible-v1-1-848d4d891f21@google.com>

Hi Jann,

kernel test robot noticed the following build errors:

[auto build test ERROR on 8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b]

url:    https://github.com/intel-lab-lkp/linux/commits/Jann-Horn/mm-Enforce-a-minimal-stack-gap-even-against-inaccessible-VMAs/20241008-065733
base:   8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b
patch link:    https://lore.kernel.org/r/20241008-stack-gap-inaccessible-v1-1-848d4d891f21%40google.com
patch subject: [PATCH] mm: Enforce a minimal stack gap even against inaccessible VMAs
config: parisc-randconfig-r072-20241009 (https://download.01.org/0day-ci/archive/20241009/202410090632.brLG8w0b-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241009/202410090632.brLG8w0b-lkp@intel.com/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
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410090632.brLG8w0b-lkp@intel.com/

All errors (new ones prefixed by >>):

   mm/mmap.c: In function 'expand_upwards':
>> mm/mmap.c:1069:39: error: 'prev' undeclared (first use in this function)
    1069 |                 if (vma_is_accessible(prev))
         |                                       ^~~~
   mm/mmap.c:1069:39: note: each undeclared identifier is reported only once for each function it appears in


vim +/prev +1069 mm/mmap.c

  1036	
  1037	#if defined(CONFIG_STACK_GROWSUP)
  1038	/*
  1039	 * PA-RISC uses this for its stack.
  1040	 * vma is the last one with address > vma->vm_end.  Have to extend vma.
  1041	 */
  1042	static int expand_upwards(struct vm_area_struct *vma, unsigned long address)
  1043	{
  1044		struct mm_struct *mm = vma->vm_mm;
  1045		struct vm_area_struct *next;
  1046		unsigned long gap_addr;
  1047		int error = 0;
  1048		VMA_ITERATOR(vmi, mm, vma->vm_start);
  1049	
  1050		if (!(vma->vm_flags & VM_GROWSUP))
  1051			return -EFAULT;
  1052	
  1053		/* Guard against exceeding limits of the address space. */
  1054		address &= PAGE_MASK;
  1055		if (address >= (TASK_SIZE & PAGE_MASK))
  1056			return -ENOMEM;
  1057		address += PAGE_SIZE;
  1058	
  1059		/* Enforce stack_guard_gap */
  1060		gap_addr = address + stack_guard_gap;
  1061	
  1062		/* Guard against overflow */
  1063		if (gap_addr < address || gap_addr > TASK_SIZE)
  1064			gap_addr = TASK_SIZE;
  1065	
  1066		next = find_vma_intersection(mm, vma->vm_end, gap_addr);
  1067		if (next && !(next->vm_flags & VM_GROWSUP)) {
  1068			/* see comments in expand_downwards() */
> 1069			if (vma_is_accessible(prev))
  1070				return -ENOMEM;
  1071			if (address == next->vm_start)
  1072				return -ENOMEM;
  1073		}
  1074	
  1075		if (next)
  1076			vma_iter_prev_range_limit(&vmi, address);
  1077	
  1078		vma_iter_config(&vmi, vma->vm_start, address);
  1079		if (vma_iter_prealloc(&vmi, vma))
  1080			return -ENOMEM;
  1081	
  1082		/* We must make sure the anon_vma is allocated. */
  1083		if (unlikely(anon_vma_prepare(vma))) {
  1084			vma_iter_free(&vmi);
  1085			return -ENOMEM;
  1086		}
  1087	
  1088		/* Lock the VMA before expanding to prevent concurrent page faults */
  1089		vma_start_write(vma);
  1090		/*
  1091		 * vma->vm_start/vm_end cannot change under us because the caller
  1092		 * is required to hold the mmap_lock in read mode.  We need the
  1093		 * anon_vma lock to serialize against concurrent expand_stacks.
  1094		 */
  1095		anon_vma_lock_write(vma->anon_vma);
  1096	
  1097		/* Somebody else might have raced and expanded it already */
  1098		if (address > vma->vm_end) {
  1099			unsigned long size, grow;
  1100	
  1101			size = address - vma->vm_start;
  1102			grow = (address - vma->vm_end) >> PAGE_SHIFT;
  1103	
  1104			error = -ENOMEM;
  1105			if (vma->vm_pgoff + (size >> PAGE_SHIFT) >= vma->vm_pgoff) {
  1106				error = acct_stack_growth(vma, size, grow);
  1107				if (!error) {
  1108					/*
  1109					 * We only hold a shared mmap_lock lock here, so
  1110					 * we need to protect against concurrent vma
  1111					 * expansions.  anon_vma_lock_write() doesn't
  1112					 * help here, as we don't guarantee that all
  1113					 * growable vmas in a mm share the same root
  1114					 * anon vma.  So, we reuse mm->page_table_lock
  1115					 * to guard against concurrent vma expansions.
  1116					 */
  1117					spin_lock(&mm->page_table_lock);
  1118					if (vma->vm_flags & VM_LOCKED)
  1119						mm->locked_vm += grow;
  1120					vm_stat_account(mm, vma->vm_flags, grow);
  1121					anon_vma_interval_tree_pre_update_vma(vma);
  1122					vma->vm_end = address;
  1123					/* Overwrite old entry in mtree. */
  1124					vma_iter_store(&vmi, vma);
  1125					anon_vma_interval_tree_post_update_vma(vma);
  1126					spin_unlock(&mm->page_table_lock);
  1127	
  1128					perf_event_mmap(vma);
  1129				}
  1130			}
  1131		}
  1132		anon_vma_unlock_write(vma->anon_vma);
  1133		vma_iter_free(&vmi);
  1134		validate_mm(mm);
  1135		return error;
  1136	}
  1137	#endif /* CONFIG_STACK_GROWSUP */
  1138	

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


  parent reply	other threads:[~2024-10-08 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-07 22:55 Jann Horn
2024-10-08 11:39 ` Lorenzo Stoakes
2024-10-08 14:20   ` Jann Horn
2024-10-09 14:53     ` Lorenzo Stoakes
2024-10-09 17:02       ` Jann Horn
2024-10-08 22:45 ` kernel test robot [this message]
2024-10-09 14:53   ` Lorenzo Stoakes
2024-10-09 21:08     ` Andrew Morton
2024-10-10 17:31       ` Lorenzo Stoakes

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=202410090632.brLG8w0b-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bwh@kernel.org \
    --cc=deller@gmx.de \
    --cc=hughd@google.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oleg@redhat.com \
    --cc=riel@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    --cc=w@1wt.eu \
    /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