Skip to contentSkip to conversation

rpc: properly check debugfs dentry before using it

PATCH In review Greg Kroah-Hartman 2 participants 3 messages Feb 12, 2019 – Feb 13, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpc: properly check debugfs dentry before using it

debugfs can now report an error code if something went wrong instead of just NULL. So if the return value is to be used as a "real" dentry, it needs to be checked if it is an error before dereferencing it.

This is now happening because of ff9fb72bc077 ("debugfs: return error values, not NULL"), but why debugfs files are not being created properly is an older issue, probably one that has always been there and should probably be looked at...

---
 net/sunrpc/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I can take this through my tree if people don't object, or it can go through the NFS tree. It does need to get merged before 5.0-final though.

I also have a "larger" debugfs cleanup patch for this file, but that's not really 5.0-final material and I will send it out later.

thanks,

greg k-h

net/sunrpc/debugfs.c +1 -1
index 45a033329cd4..19bb356230ed 100644
@@ -146,7 +146,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
 	rcu_read_lock();
 	xprt = rcu_dereference(clnt->cl_xprt);
 	/* no "debugfs" dentry? Don't bother with the symlink. */
-	if (!xprt->debugfs) {
+	if (IS_ERR_OR_NULL(xprt->debugfs)) {
 		rcu_read_unlock();
 		return;
 	}
#1 lore raw
Quoted 19 lines · Greg Kroah-Hartman

debugfs can now report an error code if something went wrong instead of just NULL. So if the return value is to be used as a "real" dentry, it needs to be checked if it is an error before dereferencing it.

This is now happening because of ff9fb72bc077 ("debugfs: return error values, not NULL"), but why debugfs files are not being created properly is an older issue, probably one that has always been there and should probably be looked at...

Quoted 7 lines
---
 net/sunrpc/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I can take this through my tree if people don't object, or it can go through the NFS tree. It does need to get merged before 5.0-final though.

I'm planning another bugfixes pull for 5.0, so I can take this patch and send it with the others this week.

Thanks!
Anna

Quoted 21 lines

I also have a "larger" debugfs cleanup patch for this file, but that's not really 5.0-final material and I will send it out later.

thanks,

greg k-h

net/sunrpc/debugfs.c +1 -1
index 45a033329cd4..19bb356230ed 100644
@@ -146,7 +146,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
        rcu_read_lock();
        xprt = rcu_dereference(clnt->cl_xprt);
        /* no "debugfs" dentry? Don't bother with the symlink. */
-       if (!xprt->debugfs) {
+       if (IS_ERR_OR_NULL(xprt->debugfs)) {
                rcu_read_unlock();
                return;
        }
#2 lore raw
Quoted 24 lines · Anna
Quoted 23 lines · Greg Kroah-Hartman

debugfs can now report an error code if something went wrong instead of just NULL. So if the return value is to be used as a "real" dentry, it needs to be checked if it is an error before dereferencing it.

This is now happening because of ff9fb72bc077 ("debugfs: return error values, not NULL"), but why debugfs files are not being created properly is an older issue, probably one that has always been there and should probably be looked at...

---
 net/sunrpc/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 3 lines

I can take this through my tree if people don't object, or it can go through the NFS tree. It does need to get merged before 5.0-final though.

I'm planning another bugfixes pull for 5.0, so I can take this patch and send it with the others this week.

Wonderful, thanks for doing this, and sorry for the regression.

greg k-h