From nobody Fri Dec 19 11:49:54 2025 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 618382797B5 for ; Mon, 8 Dec 2025 02:47:22 +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=1765162044; cv=none; b=sn9gHqAQ+SIZMS0PRdJruXm4F7O5ko5Wa3j00B/oy2g3XyGLTrkG8kbE3F0znti+q1eEVkPrg2Ea5iCk20mts86Di8Fw3txClensWOj0Z4ewOQOJ7uur1+B0UvuPLxBfaC4+/NAOiKJrMPMZSligG5NVqBC32YZDoVlm50Bu7zM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765162044; c=relaxed/simple; bh=tlPUO7TY456R7rr6+Jng6ekkAwsCx9ebXxFbmwh2Kvw=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=OsdKdescJu5DmoEpFX6yp7hsjZamk2hnDZzffaGAUWfyRj5/nckFQC9yopVjwCkkd+AJhhCma5+C993PIBeqVDe7IM6VRkjv/hGK7FcmVYOvCQ8tAWf4kX8DbV9NxXecipNTS/u+6/l+HKFZWX+KscFRZiIuvrQD6qxp21aRulA= 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-6574d3d44f9so5644302eaf.3 for ; Sun, 07 Dec 2025 18:47:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765162041; x=1765766841; 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=gH0VHiNMFwlDbHX3iF2zrTtjKDV508SvcRt7SNCWCMc=; b=LrcHjHLOowVMtevp3nwzDpUv2v0/WOFFe3u2AdXdGczf2YfOIHTytKbT9EAK0rBvhF 4Dnl06HAuT9d7MKCV5H40EzVb/fgrQGyZRjzRIdnIUZnlv5Lec03NFeuU1YGnQXXhC93 PEJkMgpuT/cjAgmR37SwZCj58f01Y5oQeH7ed9fvTeXNEXnLWSm5YFvf9N7/nQEoGkkO 3cDjAnFGkTOCKhi74DWowM2R0JRogixQozeX6N7GT0dI1eO//JMDv0lCrhtku2CzaqqD 9PIDmLH0nfuimvW3V87DIyUr5uB5fA09sgNUigUA/h4qNq3CK9D+BXuk1JbmPowUstYm bXVQ== X-Gm-Message-State: AOJu0Yz/iV8aKHLJFxjkuEpcsTl8VROiR6zZrMSZalCItuUEpEPu1sn+ hw/elPLD0uwAyfZuJv5Do0rcIsrY8fLLai5xMTtW08t5R8GEFuo2vqZ7eNeKgso9G6daxUZkKFG cMIXOQYDWqaxhk+TIy3WszzUtpE9H3T7oNq3ZPTT6WOFwMmRMcBcuSemqukg= X-Google-Smtp-Source: AGHT+IH8PZnemIkI3YgQ1x73cixaQk0WxtBNXCwtqj17cWrTIfhHqZo7Uy9BBaPpo5yatx3tbBI4NWpEwwnZ31TcuRKueqBLPcQn 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:a0c:b0:659:9a49:901d with SMTP id 006d021491bc7-6599a99bd69mr2542767eaf.74.1765162041611; Sun, 07 Dec 2025 18:47:21 -0800 (PST) Date: Sun, 07 Dec 2025 18:47:21 -0800 In-Reply-To: <693540fe.a70a0220.38f243.004c.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69363c39.a70a0220.38f243.0077.GAE@google.com> Subject: Forwarded: [PATCH] mm/workingset: fix NULL pointer dereference in lru_gen_test_recent() 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/workingset: fix NULL pointer dereference in lru_gen_tes= t_recent() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master Syzbot reported a general protection fault in lru_gen_test_recent() when accessing invalid memory addresses: Oops: general protection fault in lru_gen_test_recent+0xfc/0x370 KASAN: probably user-memory-access in range [0x0000000000004e00-0x0000000= 000004e07] RIP: 0010:lru_gen_test_recent+0xfc/0x370 The crash occurs when unpack_shadow() extracts a pglist_data pointer from a shadow entry. The pgdat can be NULL when NODE_DATA(nid) returns NULL for an invalid or offlined NUMA node ID stored in the shadow entry. The existing code doesn't check for NULL pgdat before passing it to mem_cgroup_lruvec(), which can lead to crashes when dereferencing the invalid pointer. Fix this by checking if pgdat is NULL and setting lruvec to NULL before returning false. The caller in lru_gen_refault() will then skip processing via the check "if (lruvec !=3D folio_lruvec(folio)) goto unlock", preventing use of the invalid lruvec. Reported-by: syzbot+e008db2ac01e282550ee@syzkaller.appspot.com Link: https://syzkaller.appspot.com/bug?extid=3De008db2ac01e282550ee Signed-off-by: Deepanshu Kartikey --- --- mm/workingset.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/workingset.c b/mm/workingset.c index e9f05634747a..b63948f4e91a 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -270,7 +270,10 @@ static bool lru_gen_test_recent(void *shadow, struct l= ruvec **lruvec, struct pglist_data *pgdat; =20 unpack_shadow(shadow, &memcg_id, &pgdat, token, workingset); - + if (unlikely(!pgdat)) { + *lruvec =3D NULL; + return false; + } memcg =3D mem_cgroup_from_id(memcg_id); *lruvec =3D mem_cgroup_lruvec(memcg, pgdat); =20 --=20 2.43.0