From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: linux-kernel@vger.kernel.org,
"J. Bruce Fields" <bfields@fieldses.org>,
Neil Brown <neilb@suse.de>,
linux-nfs@vger.kernel.org
Subject: [patch] nfsd: oopses in cache_parse()
Date: Mon, 16 Jan 2012 14:52:58 +0300 [thread overview]
Message-ID: <20120116115258.GC3294@mwanda> (raw)
In-Reply-To: <1321611289-21809-1-git-send-email-levinsasha928@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1867 bytes --]
We fixed expkey_parse() in b2ea70afad "nfsd: Fix oops when parsing a
0 length export" but there are other cache_parse() implimentations
which have the same issue.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Since half of the implimentations get this wrong, maybe we should
just check for this in cache_do_downcall(). Is there ever a valid
reason to pass a zero length string to cache_parse()?
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index cf8a6bd..1d147a8 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -496,7 +496,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
struct svc_export exp = {}, *expp;
int an_int;
- if (mesg[mlen-1] != '\n')
+ if (mlen < 1 || mesg[mlen - 1] != '\n')
return -EINVAL;
mesg[mlen-1] = 0;
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index a6e711a..d945d71 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -217,7 +217,7 @@ static int nfs_dns_parse(struct cache_detail *cd, char *buf, int buflen)
ssize_t len;
int ret = -EINVAL;
- if (buf[buflen-1] != '\n')
+ if (buflen < 1 || buf[buflen - 1] != '\n')
goto out;
buf[buflen-1] = '\0';
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 9409627..f8456a4 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -202,7 +202,7 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
int len;
int error = -EINVAL;
- if (buf[buflen - 1] != '\n')
+ if (buflen < 1 || buf[buflen - 1] != '\n')
return (-EINVAL);
buf[buflen - 1]= '\0';
@@ -378,7 +378,7 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
char *buf1;
int error = -EINVAL;
- if (buf[buflen - 1] != '\n')
+ if (buflen < 1 || buf[buflen - 1] != '\n')
return (-EINVAL);
buf[buflen - 1]= '\0';
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-01-16 11:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 10:14 [PATCH] nfsd: Fix oops when parsing a 0 length export Sasha Levin
2011-11-22 20:28 ` J. Bruce Fields
2011-11-22 20:33 ` Sasha Levin
2011-11-22 20:59 ` J. Bruce Fields
2012-01-16 11:52 ` Dan Carpenter [this message]
2012-01-16 15:50 ` [patch] nfsd: oopses in cache_parse() J. Bruce Fields
2012-01-18 9:55 ` Dan Carpenter
2012-01-18 9:56 ` [patch] nfsd: don't allow zero length strings " Dan Carpenter
2012-01-18 22:41 ` J. Bruce Fields
2012-01-20 7:48 ` [patch] nfsd: remove some unneeded checks Dan Carpenter
2012-01-20 18:35 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120116115258.GC3294@mwanda \
--to=dan.carpenter@oracle.com \
--cc=bfields@fieldses.org \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).