From nobody Thu Apr 9 15:44:36 2026 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) (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 940771A6826 for ; Sat, 7 Mar 2026 00:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772844072; cv=none; b=hnyuC8/gcRK7agxb4kWqC14IoymNHDm7laB9I22uVU7ktUlBlDi+oFgqpkOOPtElr+pKFEwgH8QNs/TW+oyWP3Rg3G807oWIyF/sKFjn0Bi7d4JWrFg2wPf5JVJV5p4qBLJWp86HkGFoId0lyPtByo8ER+clw5Ty/lbkdLTPf3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772844072; c=relaxed/simple; bh=NEjjpr1hBgRL0hTeez0Lx5+FYBwCLcZ5ycQACtMtBjc=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=ehOAFAGGraoBj1Xygc5QIsEtEMS0EMvDb0BAeyF6jVRsRfi2O+WMl45MT3T9J8DMDGebX7laMfL1PA9Ajq+aWC4Ovaq5iTng6VvHIw9rnvI4ofzD64zFFOTTOJUJ2F0bCDlurTumfiZd5T9BZkl9XLdVYwnCc9pZcud/Vfw3WF4= 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.69 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-f69.google.com with SMTP id 006d021491bc7-679dda090fbso160045104eaf.2 for ; Fri, 06 Mar 2026 16:41:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772844070; x=1773448870; 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=tnvAQ8X65Q7TwE4KaimuxvIkieCaC5xxXn2GGMH5PGE=; b=XT8gelpkJTgzBExvXtyo92tmNF0eFu/8ZBxG5gJ4Op/2Y0e8UycDNOg95bjEey/Po+ fRDIBJjy9R3f2A45Lrc9A3/z6CgVXZ7HjzsYe9bLTeOIyltUOMM6r96HrNr19onAE+8o gR3yPcFZ1tA+8iEIZ0DsiWDsMtC+YVyl7hjLuRP5NHZrtRy2xYt3N8849Rdl99+hbOCi Rn/UW+EpywTVZ4HY7Oda+cvBIjl4SWDumB1DcX37/Rwf0NQZPXmRCuepctkp6Y4yNspl nSsDxiXPYbj4Wz+D6CWMrnXMJ6f/7qnkKTK18eAO3BWlYm2E/LXNapkrJBZnTugR/DgP SPOw== X-Gm-Message-State: AOJu0YzVLMpwjKgsgSlIbKDVKFAmhEQofUTXRuJLUEwRuJhhBqSpIUWN Bs7UL+eGGemCtEeBpYYo94yevxu7j8pR4z0IjDCwgiQvy0TXEeBcSaCcKLn3uZP4Oi30mxaaylh QW3PtVlwgYOwMzm6y5rdYIxIzmNZqTcvRNZP6T0qT4DH8yNpzsAfvyVEpT8E= 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:4c09:b0:65f:71ec:4ec8 with SMTP id 006d021491bc7-67b9bd0ce4amr2388249eaf.47.1772844070630; Fri, 06 Mar 2026 16:41:10 -0800 (PST) Date: Fri, 06 Mar 2026 16:41:10 -0800 In-Reply-To: <69aa75e2.050a0220.13f275.0010.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69ab7426.050a0220.13f275.0033.GAE@google.com> Subject: Forwarded: [PATCH] netfs: Fix NULL pointer dereference in netfs_unbuffered_write() on retry 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] netfs: Fix NULL pointer dereference in netfs_unbuffered_wr= ite() on retry Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master When a write subrequest is marked NETFS_SREQ_NEED_RETRY, the retry path in netfs_unbuffered_write() unconditionally calls stream->prepare_write() without checking if it is NULL. Filesystems such as 9P do not set the prepare_write operation, so stream->prepare_write remains NULL. When get_user_pages() fails with -EFAULT and the subrequest is flagged for retry, this results in a NULL pointer dereference at fs/netfs/direct_write.c:189. Fix this by mirroring the pattern already used in write_retry.c: if stream->prepare_write is NULL, skip renegotiation and directly reissue the subrequest via netfs_reissue_write(), which handles iterator reset, IN_PROGRESS flag, stats update and reissue internally. Reported-by: syzbot+7227db0fbac9f348dba0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D7227db0fbac9f348dba0 Signed-off-by: Deepanshu Kartikey --- fs/netfs/direct_write.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c index dd1451bf7543..d7295a64f0a9 100644 --- a/fs/netfs/direct_write.c +++ b/fs/netfs/direct_write.c @@ -186,10 +186,17 @@ static int netfs_unbuffered_write(struct netfs_io_req= uest *wreq) stream->sreq_max_segs =3D INT_MAX; =20 netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); - stream->prepare_write(subreq); =20 - __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); - netfs_stat(&netfs_n_wh_retry_write_subreq); + if (stream->prepare_write) { + stream->prepare_write(subreq); + __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); + netfs_stat(&netfs_n_wh_retry_write_subreq); + } else { + struct iov_iter source; + netfs_reset_iter(subreq); + source =3D subreq->io_iter; + netfs_reissue_write(stream, subreq, &source); + } } =20 netfs_unbuffered_write_done(wreq); --=20 2.43.0