Charan Teja Kalla
722c6e954c
dmabuf: use spinlock to access dmabuf->name
...
[ Upstream commit 6348dd291e ]
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
Signed-off-by: Sasha Levin <sashal@kernel.org >
2020-07-29 10:18:29 +02:00
..
2020-01-14 20:08:28 +01:00
2020-04-02 15:11:02 +02:00
2019-09-17 10:27:46 -07:00
2020-04-01 11:01:34 +02:00
2019-09-18 11:14:31 -07:00
2020-02-19 19:53:09 +01:00
2019-08-28 17:24:22 +02:00
2020-04-29 16:33:12 +02:00
2020-07-22 09:33:13 +02:00
2019-09-17 00:40:05 -05:00
2020-06-24 17:50:33 +02:00
2020-06-03 08:20:53 +02:00
2020-04-01 11:01:27 +02:00
2019-09-21 10:59:54 -07:00
2020-06-03 08:21:39 +02:00
2019-09-13 12:47:36 +02:00
2019-09-13 12:47:36 +02:00
2019-09-13 12:47:36 +02:00
2019-09-13 12:47:36 +02:00
2020-07-22 09:32:58 +02:00
2020-02-01 09:34:49 +00:00
2020-06-30 15:36:58 -04:00
2020-02-24 08:36:47 +01:00
2020-02-11 04:35:55 -08:00
2020-06-22 09:31:01 +02:00
2019-09-19 16:24:24 -07:00
2019-09-04 14:57:28 +05:30
2020-06-22 09:31:24 +02:00
2020-06-24 17:50:44 +02:00
2020-04-13 10:48:08 +02:00
2020-01-09 10:19:59 +01:00
2019-08-30 21:29:32 -04:00
2020-05-14 07:58:30 +02:00
2020-05-14 07:58:30 +02:00
2019-09-02 15:55:03 +01:00
2020-01-09 10:19:54 +01:00
2019-10-14 15:04:01 -07:00
2020-06-24 17:50:39 +02:00
2019-08-28 21:17:12 -06:00
2019-08-28 21:17:04 -06:00
2019-09-05 19:52:34 -06:00
2020-07-22 09:32:52 +02:00
2020-03-05 16:43:52 +01:00
2019-08-28 00:30:11 +02:00
2019-10-31 21:41:33 +01:00
2020-04-23 10:36:15 +02:00
2019-09-05 10:15:16 +02:00
2020-07-22 09:32:50 +02:00
2020-07-22 09:32:49 +02:00
2019-09-19 15:31:27 -07:00
2019-09-20 15:45:07 -07:00
2019-09-24 15:54:10 -07:00
2019-11-29 10:10:08 +01:00
2019-10-11 09:26:05 -07:00
2019-09-21 09:47:19 -07:00
2020-05-20 08:20:34 +02:00
2019-09-04 13:38:26 +02:00
2020-04-17 10:50:11 +02:00
2020-02-11 04:35:25 -08:00
2020-02-24 08:36:34 +01:00
2019-09-03 09:36:36 +02:00
2019-09-17 19:15:14 -07:00
2019-09-25 17:51:40 -07:00
2019-09-23 11:21:04 -07:00
2020-04-17 10:50:09 +02:00
2019-09-18 10:33:46 -07:00
2020-07-29 10:18:29 +02:00
2020-01-04 19:17:24 +01:00
2020-01-04 19:17:00 +01:00
2019-08-29 16:43:22 +02:00
2020-02-24 08:36:40 +01:00
2020-04-01 11:01:53 +02:00
2019-10-22 12:54:44 -07:00
2019-09-03 19:21:19 +02:00
2019-10-31 09:40:19 +01:00
2019-09-05 19:52:33 -06:00
2020-06-17 16:40:20 +02:00
2020-02-11 04:35:37 -08:00
2019-10-18 15:32:52 +02:00
2020-04-23 10:36:33 +02:00
2020-07-16 08:16:45 +02:00
2019-09-25 09:55:59 -07:00
2020-05-20 08:20:29 +02:00
2020-05-14 07:58:30 +02:00
2020-03-25 08:25:58 +01:00
2020-06-24 17:50:49 +02:00
2019-10-28 16:17:31 -07:00
2019-09-05 11:40:54 +02:00
2020-03-05 16:43:42 +01:00
2020-01-04 19:18:41 +01:00
2019-09-29 10:33:41 -07:00
2020-04-23 10:36:36 +02:00
2019-10-02 06:36:50 -07:00
2019-09-24 12:36:31 -07:00
2019-09-24 16:48:02 -07:00
2019-09-03 11:33:29 +02:00
2019-11-08 08:46:49 -08:00
2020-06-03 08:21:36 +02:00
2020-01-12 12:21:46 +01:00
2019-10-24 14:53:49 -07:00
2019-10-24 14:53:48 -07:00
2020-07-22 09:32:49 +02:00
2019-09-28 08:14:15 -07:00
2020-03-18 07:17:38 +01:00
2019-08-28 11:50:33 +02:00
2020-04-01 11:01:55 +02:00
2020-02-28 17:22:26 +01:00
2019-09-17 19:15:14 -07:00
2019-09-25 17:51:39 -07:00
2019-08-30 16:12:10 +02:00
2020-05-10 10:31:30 +02:00
2020-04-17 10:50:04 +02:00
2019-09-19 15:32:45 -07:00
2020-06-24 17:50:35 +02:00
2019-12-31 16:44:14 +01:00
2020-02-11 04:35:54 -08:00
2020-02-28 17:22:20 +01:00
2020-06-24 17:50:48 +02:00
2020-07-16 08:16:44 +02:00
2019-09-07 04:28:05 -03:00
2019-12-13 08:42:53 +01:00
2019-09-28 08:14:15 -07:00
2020-04-23 10:36:45 +02:00
2019-09-02 11:43:54 +01:00
2020-06-22 09:31:03 +02:00
2019-09-24 15:54:11 -07:00
2020-06-24 17:50:52 +02:00
2020-06-17 16:40:26 +02:00
2020-02-11 04:35:40 -08:00
2019-10-08 22:05:58 +02:00
2020-06-24 17:50:47 +02:00
2020-01-04 19:18:28 +01:00
2019-08-29 13:49:13 -07:00
2020-02-24 08:36:45 +01:00
2019-09-28 08:14:15 -07:00
2019-09-05 12:32:05 +02:00
2020-05-20 08:20:27 +02:00
2020-01-09 10:19:56 +01:00
2019-11-15 18:34:00 -08:00
2019-09-28 14:05:38 -07:00
2019-09-29 10:33:41 -07:00
2019-10-17 16:31:52 -07:00
2019-10-04 18:11:08 -07:00
2019-12-13 08:43:18 +01:00
2019-09-25 17:51:40 -07:00
2019-11-06 08:28:58 -08:00
2020-06-17 16:40:23 +02:00
2019-09-07 04:28:04 -03:00
2020-06-22 09:31:14 +02:00
2020-06-10 20:24:57 +02:00
2019-09-27 19:37:27 -07:00
2019-09-03 09:30:45 -04:00
2020-06-30 15:36:44 -04:00
2019-09-13 12:35:33 +02:00
2019-09-13 12:35:33 +02:00
2019-09-13 12:47:36 +02:00
2020-06-24 17:50:44 +02:00
2020-05-06 08:15:05 +02:00
2020-04-17 10:50:10 +02:00
2019-12-31 16:44:40 +01:00
2019-12-31 16:44:43 +01:00
2019-09-11 14:46:02 +01:00
2020-06-17 16:40:22 +02:00
2019-10-14 15:04:00 -07:00
2020-03-25 08:25:58 +01:00
2019-09-24 15:54:08 -07:00
2019-09-07 04:28:04 -03:00
2019-08-28 15:25:53 -05:00
2020-06-22 09:31:17 +02:00
2020-04-17 10:50:11 +02:00
2020-02-24 08:36:37 +01:00
2020-04-23 10:36:37 +02:00
2020-02-11 04:35:44 -08:00
2019-10-28 11:02:01 +01:00
2019-09-05 11:54:14 +02:00
2020-03-18 07:17:46 +01:00
2020-03-18 07:17:56 +01:00
2019-12-21 11:04:31 +01:00
2020-05-20 08:20:27 +02:00
2020-01-04 19:18:48 +01:00
2019-09-05 21:16:22 +02:00
2020-05-02 08:48:42 +02:00
2019-09-21 03:25:10 +02:00
2020-01-04 19:17:25 +01:00
2019-12-17 19:56:43 +01:00
2019-11-01 22:26:34 -04:00
2019-09-12 21:05:34 -04:00
2019-09-25 17:51:39 -07:00
2020-02-24 08:36:45 +01:00
2019-09-16 17:25:49 -07:00
2019-09-25 17:42:29 +02:00
2019-10-28 12:18:23 +01:00
2019-10-24 10:26:33 +02:00
2019-09-16 11:43:38 -05:00
2020-04-17 10:50:12 +02:00
2020-06-07 13:18:49 +02:00
2020-04-02 15:11:00 +02:00
2020-06-17 16:40:31 +02:00
2019-09-12 21:05:34 -04:00
2019-09-24 15:54:11 -07:00
2020-04-01 11:02:18 +02:00
2020-06-22 09:31:12 +02:00
2019-10-07 15:47:20 -07:00
2019-10-31 14:01:40 -07:00
2019-09-11 15:27:09 +01:00
2020-06-22 09:31:12 +02:00
2020-02-19 19:52:56 +01:00
2020-04-13 10:48:07 +02:00
2019-09-25 17:51:41 -07:00
2020-04-23 10:36:37 +02:00
2019-09-11 12:34:29 +02:00
2019-09-07 21:42:25 +02:00
2019-10-02 10:06:45 +02:00
2019-09-17 20:03:49 -06:00
2019-10-13 10:13:08 -07:00
2020-01-04 19:18:42 +01:00
2019-08-30 07:27:17 -07:00
2019-12-18 16:08:43 +01:00
2019-08-28 11:50:43 +02:00
2020-01-23 08:22:44 +01:00
2019-09-16 17:25:49 -07:00
2020-06-30 15:36:54 -04:00
2019-08-31 06:51:49 -04:00
2020-05-20 08:20:29 +02:00
2020-01-17 19:48:40 +01:00
2020-06-10 20:24:55 +02:00
2019-10-28 04:25:04 -04:00
2020-04-29 16:33:14 +02:00
2020-04-02 15:11:00 +02:00
2019-09-04 14:34:31 +02:00
2019-09-17 12:35:15 -07:00
2019-09-13 21:15:39 +10:00
2020-04-17 10:50:18 +02:00
2019-09-24 15:54:12 -07:00