From nobody Mon Jun 8 14:35:27 2026 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.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 370A53FD971 for ; Thu, 28 May 2026 15:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779983592; cv=none; b=u3V9hvL/bsUVauhyVb/4EKPzYKukPjh08S5Bc0HBiwA0rJsUrFM7nbSSeh7XwO0iSOU/ViWEjBmxJLoXAOlFQuid4nOQXqdisfuUJYpel1dsS8QEEhcGc85GT80JWUdH7XzMqGXTXg9JmTDDadd8ep2xL9bioObKiD7NpGFoEFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779983592; c=relaxed/simple; bh=5Ih8kZAhZLbOn+BWycxEC+3p7jHDL4MrscLjcX8egEE=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=YJ4BcPe8Q3AxERoyBvvBw3Vqq96BUvGB4HFYMEOVly4+kE9JGos/F3CrISng5fIMPxAPMgn91yj9w8iHMVbuAtwyamc1UEavVzki6DrsOcoc+0AmLwtF5LIsZEVU2HBK0fXtQGYGi4DtdewEiQXhN3dAUvB6kxPLW3WUWuAYUbI= 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.210.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-ot1-f71.google.com with SMTP id 46e09a7af769-7e65a0125c3so5785644a34.3 for ; Thu, 28 May 2026 08:53:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779983589; x=1780588389; 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=rjDf0SNzXxR86/vaFMGsWuods9da0i8gN+ybnHjmX8Y=; b=nwA35cMtrJ18bjvDF2YSDEbaaPI2GJ0o4dkISYRCq0djurE027pHHz6vr1clppH1/m IGwGJghJnGc6ZymLy/4okSeLfGzRq0CwsXZ/cE5CynmPhPz3I3VY0/HG4U8gmLP0vzNF OG//M0WT61ZljeVmyip1kMNSGb6zEd5VG0kURT+XuLsGA5IWiSAENxNX55eoAx2xFiEb eCzsaBEj1c5jh2qQPr4K95oH6h2BZ7MLvTuJgBf1vck4ckmK6qsrlgWnKhuwGHd/4shI th0y3YgiWdefNHpi6JqVW8GbFd5m5Ra0z82Xa1xmEdb2RixTtph6hE40hHF2eUtuLPhJ txZA== X-Gm-Message-State: AOJu0Yze+ojLPbfVlyw/yUWHXyF/VhJSxwA7H/+zWqADnPDVOMuO4HYt 10PEZJZ2rkD2PDzpHoJY4dJu22vGUOs+1deLrsJB0y00Kk311jsmLbV4IBjHeomoJ5DlcnXaXHd wbxrahgV6k75vga8BoMeKyCR+Q8XRSQ7d3QDXh+G6+aYgDybIP6Ue/S+AXWQ= 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:2a02:b0:69d:7df9:570 with SMTP id 006d021491bc7-69d7ec6f94emr7300707eaf.39.1779983589348; Thu, 28 May 2026 08:53:09 -0700 (PDT) Date: Thu, 28 May 2026 08:53:09 -0700 In-Reply-To: <6a10b30b.050a0220.19f61f.0003.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a1864e5.556265cb.6a38.0000.GAE@google.com> Subject: Forwarded: [PATCH] eventpoll: restore EP_UNACTIVE_PTR sentinel for ctx->tfile_check_list From: syzbot To: linux-kernel@vger.kernel.org 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. *** Subject: [PATCH] eventpoll: restore EP_UNACTIVE_PTR sentinel for ctx->tfile= _check_list Author: zhanwei919@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master commit e09c77d94003 ("eventpoll: hoist CTL_ADD scratch state into struct ep_ctl_ctx") moved tfile_check_list from file-scope global to stack-allocated struct ep_ctl_ctx, replacing the EP_UNACTIVE_PTR sentinel with NULL because "NULL is the obvious 'empty' value and the zero-init handle it for free", and describe the change "No functional change". but its not. epitems_head->next is overload: 1: as a linked-list next pointer for heads on ctx->tfile_check_list, 2: as a membership flag: ep_remove_file() uses !smp_load_acquire(&v->next) to mean "this head is not on any pending ctx->tfile_check_list and is safe to free". Before e09c77d94003, the EP_UNACTIVE_PTR sentinel made the two role disjoint: a head on tfile_check_list always has a non-NULL next (another head, or the sentinel), so v->next =3D=3D NULL was equivalent to never list. With the sentinel gone the list is NULL-terminated and the tail head's ->next is NULL also. ep_remove_file()'s gate no longer tell never list from list at the tail, and misfires on the tail. The reader hold epnested_mutex + rcu_read_lock; the freer hold ep->mtx + file->f_lock. There is no sharing mutex between them; the sentinel was the invariant the gate relied on to skip the read side. The syzbot reproducer hit this within seconds on a multi-CPU VM. Restore the sentinel: initialize ctx.tfile_check_list to EP_UNACTIVE_PTR in do_epoll_ctl_file(), and walk it with "!=3D EP_UNACTIVE_PTR" termination in reverse_path_check() and clear_tfile_check_list(). The gate in ep_remove_file() regains its never list exclusivity and stop misfiring on the tail. ep_remove_file() itself does not change. This restores the invariant the file-scope tfile_check_list relied on before e09c77d94003, preserving the ctx packaging that commit introduced. Reported-by: syzbot+e70e1b6cba8714543f7c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3De70e1b6cba8714543f7c Fixes: e09c77d94003 ("eventpoll: hoist CTL_ADD scratch state into struct ep= _ctl_ctx") Suggested-by: Christian Brauner Link: https://lore.kernel.org/all/20260528-rotwild-summt-kuhhandel-7276ef4c= 33b7@brauner.io/ Signed-off-by: Zhan Wei --- fs/eventpoll.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index a569e98d4a99..4973a5a5a3e1 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1685,7 +1685,7 @@ static int reverse_path_check(struct ep_ctl_ctx *ctx) { struct epitems_head *p; =20 - for (p =3D ctx->tfile_check_list; p; p =3D p->next) { + for (p =3D ctx->tfile_check_list; p !=3D EP_UNACTIVE_PTR; p =3D p->next) { int error; path_count_init(ctx); rcu_read_lock(); @@ -2438,7 +2438,7 @@ static int ep_loop_check(struct ep_ctl_ctx *ctx, stru= ct eventpoll *ep, static void clear_tfile_check_list(struct ep_ctl_ctx *ctx) { rcu_read_lock(); - while (ctx->tfile_check_list) { + while (ctx->tfile_check_list !=3D EP_UNACTIVE_PTR) { struct epitems_head *head =3D ctx->tfile_check_list; ctx->tfile_check_list =3D head->next; unlist_file(head); @@ -2601,7 +2601,9 @@ int do_epoll_ctl_file(struct file *f, int op, struct = epoll_key *tf, int full_check; struct eventpoll *ep; struct epitem *epi; - struct ep_ctl_ctx ctx =3D { }; + struct ep_ctl_ctx ctx =3D { + .tfile_check_list =3D EP_UNACTIVE_PTR, + }; =20 /* The target file descriptor must support poll */ if (!file_can_poll(tf->file)) --=20 2.43.0