From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E787F3FCC for ; Sat, 11 Jul 2026 00:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783730622; cv=none; b=FkA6V7di4LX1yTACrso5CDngEnHKMlOldmAm6rRLT3sulF5JQNNpJYQJ8nPv4T/TbLLxoYO71tPpSR7dnPEURVFstzneRFMwe3yPYtXNBt+DYU4yin9PYGluYWO1gRUaAwOHkQPv3b8n9kIR4hoeJ0RDXHEwZY7Uj7jA6UKsNbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783730622; c=relaxed/simple; bh=IqD/pVaAHzZY3zGfVqactDJlqFheBAUrW7AwQ1n3Xdw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=fcNRGAglCjvlt8ihNRpTYkUK+YZwI5WktJhgRwB7PEfpfkK19CqMjizFOiEzNjzJ6CeIh5Y5mYrCKkn1WX/x0qmUjz4ypW3QU426htZJ2qCvzZGqOyLrnbVoduSn0BF0HlFp/WQskN9J8RNLAQCMDy3ujeOty9vHj8f2ERJaD4A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Bt0/BvUx; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Bt0/BvUx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21F9A1F000E9; Sat, 11 Jul 2026 00:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783730621; bh=/LbfHUrmsdfE/Gd8GJrnmyAOP3YNcTodQ3L23/iC5b0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Bt0/BvUxbtZOGR9BnfwlJwap/0GQ8fHT1MZ9VGpIu0afakcvrOaFjGwt5JLkDhW/7 2Euz7Z3ngnsUmpKO5aSIs4xOgtemWJ6hb2Znyblf06uxfAJ2en3cY2WQbAwWjFhsyQ Q1Z2slFaS8g8rOHPuXuXa9DGrhQyJ/yrbicPHS1o= Date: Fri, 10 Jul 2026 17:43:40 -0700 From: Andrew Morton To: Hajime Tazaki Cc: liam@infradead.org, ljs@kernel.org, vbabka@kernel.org, jannh@google.com, pfalcato@suse.de, linux-mm@kvack.org, geert@linux-m68k.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: nommu: free unused resources when mremap shrinks the vma Message-Id: <20260710174340.9f3b420629769b556f44640f@linux-foundation.org> In-Reply-To: <20260710021028.892645-1-thehajime@gmail.com> References: <20260710021028.892645-1-thehajime@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 10 Jul 2026 11:10:28 +0900 Hajime Tazaki wrote: > When shrinking a VMA via mremap, the bounds are modified directly: > mm/nommu.c:do_mremap() { > ... > vma->vm_end = vma->vm_start + new_len; > ... > } > This shrink the VMA without updating its bounds in the maple tree. > If the maple tree (mm->mm_mt) still contains the old bounds, a user > process could access the freed portion. The stale maple tree would > incorrectly return the shrunk VMA for an address past its new vm_end. > > This commit fixes this issue by calling vmi_shrink_vma() when shrink > happens. Thanks again for helping with NOMMU. I'd like to give you a medal, but you'll have to settle for an overstuffed inbox. Sashiko is up to its usual tricks: https://sashiko.dev/#/patchset/20260710021028.892645-1-thehajime@gmail.com I assume that ENOMEM is more likely on NOMMU, and that we should hence be more defensive about handling it. Seems we have not been.