Skip to content

Commit a31b3cf

Browse files
cschoenebeckmartinetd
authored andcommitted
net/9p: fix response size check in p9_check_errors()
Since commit 60ece08 ("net/9p: allocate appropriate reduced message buffers") it is no longer appropriate to check server's response size against msize. Check against the previously allocated buffer capacity instead. - Omit this size check entirely for zero-copy messages, as those always allocate 4k (P9_ZC_HDR_SZ) linear buffers which are not used for actual payload and can be much bigger than 4k. - Replace p9_debug() by pr_err() to make sure this message is always printed in case this error is triggered. - Add 9p message type to error message to ease investigation. Link: https://lkml.kernel.org/r/e0edec84b1c80119ae937ce854b4f5f6dbe2d08c.1669144861.git.linux_oss@crudebyte.com Signed-off-by: Christian Schoenebeck <[email protected]> Tested-by: Stefano Stabellini <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent 8e4c2ee commit a31b3cf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

net/9p/client.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,9 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
519519
int ecode;
520520

521521
err = p9_parse_header(&req->rc, NULL, &type, NULL, 0);
522-
if (req->rc.size >= c->msize) {
523-
p9_debug(P9_DEBUG_ERROR,
524-
"requested packet size too big: %d\n",
525-
req->rc.size);
522+
if (req->rc.size > req->rc.capacity && !req->rc.zc) {
523+
pr_err("requested packet size too big: %d does not fit %zu (type=%d)\n",
524+
req->rc.size, req->rc.capacity, req->rc.id);
526525
return -EIO;
527526
}
528527
/* dump the response from server

0 commit comments

Comments
 (0)