2022-06-12 14:37:48

by Dominique Martinet

[permalink] [raw]
Subject: [PATCH 01/06] 9p: fix fid refcount leak in v9fs_vfs_atomic_open_dotl

We need to release directory fid if we fail halfway through open

This fixes fid leaking with xfstests generic 531

Fixes: 6636b6dcc3db ("9p: add refcount to p9_fid struct")
Cc: [email protected]
Reported-by: Tyler Hicks <[email protected]>
Signed-off-by: Dominique Martinet <[email protected]>
---
fs/9p/vfs_inode_dotl.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index d17502a738a9..b6eb1160296c 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -274,6 +274,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (IS_ERR(ofid)) {
err = PTR_ERR(ofid);
p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
+ p9_client_clunk(dfid);
goto out;
}

@@ -285,6 +286,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (err) {
p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n",
err);
+ p9_client_clunk(dfid);
goto error;
}
err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
@@ -292,6 +294,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (err < 0) {
p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n",
err);
+ p9_client_clunk(dfid);
goto error;
}
v9fs_invalidate_inode_attr(dir);
--
2.35.1


2022-06-13 19:37:13

by Tyler Hicks

[permalink] [raw]
Subject: Re: [PATCH 01/06] 9p: fix fid refcount leak in v9fs_vfs_atomic_open_dotl

On 2022-06-12 17:53:24, Dominique Martinet wrote:
> We need to release directory fid if we fail halfway through open
>
> This fixes fid leaking with xfstests generic 531
>
> Fixes: 6636b6dcc3db ("9p: add refcount to p9_fid struct")
> Cc: [email protected]
> Reported-by: Tyler Hicks <[email protected]>

Reviewed-by: Tyler Hicks <[email protected]>

Tyler

> Signed-off-by: Dominique Martinet <[email protected]>
> ---
> fs/9p/vfs_inode_dotl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index d17502a738a9..b6eb1160296c 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -274,6 +274,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
> if (IS_ERR(ofid)) {
> err = PTR_ERR(ofid);
> p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
> + p9_client_clunk(dfid);
> goto out;
> }
>
> @@ -285,6 +286,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
> if (err) {
> p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n",
> err);
> + p9_client_clunk(dfid);
> goto error;
> }
> err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
> @@ -292,6 +294,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
> if (err < 0) {
> p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n",
> err);
> + p9_client_clunk(dfid);
> goto error;
> }
> v9fs_invalidate_inode_attr(dir);
> --
> 2.35.1
>

2022-06-14 14:12:52

by Christian Schoenebeck

[permalink] [raw]
Subject: Re: [PATCH 01/06] 9p: fix fid refcount leak in v9fs_vfs_atomic_open_dotl

On Sonntag, 12. Juni 2022 10:53:24 CEST Dominique Martinet wrote:
> We need to release directory fid if we fail halfway through open
>
> This fixes fid leaking with xfstests generic 531
>
> Fixes: 6636b6dcc3db ("9p: add refcount to p9_fid struct")
> Cc: [email protected]
> Reported-by: Tyler Hicks <[email protected]>
> Signed-off-by: Dominique Martinet <[email protected]>

Reviewed-by: Christian Schoenebeck <[email protected]>

> ---
> fs/9p/vfs_inode_dotl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index d17502a738a9..b6eb1160296c 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -274,6 +274,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct
> dentry *dentry, if (IS_ERR(ofid)) {
> err = PTR_ERR(ofid);
> p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
> + p9_client_clunk(dfid);
> goto out;
> }
>
> @@ -285,6 +286,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct
> dentry *dentry, if (err) {
> p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n",
> err);
> + p9_client_clunk(dfid);
> goto error;
> }
> err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
> @@ -292,6 +294,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct
> dentry *dentry, if (err < 0) {
> p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n",
> err);
> + p9_client_clunk(dfid);
> goto error;
> }
> v9fs_invalidate_inode_attr(dir);