Skip to contentSkip to conversation

objtool: two seg fault fixes

PATCH New Josh Poimboeuf 2 participants 5 messages Dec 30, 2017 objtool

lore
Share & tools
lore
#0 lore raw

cover objtool: two seg fault fixes

Hi Ingo,

Here are a couple of objtool seg fault fixes from Simon Ser.

Simon Ser (2):
objtool: Fix seg fault caused by missing parameter
objtool: Fix seg fault with clang-compiled objects

 tools/objtool/builtin-orc.c | 4 +++-
 tools/objtool/orc_gen.c     | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/2 objtool: Fix seg fault caused by missing parameter

From: Simon Ser <[email protected]>

Fix a seg fault when no parameter is provided to 'objtool orc'.

---
 tools/objtool/builtin-orc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/objtool/builtin-orc.c +3 -1
index 4c6b5c9ef073..91e8e19ff5e0 100644
@@ -44,6 +44,9 @@ int cmd_orc(int argc, const char **argv)
 	const char *objname;
 
 	argc--; argv++;
+	if (argc <= 0)
+		usage_with_options(orc_usage, check_options);
+
 	if (!strncmp(argv[0], "gen", 3)) {
 		argc = parse_options(argc, argv, check_options, orc_usage, 0);
 		if (argc != 1)
@@ -52,7 +55,6 @@ int cmd_orc(int argc, const char **argv)
 		objname = argv[0];
 
 		return check(objname, no_fp, no_unreachable, true);
-
 	}
 
 	if (!strcmp(argv[0], "dump")) {
Signature · 1 line
2.13.6
#2 lore raw

[tip:core/urgent] objtool: Fix seg fault caused by missing parameter

objtool: Fix seg fault caused by missing parameter
Commit-ID:  d89e426499cf36b96161bd32970d6783f1fbcb0e
Gitweb:     https://git.kernel.org/tip/d89e426499cf36b96161bd32970d6783f1fbcb0e
Author:     Simon Ser <[email protected]>
AuthorDate: Sat, 30 Dec 2017 14:43:31 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 30 Dec 2017 22:04:17 +0100

objtool: Fix seg fault caused by missing parameter

Fix a seg fault when no parameter is provided to 'objtool orc'.

---
 tools/objtool/builtin-orc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/objtool/builtin-orc.c +3 -1
index 4c6b5c9..91e8e19 100644
@@ -44,6 +44,9 @@ int cmd_orc(int argc, const char **argv)
 	const char *objname;
 
 	argc--; argv++;
+	if (argc <= 0)
+		usage_with_options(orc_usage, check_options);
+
 	if (!strncmp(argv[0], "gen", 3)) {
 		argc = parse_options(argc, argv, check_options, orc_usage, 0);
 		if (argc != 1)
@@ -52,7 +55,6 @@ int cmd_orc(int argc, const char **argv)
 		objname = argv[0];
 
 		return check(objname, no_fp, no_unreachable, true);
-
 	}
 
 	if (!strcmp(argv[0], "dump")) {
#3 lore raw

PATCH 2/2 objtool: Fix seg fault with clang-compiled objects

In reply to Josh Poimboeuf

From: Simon Ser <[email protected]>

Fix a seg fault which happens when an input file provided to 'objtool orc generate' doesn't have a '.shstrtab' section (for instance, object files produced by clang don't have this section).

---
 tools/objtool/orc_gen.c | 2 ++
 1 file changed, 2 insertions(+)
tools/objtool/orc_gen.c +2 -0
index e5ca31429c9b..e61fe703197b 100644
@@ -165,6 +165,8 @@ int create_orc_sections(struct objtool_file *file)
 
 	/* create .orc_unwind_ip and .rela.orc_unwind_ip sections */
 	sec = elf_create_section(file->elf, ".orc_unwind_ip", sizeof(int), idx);
+	if (!sec)
+		return -1;
 
 	ip_relasec = elf_create_rela_section(file->elf, sec);
 	if (!ip_relasec)
Signature · 1 line
2.13.6
#4 lore raw

[tip:core/urgent] objtool: Fix seg fault with clang-compiled objects

objtool: Fix seg fault with clang-compiled objects
Commit-ID:  ce90aaf5cde4ce057b297bb6c955caf16ef00ee6
Gitweb:     https://git.kernel.org/tip/ce90aaf5cde4ce057b297bb6c955caf16ef00ee6
Author:     Simon Ser <[email protected]>
AuthorDate: Sat, 30 Dec 2017 14:43:32 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 30 Dec 2017 22:04:17 +0100

objtool: Fix seg fault with clang-compiled objects

Fix a seg fault which happens when an input file provided to 'objtool orc generate' doesn't have a '.shstrtab' section (for instance, object files produced by clang don't have this section).

---
 tools/objtool/orc_gen.c | 2 ++
 1 file changed, 2 insertions(+)
tools/objtool/orc_gen.c +2 -0
index e5ca314..e61fe70 100644
@@ -165,6 +165,8 @@ int create_orc_sections(struct objtool_file *file)
 
 	/* create .orc_unwind_ip and .rela.orc_unwind_ip sections */
 	sec = elf_create_section(file->elf, ".orc_unwind_ip", sizeof(int), idx);
+	if (!sec)
+		return -1;
 
 	ip_relasec = elf_create_rela_section(file->elf, sec);
 	if (!ip_relasec)