Skip to content

Commit 0aad37e

Browse files
Abhishek Kulkarniericvh
authored andcommitted
net/9p: insulate the client against an invalid error code sent by a 9p server
A looney tunes server sending an invalid error code (which is !IS_ERR_VALUE) can result in a client oops. So fix it by adding a check and converting unknown or invalid error codes to -ESERVERFAULT. Signed-off-by: Abhishek Kulkarni <adkulkar@umail.iu.edu> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 parent 48559b4 commit 0aad37e

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

‎net/9p/client.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,9 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
411411
if (c->dotu)
412412
err = -ecode;
413413

414-
if (!err) {
414+
if (!err || !IS_ERR_VALUE(err))
415415
err = p9_errstr2errno(ename, strlen(ename));
416416

417-
/* string match failed */
418-
if (!err)
419-
err = -ESERVERFAULT;
420-
}
421-
422417
P9_DPRINTK(P9_DEBUG_9P, "<<< RERROR (%d) %s\n", -ecode, ename);
423418

424419
kfree(ename);

‎net/9p/error.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int p9_errstr2errno(char *errstr, int len)
239239
errstr[len] = 0;
240240
printk(KERN_ERR "%s: server reported unknown error %s\n",
241241
__func__, errstr);
242-
errno = 1;
242+
errno = ESERVERFAULT;
243243
}
244244

245245
return -errno;

0 commit comments

Comments
 (0)