Skip to content

Commit

Permalink
NFSD: Full checking of authentication name
Browse files Browse the repository at this point in the history
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
kinglongmee authored and J. Bruce Fields committed Sep 3, 2014
1 parent 48c348b commit 13c82e8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions fs/nfsd/nfs4idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
memset(&ent, 0, sizeof(ent));

/* Authentication name */
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
len = qword_get(&buf, buf1, PAGE_SIZE);
if (len <= 0 || len >= IDMAP_NAMESZ)
goto out;
memcpy(ent.authname, buf1, sizeof(ent.authname));

Expand Down Expand Up @@ -245,12 +246,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
/* Name */
error = -EINVAL;
len = qword_get(&buf, buf1, PAGE_SIZE);
if (len < 0)
if (len < 0 || len >= IDMAP_NAMESZ)
goto out;
if (len == 0)
set_bit(CACHE_NEGATIVE, &ent.h.flags);
else if (len >= IDMAP_NAMESZ)
goto out;
else
memcpy(ent.name, buf1, sizeof(ent.name));
error = -ENOMEM;
Expand All @@ -259,15 +258,12 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
goto out;

cache_put(&res->h, cd);

error = 0;
out:
kfree(buf1);

return error;
}


static struct ent *
idtoname_lookup(struct cache_detail *cd, struct ent *item)
{
Expand Down Expand Up @@ -381,7 +377,8 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
memset(&ent, 0, sizeof(ent));

/* Authentication name */
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
len = qword_get(&buf, buf1, PAGE_SIZE);
if (len <= 0 || len >= IDMAP_NAMESZ)
goto out;
memcpy(ent.authname, buf1, sizeof(ent.authname));

Expand Down Expand Up @@ -421,7 +418,6 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
error = 0;
out:
kfree(buf1);

return (error);
}

Expand Down

0 comments on commit 13c82e8

Please sign in to comment.