[Devel] [PATCH RHEL8 COMMIT] fs: Fix race with old fdt parallel reuse
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 24 12:08:51 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.31
------>
commit b11dc0d1fc673f9e1112b67274b27f5f5b92f75b
Author: Vasily Averin <vvs at virtuozzo.com>
Date: Mon May 24 12:08:51 2021 +0300
fs: Fix race with old fdt parallel reuse
We own files->resize_in_progress in this moment,
but it's only seen by guys, who expands the fdt.
If someone wants to use fd inside old fdt max number,
he just doesn't look at this.
So, let's check old maximum fd after lock is
acquired to see such the parallel users.
https://jira.sw.ru/browse/PSBM-82984
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
(cherry picked from vz7 commit 01eb18f336ef ("fs: Fix race with old fdt
parallel reuse"))
Fixes: c4a4fada18a "ve/fs/files: Shrink big fdtable on close in
is_pseudosuper mode"
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
fs/file.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/file.c b/fs/file.c
index 0ed1c4cd6eae..b7618d3d4458 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -189,8 +189,7 @@ static int expand_fdtable(struct files_struct *files, unsigned int nr, bool shri
if (unlikely(shrink)) {
int i;
i = find_last_bit(cur_fdt->open_fds, cur_fdt->max_fds);
- i = fdtable_align(i);
- if (i == cur_fdt->max_fds) {
+ if (i >= new_fdt->max_fds) {
__free_fdtable(new_fdt);
return 1;
}
More information about the Devel
mailing list