From: Paulo Alcantara <pc@manguebit.org>
To: ozgun kultekin <ozgunkultekin@gmail.com>, linux-cifs@vger.kernel.org
Cc: Namjae Jeon <linkinjeon@kernel.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
David Howells <dhowells@redhat.com>,
netfs@lists.linux.dev, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] smb: client: do not let the server grow a write subrequest
Date: Thu, 19 Nov 2026 10:47:40 -0300 [thread overview]
Message-ID: <a74e3d9296fcebce8d4c803093d4c81b@manguebit.org> (raw)
In-Reply-To: <20261118002159.20576-1-ozgunkultekin@gmail.com>
ozgun kultekin <ozgunkultekin@gmail.com> writes:
> smb2_writev_callback() takes the byte count from the SMB2 WRITE
> response, masks it with 0xFFFF if it is larger than the request (for
> old OS/2 servers), and then copies it into wdata->subreq.len. A server
> can return a count that is still larger than the request after the
> mask, for example 0x8002 for a 5-byte write or 0xFFFF for a 4 KiB
> write, and the subrequest then covers data that was never sent.
>
> netfs uses the subrequest length to decide how far the write collector
> may advance. With a grown subrequest the collector moves collected_to
> past the data that was issued: netfs_writeback_unlock_folios() walks
> folio_queue slots that were never filled, and
> rolling_buffer_delete_spent() frees folio_queue segments that later
> in-flight subrequests still use. This is a use-after-free that a
> malicious or broken server triggers from an ordinary write:
>
> BUG: KASAN: slab-use-after-free in netfs_limit_iter+0xed4/0x1040
> Read of size 1 at addr ff11000010561511 by task kworker/u8:4/63
> Workqueue: events_unbound netfs_write_collection_worker
> netfs_limit_iter+0xed4/0x1040
> netfs_retry_writes+0x1410/0x1e90
> netfs_write_collection+0x2647/0x3880
> netfs_write_collection_worker+0x1cd/0x3e0
> Allocated by task 141:
> netfs_folioq_alloc+0x39a/0x470
> rolling_buffer_init+0x29/0xc0
> netfs_create_write_req+0x12f/0x840
> Freed by task 42:
> rolling_buffer_delete_spent+0xb1/0x220
> netfs_write_collection+0x1f62/0x3880
>
> Never change the subrequest length from the response. If the count is
> still larger than the request after the mask, fail the write with -EIO
> and record it with a new write_overlarge trace point, like the read
> path does with read_overlarge. A short count still returns -ENOSPC as
> before.
> ...
Applied.
prev parent reply other threads:[~2026-11-19 13:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 0:21 ozgun kultekin
2026-11-18 1:15 ` Namjae Jeon
2026-11-19 13:47 ` Paulo Alcantara [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a74e3d9296fcebce8d4c803093d4c81b@manguebit.org \
--to=pc@manguebit.org \
--cc=bharathsm@microsoft.com \
--cc=dhowells@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=ozgunkultekin@gmail.com \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®