From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B124B640 for ; Sat, 7 Mar 2026 07:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772868410; cv=none; b=TYaW4/w5mvTZZ9H/voPhLNZR+OvPJSzfKyOHbx14+Y7vpNzq0mY5AXNNPJ2rQa31rDaZfcSDmnirTXc5LukxZs6L72V9+M7Qz5Rn0IPU5OKbRWWKF4vNqho0RmIiBkLuuGWQd9KXUYqDATnYHGA+jHKISuuYQYJ06hU9qIbgMWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772868410; c=relaxed/simple; bh=CZBo56vAiijt9ljba/FRXjd848V8Psje8zj7FhMYElQ=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=lOPgAGcl6Z53nsHa/lLoK4a0jXzHlvq/b0dDZ09fJY3VoB5xwu1PtV9oBlkgyJu8LzjjWglaDsBVmVmjm05weblDC8nKC155KLNXSOvwNzKpfPFWMIf3b0CQ/lCF5f4iecwMDQnM/d+t+BQEmoflgacVUbvxn4JjiTEwew6tBTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UyPlxt6z; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UyPlxt6z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772868408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DEsPSV+2TI7csiZYbt7+qSwIqSMdwZHkJYhnl4qV0Xk=; b=UyPlxt6zvVGNNCGZTo9VCTIk8GP5yq12EtvsjiPYOR+4Rh3gMaaICgkt36Qxi5+eXA4C1n WoZ4HJi5awKzFBCHC/d5DWKJMzDrwon99OebzpLhF+wNVEBzGILoRZ3o1tkbGdvzIEOw56 eHEiGkvyV0ndOzfXFH59AidvV0+TTu8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-sDRjS14VPmiAvSRWfsjoUg-1; Sat, 07 Mar 2026 02:26:46 -0500 X-MC-Unique: sDRjS14VPmiAvSRWfsjoUg-1 X-Mimecast-MFC-AGG-ID: sDRjS14VPmiAvSRWfsjoUg_1772868404 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 80A411956089; Sat, 7 Mar 2026 07:26:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.45.224.65]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DBA313003E9F; Sat, 7 Mar 2026 07:26:41 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <69aa75e2.050a0220.13f275.000f.GAE@google.com> References: <69aa75e2.050a0220.13f275.000f.GAE@google.com> To: syzbot Cc: dhowells@redhat.com, Deepanshu Kartikey , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netfs@lists.linux.dev, pc@manguebit.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [netfs?] kernel BUG in netfs_limit_iter Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <675768.1772868400.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Sat, 07 Mar 2026 07:26:40 +0000 Message-ID: <675769.1772868400@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gi= t c107785c7e8d commit eb8299de8f603a6d7acf50e534c87ac1adeb3060 Author: Deepanshu Kartikey Date: Sat Mar 7 10:09:47 2026 +0530 netfs: Fix NULL pointer dereference in netfs_unbuffered_write() on ret= ry = When a write subrequest is marked NETFS_SREQ_NEED_RETRY, the retry pat= h in netfs_unbuffered_write() unconditionally calls stream->prepare_writ= e() 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 NUL= L 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. = Fixes: a0b4c7a49137 ("netfs: Fix unbuffered/DIO writes to dispatch sub= requests in strict sequence") Reported-by: syzbot+7227db0fbac9f348dba0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D7227db0fbac9f348dba0 Signed-off-by: Deepanshu Kartikey diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c index dd1451bf7543..4d9760e36c11 100644 --- a/fs/netfs/direct_write.c +++ b/fs/netfs/direct_write.c @@ -186,10 +186,18 @@ static int netfs_unbuffered_write(struct netfs_io_re= quest *wreq) stream->sreq_max_segs =3D INT_MAX; = netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); - stream->prepare_write(subreq); = - __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); + } } = netfs_unbuffered_write_done(wreq);