lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 15 Dec 2020 19:41:23 +0300 From: Sergey Temerkhanov <s.temerkhanov@...il.com> To: Alexander Viro <viro@...iv.linux.org.uk>, linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org Cc: Sergey Temerkhanov <s.temerkhanov@...il.com> Subject: [PATCH] fget: Do not loop with rcu lock held Unlock RCU before running another loop iteration Signed-off-by: Sergey Temerkhanov <s.temerkhanov@...il.com> --- fs/file.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/fs/file.c b/fs/file.c index 4559b5fec3bd..49d57752e7a6 100644 --- a/fs/file.c +++ b/fs/file.c @@ -823,21 +823,27 @@ static struct file *__fget_files(struct files_struct *files, unsigned int fd, fmode_t mask, unsigned int refs) { struct file *file; + bool again = false; - rcu_read_lock(); -loop: - file = fcheck_files(files, fd); - if (file) { - /* File object ref couldn't be taken. - * dup2() atomicity guarantee is the reason - * we loop to catch the new file (or NULL pointer) - */ - if (file->f_mode & mask) - file = NULL; - else if (!get_file_rcu_many(file, refs)) - goto loop; - } - rcu_read_unlock(); + do { + rcu_read_lock(); + + file = fcheck_files(files, fd); + if (file) { + /* File object ref couldn't be taken. + * dup2() atomicity guarantee is the reason + * we loop to catch the new file (or NULL pointer) + */ + if (file->f_mode & mask) + file = NULL; + else if (!get_file_rcu_many(file, refs)) + again = true; + } + rcu_read_unlock(); + + if (unlikely(again)) + schedule(); + } while (again); return file; } -- 2.25.1
Powered by blists - more mailing lists