From nobody Sun Feb 8 23:41:19 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 420DD2D47EF for ; Mon, 12 Jan 2026 08:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768207652; cv=none; b=HWLh/IJ9FK1W7HWUszTdEjpmx7vmSUEEAx/9nw4s0LBwj1iFjN+JK76b021Uf+kRIU+zxXpROhj8zgVeAW3EJ5IzdwPYky8VkP7O26udh80BVsMC7WxrDOZ4MmOIpgz+qtAz91wpyQY1on5fvymdljC/KS2bhmdKbYlk+aANABg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768207652; c=relaxed/simple; bh=35m5e/5bWhRHejqv8OISOQ4t2X3yJEcfD7kC7OmtCNU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XmgxPHPX96if0EWmsDNiKhvFTn2VT03xU8x9F9PvgbcXKCkQVG8+6BtPY8Ui4E/gaChJcSdhPE2nSkzipPo7ugzpMP47nyaO+JcxFuh6s8q9i1LVewoYKgDewIt+rJEBYh4jcJY0CX9PaE9xgNENY/pqLngwgq7fknIO9qjlBGw= 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=QSC0OuCq; arc=none smtp.client-ip=209.85.214.181 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="QSC0OuCq" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2a09d981507so37688245ad.1 for ; Mon, 12 Jan 2026 00:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768207650; x=1768812450; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hklsKrrHIgsoCmky375DsGUrVmni2mBT3d93lWnbdtU=; b=QSC0OuCqThuyfHLdfOT9OyKppc++hnrOdstqAhPtxURwlWP28cOw1ypCvdJ2ig5wg0 C1dGbp7fjoBGt9YEORS0qnnM/ndl3cT1b+IQ19qd8lMhJ1ovpNSbFVOB8NDioR6zXEur WmNT58fuEv3l1QlLKE9TSqkLFBy0wNUymb9hfFr/Lw6bJZ0DUedyjP2A+shZR3f96VQK pyrEGmzMZH54xzZYUCGw70S8aWY1to+3fxFErS521zKjZ1JEGqK9fKsRHXG4DRl9/iJr xMD7dFcUsM/q/MqfKJRWb/0awqvlqR+7MFgugrx1Na4lqmZLjdcFfVdbjdISWcL+is/Z YmhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768207650; x=1768812450; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hklsKrrHIgsoCmky375DsGUrVmni2mBT3d93lWnbdtU=; b=qi4pj1baZfCJD0QIsHKp5S8CDX97v6To97cZr9LAzqxTiEdRt9RKdnD72ard2hKSux 8KFZqC3uvBRhjVOjuOdErmNDcwhnPqnN6pxclR3q/ajWzXW7FdWFNjSLZuhEbD7/ij9C TQLA6VP/qNEFGUO5TxjRJqrrNrfFA69R3jh+79V1KgCWEA3xg6g8Ilel+IDjNdQzm91l BIXHJ0WJRg2wLbHKafogh8fJ3KLTwzY6dl54vnnHiMZbzi2htYW68CFamOVTm00negpc 61+uiMGAxb0J4muxinie0kz70rDaM4+gSnrYj9l+brOq5D+g3e6tw5Js0dmVRjbWjO/b m1nw== X-Forwarded-Encrypted: i=1; AJvYcCUI3K5azRMQUO8S+fRMNJisTHB8Zsmi/wWq3VQK5P2W5bZ/mHjASAQ5PBZMwC2J/ITQzK7Gfq4IoginSMY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz52rNPu14cGOngHaNTfmkZ3D3mj6j2KCI4Gj4QT6YZfIsnwjxk X7bavazvDKkEXWvGGFm+4dWwOnP7zx9mkF18u6+1ha8kS+weCi5GxOVmCuST6g== X-Gm-Gg: AY/fxX561aHScOBdeHV6f2mqpsitnPHnCEgFHFCNxWYGUvXWRVeSZCtT+4nLtBVct7D vpOI5FYvHqJiXwaNjH0KjdYrYHUDS/X3UHUMVdlAx+QZOIpZNF5RCAYQNeNUxEGF3uyR0o0jKO2 kdJmlmAJwb4KEXFIJml4DrufWeGEDmuv6gl894mfaF0YBk9w4ClbarjKn3hdnYK9lFpMBUSclRn 3EsEsIy2ACqi7mFnYgxA/gyqCoc91UskRL6u4Q58dgYVDqpRBOEK2kjz7e5jdnMCAilnNa3iT2G CXWVOoLMSsFRoWNn876XdbXqDkEVWaVJlvwsKOJZa4DU8NfZtd2s1wlY5/flBZhrMDI9h20CmLo CUATpyL2Ny0Mn4B0v2pV1GZ9A4PFe7jAKh3lCTfSz98M+/HDc+/pJydRMesJg752EOCROFM58MP DcpbtnAnU4Hw8zzjletn/12CcswjKZV8OgUdd0kj4dMd9XathJFjLPuPbK5EJZcA56WOg= X-Google-Smtp-Source: AGHT+IFnYxNSqiGxNAqd32y+etQrz589zxynwCAGgapm31trBYhiWdXuubNT5Yto2ExOwPbTaMgHlg== X-Received: by 2002:a17:903:11d0:b0:29f:1b1f:784 with SMTP id d9443c01a7336-2a3e39828f1mr207992795ad.4.1768207650502; Mon, 12 Jan 2026 00:47:30 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:7751:dfe4:62a3:f9d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3c48e8esm53450075ad.37.2026.01.12.00.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 00:47:29 -0800 (PST) From: Deepanshu Kartikey To: akpm@linux-foundation.org, urezki@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+d8d4c31d40f868eaea30@syzkaller.appspotmail.com Subject: [PATCH] mm/vmalloc: prevent RCU stalls in kasan_release_vmalloc_node Date: Mon, 12 Jan 2026 14:17:23 +0530 Message-ID: <20260112084723.622910-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When CONFIG_PAGE_OWNER is enabled, freeing KASAN shadow pages during vmalloc cleanup triggers expensive stack unwinding that acquires RCU read locks. Processing a large purge_list without rescheduling can cause the task to hold CPU for extended periods (10+ seconds), leading to RCU stalls and potential OOM conditions. The issue manifests in purge_vmap_node() -> kasan_release_vmalloc_node() where iterating through hundreds or thousands of vmap_area entries and freeing their associated shadow pages causes: rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P6229/1:b..l ... task:kworker/0:17 state:R running task stack:28840 pid:6229 ... kasan_release_vmalloc_node+0x1ba/0xad0 mm/vmalloc.c:2299 purge_vmap_node+0x1ba/0xad0 mm/vmalloc.c:2299 Each call to kasan_release_vmalloc() can free many pages, and with page_owner tracking, each free triggers save_stack() which performs stack unwinding under RCU read lock. Without yielding, this creates an unbounded RCU critical section. Add periodic cond_resched() calls within the loop to allow: - RCU grace periods to complete - Other tasks to run - Scheduler to preempt when needed The fix uses need_resched() for immediate response under load, with a batch count of 32 as a guaranteed upper bound to prevent worst-case stalls even under light load. Reported-by: syzbot+d8d4c31d40f868eaea30@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dd8d4c31d40f868eaea30 Signed-off-by: Deepanshu Kartikey --- mm/vmalloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 41dd01e8430c..a9161007cf02 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2273,6 +2273,7 @@ kasan_release_vmalloc_node(struct vmap_node *vn) { struct vmap_area *va; unsigned long start, end; + unsigned int batch_count =3D 0; =20 start =3D list_first_entry(&vn->purge_list, struct vmap_area, list)->va_s= tart; end =3D list_last_entry(&vn->purge_list, struct vmap_area, list)->va_end; @@ -2282,6 +2283,11 @@ kasan_release_vmalloc_node(struct vmap_node *vn) kasan_release_vmalloc(va->va_start, va->va_end, va->va_start, va->va_end, KASAN_VMALLOC_PAGE_RANGE); + + if (need_resched() || (++batch_count >=3D 32)) { + cond_resched(); + batch_count =3D 0; + } } =20 kasan_release_vmalloc(start, end, start, end, KASAN_VMALLOC_TLB_FLUSH); --=20 2.43.0