Will Shiu 74f6f59126 locks: fix KASAN: use-after-free in trace_event_raw_event_filelock_lock
As following backtrace, the struct file_lock request , in posix_lock_inode
is free before ftrace function using.
Replace the ftrace function ahead free flow could fix the use-after-free
issue.

[name:report&]===============================================
BUG:KASAN: use-after-free in trace_event_raw_event_filelock_lock+0x80/0x12c
[name:report&]Read at addr f6ffff8025622620 by task NativeThread/16753
[name:report_hw_tags&]Pointer tag: [f6], memory tag: [fe]
[name:report&]
BT:
Hardware name: MT6897 (DT)
Call trace:
 dump_backtrace+0xf8/0x148
 show_stack+0x18/0x24
 dump_stack_lvl+0x60/0x7c
 print_report+0x2c8/0xa08
 kasan_report+0xb0/0x120
 __do_kernel_fault+0xc8/0x248
 do_bad_area+0x30/0xdc
 do_tag_check_fault+0x1c/0x30
 do_mem_abort+0x58/0xbc
 el1_abort+0x3c/0x5c
 el1h_64_sync_handler+0x54/0x90
 el1h_64_sync+0x68/0x6c
 trace_event_raw_event_filelock_lock+0x80/0x12c
 posix_lock_inode+0xd0c/0xd60
 do_lock_file_wait+0xb8/0x190
 fcntl_setlk+0x2d8/0x440
...
[name:report&]
[name:report&]Allocated by task 16752:
...
 slab_post_alloc_hook+0x74/0x340
 kmem_cache_alloc+0x1b0/0x2f0
 posix_lock_inode+0xb0/0xd60
...
 [name:report&]
 [name:report&]Freed by task 16752:
...
  kmem_cache_free+0x274/0x5b0
  locks_dispose_list+0x3c/0x148
  posix_lock_inode+0xc40/0xd60
  do_lock_file_wait+0xb8/0x190
  fcntl_setlk+0x2d8/0x440
  do_fcntl+0x150/0xc18
...

Signed-off-by: Will Shiu <Will.Shiu@mediatek.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
2023-08-24 10:42:19 -04:00
..
2023-05-24 08:42:16 -06:00
2023-06-26 11:52:12 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 10:14:36 -07:00
2023-06-26 11:52:12 -07:00
2023-05-24 08:42:16 -06:00
2023-02-27 10:04:49 -08:00
2023-04-26 16:07:23 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 11:52:12 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 11:52:12 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 11:52:12 -07:00
2023-03-14 12:56:30 -06:00
2023-06-26 11:52:12 -07:00
2023-06-26 11:52:12 -07:00
2023-06-26 11:52:12 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 12:47:20 -07:00
2023-03-30 08:51:48 +02:00
2023-04-08 13:45:37 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 09:50:21 -07:00
2023-05-17 09:16:59 +02:00
2023-04-05 18:06:23 -07:00
2023-06-26 09:50:21 -07:00
2023-04-28 15:57:53 -07:00
2023-02-20 11:53:11 -08:00
2023-05-06 08:28:58 -07:00
2023-06-26 12:47:20 -07:00
2023-06-26 10:14:36 -07:00
2023-06-26 12:47:20 -07:00
2023-01-19 09:24:30 +01:00
2023-06-26 10:14:36 -07:00
2023-06-26 10:27:04 -07:00
2023-06-26 10:14:36 -07:00
2023-05-19 04:30:22 +02:00
2023-05-19 04:30:22 +02:00
2023-03-06 09:59:20 +01:00
2023-02-20 11:53:11 -08:00
2023-06-26 12:47:20 -07:00
2023-02-20 11:53:11 -08:00