mac80211: don’t attempt to rename ERR_PTR() debugfs dirs [Linux 3.16.72]

This Linux kernel change "mac80211: don’t attempt to rename ERR_PTR() debugfs dirs" is included in the Linux 3.16.72 release. This change is authored by Johannes Berg <johannes.berg [at] intel.com> on Mon Apr 15 11:39:33 2019 +0200. The commit for this change in Linux stable tree is 3ecce42 (patch) which is from upstream commit 5178791. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 5178791.

mac80211: don't attempt to rename ERR_PTR() debugfs dirs

commit 517879147493a5e1df6b89a50f708f1133fcaddb upstream.

We need to dereference the directory to get its parent to
be able to rename it, so it's clearly not safe to try to
do this with ERR_PTR() pointers. Skip in this case.

It seems that this is most likely what was causing the
report by syzbot, but I'm not entirely sure as it didn't
come with a reproducer this time.

Reported-by: [email protected]
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

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

diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 1ab5e1a..607d8fd 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -735,7 +735,7 @@ void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)

    dir = sdata->vif.debugfs_dir;

-   if (!dir)
+   if (IS_ERR_OR_NULL(dir))
        return;

    sprintf(buf, "netdev:%s", sdata->name);

Leave a Reply

Your email address will not be published. Required fields are marked *