|
@@ -908,6 +908,9 @@ static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
|
|
|
static const char *const init_exit_sections[] =
|
|
|
{ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
|
|
|
|
|
|
+/* all text sections */
|
|
|
+static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL };
|
|
|
+
|
|
|
/* data section */
|
|
|
static const char *const data_sections[] = { DATA_SECTIONS, NULL };
|
|
|
|
|
@@ -926,6 +929,7 @@ static const char *const data_sections[] = { DATA_SECTIONS, NULL };
|
|
|
static const char *const head_sections[] = { ".head.text*", NULL };
|
|
|
static const char *const linker_symbols[] =
|
|
|
{ "__init_begin", "_sinittext", "_einittext", NULL };
|
|
|
+static const char *const optim_symbols[] = { "*.constprop.*", NULL };
|
|
|
|
|
|
enum mismatch {
|
|
|
TEXT_TO_ANY_INIT,
|
|
@@ -1136,6 +1140,17 @@ static const struct sectioncheck *section_mismatch(
|
|
|
* This pattern is identified by
|
|
|
* refsymname = __init_begin, _sinittext, _einittext
|
|
|
*
|
|
|
+ * Pattern 5:
|
|
|
+ * GCC may optimize static inlines when fed constant arg(s) resulting
|
|
|
+ * in functions like cpumask_empty() -- generating an associated symbol
|
|
|
+ * cpumask_empty.constprop.3 that appears in the audit. If the const that
|
|
|
+ * is passed in comes from __init, like say nmi_ipi_mask, we get a
|
|
|
+ * meaningless section warning. May need to add isra symbols too...
|
|
|
+ * This pattern is identified by
|
|
|
+ * tosec = init section
|
|
|
+ * fromsec = text section
|
|
|
+ * refsymname = *.constprop.*
|
|
|
+ *
|
|
|
**/
|
|
|
static int secref_whitelist(const struct sectioncheck *mismatch,
|
|
|
const char *fromsec, const char *fromsym,
|
|
@@ -1168,6 +1183,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
|
|
|
if (match(tosym, linker_symbols))
|
|
|
return 0;
|
|
|
|
|
|
+ /* Check for pattern 5 */
|
|
|
+ if (match(fromsec, text_sections) &&
|
|
|
+ match(tosec, init_sections) &&
|
|
|
+ match(fromsym, optim_symbols))
|
|
|
+ return 0;
|
|
|
+
|
|
|
return 1;
|
|
|
}
|
|
|
|