1 |
On 3 Jan 2012 at 22:10, Andrea Zuccherelli wrote: |
2 |
|
3 |
> The switch I was referring to is |
4 |
> '-fplugin-arg-constify_plugin-no-constify' gcc option. |
5 |
> This should disable the constify_plugin but it is not checked on gcc |
6 |
> callbacks when a 'no_const' attribute is found. |
7 |
|
8 |
it doesn't exactly disable the plugin, it disables actually constifying |
9 |
ops structures, but it still lets gcc understand the special attributes |
10 |
introduced for this constification effort. |
11 |
|
12 |
> Using the kernel option will turn off the plugin system wide. |
13 |
|
14 |
that's because this is the only supported/meaningful way of using the plugin |
15 |
(that's why modversion now depends on the plugin too). |
16 |
|
17 |
> Using the gcc flag option willl turn it off only for this case. |
18 |
|
19 |
and this will never work ;). consider that you compile your kernel with |
20 |
constification enabled but some external module without it. now this external |
21 |
module will believe that it has free reign over ops structures whereas the |
22 |
kernel will happily enforce the read-only property on at least its own static |
23 |
instances and may cause the external module to oops at runtime. |
24 |
|
25 |
now if some code needs writable ops structure variables it has 3 options under |
26 |
the plugin approach: |
27 |
|
28 |
1. add __no_const to the structure declaration |
29 |
|
30 |
2. typedef a __no_const version of the constified structure type |
31 |
|
32 |
3. use pax_open_kernel/pax_close_kernel to temporarily override |
33 |
the (runtime enforced) constness of a given variable |
34 |
|
35 |
each approach has its own conditions to use, here's a quick summary: |
36 |
|
37 |
1. when all instances of the given structure type are runtime allocated |
38 |
(i.e., there're no static instances) |
39 |
|
40 |
2. when some instances of the given structure type are statically allocated |
41 |
it's best to let them be consitified by the plugin and use the typedef'd |
42 |
__no_const type for dynamically allocated ones |
43 |
|
44 |
3. when some constified statically allocated variables do need to be modified |
45 |
at runtime |
46 |
|
47 |
if you look at PaX carefully, you'll find use cases for each of the above, |
48 |
it should be your guidance for patching aufs as well. although i didn't look |
49 |
at its code, i think aufs is case #1 or #2. |