linux - Giving S_IWUGO permission to module parameter results in compilation error (while S_IRUGO or S_IXUGO doesn't) - why? -
i wrote simple kernel module learn module_param feature of kernel module. however, if give s_iwugo, s_irwxugo
or s_iallugo
permissions perm
field, follwing compilation error:
[root@localhost param]# make -c $kdir m=$pwd modules make: entering directory `/usr/src/kernels/3.11.10-301.fc20.i686+pae' cc [m] /root/ldd/misc/param/param/hello.o /root/ldd/misc/param/param/hello.c:6:168: error: negative width in bit-field ‘<anonymous>’ module_param(a, int, s_iwugo); ^ make[1]: *** [/root/ldd/misc/param/param/hello.o] error 1 make: *** [_module_/root/ldd/misc/param/param] error 2 make: leaving directory `/usr/src/kernels/3.11.10-301.fc20.i686+pae'
compilation successful s_irugo or s_ixugo
(permission not containing write permssion). suppose must doing wrong because know, wrtie permission legal. doing wrong here?
the program:
#include<linux/module.h> #include<linux/stat.h> int = 2; module_param(a, int, s_ixugo); int f1(void){ return 0; } void f2(void){ } module_init(f1); module_exit(f2); module_author("lavya"); module_license("gpl v2"); module_description("experiment parameters");
linux not accept s_iwoth permission. if follow macro chain behind module_param, arrive __module_param_call includes:
build_bug_on_zero((perm) < 0 || (perm) > 0777 || ((perm) & 2))
s_iwoth == 2
test fails.
the negative width in bit-field
error merely artefact of implementation of build_bug_on_zero
linux refuses make module parameters world-writable security reasons. should able use narrower permissions such s_iwusr | s_iwgrp
.
Comments
Post a Comment