From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2CA42737F8 for ; Sat, 11 Jul 2026 03:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783739023; cv=none; b=N/QVE58Vdaxpp4QCEc5WIsFMa6jLKerRBbF466t5dCWlzbcvCOQLOrNyQr44MDUFDRJyLpWiaoaCenND9V0tiJNrGTyNS/moBDFZDYQjzKgIFC+fFm1MarBcK1+Zuw0mGh2Wmy15qbx43ajArUtlKMTpblrU98vBuXwu5rxk+R8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783739023; c=relaxed/simple; bh=5VoMaUrR8xdKHqUWhguvGuMDfauDICgzrqJeY6fvdP0=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=InUNN4O54X9B2lOWAHAK3rHsy7TmovQ/QYkMK3J4sp3jFEmVc1Fj5Emy/0r9phGRFnZ8hzzyY7S9jKLeZB2+e3qFm2ALgXYFNL+HjIhgE+7MIesSvMuMrsbmfJA/zwynkpeak3QF4+iLIzn8wBtKHvSO19GXL5o5ZBv4rsSHT0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ldcl+hFB; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ldcl+hFB" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-38dc4553f62so485212a91.0 for ; Fri, 10 Jul 2026 20:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783739022; x=1784343822; darn=vger.kernel.org; h=content-type:mime-version:user-agent:references:in-reply-to:subject :cc:to:from:message-id:date:from:to:cc:subject:date:message-id :reply-to:content-type; bh=gPqLXi2lg589wIdZoaJLi7vCawzOw1W2oonH67X+kuI=; b=ldcl+hFBDQ/nJAASkkl53lWbCVPAbD0WDZA01pb/wC4TmiCdzoIkuIjoOV6DF5VQwV 9qWwyXKVGjuvrfs5mDMiI6j484PlWk/2KMIjEO8c1GYClmokQiDGEJo0dZywYFHYs0LU DFJg1BjGnIUxRWka9bhcWaL5dWVGdigXaM1HqYd9fdYYYWSumnLt3tYtwcz2ci1yYFIZ 13Gjpuihxym3oHNapruu4ouGEKRnITj1Q8LtvDxMtFt3iI7nOk92y7vX2nQWkRJnqOIg 0yBWnCuU7cAkJ6J0HXSbCdP8SPI5MviUTI0QqHannt5+eJGbKcNx07AGyB1Erh4y2E0s elkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783739022; x=1784343822; h=content-type:mime-version:user-agent:references:in-reply-to:subject :cc:to:from:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=gPqLXi2lg589wIdZoaJLi7vCawzOw1W2oonH67X+kuI=; b=nPevXg1k2+PShlDHfefmrAm6qL8LrW6HV8dY5zQYLInNa8+MYocsYa/WH5E9jTc2bp ELhsgA9csQ1KfYAdWp9SP8RW1AYlmMY1L3LVLD/7MmkGIqtdGscrW3y2tw8qh7oTs3rQ S3vd77xMXvIz243SY/40j+zdrn8DUx1ip8iEfBaZd9KWKsiGiR5hx0cUNUa6Otr7ioip S3X0uiWLYNIjTqf+W7ULjOYvHTKXeaTglsH0OrfbCAfsogXxg8w9XRNkknpIxWZm6Cmb dG3od4cSGrjw3PEYPtObQLWGEMmHeHI7zCLpjDqOkWtaN9CXObq6WxKxCdrquYjigY5T 0Szg== X-Forwarded-Encrypted: i=1; AHgh+RrVd1ajvswagNjgYvFGh2GeQKKKpwQVHCFDt/6P9pqfreTRvpxZHS7yj7FGHCXW8L8Xry5+kef4X0VvpnE=@vger.kernel.org X-Gm-Message-State: AOJu0YyFD2uemRR/vX/8v3SnO0YxW+7m34D3EyVa694toypYAO/9OZJ6 tgC3jFvvJeY7J5/jjnVTYlAvPDcFuK6u8l9px2JJWubS8E9O8goNyxrD X-Gm-Gg: AfdE7ckWFHS142ociLRp646elEdYmejhWuYhTWuEJMGsYjbQFv3rQvYFfnzQ1rUku1B XXZ9d5BjWAggY2RyFblkrMav9Nuh1CcpG19NYzeCYNRe+pK+y7UK/kX/f9OVjNLVPfMYvXK1UrV i/ZLLymUZOOEMDfkeLsfKdGtgdN1fDowg35RzfQ/uPPjAHjIfrg+kPU5hOkggD+UlaSDCWourrE YlOjdU4E5LkyAGjE9N35b1fozME2NHEplQQdvck7TqAYhMhUuxUK274ar0uv5x2ovxsrfw0aYcl Euc4VnoGv7pnS2wvtImWB407J6IvihII111Gm3pZKVsUsVI3CNufnKR/Sk0QttcObLUzc9lopo6 rxuc1NZ3M5odc0aWZKfHyL/GJTTKCwck9ZY2BO8eNT/AsbqDIPOodbj5t4qXO85GYbFxHHqr1dz YYJsnrtxCHXpRXoqLREF5hBYv8Ma16ehgj5OhIvJKVBISvx6J3tgxiFituw5ldOlXyfyZBtMmmc fP5mnXQRAfEZeCCwHDJKUPFxORiQIIKn5jupmiNNHxssub7 X-Received: by 2002:a17:90b:1a8b:b0:387:e0cb:c8e1 with SMTP id 98e67ed59e1d1-38dc77c3378mr1359152a91.42.1783739021927; Fri, 10 Jul 2026 20:03:41 -0700 (PDT) Received: from jupiter.local.gmail.com (221x241x217x81.ap221.ftth.ucom.ne.jp. [221.241.217.81]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38a5622ae99sm3496029a91.14.2026.07.10.20.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 20:03:41 -0700 (PDT) Date: Sat, 11 Jul 2026 12:03:35 +0900 Message-ID: From: Hajime Tazaki To: akpm@linux-foundation.org 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 In-Reply-To: <20260710174340.9f3b420629769b556f44640f@linux-foundation.org> References: <20260710021028.892645-1-thehajime@gmail.com> <20260710174340.9f3b420629769b556f44640f@linux-foundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/26.3 Mule/6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII On Sat, 11 Jul 2026 09:43:40 +0900, Andrew Morton wrote: > > 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. thanks for looking at this and sorry for the rush of patches due to my bad (lack of local sashiko review). I'll try to be calm and find a local env anyway. > Sashiko is up to its usual tricks: > https://sashiko.dev/#/patchset/20260710021028.892645-1-thehajime@gmail.com thanks, I already posted a v2 patch which addresses this issue (but found another issue in a different location). https://lore.kernel.org/linux-mm/20260710054648.924005-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. I agree. -- Hajime