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 6685A8F5B for ; Sat, 7 Mar 2026 00:12:45 +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=1772842366; cv=none; b=Qj+qQNLY9NrxOfQJFZz/rvn6g0hs2tL74aPbATZvT/qRk6e5n2NqKXq1gWSJtPK+yhfY4wm1pXZ4kSlt4mxzAnw1E17Dldwy887UIgYfVm+P7/rKns1x7wvOCAbXRWGP+WQWpYLpSe0g5gYAg4x9ZIFHAKn6BXuGo7Ny79Wwmgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772842366; c=relaxed/simple; bh=NEjjpr1hBgRL0hTeez0Lx5+FYBwCLcZ5ycQACtMtBjc=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=XzL/rmOWQlXp9cYRxZiokmMTfnBbWbUsAJn/6yoOlcOzqWXb1n2Ufuthhwvm3Dy8eMWDFW8zfBvCDdftJQmfzUbcC2EUZ7ZvPKvuuuTKCsIcd5poUQuHr9h627coYNQvC5hhfbIq08FAqWNq2NXms+WRURGPFMVk2AsezE3Y0PU= 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-679caf7ec07so156994515eaf.1 for ; Fri, 06 Mar 2026 16:12:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772842364; x=1773447164; 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=d69Ry23Q3IN/OZ24uQqsoZqREAPyzCJXRpjZzIDTwjoREY3lvTwh6szQVfsuLZzsLN dXWLJdUyZdM/ShtMjsCpRybrFaGbMQLeuGkCxSrpjEFnVncD7RCmQUThkHTtgDzya7cP 2Gztb9V2s53fjVTAYmddXuF/QOJ/vRVGT4BIqcCkJjI2PbjdqTBLQWzXjLw8wvy4rDKR eGytGT+Tx+1Q0/pVgc0YFjAJIkv4fMUWhmbcYknmGn4B50lrf0WkhG5/4iwDYGPSKRh8 jmFaUW0X1m8zRY6VwLAan0go2Tm7HhU6iy4+07V9EYFFXiUK3icxRjV5h9zUOXBgFvaT QkDg== X-Gm-Message-State: AOJu0YxxH3BE3zT8UoZshwBjShYXzyZd8YMATmUMn1O+yrGZ+TZ6rk4d uc4fHPYBKSeewNgDzgysxXTk6zxY+oYQ4ttBgaf0hAfIaQDfJihOdolkk1pFvK/nXmL0Ahnk/cZ pTpFt/7qs2sVxLqqO9MXpZ6uL+XR1mXa5m55q5oxsQo6U4IUS5V70ZvokVC0= 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:81d0:b0:65f:1012:69c5 with SMTP id 006d021491bc7-67b9bd8f1f7mr2439314eaf.76.1772842364438; Fri, 06 Mar 2026 16:12:44 -0800 (PST) Date: Fri, 06 Mar 2026 16:12:44 -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: <69ab6d7c.050a0220.13f275.0030.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