)]}'
{
  "commit": "35b6b28e69985eafb20b3b2c7bd6eca452b56b53",
  "tree": "ef74d191c9197246f044d5a7ee1474683b596095",
  "parents": [
    "2f2183243f52a8ee77eecba4796316606701d101"
  ],
  "author": {
    "name": "Mark Rutland",
    "email": "mark.rutland@arm.com",
    "time": "Mon Nov 29 13:57:09 2021 +0000"
  },
  "committer": {
    "name": "Will Deacon",
    "email": "will@kernel.org",
    "time": "Thu Dec 02 10:18:32 2021 +0000"
  },
  "message": "arm64: ftrace: add missing BTIs\n\nWhen branch target identifiers are in use, code reachable via an\nindirect branch requires a BTI landing pad at the branch target site.\n\nWhen building FTRACE_WITH_REGS atop patchable-function-entry, we miss\nBTIs at the start start of the `ftrace_caller` and `ftrace_regs_caller`\ntrampolines, and when these are called from a module via a PLT (which\nwill use a `BR X16`), we will encounter a BTI failure, e.g.\n\n| # insmod lkdtm.ko\n| lkdtm: No crash points registered, enable through debugfs\n| # echo function_graph \u003e /sys/kernel/debug/tracing/current_tracer\n| # cat /sys/kernel/debug/provoke-crash/DIRECT\n| Unhandled 64-bit el1h sync exception on CPU0, ESR 0x34000001 -- BTI\n| CPU: 0 PID: 174 Comm: cat Not tainted 5.16.0-rc2-dirty #3\n| Hardware name: linux,dummy-virt (DT)\n| pstate: 60400405 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE\u003djc)\n| pc : ftrace_caller+0x0/0x3c\n| lr : lkdtm_debugfs_open+0xc/0x20 [lkdtm]\n| sp : ffff800012e43b00\n| x29: ffff800012e43b00 x28: 0000000000000000 x27: ffff800012e43c88\n| x26: 0000000000000000 x25: 0000000000000000 x24: ffff0000c171f200\n| x23: ffff0000c27b1e00 x22: ffff0000c2265240 x21: ffff0000c23c8c30\n| x20: ffff8000090ba380 x19: 0000000000000000 x18: 0000000000000000\n| x17: 0000000000000000 x16: ffff80001002bb4c x15: 0000000000000000\n| x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000900ff0\n| x11: ffff0000c4166310 x10: ffff800012e43b00 x9 : ffff8000104f2384\n| x8 : 0000000000000001 x7 : 0000000000000000 x6 : 000000000000003f\n| x5 : 0000000000000040 x4 : ffff800012e43af0 x3 : 0000000000000001\n| x2 : ffff8000090b0000 x1 : ffff0000c171f200 x0 : ffff0000c23c8c30\n| Kernel panic - not syncing: Unhandled exception\n| CPU: 0 PID: 174 Comm: cat Not tainted 5.16.0-rc2-dirty #3\n| Hardware name: linux,dummy-virt (DT)\n| Call trace:\n|  dump_backtrace+0x0/0x1a4\n|  show_stack+0x24/0x30\n|  dump_stack_lvl+0x68/0x84\n|  dump_stack+0x1c/0x38\n|  panic+0x168/0x360\n|  arm64_exit_nmi.isra.0+0x0/0x80\n|  el1h_64_sync_handler+0x68/0xd4\n|  el1h_64_sync+0x78/0x7c\n|  ftrace_caller+0x0/0x3c\n|  do_dentry_open+0x134/0x3b0\n|  vfs_open+0x38/0x44\n|  path_openat+0x89c/0xe40\n|  do_filp_open+0x8c/0x13c\n|  do_sys_openat2+0xbc/0x174\n|  __arm64_sys_openat+0x6c/0xbc\n|  invoke_syscall+0x50/0x120\n|  el0_svc_common.constprop.0+0xdc/0x100\n|  do_el0_svc+0x84/0xa0\n|  el0_svc+0x28/0x80\n|  el0t_64_sync_handler+0xa8/0x130\n|  el0t_64_sync+0x1a0/0x1a4\n| SMP: stopping secondary CPUs\n| Kernel Offset: disabled\n| CPU features: 0x0,00000f42,da660c5f\n| Memory Limit: none\n| ---[ end Kernel panic - not syncing: Unhandled exception ]---\n\nFix this by adding the required `BTI C`, as we only require these to be\nreachable via BL for direct calls or BR X16/X17 for PLTs. For now, these\nare open-coded in the function prologue, matching the style of the\n`__hwasan_tag_mismatch` trampoline.\n\nIn future we may wish to consider adding a new SYM_CODE_START_*()\nvariant which has an implicit BTI.\n\nWhen ftrace is built atop mcount, the trampolines are marked with\nSYM_FUNC_START(), and so get an implicit BTI. We may need to change\nthese over to SYM_CODE_START() in future for RELIABLE_STACKTRACE, in\ncase we need to apply special care aroud the return address being\nrewritten.\n\nFixes: 97fed779f2a6 (\"arm64: bti: Provide Kconfig for kernel mode BTI\")\nSigned-off-by: Mark Rutland \u003cmark.rutland@arm.com\u003e\nCc: Catalin Marinas \u003ccatalin.marinas@arm.com\u003e\nCc: Mark Brown \u003cbroonie@kernel.org\u003e\nCc: Will Deacon \u003cwill@kernel.org\u003e\nReviewed-by: Mark Brown \u003cbroonie@kernel.org\u003e\nLink: https://lore.kernel.org/r/20211129135709.2274019-1-mark.rutland@arm.com\nSigned-off-by: Will Deacon \u003cwill@kernel.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b3e4f9a088b1a76118205f0065fda2cc6859aa2f",
      "old_mode": 33188,
      "old_path": "arch/arm64/kernel/entry-ftrace.S",
      "new_id": "8cf970d219f5d896a7805c446e9854dadf7d0cd9",
      "new_mode": 33188,
      "new_path": "arch/arm64/kernel/entry-ftrace.S"
    }
  ]
}
