All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Wieczorkiewicz <wipawel@amazon.de>
To: <xen-devel@lists.xenproject.org>
Cc: wipawel@amazon.com, Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	mpohlack@amazon.com, Tim Deegan <tim@xen.org>,
	Pawel Wieczorkiewicz <wipawel@amazon.de>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [Xen-devel] [PATCH] create-diff-object: more precisely identify .rodata sections
Date: Wed, 18 Sep 2019 07:35:38 +0000	[thread overview]
Message-ID: <20190918073538.24707-1-wipawel@amazon.de> (raw)

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>
---
 common.c             |  7 +++++++
 common.h             |  1 +
 create-diff-object.c | 13 ++++++-------
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/common.c b/common.c
index 0ddc9fa..8f553ea 100644
--- 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;
diff --git a/common.h b/common.h
index 7c6fb73..b6489db 100644
--- a/common.h
+++ b/common.h
@@ -159,6 +159,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);
diff --git a/create-diff-object.c b/create-diff-object.c
index e4592a6..2f0e162 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1672,13 +1672,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
-- 
2.16.5




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-09-18  7:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18  7:35 Pawel Wieczorkiewicz [this message]
2019-09-18  9:49 ` [Xen-devel] [PATCH] create-diff-object: more precisely identify .rodata sections Jan Beulich
2019-09-18  9:52   ` Wieczorkiewicz, Pawel
2019-09-18 10:28     ` Julien Grall
2019-09-18 10:41       ` Ian Jackson
2019-09-18 10:44         ` Wieczorkiewicz, Pawel
2019-09-18 11:19           ` Julien Grall
2019-09-18 11:27             ` Wieczorkiewicz, Pawel
2019-09-18 11:35               ` Julien Grall
2019-09-18 15:23               ` Lars Kurth
2019-09-19  6:48                 ` Wieczorkiewicz, Pawel
2019-09-18 11:50           ` Lars Kurth
2019-09-19  9:22             ` Julien Grall
2019-09-18 11:14         ` Julien Grall
2019-09-18 12:14           ` Lars Kurth
2019-09-19  9:30             ` Julien Grall
2019-11-05 15:37 [Xen-devel] [PATCH] create-diff-object: do not strip STN_UNDEF symbols from *.fixup Pawel Wieczorkiewicz
2019-11-05 15:37 ` [Xen-devel] [PATCH] create-diff-object: more precisely identify .rodata sections Pawel Wieczorkiewicz
2019-11-25 17:14   ` Ross Lagerwall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190918073538.24707-1-wipawel@amazon.de \
    --to=wipawel@amazon.de \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=mpohlack@amazon.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wipawel@amazon.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.