@@ -845,28 +845,12 @@ static const char *const init_data_sections[] =
845
845
/* all init sections */
846
846
static const char * const init_sections [] = { ALL_INIT_SECTIONS , NULL };
847
847
848
- /* All init and exit sections (code + data) */
849
- static const char * const init_exit_sections [] =
850
- {ALL_INIT_SECTIONS , ALL_EXIT_SECTIONS , NULL };
851
-
852
848
/* all text sections */
853
849
static const char * const text_sections [] = { ALL_TEXT_SECTIONS , NULL };
854
850
855
851
/* data section */
856
852
static const char * const data_sections [] = { DATA_SECTIONS , NULL };
857
853
858
-
859
- /* symbols in .data that may refer to init/exit sections */
860
- #define DEFAULT_SYMBOL_WHITE_LIST \
861
- "*driver", \
862
- "*_template", /* scsi uses *_template a lot */ \
863
- "*_timer" , /* arm uses ops structures named _timer a lot */ \
864
- "*_sht" , /* scsi also used *_sht to some extent */ \
865
- "*_ops" , \
866
- "*_probe" , \
867
- "*_probe_one" , \
868
- "*_console"
869
-
870
854
static const char * const head_sections [] = { ".head.text*" , NULL };
871
855
static const char * const linker_symbols [] =
872
856
{ "__init_begin" , "_sinittext" , "_einittext" , NULL };
@@ -898,9 +882,6 @@ enum mismatch {
898
882
*
899
883
* @mismatch: Type of mismatch.
900
884
*
901
- * @symbol_white_list: Do not match a relocation to a symbol in this list
902
- * even if it is targeting a section in @bad_to_sec.
903
- *
904
885
* @handler: Specific handler to call when a match is found. If NULL,
905
886
* default_mismatch_handler() will be called.
906
887
*
@@ -910,7 +891,6 @@ struct sectioncheck {
910
891
const char * bad_tosec [20 ];
911
892
const char * good_tosec [20 ];
912
893
enum mismatch mismatch ;
913
- const char * symbol_white_list [20 ];
914
894
void (* handler )(const char * modname , struct elf_info * elf ,
915
895
const struct sectioncheck * const mismatch ,
916
896
Elf_Rela * r , Elf_Sym * sym , const char * fromsec );
@@ -935,16 +915,11 @@ static const struct sectioncheck sectioncheck[] = {
935
915
.fromsec = { DATA_SECTIONS , NULL },
936
916
.bad_tosec = { ALL_XXXINIT_SECTIONS , NULL },
937
917
.mismatch = DATA_TO_ANY_INIT ,
938
- .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST , NULL },
939
918
},
940
919
{
941
920
.fromsec = { DATA_SECTIONS , NULL },
942
921
.bad_tosec = { INIT_SECTIONS , NULL },
943
922
.mismatch = DATA_TO_ANY_INIT ,
944
- .symbol_white_list = {
945
- "*_template" , "*_timer" , "*_sht" , "*_ops" ,
946
- "*_probe" , "*_probe_one" , "*_console" , NULL
947
- },
948
923
},
949
924
{
950
925
.fromsec = { TEXT_SECTIONS , NULL },
@@ -955,7 +930,6 @@ static const struct sectioncheck sectioncheck[] = {
955
930
.fromsec = { DATA_SECTIONS , NULL },
956
931
.bad_tosec = { ALL_EXIT_SECTIONS , NULL },
957
932
.mismatch = DATA_TO_ANY_EXIT ,
958
- .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST , NULL },
959
933
},
960
934
/* Do not reference init code/data from meminit code/data */
961
935
{
@@ -1051,15 +1025,6 @@ static const struct sectioncheck *section_mismatch(
1051
1025
* fromsec = .data*
1052
1026
* atsym = __param_ops_*
1053
1027
*
1054
- * Pattern 2:
1055
- * Many drivers utilise a *driver container with references to
1056
- * add, remove, probe functions etc.
1057
- * the pattern is identified by:
1058
- * tosec = init or exit section
1059
- * fromsec = data section
1060
- * atsym = *driver, *_template, *_sht, *_ops, *_probe,
1061
- * *probe_one, *_console, *_timer
1062
- *
1063
1028
* Pattern 3:
1064
1029
* Whitelist all references from .head.text to any init section
1065
1030
*
@@ -1108,10 +1073,22 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
1108
1073
strstarts (fromsym , "__param_ops_" ))
1109
1074
return 0 ;
1110
1075
1111
- /* Check for pattern 2 */
1112
- if (match (tosec , init_exit_sections ) &&
1113
- match (fromsec , data_sections ) &&
1114
- match (fromsym , mismatch -> symbol_white_list ))
1076
+ /* symbols in data sections that may refer to any init/exit sections */
1077
+ if (match (fromsec , PATTERNS (DATA_SECTIONS )) &&
1078
+ match (tosec , PATTERNS (ALL_INIT_SECTIONS , ALL_EXIT_SECTIONS )) &&
1079
+ match (fromsym , PATTERNS ("*_template" , // scsi uses *_template a lot
1080
+ "*_timer" , // arm uses ops structures named _timer a lot
1081
+ "*_sht" , // scsi also used *_sht to some extent
1082
+ "*_ops" ,
1083
+ "*_probe" ,
1084
+ "*_probe_one" ,
1085
+ "*_console" )))
1086
+ return 0 ;
1087
+
1088
+ /* symbols in data sections that may refer to meminit/exit sections */
1089
+ if (match (fromsec , PATTERNS (DATA_SECTIONS )) &&
1090
+ match (tosec , PATTERNS (ALL_XXXINIT_SECTIONS , ALL_EXIT_SECTIONS )) &&
1091
+ match (fromsym , PATTERNS ("*driver" )))
1115
1092
return 0 ;
1116
1093
1117
1094
/* Check for pattern 3 */
0 commit comments