[PATCH 11/13] nfsd4: fslocations data structures
Neil Brown
neilb at suse.de
Mon Sep 4 03:49:16 EDT 2006
On Friday September 1, bfields at fieldses.org wrote:
> From: Manoj Naik <manoj at almaden.ibm.com>
>
> Define FS locations structures, some functions to manipulate them, and add
> code to parse FS locations in downcall and add to the exports structure.
>
> Signed-off-by: Manoj Naik <manoj at almaden.ibm.com>
> Signed-off-by: Fred Isaman <iisaman at citi.umich.edu>
> Signed-off-by: J. Bruce Fields <bfields at citi.umich.edu>
> ---
> +
> + err = -ENOMEM;
> + fsloc->locations = kzalloc(fsloc->locations_count
> + * sizeof(struct nfsd4_fs_location), GFP_KERNEL);
> + if (!fsloc->locations)
> + goto out_free_all;
Nope. This will de-reference that NULL that kzalloc returned.
You just want a 'return -ENOMEM' there.
Fixed
> + /* migrated */
> + err = get_int(mesg, &migrated);
> + if (err)
> + goto out_free_all;
> + fsloc->migrated = migrated;
Should 'migrated' be range checked at all?
I would prefer to reject any unexpected value.
PleaseFix.
> -static void exp_flags(struct seq_file *m, int flag, int fsid, uid_t anonu, uid_t anong)
> +static void exp_flags(struct seq_file *m, int flag, int fsid,
> + uid_t anonu, uid_t anong, struct nfsd4_fs_locations *fsloc)
> {
> int first = 0;
> struct flags *flg;
> @@ -1171,6 +1264,16 @@ static void exp_flags(struct seq_file *m
> seq_printf(m, "%sanonuid=%d", first++?",":"", anonu);
> if (anong != (gid_t)-2 && anong != (0x10000-2))
> seq_printf(m, "%sanongid=%d", first++?",":"", anong);
> + if (fsloc && fsloc->locations_count > 0) {
> + char *loctype = (fsloc->migrated) ? "refer" : "replicas";
> + int i;
> +
> + seq_printf(m, "%s%s=", first++?",":"", loctype);
> + seq_printf(m, "%s@%s", fsloc->locations[0].path, fsloc->locations[0].hosts);
> + for (i = 1; i < fsloc->locations_count; i++) {
> + seq_printf(m, ",%s@%s", fsloc->locations[i].path, fsloc->locations[i].hosts);
> + }
> + }
You need to seq_escape the 'path' and 'hosts' fields.
And you have a comma separated list of path at host inside a comma
separated list of flags. That's not good.
PleaseFix.
NeilBrown
More information about the NFSv4
mailing list