@@ -842,6 +842,26 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
842
842
return ret ;
843
843
}
844
844
845
+ static size_t module_flags_taint (struct module * mod , char * buf )
846
+ {
847
+ size_t l = 0 ;
848
+
849
+ if (mod -> taints & (1 << TAINT_PROPRIETARY_MODULE ))
850
+ buf [l ++ ] = 'P' ;
851
+ if (mod -> taints & (1 << TAINT_OOT_MODULE ))
852
+ buf [l ++ ] = 'O' ;
853
+ if (mod -> taints & (1 << TAINT_FORCED_MODULE ))
854
+ buf [l ++ ] = 'F' ;
855
+ if (mod -> taints & (1 << TAINT_CRAP ))
856
+ buf [l ++ ] = 'C' ;
857
+ /*
858
+ * TAINT_FORCED_RMMOD: could be added.
859
+ * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
860
+ * apply to modules.
861
+ */
862
+ return l ;
863
+ }
864
+
845
865
static inline void print_unload_info (struct seq_file * m , struct module * mod )
846
866
{
847
867
struct module_use * use ;
@@ -900,10 +920,8 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
900
920
return sprintf (buffer , "%lu\n" , module_refcount (mk -> mod ));
901
921
}
902
922
903
- static struct module_attribute refcnt = {
904
- .attr = { .name = "refcnt" , .mode = 0444 },
905
- .show = show_refcnt ,
906
- };
923
+ static struct module_attribute modinfo_refcnt =
924
+ __ATTR (refcnt , 0444 , show_refcnt , NULL );
907
925
908
926
void module_put (struct module * module )
909
927
{
@@ -963,10 +981,8 @@ static ssize_t show_initstate(struct module_attribute *mattr,
963
981
return sprintf (buffer , "%s\n" , state );
964
982
}
965
983
966
- static struct module_attribute initstate = {
967
- .attr = { .name = "initstate" , .mode = 0444 },
968
- .show = show_initstate ,
969
- };
984
+ static struct module_attribute modinfo_initstate =
985
+ __ATTR (initstate , 0444 , show_initstate , NULL );
970
986
971
987
static ssize_t store_uevent (struct module_attribute * mattr ,
972
988
struct module_kobject * mk ,
@@ -979,18 +995,50 @@ static ssize_t store_uevent(struct module_attribute *mattr,
979
995
return count ;
980
996
}
981
997
982
- struct module_attribute module_uevent = {
983
- .attr = { .name = "uevent" , .mode = 0200 },
984
- .store = store_uevent ,
985
- };
998
+ struct module_attribute module_uevent =
999
+ __ATTR (uevent , 0200 , NULL , store_uevent );
1000
+
1001
+ static ssize_t show_coresize (struct module_attribute * mattr ,
1002
+ struct module_kobject * mk , char * buffer )
1003
+ {
1004
+ return sprintf (buffer , "%u\n" , mk -> mod -> core_size );
1005
+ }
1006
+
1007
+ static struct module_attribute modinfo_coresize =
1008
+ __ATTR (coresize , 0444 , show_coresize , NULL );
1009
+
1010
+ static ssize_t show_initsize (struct module_attribute * mattr ,
1011
+ struct module_kobject * mk , char * buffer )
1012
+ {
1013
+ return sprintf (buffer , "%u\n" , mk -> mod -> init_size );
1014
+ }
1015
+
1016
+ static struct module_attribute modinfo_initsize =
1017
+ __ATTR (initsize , 0444 , show_initsize , NULL );
1018
+
1019
+ static ssize_t show_taint (struct module_attribute * mattr ,
1020
+ struct module_kobject * mk , char * buffer )
1021
+ {
1022
+ size_t l ;
1023
+
1024
+ l = module_flags_taint (mk -> mod , buffer );
1025
+ buffer [l ++ ] = '\n' ;
1026
+ return l ;
1027
+ }
1028
+
1029
+ static struct module_attribute modinfo_taint =
1030
+ __ATTR (taint , 0444 , show_taint , NULL );
986
1031
987
1032
static struct module_attribute * modinfo_attrs [] = {
1033
+ & module_uevent ,
988
1034
& modinfo_version ,
989
1035
& modinfo_srcversion ,
990
- & initstate ,
991
- & module_uevent ,
1036
+ & modinfo_initstate ,
1037
+ & modinfo_coresize ,
1038
+ & modinfo_initsize ,
1039
+ & modinfo_taint ,
992
1040
#ifdef CONFIG_MODULE_UNLOAD
993
- & refcnt ,
1041
+ & modinfo_refcnt ,
994
1042
#endif
995
1043
NULL ,
996
1044
};
@@ -3236,20 +3284,7 @@ static char *module_flags(struct module *mod, char *buf)
3236
3284
mod -> state == MODULE_STATE_GOING ||
3237
3285
mod -> state == MODULE_STATE_COMING ) {
3238
3286
buf [bx ++ ] = '(' ;
3239
- if (mod -> taints & (1 << TAINT_PROPRIETARY_MODULE ))
3240
- buf [bx ++ ] = 'P' ;
3241
- else if (mod -> taints & (1 << TAINT_OOT_MODULE ))
3242
- buf [bx ++ ] = 'O' ;
3243
- if (mod -> taints & (1 << TAINT_FORCED_MODULE ))
3244
- buf [bx ++ ] = 'F' ;
3245
- if (mod -> taints & (1 << TAINT_CRAP ))
3246
- buf [bx ++ ] = 'C' ;
3247
- /*
3248
- * TAINT_FORCED_RMMOD: could be added.
3249
- * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
3250
- * apply to modules.
3251
- */
3252
-
3287
+ bx += module_flags_taint (mod , buf + bx );
3253
3288
/* Show a - for module-is-being-unloaded */
3254
3289
if (mod -> state == MODULE_STATE_GOING )
3255
3290
buf [bx ++ ] = '-' ;
0 commit comments