Steven Rostedt (Google)
1a6edfc7be
eventfs: Hold eventfs_mutex when calling callback functions
...
commit 44365329f8219fc379097c2c9a75ff53f123764f upstream.
The callback function that is used to create inodes and dentries is not
protected by anything and the data that is passed to it could become
stale. After eventfs_remove_dir() is called by the tracing system, it is
free to remove the events that are associated to that directory.
Unfortunately, that means the callbacks must not be called after that.
CPU0 CPU1
---- ----
eventfs_root_lookup() {
eventfs_remove_dir() {
mutex_lock(&event_mutex);
ei->is_freed = set;
mutex_unlock(&event_mutex);
}
kfree(event_call);
for (...) {
entry = &ei->entries[i];
r = entry->callback() {
call = data; // call == event_call above
if (call->flags ...)
[ USE AFTER FREE BUG ]
The safest way to protect this is to wrap the callback with:
mutex_lock(&eventfs_mutex);
if (!ei->is_freed)
r = entry->callback();
else
r = -1;
mutex_unlock(&eventfs_mutex);
This will make sure that the callback will not be called after it is
freed. But now it needs to be known that the callback is called while
holding internal eventfs locks, and that it must not call back into the
eventfs / tracefs system. There's no reason it should anyway, but document
that as well.
Link: https://lore.kernel.org/all/CA+G9fYu9GOEbD=rR5eMR-=HJ8H6rMsbzDC2ZY5=Y50WpWAE7_Q@mail.gmail.com/
Link: https://lkml.kernel.org/r/20231101172649.906696613@goodmis.org
Cc: Ajay Kaher <akaher@vmware.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_inode")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 09:25:21 +01:00
..
2023-09-20 09:39:03 +02:00
2023-08-16 09:14:14 -07:00
2023-07-28 09:45:25 +02:00
2024-02-16 19:10:53 +01:00
2023-08-22 14:13:11 -07:00
2023-08-07 20:55:27 +02:00
2023-06-26 12:47:20 -07:00
2023-07-04 19:42:27 +01:00
2023-09-01 09:53:54 -07:00
2024-01-25 15:35:39 -08:00
2023-08-22 16:32:35 +02:00
2024-02-23 09:25:06 +01:00
2023-06-26 17:07:53 -07:00
2023-08-29 17:45:22 -04:00
2023-11-20 11:59:23 +01:00
2023-08-23 08:25:28 +01:00
2024-01-31 16:19:02 -08:00
2023-11-28 17:20:01 +00:00
2024-01-31 16:18:50 -08:00
2024-02-23 09:25:18 +01:00
2023-08-25 07:42:58 +01:00
2023-08-16 10:54:46 -06:00
2023-09-01 08:09:48 -07:00
2023-09-07 16:07:35 -07:00
2023-07-19 23:15:21 +02:00
2023-08-23 08:21:37 +01:00
2023-09-06 22:53:55 +08:00
2023-08-18 13:58:05 +01:00
2023-12-03 07:33:06 +01:00
2023-08-30 19:53:39 -07:00
2024-01-31 16:18:47 -08:00
2023-11-28 17:19:55 +00:00
2023-11-28 17:19:49 +00:00
2023-06-22 08:59:56 +02:00
2023-12-20 17:01:42 +01:00
2023-08-15 12:50:53 +01:00
2023-10-04 16:31:27 +01:00
2023-09-11 15:24:16 -07:00
2023-08-07 14:55:33 +02:00
2023-12-08 08:52:24 +01:00
2023-08-18 10:18:56 -07:00
2023-07-01 07:04:29 -04:00
2023-08-04 17:35:33 +01:00
2023-09-12 13:07:37 +01:00
2024-01-31 16:18:49 -08:00
2023-08-31 01:29:28 +02:00
2024-02-23 09:25:16 +01:00
2023-08-21 13:38:01 -07:00
2024-01-25 15:35:46 -08:00
2023-06-22 13:57:41 -07:00
2024-01-20 11:51:38 +01:00
2023-07-05 16:36:12 -06:00
2023-08-30 17:35:54 +08:00
2024-01-05 15:19:42 +01:00
2023-07-08 09:29:31 -07:00
2024-01-25 15:35:28 -08:00
2023-07-31 14:44:02 -07:00
2024-01-31 16:18:59 -08:00
2024-01-31 16:19:04 -08:00
2024-01-25 15:35:22 -08:00
2023-07-17 07:39:04 +01:00
2023-09-15 12:08:27 -07:00
2023-09-02 11:10:50 -07:00
2023-09-17 10:33:53 -07:00
2023-06-19 16:19:20 -07:00
2023-08-24 16:20:25 -07:00
2023-08-02 16:27:07 +02:00
2023-10-12 07:22:56 -10:00
2023-06-28 10:28:11 -07:00
2023-06-26 11:14:18 +02:00
2024-01-25 15:35:38 -08:00
2023-08-04 18:18:19 -07:00
2023-06-19 16:19:28 -07:00
2023-06-22 17:10:09 +02:00
2023-08-17 16:46:35 -07:00
2024-02-23 09:24:47 +01:00
2023-06-26 11:14:18 +02:00
2024-02-23 09:24:47 +01:00
2023-07-17 16:08:08 -07:00
2023-07-23 11:34:22 +01:00
2023-07-20 13:06:22 +02:00
2023-07-26 16:46:25 +01:00
2023-08-16 09:41:29 -04:00
2023-07-28 09:53:37 +02:00
2023-10-11 14:27:37 +02:00
2023-08-29 20:51:40 +02:00
2023-12-13 18:44:56 +01:00
2023-07-17 15:47:21 -07:00
2023-08-24 16:25:13 -07:00
2023-12-20 17:01:51 +01:00
2023-06-23 16:15:36 +08:00
2024-01-01 12:42:23 +00:00
2024-01-10 17:16:53 +01:00
2023-08-05 08:31:41 +02:00
2024-01-20 11:51:44 +01:00
2023-07-20 17:25:04 -05:00
2023-08-25 16:07:30 -07:00
2023-12-08 08:52:19 +01:00
2023-07-31 17:54:28 +02:00
2023-08-01 18:02:20 +02:00
2024-02-16 19:10:42 +01:00
2023-08-09 17:46:19 +02:00
2023-07-10 14:36:12 +02:00
2023-08-04 15:28:41 +02:00
2023-08-30 13:34:34 -07:00
2023-08-23 14:17:42 -07:00
2023-11-28 17:20:11 +00:00
2023-07-10 13:59:38 -04:00
2024-01-05 15:19:41 +01:00
2023-07-25 00:59:32 +09:00
2023-07-24 04:39:16 +09:00
2023-11-28 17:19:45 +00:00
2023-09-01 00:29:34 +02:00
2023-06-26 11:14:18 +02:00
2023-07-10 14:36:11 +02:00
2024-01-31 16:19:04 -08:00
2023-07-04 11:02:34 -07:00
2023-10-12 18:53:36 +03:00
2023-07-24 10:30:07 +02:00
2024-01-05 15:19:40 +01:00
2023-08-01 23:46:17 +02:00
2023-06-19 18:18:04 +02:00
2023-08-22 05:20:34 -04:00
2023-07-07 16:53:48 -07:00
2023-11-28 17:19:35 +00:00
2023-08-18 10:18:57 -07:00
2023-08-18 10:18:57 -07:00
2023-06-19 09:02:51 +02:00
2023-08-14 11:23:35 +02:00
2023-12-03 07:33:04 +01:00
2023-12-13 18:45:21 +01:00
2024-01-25 15:35:17 -08:00
2024-02-16 19:10:55 +01:00
2023-08-21 14:28:43 -07:00
2023-12-13 18:45:24 +01:00
2023-08-16 23:54:50 +10:00
2023-11-20 11:59:18 +01:00
2023-09-04 11:26:29 -07:00
2023-07-14 13:11:44 +02:00
2023-09-13 10:48:48 +02:00
2023-07-14 08:27:33 +01:00
2023-11-20 11:59:35 +01:00
2024-01-20 11:51:37 +01:00
2023-08-25 08:08:27 +01:00
2023-09-19 16:28:37 +02:00
2023-08-04 11:02:46 +01:00
2024-02-23 09:25:03 +01:00
2023-09-12 17:50:53 +02:00
2023-07-09 22:47:50 +01:00
2023-08-01 13:45:08 +02:00
2023-07-14 15:24:45 +02:00
2023-08-22 01:11:32 +03:00
2023-09-27 16:54:03 +02:00
2023-12-08 08:52:20 +01:00
2023-08-09 10:46:15 -06:00
2023-08-29 20:21:42 -07:00
2023-12-08 08:52:19 +01:00
2023-07-28 13:31:24 -03:00
2023-08-18 10:12:35 -07:00
2023-09-01 08:11:51 +01:00
2024-02-05 20:14:17 +00:00
2023-11-28 17:19:56 +00:00
2023-06-26 11:14:18 +02:00
2023-06-26 07:47:11 +02:00
2023-07-08 10:07:14 +01:00
2024-01-20 11:51:42 +01:00
2023-07-14 13:47:07 -06:00
2023-10-18 12:12:41 -07:00
2023-07-03 09:27:12 +01:00
2023-08-21 13:46:24 -07:00
2023-08-05 08:31:42 +02:00
2023-08-24 16:25:14 -07:00
2024-01-01 12:42:33 +00:00
2023-08-18 10:12:39 -07:00
2023-06-29 15:06:32 +01:00
2023-08-05 08:31:41 +02:00
2023-12-13 18:45:31 +01:00
2023-08-18 10:12:10 -07:00
2023-08-18 10:18:59 -07:00
2023-08-31 13:48:50 -04:00
2023-08-17 09:00:34 +01:00
2023-09-28 21:23:03 +09:00
2023-08-18 10:19:00 -07:00
2023-08-15 14:57:25 -07:00
2023-06-27 14:14:30 -07:00
2023-08-07 13:05:53 -07:00
2024-02-23 09:25:02 +01:00
2023-07-10 13:59:37 -04:00
2023-09-29 17:20:46 -07:00
2023-07-20 12:24:06 +02:00
2023-08-18 10:18:59 -07:00
2024-01-31 16:18:56 -08:00
2023-10-05 09:50:14 +02:00
2023-07-14 08:51:48 +01:00
2023-08-21 13:37:47 -07:00
2023-09-19 13:21:34 -07:00
2023-08-21 13:37:48 -07:00
2023-08-18 10:12:11 -07:00
2023-08-21 13:37:49 -07:00
2024-01-25 15:35:53 -08:00
2023-08-04 12:09:56 +05:30
2023-09-06 20:49:04 -07:00
2023-06-19 16:19:12 -07:00
2024-02-05 20:14:21 +00:00
2023-07-18 12:10:00 -10:00
2023-12-20 17:02:02 +01:00
2023-08-18 10:12:36 -07:00
2023-08-24 16:20:28 -07:00
2023-08-31 12:20:12 -07:00
2023-07-11 14:12:19 -07:00
2023-08-18 10:12:46 -07:00
2023-08-18 10:12:41 -07:00
2024-02-05 20:14:38 +00:00
2023-07-03 12:56:23 -07:00
2023-07-24 12:09:47 -07:00
2023-08-03 13:42:02 -07:00
2023-06-28 10:59:38 -07:00
2023-06-20 20:17:10 -07:00
2023-06-20 20:18:39 -07:00
2023-11-28 17:19:56 +00:00
2023-06-26 11:14:18 +02:00
2023-08-02 19:11:06 -07:00
2023-08-09 15:32:43 -07:00
2023-12-03 07:33:04 +01:00
2024-01-25 15:35:59 -08:00
2023-07-28 16:52:08 -07:00
2023-07-23 11:34:22 +01:00
2023-09-13 11:51:11 -04:00
2023-09-13 11:51:11 -04:00
2023-06-19 12:10:48 -04:00
2023-07-25 00:30:02 -05:00
2023-08-18 10:19:00 -07:00
2023-06-22 13:57:41 -07:00
2023-08-16 14:27:01 -07:00
2023-08-21 11:29:12 -07:00
2023-11-20 11:58:53 +01:00
2023-09-05 05:34:14 -04:00
2023-07-10 09:12:31 -07:00
2023-08-23 16:34:02 +02:00
2023-12-20 17:02:06 +01:00
2023-08-04 11:36:33 -06:00
2023-09-05 13:02:13 -05:00
2023-09-09 08:18:16 -05:00
2023-08-21 13:37:31 -07:00
2023-08-18 10:12:25 -07:00
2023-08-24 16:20:18 -07:00
2023-08-21 14:28:45 -07:00
2023-06-19 16:19:00 -07:00
2023-12-03 07:33:03 +01:00
2023-06-23 16:59:30 -07:00
2023-08-21 13:07:20 -07:00
2023-07-03 12:46:47 -07:00
2024-02-05 20:14:27 +00:00
2023-06-23 15:05:28 -05:00
2023-06-23 15:05:28 -05:00
2024-01-25 15:35:50 -08:00
2023-08-04 16:21:30 +02:00
2023-08-25 08:06:53 -07:00
2023-07-18 10:07:47 +02:00
2023-11-28 17:19:54 +00:00
2023-09-29 17:20:46 -07:00
2023-08-14 08:12:53 +01:00
2023-08-02 19:11:06 -07:00
2023-09-06 07:46:49 +01:00
2023-08-21 13:37:59 -07:00
2023-06-30 09:04:01 -07:00
2024-01-31 16:19:09 -08:00
2023-07-18 15:19:00 +01:00
2023-07-24 13:27:12 +05:30
2023-08-22 21:31:57 +02:00
2023-07-24 09:51:51 +02:00
2023-08-22 22:03:43 +02:00
2023-11-20 11:58:57 +01:00
2023-11-08 11:56:20 +01:00
2023-11-28 17:19:48 +00:00
2023-08-12 09:18:47 -07:00
2023-08-02 15:01:51 -07:00
2023-07-10 09:52:30 +02:00
2023-07-10 09:52:30 +02:00
2023-07-20 22:14:21 +12:00
2023-06-20 09:02:33 +01:00
2023-08-09 15:59:21 -07:00
2024-02-23 09:24:53 +01:00
2023-11-28 17:19:48 +00:00
2023-10-06 11:01:23 +02:00
2023-10-06 11:01:23 +02:00
2023-08-24 21:34:28 -04:00
2023-06-19 16:19:04 -07:00
2023-08-18 10:19:00 -07:00
2023-07-19 09:43:58 +02:00
2023-08-16 14:27:41 -07:00
2023-07-14 15:01:49 -07:00
2023-07-19 13:19:41 -07:00
2024-01-25 15:35:49 -08:00
2023-07-12 23:45:23 +02:00
2023-07-12 23:45:23 +02:00
2023-07-18 15:05:10 +01:00
2023-07-15 12:56:48 -07:00
2023-09-19 13:21:34 -07:00
2023-12-13 18:45:19 +01:00
2024-01-31 16:18:56 -08:00
2023-07-15 11:34:49 -07:00
2023-08-27 23:50:22 +02:00
2023-06-26 11:14:18 +02:00
2023-06-23 16:59:28 -07:00
2023-08-30 10:08:38 +02:00
2023-12-13 18:45:15 +01:00
2023-08-24 16:20:31 -07:00
2024-01-31 16:18:54 -08:00
2023-08-22 11:10:26 -06:00
2023-07-27 08:48:12 -07:00
2023-09-21 08:37:44 +02:00
2023-06-21 17:55:53 +02:00
2024-02-23 09:25:10 +01:00
2023-08-09 09:15:51 +02:00
2024-01-25 15:35:59 -08:00
2024-01-31 16:19:01 -08:00
2023-07-18 10:07:47 +02:00
2023-07-26 21:24:40 -07:00
2023-11-28 17:19:38 +00:00
2023-06-26 11:14:18 +02:00
2023-06-28 16:43:10 -07:00
2023-08-21 13:46:24 -07:00
2024-01-25 15:35:49 -08:00
2023-08-16 14:27:01 -07:00
2024-01-31 16:18:47 -08:00
2023-07-28 17:05:47 +02:00
2023-08-04 18:21:50 -07:00
2023-11-28 17:19:40 +00:00
2023-06-28 10:28:11 -07:00
2023-07-17 16:08:08 -07:00
2023-08-24 16:20:28 -07:00
2023-08-21 13:37:26 -07:00
2023-08-18 10:12:16 -07:00
2023-09-27 11:19:15 +02:00
2023-08-09 14:16:44 -05:00
2024-01-31 16:19:14 -08:00
2023-11-28 17:19:57 +00:00
2023-07-08 20:26:39 +02:00
2023-07-25 19:21:03 +02:00
2023-07-28 18:04:14 -07:00
2023-08-06 08:24:55 +01:00
2024-02-05 20:14:15 +00:00
2023-08-11 21:12:45 +02:00
2023-11-20 11:58:51 +01:00
2023-11-28 17:20:08 +00:00
2023-08-07 17:55:54 +00:00
2024-02-23 09:25:19 +01:00
2024-02-23 09:25:21 +01:00
2023-08-22 14:58:15 +02:00
2023-08-11 21:12:46 +02:00
2023-08-22 14:58:15 +02:00
2023-08-11 21:12:47 +02:00
2023-08-11 21:12:44 +02:00
2023-08-27 11:47:44 +02:00
2023-06-28 10:59:38 -07:00
2023-11-20 11:58:56 +01:00
2023-07-24 18:03:58 -04:00
2023-08-09 14:17:06 +02:00
2023-08-18 10:12:16 -07:00
2023-09-03 18:10:22 -04:00
2023-11-20 11:59:18 +01:00
2023-12-08 08:52:25 +01:00
2023-08-24 13:27:47 -05:00
2024-01-25 15:35:57 -08:00
2023-06-27 10:47:08 -04:00
2024-01-25 15:35:26 -08:00
2023-09-04 13:44:11 -07:00
2023-07-17 16:08:08 -07:00
2023-11-28 17:19:36 +00:00
2023-08-21 14:52:16 +02:00
2023-09-05 19:01:38 -04:00
2023-08-10 12:06:04 +02:00
2023-06-19 16:19:27 -07:00
2023-08-21 13:37:27 -07:00