[PATCH v2 11/17] modpost: Warn about calls from __pitext into other text sections

From: Ard Biesheuvel
Date: Thu Jan 25 2024 - 06:36:38 EST


From: Ard Biesheuvel <ardb@xxxxxxxxxx>

Ensure that code that is marked as being able to safely run from a 1:1
mapping does not call into other code which might lack that property.

Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
---
scripts/mod/modpost.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 962d00df47ab..33b56d6b4e7b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -825,6 +825,7 @@ enum mismatch {
ANY_INIT_TO_ANY_EXIT,
ANY_EXIT_TO_ANY_INIT,
EXTABLE_TO_NON_TEXT,
+ PI_TEXT_TO_NON_PI_TEXT,
};

/**
@@ -887,6 +888,11 @@ static const struct sectioncheck sectioncheck[] = {
.bad_tosec = { ".altinstr_replacement", NULL },
.good_tosec = {ALL_TEXT_SECTIONS , NULL},
.mismatch = EXTABLE_TO_NON_TEXT,
+},
+{
+ .fromsec = { ALL_PI_TEXT_SECTIONS, NULL },
+ .bad_tosec = { ALL_NON_PI_TEXT_SECTIONS, NULL },
+ .mismatch = PI_TEXT_TO_NON_PI_TEXT,
}
};

--
2.43.0.429.g432eaa2c6b-goog