]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
create-diff-object: more precisely identify .rodata sections
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Tue, 5 Nov 2019 15:37:45 +0000 (15:37 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Tue, 26 Nov 2019 10:53:44 +0000 (10:53 +0000)
This is needed for more precise patchability verification.
Only non-special .rodata sections should be subject
for such a non-referenced check in kpatch_verify_patchability().
Current check (non-standard, non-rela, non-debug) is too weak and
allows also non-rodata sections without referenced symbols to slip
through.

Detect .rodata section by checking section's type (SHT_PROGBITS),
flags (no exec, no write) and finally name prefix.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
common.c
common.h
create-diff-object.c

index 0ddc9fafc173f988475dd6c2247702a01512bd60..8f553eaf893528e288ac4df7f3296b5abaf7bed3 100644 (file)
--- a/common.c
+++ b/common.c
@@ -249,6 +249,13 @@ int is_text_section(struct section *sec)
                (sec->sh.sh_flags & SHF_EXECINSTR));
 }
 
+int is_rodata_section(struct section *sec)
+{
+       return sec->sh.sh_type == SHT_PROGBITS &&
+              !(sec->sh.sh_flags & (SHF_EXECINSTR | SHF_WRITE)) &&
+              !strncmp(sec->name, ".rodata", 7);
+}
+
 int is_debug_section(struct section *sec)
 {
        char *name;
index 06e19e76f78a5e23b438cef93bc0ce2116fa5791..300e508343b8719e9e8c92df7a36c7e4ff5d9143 100644 (file)
--- a/common.h
+++ b/common.h
@@ -148,6 +148,7 @@ struct symbol *find_symbol_by_index(struct list_head *list, size_t index);
 struct symbol *find_symbol_by_name(struct list_head *list, const char *name);
 
 int is_text_section(struct section *sec);
+int is_rodata_section(struct section *sec);
 int is_debug_section(struct section *sec);
 int is_rela_section(struct section *sec);
 int is_standard_section(struct section *sec);
index 95e1cf40bffb7f94c1dc55d7419d8050691a6d34..8d63940cdb4e380709f37ac78c4e0ffd693cb943 100644 (file)
@@ -1621,13 +1621,12 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf)
                }
 
                if (sec->include) {
-                       if (!is_standard_section(sec) && !is_rela_section(sec) &&
-                           !is_debug_section(sec) && !is_special_section(sec)) {
-                               if (!is_referenced_section(sec, kelf)) {
-                                       log_normal("section %s included, but not referenced\n",
-                                                  sec->name);
-                                       errs++;
-                               }
+                       if (is_rodata_section(sec) &&
+                           !is_special_section(sec) &&
+                           !is_referenced_section(sec, kelf)) {
+                               log_normal(".rodata section %s included, but not referenced\n",
+                                          sec->name);
+                               errs++;
                        }
 
                        /* Check if a RELA section does not contain any entries with