From nobody Thu Apr 9 15:44:36 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 C6AD11CAA6C for ; Sat, 7 Mar 2026 01:06:41 +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=1772845603; cv=none; b=ob9eIEdByonAoM5iPy/xhNUjqiwMrSBfwYvXL8Uq6FuAZqzpjMgfbgMQjMMBeIJJ35ODtDGdOSB2Orwmsg/FlhjJPoYUgLDw6Y2vri4s+V+kNSkAwl1t4dbe42RCkQ0oiG52FDY/BEhocC3EcA+Q/+m3oI8rfEeYECkTlfGlqNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772845603; c=relaxed/simple; bh=NEjjpr1hBgRL0hTeez0Lx5+FYBwCLcZ5ycQACtMtBjc=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=jK5khYhj5cgOkS1/pRe49suh3I5GzcjulPDty6d2ySXXy/TK3EykpKHwlf5Q/sKu/9eoN8QmIv8b/JTFHaslUSFXkrNwPcdhY+PoK1SjzSZuOM3xecTIDXM4PvtL4VCdbdKWMkcUsrE8Aw2tDSXyLFeQzotiDx6+6Q3tx0ElM7A= 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-679c6ef1538so151357858eaf.3 for ; Fri, 06 Mar 2026 17:06:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772845600; x=1773450400; 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=ch2YwjFMF8APGM+SF17SgsvmSrIZqboLO5uhU3mLVDbBKqf6r6tqunabDHEjPF3qN1 sLe5w6CLiEn64crXlpcNc2IVjJaG0qyn5PFkfkATtBgUGOT2sXc5Y+AJfT5vMQevqn0I kP5M27wOwgSdJxnaRvdumqFELCUpe/GTSkrgVXt2KPKWDzg1KeG1OlyZWRPR6ZNVt54i JRs1yeUS8ST+fasr89PTYLRmoeNjvDHE0gYH/f1lw8SVd3GUbTDW+wwnAytJEkrPi1pq sMPdMq4YdXAwiJtHnZEsg4f0RLBizQXmij41MTZB8zKkF8IA1frn0WyvyplMl1QZrhkx 7kVw== X-Gm-Message-State: AOJu0Yw7KIBUTirwb+b4xRX1xOthAV0bDRlLR8FZ60kH+ypxf6/xzuBi Mks1kxi675ZWw5Rltjb/yKuOMYtPBsh/3hpp+p2M/88h4jxSofBOo/CPjaALxv3Jxp3KTFrlpwG RK/+XZlqoDHGfTLkbsZ5iLmz2uvXCQGCTXIsRvuOty9x/4gwdAckbcQgfH5s= 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:4b92:b0:679:975b:f227 with SMTP id 006d021491bc7-67b9bd2e167mr2601614eaf.42.1772845600682; Fri, 06 Mar 2026 17:06:40 -0800 (PST) Date: Fri, 06 Mar 2026 17:06:40 -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: <69ab7a20.050a0220.13f275.0036.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