Skip to content

Commit 0f1db7d

Browse files
author
Al Viro
committed
9p: cope with bogus responses from server in p9_client_{read,write}
if server claims to have written/read more than we'd told it to, warn and cap the claimed byte count to avoid advancing more than we are ready to.
1 parent 67e808f commit 0f1db7d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net/9p/client.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,10 @@ p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
15831583
p9_free_req(clnt, req);
15841584
break;
15851585
}
1586+
if (rsize < count) {
1587+
pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
1588+
count = rsize;
1589+
}
15861590

15871591
p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
15881592
if (!count) {
@@ -1650,6 +1654,10 @@ p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
16501654
p9_free_req(clnt, req);
16511655
break;
16521656
}
1657+
if (rsize < count) {
1658+
pr_err("bogus RWRITE count (%d > %d)\n", count, rsize);
1659+
count = rsize;
1660+
}
16531661

16541662
p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);
16551663

0 commit comments

Comments
 (0)