Re: [patch 9/9 v3] x86: export x86 boot_params to sysfs

From: Dave Young
Date: Thu Nov 21 2013 - 22:23:59 EST


On 11/21/13 at 08:45am, Greg KH wrote:
> > +static struct kobj_attribute boot_params_version_attr =
> > + __ATTR(version, S_IRUGO, boot_params_version_show, NULL);
>
> __ATTR_RO() please.

Will do

>
> > +static struct kobj_attribute type_attr =
> > + __ATTR(type, S_IRUGO, setup_data_type_show, NULL);
>
> __ATTR_RO() here too.

Will do

[snip]
> > +
> > + ret = get_setup_data_size(nr, &size);
> > + if (ret)
> > + goto out_kobj;
> > +
> > + data_attr.size = size;
> > + ret = sysfs_create_bin_file(kobj, &data_attr);
> > + if (ret)
> > + goto out_file;
> > + *kobjp = kobj;
>
> You just raced with userspace (creating and announcing the kobject and
> then, afterward, at some later point in time, created the sysfs files.
> Please use the groups option to create the files properly before
> announcing the kobject to userspace.

Will do

[snip]
> > + goto out_boot_params_kobj;
> > + ret = sysfs_create_bin_file(boot_params_kobj,
> > + &boot_params_data_attr);
> > + if (ret)
> > + goto out_create_file;
> > +
> > + ret = create_setup_data_nodes(boot_params_kobj);
> > + if (ret)
> > + goto out_create_bin;
> > +
> > + return 0;
>
> Same race condition here as well. Use a groups structure please.
>

Will use group attributes

Thanks for review
Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/