userfaultfd: avoid the duplicated release for userfaultfd_ctx
PATCH 1/1 userfaultfd: avoid the duplicated release for userfaultfd_ctx
From: Yanfei Xu <[email protected]>
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)
--- fs/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/userfaultfd.c +1 -1
@@ -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);
Signature · 1 line
2.18.2
Add maintainer Alexander Viro :)
Quoted 29 lines · On 7/15/20 12:12 AM, [email protected] wrote:
From: Yanfei Xu <[email protected]>
when
get_unused_fd_flagsgets failure,userfaultfd_ctx_cachepwill be freed by userfaultfd_fops's release function which is theuserfaultfd_release. So we could return directly afterfput().userfaultfd_release()->userfaultfd_ctx_put(ctx)
Fixes d08ac70b1e0d (Wire UFFD up to SELinux)Reported-by [email protected]Signed-off-by Yanfei Xu <[email protected]>--- fs/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/userfaultfd.c +1
-1@@ -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);
ping Al Viro
Could you please help to review this patch? Thanks a lot.
Yanfei
Quoted 29 lines · On 7/15/20 12:12 AM, [email protected] wrote:
From: Yanfei Xu <[email protected]>
when
get_unused_fd_flagsgets failure,userfaultfd_ctx_cachepwill be freed by userfaultfd_fops's release function which is theuserfaultfd_release. So we could return directly afterfput().userfaultfd_release()->userfaultfd_ctx_put(ctx)
Fixes d08ac70b1e0d (Wire UFFD up to SELinux)Reported-by [email protected]Signed-off-by Yanfei Xu <[email protected]>--- fs/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/userfaultfd.c +1
-1@@ -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);
Al Viro
maintainerQuoted 3 lines · Yanfei
ping Al Viro
Could you please help to review this patch? Thanks a lot.
That's -next, right? As for the patch itself... Frankly, Daniel's patch looks seriously wrong.
* why has O_CLOEXEC been quietly smuggled in? It's
a userland ABI change, for fsck sake...
* the double-put you've spotted
* the whole out: thing - just make it
if (IS_ERR(file)) {
userfaultfd_ctx_put(ctx);
return PTR_ERR(file);
}
and be done with that.Quoted 6 lines · Al Viro
Quoted 3 lines · Yanfei
ping Al Viro
Could you please help to review this patch? Thanks a lot.
That's -next, right? As for the patch itself... Frankly,
Yes, it's -next.
Quoted 1 line
Daniel's patch looks seriously wrong.
Get it.
Regards,
Yanfei
Quoted 10 lines
* why has
O_CLOEXECbeen quietly smuggled in? It's
a userland ABI change, for fsck sake...* the double-put you've spotted * the whole out: thing - just make it if (IS_ERR(file)) { userfaultfd_ctx_put(ctx); return PTR_ERR(file); } and be done with that.
Quoted 9 lines · Yanfei
Quoted 5 lines · Al Viro
Quoted 3 lines · Yanfei
ping Al Viro
Could you please help to review this patch? Thanks a lot.
Quoted 17 lines
Quoted 1 line
That's -next, right? As for the patch itself... Frankly,
Yes, it's -next.
Quoted 1 line
Daniel's patch looks seriously wrong.
Get it.
Regards,
YanfeiQuoted 10 lines
* why has
O_CLOEXECbeen quietly smuggled in? It's
a userland ABI change, for fsck sake...* the double-put you've spotted * the whole out: thing - just make it if (IS_ERR(file)) { userfaultfd_ctx_put(ctx); return PTR_ERR(file); } and be done with that.
Adding Lokesh to take a look.