> I don't see "no_const attribute used on type that is not constified"
> message here, and I don't know why you got it.

Ok, this is my attempt compiling aufs using
"-fplugin-arg-constify_plugin-no-constify" in EXTRA_CFLAGS.
For my system informations please refer to:
https://393559.bugs.gentoo.org/attachment.cgi?id=295143

zrouter aufs3-standalone # grep EXTRA_CFLAGS Makefile
EXTRA_CFLAGS := -I${CURDIR}/include
EXTRA_CFLAGS += ${AUFS_DEF_CONFIG} -fplugin-arg-constify_plugin-no-constify
MakeMod = ${MAKE} -C ${KDIR} M=${CURDIR}/fs/aufs EXTRA_CFLAGS="${EXTRA_CFLAGS}"
        @echo ${EXTRA_CFLAGS}
zrouter aufs3-standalone # make
-I/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/include
-DCONFIG_AUFS_FS_MODULE -UCONFIG_AUFS -DCONFIG_AUFS_BRANCH_MAX_127
-DCONFIG_AUFS_HNOTIFY -DCONFIG_AUFS_HFSNOTIFY -DCONFIG_AUFS_SBILIST
-DCONFIG_AUFS_RDU -fplugin-arg-constify_plugin-no-constify
make -C /lib/modules/3.0.4-hardened-r5-zlive-1/build
M=/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/fs/aufs
EXTRA_CFLAGS="-I/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/include
-DCONFIG_AUFS_FS_MODULE -UCONFIG_AUFS -DCONFIG_AUFS_BRANCH_MAX_127
-DCONFIG_AUFS_HNOTIFY -DCONFIG_AUFS_HFSNOTIFY -DCONFIG_AUFS_SBILIST
-DCONFIG_AUFS_RDU -fplugin-arg-constify_plugin-no-constify" modules
make[1]: Entering directory `/usr/src/linux-3.0.4-hardened-r5'
  CC [M]  
/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/fs/aufs/module.o
In file included from
/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/fs/aufs/module.c:24:0:
include/linux/seq_file.h:35:16: error: 'no_const' attribute used on
type that is not constified
make[2]: *** 
[/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/fs/aufs/module.o]
Error 1
make[1]: *** 
[_module_/var/tmp/portage/sys-fs/aufs3-3_p20111114/work/aufs3-standalone/fs/aufs]
Error 2
make[1]: Leaving directory `/usr/src/linux-3.0.4-hardened-r5'
make: *** [fs/aufs/aufs.ko] Error 2


I found the typedef causing problem in
"/usr/src/linux/include/linux/seq_file.h".
So added a "no_const" typedef to our "a.c":

zrouter constest # cat a.c
#define NULL (void *)0

struct ops3 {
  void (* foo1)(void);
  void (* foo)(void);
  void (* foo2)(void);
  void (* foo3)(void);
} __attribute((no_const));

struct ops {
  void (* foo1)(void);
  void (* foo)(void);
  void (* foo2)(void);
  void (* foo3)(void);
};

#if 1
#define __no_const __attribute__((no_const))
typedef struct ops __no_const ops_no_const;
#endif

#if 1
struct {
  const struct ops3 *ops3;
  const struct ops *ops;
} no;
#endif

struct ops3 a, aa;
struct ops b, bb;

int main()
{
  a = aa;
  b = bb;
  a.foo2 = NULL;
  b.foo = NULL;
  return 0;
}
zrouter constest # gcc
-fplugin=/usr/src/linux/tools/gcc/constify_plugin.so
-fplugin-arg-constify_plugin-no-constify a.c
a.c:19:16: error: 'no_const' attribute used on type that is not constified

Got it!
Should be disabled but is still there listening attribute events..

>
> If the grsec patch modifies the declaration of "struct fsnotify_ops" as
> "const", then the message you got
>        hfsnotify.c:208:2: error: assignment of read-only member 'br_hfsn_ops'
> might be correct, since
> - "struct au_branch" is not const.
> - the variable "br" is not const either.
> - the variable "br->br_hfsn_ops" is not declared as const either, but
>  its type "struct fsnotify_ops" is handled as const.
> This is just my guess.
>

Think so, and read somewhere so:
that plugin makes kernel structs "const" if their members are functions
and there is no "const" or "__no_const" attribute specification.

> If the constify_plugin handles
> - "struct au_branch" is const
>  or
> - the variable "br" is const
>  or
> - the variable "br->br_hfsn_ops" is declared as const
> then I am afraid there is something wrong in the constify_plugin.
> But this is not your case, right?
>
Don't understand your question here...
Given the previous fact  "br->br_hfsn_ops" is const for the compiler.

The problem could lay in struct fsnotify_ops defined in
include/linux/fsnotify_backend.h.
Infact adding a __no_const attribute is a solution.
But I don't know if this is the correct solution...
Neither I know who should apply it.

> So I'd suggest you to dive into these as next step.
> - Does the grsec patch (or someone else) modifies the declaration of
>  "struct fsnotify_ops" as "const"?

As I said this is the case.

> - Does gcc have another option not to produce "no_const attribute used
>  ..."?

Disabling the plugin changes module signature (lacks CONSTIFY_PLUGIN
beside GRSEC and kernel version information)
the compiled plugin fails to load (look my previous post)...

Don't know and can't test the effect if
"-fplugin-arg-constify_plugin-no-constify" should work as expected.
For me (has I didn't find any documentation for that plugin option)
"'no_const' attribute used..."  is a bug as I think that option should
disable the plugin.

>
>
> J. R. Okajima

A. Zuccherelli

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox

Reply via email to