Charan Teja Kalla
6348dd291e
dmabuf: use spinlock to access dmabuf->name
...
There exists a sleep-while-atomic bug while accessing the dmabuf->name
under mutex in the dmabuffs_dname(). This is caused from the SELinux
permissions checks on a process where it tries to validate the inherited
files from fork() by traversing them through iterate_fd() (which
traverse files under spin_lock) and call
match_file(security/selinux/hooks.c) where the permission checks happen.
This audit information is logged using dump_common_audit_data() where it
calls d_path() to get the file path name. If the file check happen on
the dmabuf's fd, then it ends up in ->dmabuffs_dname() and use mutex to
access dmabuf->name. The flow will be like below:
flush_unauthorized_files()
iterate_fd()
spin_lock() --> Start of the atomic section.
match_file()
file_has_perm()
avc_has_perm()
avc_audit()
slow_avc_audit()
common_lsm_audit()
dump_common_audit_data()
audit_log_d_path()
d_path()
dmabuffs_dname()
mutex_lock()--> Sleep while atomic.
Call trace captured (on 4.19 kernels) is below:
___might_sleep+0x204/0x208
__might_sleep+0x50/0x88
__mutex_lock_common+0x5c/0x1068
__mutex_lock_common+0x5c/0x1068
mutex_lock_nested+0x40/0x50
dmabuffs_dname+0xa0/0x170
d_path+0x84/0x290
audit_log_d_path+0x74/0x130
common_lsm_audit+0x334/0x6e8
slow_avc_audit+0xb8/0xf8
avc_has_perm+0x154/0x218
file_has_perm+0x70/0x180
match_file+0x60/0x78
iterate_fd+0x128/0x168
selinux_bprm_committing_creds+0x178/0x248
security_bprm_committing_creds+0x30/0x48
install_exec_creds+0x1c/0x68
load_elf_binary+0x3a4/0x14e0
search_binary_handler+0xb0/0x1e0
So, use spinlock to access dmabuf->name to avoid sleep-while-atomic.
Cc: <stable@vger.kernel.org > [5.3+]
Signed-off-by: Charan Teja Kalla <charante@codeaurora.org >
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com >
Acked-by: Christian König <christian.koenig@amd.com >
[sumits: added comment to spinlock_t definition to avoid warning]
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://patchwork.freedesktop.org/patch/msgid/a83e7f0d-4e54-9848-4b58-e1acdbe06735@codeaurora.org
2020-07-10 15:39:29 +05:30
..
2020-05-22 20:47:21 -07:00
2020-06-01 23:32:35 +02:00
2020-05-12 22:48:42 +02:00
2020-06-01 13:22:53 +02:00
2020-05-12 13:08:08 -07:00
2020-06-07 10:59:32 -07:00
2020-06-04 19:56:20 -07:00
2020-06-03 10:48:37 +02:00
2020-05-13 13:59:13 +02:00
2020-05-15 16:03:28 +02:00
2020-05-17 21:10:28 -07:00
2020-06-04 20:11:25 -07:00
2020-06-05 14:05:57 -07:00
2020-06-05 14:05:57 -07:00
2020-05-29 12:37:59 +02:00
2020-06-03 09:21:52 +02:00
2020-05-27 13:39:08 +02:00
2020-05-18 19:30:56 +05:30
2020-06-13 13:12:38 -07:00
2020-06-05 15:11:50 -07:00
2020-05-29 14:36:03 +01:00
2020-06-09 09:39:14 -07:00
2020-05-20 17:22:30 +05:30
2020-06-07 16:13:43 -07:00
2020-06-11 12:22:41 -07:00
2020-05-26 10:27:14 +02:00
2020-05-21 14:07:37 +01:00
2020-06-11 08:03:24 +02:00
2020-06-11 08:03:24 +02:00
2020-06-11 08:03:24 +02:00
2020-05-24 20:48:11 +02:00
2020-06-04 19:18:29 -07:00
2020-06-02 19:59:25 -07:00
2020-06-04 19:06:25 -07:00
2020-05-16 14:23:54 -06:00
2020-05-14 09:48:03 -06:00
2020-05-29 10:23:25 -06:00
2020-05-28 08:47:13 -06:00
2020-06-01 15:21:03 -07:00
2020-06-01 14:38:22 -07:00
2020-05-19 11:32:04 -07:00
2020-06-01 15:21:03 -07:00
2020-06-01 15:08:04 -07:00
2020-05-15 10:56:31 -07:00
2020-06-11 15:14:53 +02:00
2020-06-02 10:59:08 -07:00
2020-05-19 09:40:29 -06:00
2020-06-09 09:39:16 -07:00
2020-05-15 17:29:41 +02:00
2020-06-03 20:24:15 -07:00
2020-06-11 20:04:04 +02:00
2020-06-11 20:02:46 +02:00
2020-06-11 20:02:46 +02:00
2020-06-11 20:04:04 +02:00
2020-06-01 10:15:16 +02:00
2020-06-11 15:14:36 +02:00
2020-06-11 15:14:36 +02:00
2020-05-19 16:31:16 +02:00
2020-05-14 11:11:20 +02:00
2020-05-19 12:55:29 +02:00
2020-06-05 14:20:02 +02:00
2020-06-11 12:55:20 -07:00
2020-06-09 09:39:13 -07:00
2020-05-21 08:22:20 -06:00
2020-06-09 09:39:13 -07:00
2020-05-13 08:44:35 -07:00
2020-06-11 15:15:28 +02:00
2020-06-08 11:05:56 -07:00
2020-06-01 16:44:06 -07:00
2020-05-20 17:09:45 -04:00
2020-06-05 14:59:41 -04:00
2020-07-10 15:39:29 +05:30
2020-06-06 11:55:53 -07:00
2020-06-09 09:39:13 -07:00
2020-06-08 11:05:56 -07:00
2020-05-25 15:11:14 +02:00
2020-05-29 10:23:24 -06:00
2020-06-04 19:06:25 -07:00
2020-06-05 13:17:05 -07:00
2020-05-27 18:55:54 +02:00
2020-06-03 23:16:55 -04:00
2020-06-03 16:27:18 -07:00
2020-06-14 09:47:25 -07:00
2020-05-18 20:21:48 -07:00
2020-05-12 16:44:00 -07:00
2020-05-19 15:51:18 +02:00
2020-06-10 16:05:54 -07:00
2020-05-15 16:34:52 +02:00
2020-06-02 15:37:03 -07:00
2020-06-03 20:09:45 -07:00
2020-06-11 15:15:06 +02:00
2020-05-14 13:50:43 +03:00
2020-06-04 19:06:22 -07:00
2020-06-09 09:39:13 -07:00
2020-06-09 09:39:14 -07:00
2020-06-09 09:39:13 -07:00
2020-06-02 20:58:55 +10:00
2020-05-28 07:59:45 -07:00
2020-05-23 09:07:00 +00:00
2020-05-15 11:23:49 +02:00
2020-05-29 12:53:04 +02:00
2020-05-28 18:07:11 +02:00
2020-05-19 12:54:05 +02:00
2020-05-28 10:31:09 +02:00
2020-05-31 17:48:46 -07:00
2020-05-11 13:19:00 -07:00
2020-05-20 20:31:27 -04:00
2020-05-22 14:41:04 -04:00
2020-05-29 15:11:43 +02:00
2020-05-18 15:37:25 +02:00
2020-06-10 14:04:39 -07:00
2020-06-11 15:15:29 +02:00
2020-06-09 09:39:13 -07:00
2020-06-05 16:19:28 -07:00
2020-06-08 11:42:23 -07:00
2020-06-07 10:59:32 -07:00
2020-06-08 11:05:56 -07:00
2020-05-18 10:30:21 +01:00
2020-06-02 12:34:45 +02:00
2020-05-18 10:29:26 +01:00
2020-06-11 15:15:24 +02:00
2020-06-09 09:39:10 -07:00
2020-06-09 09:39:13 -07:00
2020-05-12 13:28:33 +09:00
2020-06-02 15:15:46 +01:00
2020-06-08 11:05:56 -07:00
2020-05-19 15:42:22 +01:00
2020-05-14 09:46:54 -06:00
2020-05-18 17:49:27 +01:00
2020-05-30 10:34:03 -07:00
2020-06-10 11:28:35 -07:00
2020-06-11 13:25:53 -07:00
2020-06-11 12:35:19 -04:00
2020-05-28 10:31:09 +02:00
2020-05-28 10:31:09 +02:00
2020-05-19 15:51:18 +02:00
2020-05-19 15:47:38 +01:00
2020-06-14 11:39:31 -07:00
2020-06-14 11:39:31 -07:00
2020-05-26 15:31:45 -07:00
2020-06-03 20:09:49 -07:00
2020-06-03 20:09:49 -07:00
2020-06-10 13:42:09 -07:00
2020-06-09 09:39:14 -07:00
2020-05-28 11:22:13 +02:00
2020-05-22 09:35:43 +02:00
2020-06-09 09:39:14 -07:00
2020-06-09 09:39:14 -07:00
2020-06-09 09:39:14 -07:00
2020-06-10 19:14:18 -07:00
2020-06-09 09:39:14 -07:00
2020-06-10 19:14:18 -07:00
2020-05-13 11:41:22 +02:00
2020-06-06 11:30:00 -07:00
2020-06-04 11:13:03 -07:00
2020-05-19 11:42:16 +01:00
2020-06-09 15:40:50 -07:00
2020-06-02 10:59:07 -07:00
2020-06-08 11:05:56 -07:00
2020-06-13 16:27:13 -07:00
2020-05-27 10:10:12 -04:00
2020-06-11 13:33:48 -04:00
2020-05-27 10:10:12 -04:00
2020-06-05 20:02:08 -04:00
2020-05-27 07:12:40 +02:00
2020-05-12 22:45:39 +02:00
2020-06-03 20:09:45 -07:00
2020-06-02 10:59:09 -07:00
2020-06-04 15:36:52 -04:00
2020-06-09 09:39:14 -07:00
2020-05-15 13:51:28 -07:00
2020-05-27 05:21:23 -06:00
2020-06-11 15:17:57 +02:00
2020-06-04 12:59:16 -05:00
2020-05-27 14:35:41 +02:00
2020-05-22 12:35:07 +01:00
2020-06-08 12:05:31 -07:00
2020-06-03 16:27:18 -07:00
2020-06-09 09:39:14 -07:00
2020-05-26 23:22:21 -07:00
2020-06-04 13:54:34 -07:00
2020-06-13 09:56:21 -07:00
2020-05-29 10:15:08 +05:30
2020-05-29 18:03:12 +02:00
2020-05-28 19:25:31 +02:00
2020-05-19 15:51:17 +02:00
2020-06-08 11:05:56 -07:00
2020-06-04 13:54:34 -07:00
2020-06-07 10:53:36 -07:00
2020-05-20 19:10:37 +01:00
2020-05-31 19:49:00 -07:00
2020-05-30 10:34:03 -07:00
2020-05-31 19:49:00 -07:00
2020-05-30 10:34:03 -07:00
2020-06-02 10:59:10 -07:00
2020-05-15 13:48:59 -07:00
2020-05-28 10:31:09 +02:00
2020-06-04 13:54:34 -07:00
2020-05-26 19:05:11 +02:00
2020-05-26 19:05:11 +02:00
2020-05-20 03:39:40 -04:00
2020-06-01 11:35:18 -07:00
2020-06-03 16:59:31 -04:00
2020-05-12 15:00:37 -07:00
2020-06-09 09:39:14 -07:00
2020-05-22 09:38:13 +02:00
2020-05-13 15:48:17 +02:00
2020-06-13 10:21:00 -07:00
2020-05-18 17:47:48 +01:00
2020-06-14 11:39:31 -07:00
2020-06-04 19:06:26 -07:00
2020-05-29 12:42:54 +02:00
2020-06-11 15:19:17 +02:00
2020-06-02 11:50:23 -07:00
2020-06-01 14:48:32 -07:00
2020-06-03 13:06:42 -07:00
2020-05-11 16:59:16 -07:00
2020-05-17 14:10:07 -06:00
2020-06-10 19:14:18 -07:00
2020-05-14 16:44:24 +02:00
2020-06-03 20:09:42 -07:00
2020-05-27 17:55:59 +02:00
2020-06-03 20:09:49 -07:00
2020-05-14 16:44:25 +02:00
2020-06-08 11:05:56 -07:00
2020-05-15 14:53:19 +02:00
2020-05-28 11:11:45 -07:00
2020-05-25 23:15:03 +02:00
2020-05-11 13:29:30 +03:00
2020-05-22 18:50:12 +03:00
2020-06-04 15:50:42 -07:00
2020-05-29 14:52:53 +02:00
2020-06-11 20:02:46 +02:00
2020-06-04 15:36:51 -04:00
2020-05-13 12:42:46 -05:00
2020-05-28 15:53:29 -06:00
2020-05-28 16:31:30 -07:00
2020-06-03 20:09:48 -07:00
2020-06-02 10:59:12 -07:00
2020-06-03 20:24:15 -07:00
2020-06-02 02:45:13 -04:00
2020-05-19 15:08:24 +01:00
2020-06-01 11:02:28 -04:00
2020-06-05 16:19:28 -07:00
2020-06-08 11:05:56 -07:00
2020-06-02 10:59:10 -07:00