Amir Goldstein
d6da19c9ca
locks: fix TOCTOU race when granting write lease
...
Thread A trying to acquire a write lease checks the value of i_readcount
and i_writecount in check_conflicting_open() to verify that its own fd
is the only fd referencing the file.
Thread B trying to open the file for read will call break_lease() in
do_dentry_open() before incrementing i_readcount, which leaves a small
window where thread A can acquire the write lease and then thread B
completes the open of the file for read without breaking the write lease
that was acquired by thread A.
Fix this race by incrementing i_readcount before checking for existing
leases, same as the case with i_writecount.
Use a helper put_file_access() to decrement i_readcount or i_writecount
in do_dentry_open() and __fput().
Fixes: 387e3746d0 ("locks: eliminate false positive conflicts for write lease")
Reviewed-by: Jeff Layton <jlayton@kernel.org >
Signed-off-by: Amir Goldstein <amir73il@gmail.com >
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
2022-08-16 10:59:54 -04:00
..
2022-07-02 18:52:21 +09:00
2022-05-09 16:21:44 -04:00
2022-08-01 19:53:31 +02:00
2022-08-13 17:20:51 -07:00
2022-07-17 17:31:42 -07:00
2022-08-02 12:34:03 -04:00
2022-05-09 16:21:44 -04:00
2022-08-05 16:32:45 -07:00
2022-07-05 16:12:21 +01:00
2022-08-11 12:41:07 -07:00
2022-08-13 17:31:18 -07:00
2022-08-02 12:34:03 -04:00
2022-02-22 18:30:28 +01:00
2022-08-02 12:34:02 -04:00
2022-08-11 12:41:07 -07:00
2022-02-25 11:56:13 +01:00
2022-01-24 14:17:02 +01:00
2022-08-01 09:31:46 -05:00
2022-05-09 16:21:45 -04:00
2022-06-24 20:40:19 +02:00
2022-05-09 16:21:45 -04:00
2022-08-05 16:32:45 -07:00
2022-08-01 10:14:07 +09:00
2022-04-28 16:31:10 +02:00
2022-08-05 16:32:45 -07:00
2022-08-05 16:32:45 -07:00
2022-08-08 11:18:31 -07:00
2022-08-07 10:03:24 -07:00
2022-08-02 12:34:03 -04:00
2022-08-09 14:13:59 +01:00
2022-08-08 20:04:35 -07:00
2022-08-11 13:11:49 -07:00
2022-06-29 08:51:06 -04:00
2022-08-03 10:35:43 -07:00
2022-08-02 12:34:02 -04:00
2022-05-09 16:21:45 -04:00
2022-08-08 20:04:35 -07:00
2022-08-11 13:11:49 -07:00
2022-07-14 12:14:32 -06:00
2022-08-05 16:32:45 -07:00
2022-06-03 14:42:24 -07:00
2022-08-03 10:35:43 -07:00
2022-07-28 10:57:25 +02:00
2022-08-08 20:15:13 -07:00
2022-08-04 10:28:48 -04:00
2022-05-09 16:21:44 -04:00
2022-07-14 10:10:12 +02:00
2022-08-10 14:04:32 -07:00
2021-10-04 22:02:17 +01:00
2022-08-09 14:56:49 -07:00
2022-08-03 10:35:43 -07:00
2022-07-26 13:38:47 +02:00
2022-08-03 10:35:43 -07:00
2022-08-03 10:35:43 -07:00
2022-08-09 09:52:28 -07:00
2022-05-09 16:21:44 -04:00
2022-03-22 15:57:03 -07:00
2022-06-29 08:51:07 -04:00
2022-08-08 11:03:11 -07:00
2022-08-14 15:16:18 -04:00
2022-08-03 14:38:02 -07:00
2022-05-09 16:21:44 -04:00
2022-05-09 16:21:44 -04:00
2022-08-05 16:32:45 -07:00
2021-11-09 10:11:53 -08:00
2022-08-03 10:35:43 -07:00
2022-05-09 16:21:46 -04:00
2022-05-23 20:24:12 -05:00
2022-08-07 10:03:24 -07:00
2022-04-05 15:39:19 +02:00
2022-05-27 11:22:03 -07:00
2022-06-17 19:01:28 -04:00
2022-08-05 16:32:45 -07:00
2022-07-14 12:14:32 -06:00
2022-08-03 10:35:43 -07:00
2022-02-14 10:37:32 +09:00
2022-05-09 16:21:46 -04:00
2022-07-15 23:42:30 -07:00
2022-08-13 13:50:11 -07:00
2022-08-11 13:11:49 -07:00
2022-08-03 13:50:22 -07:00
2021-09-19 22:35:37 -04:00
2022-08-08 10:39:29 -07:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2022-03-08 12:55:29 -06:00
2022-03-03 20:38:56 -08:00
2022-04-15 14:49:56 -07:00
2022-04-22 10:57:18 -07:00
2022-02-09 09:50:02 -08:00
2022-08-03 10:35:43 -07:00
2022-03-03 20:38:56 -08:00
2022-07-16 09:19:15 -04:00
2021-11-06 13:30:32 -07:00
2022-08-05 16:32:45 -07:00
2022-08-11 12:41:07 -07:00
2022-08-08 22:37:22 -04:00
2021-09-03 09:58:10 -07:00
2021-09-06 07:20:56 -04:00
2022-07-17 17:31:40 -07:00
2022-08-09 20:02:13 +02:00
2022-06-10 16:10:23 -04:00
2021-04-07 13:56:43 -04:00
2022-08-16 10:59:54 -04:00
2022-06-05 15:03:03 -04:00
2021-08-23 01:25:40 -04:00
2022-01-18 09:23:19 +02:00
2021-12-09 14:09:36 -05:00
2022-06-06 09:54:30 +02:00
2022-05-19 23:25:10 -04:00
2022-08-11 12:41:07 -07:00
2022-08-16 10:59:54 -04:00
2022-04-01 19:35:56 -07:00
2022-08-08 18:06:42 -07:00
2022-05-30 10:56:18 -07:00
2022-06-16 19:58:21 -07:00
2022-05-09 16:21:44 -04:00
2022-07-18 10:01:47 -04:00
2022-07-24 18:39:10 -06:00
2022-08-05 16:32:45 -07:00
2022-07-05 16:18:21 -04:00
2022-08-03 10:35:43 -07:00
2022-08-09 09:52:28 -07:00
2022-07-05 16:18:21 -04:00
2022-08-16 10:59:54 -04:00
2022-05-27 11:22:03 -07:00
2021-03-08 15:18:43 +01:00
2022-07-15 22:09:57 +02:00
2022-06-28 13:58:05 -04:00
2022-08-08 22:37:15 -04:00
2021-04-17 11:39:49 -07:00
2022-08-05 16:32:45 -07:00
2022-01-11 09:03:05 -08:00
2022-05-22 21:03:01 +01:00
2022-01-17 05:49:30 +02:00
2022-08-08 22:37:23 -04:00
2022-05-31 14:10:54 -07:00
2021-02-13 17:17:53 +01:00
2022-08-08 11:10:02 -07:00
2022-04-26 13:36:25 -07:00
2022-01-22 08:33:36 +02:00
2021-08-10 17:57:22 +02:00
2022-08-05 16:32:45 -07:00
2022-07-15 22:08:59 +02:00