Re: [RFC] export module parameters even the permission is zero

From: Rusty Russell
Date: Tue Jan 20 2015 - 01:40:49 EST


"Wang, Yalin" <Yalin.Wang@xxxxxxxxxxxxxx> writes:
> This patch make sure to export module parameters even the permission
> is zero, this is useful for some platforms like Android,
> the init process can change the parameter mode/owner by
> chmod/chown during bootup
>
> Signed-off-by: Yalin Wang <yalin.wang@xxxxxxxxxxxxxx>

Hi!

Unfortunately, this won't work. Various parts of the code
assume that 0 permissions means "cannot be changed or read", so this
change would introduce many bugs (eg. the parameter could be
__initdata).

Since these are owned by root at boot, changing mode and owner should
still work. However, you can't make a read-only field writable and
expect it to work.

Hope that helps,
Rusty.



> ---
> kernel/params.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/kernel/params.c b/kernel/params.c
> index bd65d136..aa80c04 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -607,9 +607,6 @@ static __modinit int add_sysfs_param(struct module_kobject *mk,
> struct attribute **new_attrs;
> unsigned int i;
>
> - /* We don't bother calling this with invisible parameters. */
> - BUG_ON(!kp->perm);
> -
> if (!mk->mp) {
> /* First allocation. */
> mk->mp = kzalloc(sizeof(*mk->mp), GFP_KERNEL);
> @@ -812,9 +809,6 @@ static void __init param_sysfs_builtin(void)
> for (kp = __start___param; kp < __stop___param; kp++) {
> char *dot;
>
> - if (kp->perm == 0)
> - continue;
> -
> dot = strchr(kp->name, '.');
> if (!dot) {
> /* This happens for core_param() */
> --
> 2.1.3
> --
> 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/
--
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/