From nobody Sat Feb 7 07:24:13 2026 Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (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 4384E6FC3 for ; Sun, 18 Jan 2026 09:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768726893; cv=none; b=V/Af8bgXhG2e3skAts9XL7soMIvhy39Ej9LNcvVKEIhINtXTX64qSE3ZLbyOzZdMXVmQZbZsLidKcXVgrYfYYB/c9Oq2jDp4CBOEf0n2+W9T9AeX9V6pfln1n9uwhl1j8OjL46BwbjIAhaebiFfpNsD0orjefoskew1d1ARrjO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768726893; c=relaxed/simple; bh=EtdyFHc5YRA+BVO9JCuI5Setg8g4UpK931/1JlzBzYs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=P8U7GpYgG9+AFFHtH04DSfXtC0X7miZNpJB/4q62yehjw4v5XgeNZs623kL1QQ299NXI6I4pDX1W/Jsu8skQMBNKEAotzMg/dxkjJQkNBBWmlTZZ2bPqF2SR5mSWIM8iuyojXbsFYHjlz7x6z0Qru1MFyfQg1LZoW0fOG0UiVQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-6611cbc47a2so2731700eaf.0 for ; Sun, 18 Jan 2026 01:01:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768726891; x=1769331691; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ohoTxZX1RF/82UIf0XHRlqQmIwruYuC8HF8zxE/9oX8=; b=h8YpeW69apy/rhiqRoRch5ZIPoDvUu6yrMKAHtOQi+FY7/7w0/gL5cx2HlBQtrL6Q5 0VWfzE2VgtxMF5rUwq/4D643eYdCUNPoveLSe5xFOeBpm09IGtJ3cA+/r9aoQ/8lyXcW j88QDDTHz8jySpa7i16PR0QKhvr6myIuSYGvwjCsnPSL92wnT52O2Nxyajw3aNGjM1F3 kCiqbu/o6v9ZiF2TuEMPDVZolX3RBqCBtCbHm+xXhrR0t8gCkAnZ0hgYDg246eFZAGT+ 6BPh0XzpZxcZsylxqHZMGcYyJoEKZriiTiocqqEBGP82XrXIS5j47k/g7T8nmeqUmkoE CHuw== X-Gm-Message-State: AOJu0YxEDskXrBp9iyqkd7zVlhaylfQjELOyENpobUNJglI7dq11Zv4u GcbYfbfWe9JIfQQRND8BWPekyi1N6HZboNmk/t0vVajHgvDTV/YVsX5ysaK5U7YJIQFKvPwbObK irEQ5Lh3y+hOBA6ElRfP0kLGyi2aE9JYceTtbVIa8QkxH4Fag0xhLMHcSP5Q= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:2019:b0:65f:7470:38bd with SMTP id 006d021491bc7-6611896c5ddmr3342505eaf.58.1768726891114; Sun, 18 Jan 2026 01:01:31 -0800 (PST) Date: Sun, 18 Jan 2026 01:01:31 -0800 In-Reply-To: <696c8c10.050a0220.3390f1.001a.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <696ca16b.a70a0220.34546f.0274.GAE@google.com> Subject: Forwarded: [PATCH] mm/rmap: fix unlink_anon_vmas() handling of error case from anon_vma_fork From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] mm/rmap: fix unlink_anon_vmas() handling of error case fro= m anon_vma_fork Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master When anon_vma_fork() encounters a memory allocation failure after anon_vma_clone() has succeeded, unlink_anon_vmas() is called with vma->anon_vma being NULL but the anon_vma_chain populated with entries that are present in the anon_vma interval trees. This happens in the following sequence: 1. anon_vma_clone() succeeds, populating vma->anon_vma_chain and inserting entries into interval trees 2. maybe_reuse_anon_vma() does not set vma->anon_vma because reuse conditions are not met (common case for active processes) 3. anon_vma_alloc() or anon_vma_chain_alloc() fails due to memory pressure 4. Error path invokes unlink_anon_vmas() with vma->anon_vma =3D=3D NULL The existing code triggered VM_WARN_ON_ONCE and returned without performing cleanup, leaving entries in interval trees and causing memory leaks. Fix this by detecting the condition and properly cleaning up: - Iterate through the populated chain - Lock each anon_vma - Remove entries from interval trees - Unlock and free chain entries This prevents both the warning and the resource leaks. Reported-by: syzbot+c27fa543e10a45d4e149@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3Dc27fa543e10a45d4e149 Signed-off-by: Deepanshu Kartikey --- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index f13480cb9f2e..acc8df6ad4a7 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -477,7 +477,31 @@ void unlink_anon_vmas(struct vm_area_struct *vma) =20 /* Unfaulted is a no-op. */ if (!active_anon_vma) { - VM_WARN_ON_ONCE(!list_empty(&vma->anon_vma_chain)); + /* + * Handle anon_vma_fork() error path where anon_vma_clone() + * succeeded and populated the chain (with entries in interval + * trees), but maybe_reuse_anon_vma() didn't set vma->anon_vma + * because reuse conditions weren't met, and a later allocation + * failed before we could allocate and assign a new anon_vma. + * + * We must properly remove entries from interval trees before + * freeing to avoid leaving dangling pointers. + */ + if (!list_empty(&vma->anon_vma_chain)) { + struct anon_vma_chain *avc, *next; + + list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, + same_vma) { + struct anon_vma *anon_vma =3D avc->anon_vma; + + anon_vma_lock_write(anon_vma); + anon_vma_interval_tree_remove(avc, &anon_vma->rb_root); + anon_vma_unlock_write(anon_vma); + list_del(&avc->same_vma); + anon_vma_chain_free(avc); + } + } + return; } =20 --=20 2.43.0