From patchwork Mon Jul 27 15:14:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Kulkarni X-Patchwork-Id: 37563 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6RFfnx4022573 for ; Mon, 27 Jul 2009 15:41:49 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by 3yr0jf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MVSKU-0008KG-9L; Mon, 27 Jul 2009 15:41:34 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by 3yr0jf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MVSKT-0008K5-4y for v9fs-developer@lists.sourceforge.net; Mon, 27 Jul 2009 15:41:33 +0000 X-ACL-Warn: Received: from mail-pz0-f201.google.com ([209.85.222.201]) by 1b2kzd1.ch3.sourceforge.com with esmtp (Exim 4.69) id 1MVSKK-0007CW-6V for v9fs-developer@lists.sourceforge.net; Mon, 27 Jul 2009 15:41:33 +0000 Received: by pzk39 with SMTP id 39so2393586pzk.28 for ; Mon, 27 Jul 2009 08:41:17 -0700 (PDT) Received: by 10.142.170.20 with SMTP id s20mr1048624wfe.137.1248707669895; Mon, 27 Jul 2009 08:14:29 -0700 (PDT) Received: from localhost.localdomain ([69.254.150.158]) by mx.google.com with ESMTPS id k37sm23016164rvb.9.2009.07.27.08.14.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 27 Jul 2009 08:14:28 -0700 (PDT) From: Abhishek Kulkarni To: linux-kernel@vger.kernel.org Date: Mon, 27 Jul 2009 09:14:22 -0600 Message-Id: <1248707662-4060-1-git-send-email-adkulkar@umail.iu.edu> X-Mailer: git-send-email 1.6.0.4 X-Spam-Score: 0.5 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 1.4 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records -0.9 AWL AWL: From: address is in the auto white-list X-Headers-End: 1MVSKK-0007CW-6V Cc: v9fs-developer@lists.sourceforge.net Subject: [V9fs-developer] [PATCH] net/9p: Insulate the client against an invalid error code sent by a 9p server. X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net 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 --- :100644 100644 787ccdd... c9a5bf9... M net/9p/client.c :100644 100644 fdebe43... 5251851... M net/9p/error.c net/9p/client.c | 7 +------ net/9p/error.c | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 787ccdd..c9a5bf9 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -411,14 +411,9 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) if (c->dotu) err = -ecode; - if (!err) { + if (!err || !IS_ERR_VALUE(err)) err = p9_errstr2errno(ename, strlen(ename)); - /* string match failed */ - if (!err) - err = -ESERVERFAULT; - } - P9_DPRINTK(P9_DEBUG_9P, "<<< RERROR (%d) %s\n", -ecode, ename); kfree(ename); diff --git a/net/9p/error.c b/net/9p/error.c index fdebe43..5251851 100644 --- a/net/9p/error.c +++ b/net/9p/error.c @@ -239,7 +239,7 @@ int p9_errstr2errno(char *errstr, int len) errstr[len] = 0; printk(KERN_ERR "%s: server reported unknown error %s\n", __func__, errstr); - errno = 1; + errno = ESERVERFAULT; } return -errno;