0071-objtool-Print-top-level-commands-on-incorrect-usage.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From ca358ca3d22248f099a09d65ee25410cf3beebc5 Mon Sep 17 00:00:00 2001
  2. From: Kamalesh Babulal <[email protected]>
  3. Date: Sat, 14 Oct 2017 20:17:54 +0530
  4. Subject: [PATCH 071/231] objtool: Print top level commands on incorrect usage
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Print top-level objtool commands, along with the error on incorrect
  10. command line usage. Objtool command line parser exit's with code 129,
  11. for incorrect usage. Convert the cmd_usage() exit code also, to maintain
  12. consistency across objtool.
  13. After the patch:
  14. $ ./objtool -j
  15. Unknown option: -j
  16. usage: objtool COMMAND [ARGS]
  17. Commands:
  18. check Perform stack metadata validation on an object file
  19. orc Generate in-place ORC unwind tables for an object file
  20. $ echo $?
  21. 129
  22. Signed-off-by: Kamalesh Babulal <[email protected]>
  23. Acked-by: Josh Poimboeuf <[email protected]>
  24. Cc: Linus Torvalds <[email protected]>
  25. Cc: Peter Zijlstra <[email protected]>
  26. Cc: Thomas Gleixner <[email protected]>
  27. Link: http://lkml.kernel.org/r/[email protected]
  28. Signed-off-by: Ingo Molnar <[email protected]>
  29. (cherry picked from commit 6a93bb7e4a7d6670677d5b0eb980936eb9cc5d2e)
  30. Signed-off-by: Andy Whitcroft <[email protected]>
  31. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  32. (cherry picked from commit cd75c9c55a5f288e1d3f20c48c5c4c2caf3966e8)
  33. Signed-off-by: Fabian Grünbichler <[email protected]>
  34. ---
  35. tools/objtool/objtool.c | 6 ++----
  36. 1 file changed, 2 insertions(+), 4 deletions(-)
  37. diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
  38. index 31e0f9143840..07f329919828 100644
  39. --- a/tools/objtool/objtool.c
  40. +++ b/tools/objtool/objtool.c
  41. @@ -70,7 +70,7 @@ static void cmd_usage(void)
  42. printf("\n");
  43. - exit(1);
  44. + exit(129);
  45. }
  46. static void handle_options(int *argc, const char ***argv)
  47. @@ -86,9 +86,7 @@ static void handle_options(int *argc, const char ***argv)
  48. break;
  49. } else {
  50. fprintf(stderr, "Unknown option: %s\n", cmd);
  51. - fprintf(stderr, "\n Usage: %s\n",
  52. - objtool_usage_string);
  53. - exit(1);
  54. + cmd_usage();
  55. }
  56. (*argv)++;
  57. --
  58. 2.14.2