From: netdev-bot+sashiko@kernel.org
To: lian@is.s.u-tokyo.ac.jp
Cc: ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, linux_oss@crudebyte.com, horms@kernel.org,
viro@zeniv.linux.org.uk, tomasbortoli@gmail.com,
chirantan@chromium.org, groug@kaod.org,
aneesh.kumar@linux.vnet.ibm.com, v9fs@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
shina@is.s.u-tokyo.ac.jp, stable@vger.kernel.org
Subject: Re: [PATCH 2/5] 9p: ignore a zero-copy reply that arrives after a fatal signal
Date: Thu, 12 Nov 2026 07:53:09 +0000 [thread overview]
Message-ID: <179446998948.2199510.3182298225630042557@kernel.org> (raw)
In-Reply-To: <20261109105251.2545764-3-lian@is.s.u-tokyo.ac.jp>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] p9_client_zc_rpc() (net/9p/client.c) no longer runs `if
(READ_ONCE(req->status) == REQ_STATUS_RCVD) err = 0;` after the flush.
--
9p: ignore a zero-copy reply that arrives after a fatal signal
This patch changes p9_client_zc_rpc() so that err stays -ERESTARTSYS
after a fatal signal ends the transport wait, even if the reply arrived
before the RFLUSH. It does this to avoid parsing an unbounded or
uninitialized RERROR string from a zero-copy TREAD or TREADDIR reply that
p9_virtio_zc_request() never post-processed.
> diff --git a/net/9p/client.c b/net/9p/client.c
> index e63e8c2a853df..66980ad52bca8 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -706,10 +706,11 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
>
> if (c->trans_mod->cancel(c, req))
> p9_client_flush(c, req);
> -
> - /* if we received the response anyway, don't signal error */
> - if (READ_ONCE(req->status) == REQ_STATUS_RCVD)
> - err = 0;
> + /*
> + * err stays -ERESTARTSYS even if the reply has arrived, since
> + * the transport moves the error string of a zero-copy reply
> + * into rc only while it waits.
> + */
> }
[Severity: Medium]
This change applies to every zero-copy request type, not only TREAD and
TREADDIR. Does it also drop a completed zero-copy TWRITE?
On virtio, p9_client_write() and p9_client_write_subreq() both send
P9_TWRITE through p9_client_zc_rpc() when the write is over 1024 bytes:
net/9p/client.c:p9_client_write_subreq() {
...
if (clnt->trans_mod->zc_request && len > 1024) {
req = p9_client_zc_rpc(clnt, P9_TWRITE, NULL, &subreq->io_iter,
0, wreq->len, P9_ZC_HDR_SZ, "dqd",
fid->fid, start, len);
...
}
Here is the sequence. A fatal signal ends io_wait_event_killable() in
p9_virtio_zc_request(). The server then finishes the write and sends
RWRITE before it handles the TFLUSH. p9_client_flush() returns with
req->status == REQ_STATUS_RCVD.
Before this patch, err was reset to 0 at that point. Now the RWRITE is
dropped and the caller gets -ERESTARTSYS, even though the server state has
changed. Under 9P flush semantics, a reply that arrives before Rflush
should be honoured.
On the netfs path, v9fs_issue_write() then sees len == 0:
fs/9p/vfs_addr.c:v9fs_issue_write() {
...
netfs_write_subrequest_terminated(subreq, len ?: err);
}
So it skips the i_size/remote_i_size update and does not set
NETFS_SREQ_MADE_PROGRESS. netfs_collect_write_results() then calls
mapping_set_error(wreq->mapping, front->error) with -ERESTARTSYS.
Could a later fsync() from another opener then report a writeback error
for data the server already has? In the same way, v9fs_xattr_set() via
p9_client_write() would report failure for an xattr value that was
written.
The new comment says the transport moves the error string into rc only
while it waits. For TWRITE, inlen is 0 and no reply pages are posted. Isn't
the whole reply, including any RERROR string, already in rc.sdata then?
The commit message says:
"since p9_client_zc_rpc() already returns -ERESTARTSYS when the server
cancels such a request."
A cancelled write leaves the server unchanged, but a completed write does
not, so this reasoning doesn't seem to cover TWRITE.
For TWRITE, the only late-reply risk seems to be an rc.size that was never
clamped, because p9_check_errors() skips its size check when rc.zc is set.
On the late REQ_STATUS_RCVD path, would checking rc.size against
rc.capacity (or the posted in_hdr_len + inlen) fix the KASAN report while
keeping a valid RWRITE?
Also, the later commit "9p: take the tag of a flushed request from the
request" in this series makes a zero-copy TWRITE actually send a TFLUSH and
wait for RFLUSH. That widens the window for an RWRITE to arrive first, and
p9_client_zc_rpc() at the end of the series still leaves err as
-ERESTARTSYS in this case.
> recalc_sigpending:
> if (sigpending) {
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261109105251.2545764-1-lian%40is.s.u-tokyo.ac.jp
next prev parent reply other threads:[~2026-11-12 7:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 10:52 [PATCH 0/5] 9p: bound zero-copy error replies and keep flushed requests until the device returns them Lianjie Wang
2026-11-09 10:52 ` [PATCH 1/5] 9p/virtio: clamp the reply size of a zero-copy request Lianjie Wang
2026-11-12 7:53 ` netdev-bot+sashiko
2026-11-09 10:52 ` [PATCH 2/5] 9p: ignore a zero-copy reply that arrives after a fatal signal Lianjie Wang
2026-11-12 7:53 ` netdev-bot+sashiko [this message]
2026-11-09 10:52 ` [PATCH 3/5] 9p/virtio: keep a request until the device returns it Lianjie Wang
2026-11-12 7:53 ` netdev-bot+sashiko
2026-11-09 10:52 ` [PATCH 4/5] 9p: take the tag of a flushed request from the request Lianjie Wang
2026-11-09 10:52 ` [PATCH 5/5] 9p/virtio: keep zero-copy buffers until the device returns them Lianjie Wang
2026-11-12 7:53 ` netdev-bot+sashiko
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=179446998948.2199510.3182298225630042557@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=asmadeus@codewreck.org \
--cc=chirantan@chromium.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=ericvh@kernel.org \
--cc=groug@kaod.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=lian@is.s.u-tokyo.ac.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shina@is.s.u-tokyo.ac.jp \
--cc=stable@vger.kernel.org \
--cc=tomasbortoli@gmail.com \
--cc=v9fs@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
/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