浏览代码

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.
Al Viro 10 年之前
父节点
当前提交
0f1db7dee2
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      net/9p/client.c

+ 8 - 0
net/9p/client.c

@@ -1583,6 +1583,10 @@ p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
 			p9_free_req(clnt, req);
 			p9_free_req(clnt, req);
 			break;
 			break;
 		}
 		}
+		if (rsize < count) {
+			pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
+			count = rsize;
+		}
 
 
 		p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
 		p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
 		if (!count) {
 		if (!count) {
@@ -1650,6 +1654,10 @@ p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
 			p9_free_req(clnt, req);
 			p9_free_req(clnt, req);
 			break;
 			break;
 		}
 		}
+		if (rsize < count) {
+			pr_err("bogus RWRITE count (%d > %d)\n", count, rsize);
+			count = rsize;
+		}
 
 
 		p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);
 		p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);