VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
author: Matthew Wilcox (Oracle) <willy@infradead.org> 2021-10-25 19:16:34 +0100 committer: Linus Torvalds <torvalds@linux-foundation.org> 2021-10-25 11:27:31 -0700 commit: cb685432398122053f3e1dc6a1d68924e5b77be4 parent: ac8a6eba2a117e0fdc04da62ab568d1b7ca4c8f6
Commit Summary:
secretmem: Prevent secretmem_users from wrapping to zero
Diffstat:
1 file changed, 2 insertions, 0 deletions
diff --git a/mm/secretmem.c b/mm/secretmem.c
index 030f02ddc7c1..c2dda408bb36 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -203,6 +203,8 @@ SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
 
 	if (flags & ~(SECRETMEM_FLAGS_MASK | O_CLOEXEC))
 		return -EINVAL;
+	if (atomic_read(&secretmem_users) < 0)
+		return -ENFILE;
 
 	fd = get_unused_fd_flags(flags & O_CLOEXEC);
 	if (fd < 0)