mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] userfaultfd: avoid the duplicated release for userfaultfd_ctx
@ 2020-07-14 16:12 yanfei.xu
  2020-07-15  1:41 ` Xu, Yanfei
  2020-07-19 13:58 ` Xu, Yanfei
  0 siblings, 2 replies; 6+ messages in thread
From: yanfei.xu @ 2020-07-14 16:12 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel

From: Yanfei Xu <yanfei.xu@windriver.com>

when get_unused_fd_flags gets failure, userfaultfd_ctx_cachep will
be freed by userfaultfd_fops's release function which is the
userfaultfd_release. So we could return directly after fput().

userfaultfd_release()->userfaultfd_ctx_put(ctx)

Fixes: d08ac70b1e0d (Wire UFFD up to SELinux)
Reported-by: syzbot+75867c44841cb6373570@syzkaller.appspotmail.com
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
 fs/userfaultfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 3a4d6ac5a81a..e98317c15530 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -2049,7 +2049,7 @@ SYSCALL_DEFINE1(userfaultfd, int, flags)
 	fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC);
 	if (fd < 0) {
 		fput(file);
-		goto out;
+		return fd;
 	}
 
 	ctx->owner = file_inode(file);
-- 
2.18.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-22  0:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 16:12 [PATCH] userfaultfd: avoid the duplicated release for userfaultfd_ctx yanfei.xu
2020-07-15  1:41 ` Xu, Yanfei
2020-07-19 13:58 ` Xu, Yanfei
2020-07-19 16:57   ` Al Viro
2020-07-20  1:34     ` Xu, Yanfei
2020-07-22  0:09       ` Suren Baghdasaryan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome