2020-11-07 17:23:08

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 00/21] net: avoid to remove module when its debugfs is being used

When debugfs file is opened, its module should not be removed until
it's closed.
Because debugfs internally uses the module's data.
So, it could access freed memory.

In order to avoid panic, it just sets .owner to THIS_MODULE.
So that all modules will be held when its debugfs file is opened.

Test commands:
cat <<EOF > open.c
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
int fd = open(argv[1], O_RDONLY);

if(fd < 0) {
printf("failed to open\n");
return 1;
}

usleep(3000000);

close(fd);
return 0;
}
EOF
gcc -o open open.c
modprobe netdevsim
echo 1 > /sys/bus/netdevsim/new_device
./open /sys/kernel/debug/netdevsim/netdevsim1/take_snapshot &
modprobe -rv netdevsim

Splat looks like:
[ 75.305876][ T662] BUG: unable to handle page fault for address: fffffbfff8096db4
[ 75.308979][ T662] #PF: supervisor read access in kernel mode
[ 75.311311][ T662] #PF: error_code(0x0000) - not-present page
[ 75.313737][ T662] PGD 1237ee067 P4D 1237ee067 PUD 123612067 PMD 100ba7067 PTE 0
[ 75.316858][ T662] Oops: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI
[ 75.319389][ T662] CPU: 1 PID: 662 Comm: open Not tainted 5.10.0-rc2+ #785
[ 75.322312][ T662] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
[ 75.326429][ T662] RIP: 0010:full_proxy_release+0xca/0x290
[ 75.328712][ T662] Code: c1 ea 03 80 3c 02 00 0f 85 60 01 00 00 49 8d bc 24 80 00 00 00 4c 8b 73 28 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 71 01 00 00 49 8b 84 24 80 00 00 00 48 85 c0 0f
[ 75.336716][ T662] RSP: 0018:ffff88800400fe48 EFLAGS: 00010a06
[ 75.339153][ T662] RAX: dffffc0000000000 RBX: ffff88810139de00 RCX: ffff88810139de28
[ 75.342419][ T662] RDX: 1ffffffff8096db4 RSI: ffff88810139de00 RDI: ffffffffc04b6da0
[ 75.345629][ T662] RBP: ffff8881168342b0 R08: ffff8881168342b0 R09: ffff888110765300
[ 75.348804][ T662] R10: ffff88800400fe88 R11: ffffed1022ac648a R12: ffffffffc04b6d20
[ 75.352052][ T662] R13: ffff88810139de28 R14: ffff8881054a6d00 R15: ffff888110765300
[ 75.355325][ T662] FS: 00007f937b80f4c0(0000) GS:ffff888118e00000(0000) knlGS:0000000000000000
[ 75.358955][ T662] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 75.361634][ T662] CR2: fffffbfff8096db4 CR3: 0000000004292002 CR4: 00000000003706e0
[ 75.364847][ T662] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 75.368003][ T662] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 75.371259][ T662] Call Trace:
[ 75.372655][ T662] __fput+0x1ff/0x820
[ 75.374316][ T662] ? _raw_spin_unlock_irq+0x24/0x30
[ 75.376454][ T662] task_work_run+0xd3/0x170
[ 75.378268][ T662] exit_to_user_mode_prepare+0x14b/0x150
[ 75.380586][ T662] syscall_exit_to_user_mode+0x40/0x250
[ 75.383015][ T662] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 75.385427][ T662] RIP: 0033:0x7f937b3159e4
[ ... ]

v1 -> v2:
- Rebase
- Squash patches into per-driver/subsystem

Taehee Yoo (21):
net: set .owner to THIS_MODULE
mac80211: set .owner to THIS_MODULE
cfg80211: set .owner to THIS_MODULE
netdevsim: set .owner to THIS_MODULE
ieee802154: set .owner to THIS_MODULE
i2400m: set .owner to THIS_MODULE
wlcore: set .owner to THIS_MODULE
wl1251: set .owner to THIS_MODULE
iwlwifi: set .owner to THIS_MODULE
iwlegacy: set .owner to THIS_MODULE
rtlwifi: set .owner to THIS_MODULE
ath11k: set .owner to THIS_MODULE
ath10k: set .owner to THIS_MODULE
wcn36xx: set .owner to THIS_MODULE
wil6210: set .owner to THIS_MODULE
cw1200: set .owner to THIS_MODULE
brcmfmac: set .owner to THIS_MODULE
b43legacy: set .owner to THIS_MODULE
b43: set .owner to THIS_MODULE
mwifiex: mwifiex: set .owner to THIS_MODULE
Bluetooth: set .owner to THIS_MODULE

drivers/net/ieee802154/ca8210.c | 3 ++-
drivers/net/netdevsim/dev.c | 2 ++
drivers/net/netdevsim/health.c | 1 +
drivers/net/netdevsim/udp_tunnels.c | 1 +
drivers/net/wimax/i2400m/debugfs.c | 2 ++
drivers/net/wireless/ath/ath10k/debug.c | 15 ++++++++++-----
drivers/net/wireless/ath/ath11k/debugfs.c | 7 +++++--
drivers/net/wireless/ath/wcn36xx/debug.c | 2 ++
drivers/net/wireless/ath/wil6210/debugfs.c | 19 +++++++++++++++++++
drivers/net/wireless/broadcom/b43/debugfs.c | 1 +
.../net/wireless/broadcom/b43legacy/debugfs.c | 1 +
.../broadcom/brcm80211/brcmfmac/core.c | 1 +
drivers/net/wireless/intel/iwlegacy/3945-rs.c | 1 +
drivers/net/wireless/intel/iwlegacy/4965-rs.c | 3 +++
drivers/net/wireless/intel/iwlegacy/debug.c | 3 +++
.../net/wireless/intel/iwlwifi/dvm/debugfs.c | 3 +++
drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 3 +++
.../net/wireless/intel/iwlwifi/fw/debugfs.c | 3 +++
.../net/wireless/intel/iwlwifi/mvm/debugfs.c | 1 +
.../net/wireless/intel/iwlwifi/mvm/debugfs.h | 3 +++
drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 3 +++
.../net/wireless/intel/iwlwifi/pcie/trans.c | 3 +++
.../net/wireless/marvell/mwifiex/debugfs.c | 3 +++
drivers/net/wireless/realtek/rtlwifi/debug.c | 1 +
drivers/net/wireless/st/cw1200/debug.c | 1 +
drivers/net/wireless/ti/wl1251/debugfs.c | 4 ++++
drivers/net/wireless/ti/wlcore/debugfs.h | 3 +++
net/6lowpan/debugfs.c | 1 +
net/batman-adv/log.c | 1 +
net/bluetooth/6lowpan.c | 1 +
net/bluetooth/hci_core.c | 2 ++
net/bluetooth/hci_debugfs.c | 6 ++++++
net/bluetooth/selftest.c | 1 +
net/bluetooth/smp.c | 2 ++
net/mac80211/debugfs.c | 7 +++++++
net/mac80211/debugfs_key.c | 3 +++
net/mac80211/debugfs_netdev.c | 1 +
net/mac80211/debugfs_sta.c | 2 ++
net/mac80211/rate.c | 1 +
net/mac80211/rc80211_minstrel_ht_debugfs.c | 2 ++
net/wireless/debugfs.c | 2 ++
41 files changed, 117 insertions(+), 8 deletions(-)

--
2.17.1


2020-11-07 17:23:30

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 01/21] net: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 9e466250ede3 ("batman-adv: Prefix bat_debugfs local static functions with batadv_")
Fixes: 5609c185f24d ("6lowpan: iphc: add support for stateful compression")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

net/6lowpan/debugfs.c | 1 +
net/batman-adv/log.c | 1 +
2 files changed, 2 insertions(+)

diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
index 1c140af06d52..2f791ccc783b 100644
--- a/net/6lowpan/debugfs.c
+++ b/net/6lowpan/debugfs.c
@@ -161,6 +161,7 @@ static const struct file_operations lowpan_ctx_pfx_fops = {
.write = lowpan_ctx_pfx_write,
.llseek = seq_lseek,
.release = single_release,
+ .owner = THIS_MODULE,
};

static void lowpan_dev_debugfs_ctx_init(struct net_device *dev,
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index a67b2b091447..c0ca5fbe5b08 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -180,6 +180,7 @@ static const struct file_operations batadv_log_fops = {
.read = batadv_log_read,
.poll = batadv_log_poll,
.llseek = no_llseek,
+ .owner = THIS_MODULE,
};

/**
--
2.17.1

2020-11-07 17:23:42

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 02/21] mac80211: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: e9f207f0ff90 ("[MAC80211]: Add debugfs attributes.")
Fixes: 4b7679a561e5 ("mac80211: clean up rate control API")
Fixes: ec8aa669b839 ("mac80211: add the minstrel_ht rate control algorithm")
Fixes: 2cae0b6a70d6 ("mac80211: add new Minstrel-HT statistic output via csv")
Fixes: d0a77c6569ab ("mac80211: allow writing TX PN in debugfs")
Fixes: 8f20fc24986a ("[MAC80211]: embed key conf in key, fix driver interface")
Fixes: a75b4363eaaf ("mac80211: allow controlling aggregation manually")
Fixes: 9399b86c0e9a ("mac80211: add debug knobs for fair queuing")
Fixes: e322c07f8371 ("mac80211: debugfs: improve airtime_flags handler readability")
Fixes: 3ace10f5b5ad ("mac80211: Implement Airtime-based Queue Limit (AQL)")
Fixes: 276d9e82e06c ("mac80211: debugfs option to force TX status frames")
Fixes: 827b1fb44b7e ("mac80211: resume properly, add suspend/resume test")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

net/mac80211/debugfs.c | 7 +++++++
net/mac80211/debugfs_key.c | 3 +++
net/mac80211/debugfs_netdev.c | 1 +
net/mac80211/debugfs_sta.c | 2 ++
net/mac80211/rate.c | 1 +
net/mac80211/rc80211_minstrel_ht_debugfs.c | 2 ++
6 files changed, 16 insertions(+)

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 90470392fdaa..abbfc1bbdb8b 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -46,6 +46,7 @@ static const struct file_operations name## _ops = { \
.read = name## _read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_READONLY_FILE(name, fmt, value...) \
@@ -148,6 +149,7 @@ static const struct file_operations aqm_ops = {
.read = aqm_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t airtime_flags_read(struct file *file,
@@ -201,6 +203,7 @@ static const struct file_operations airtime_flags_ops = {
.read = airtime_flags_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t aql_txq_limit_read(struct file *file,
@@ -282,6 +285,7 @@ static const struct file_operations aql_txq_limit_ops = {
.read = aql_txq_limit_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t force_tx_status_read(struct file *file,
@@ -334,6 +338,7 @@ static const struct file_operations force_tx_status_ops = {
.read = force_tx_status_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

#ifdef CONFIG_PM
@@ -354,6 +359,7 @@ static const struct file_operations reset_ops = {
.write = reset_write,
.open = simple_open,
.llseek = noop_llseek,
+ .owner = THIS_MODULE,
};
#endif

@@ -537,6 +543,7 @@ static const struct file_operations stats_ ##name## _ops = { \
.read = stats_ ##name## _read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_STATS_ADD(name) \
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 98a713475e0f..d7c0c28045ef 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -30,6 +30,7 @@ static const struct file_operations key_ ##name## _ops = { \
.read = key_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define KEY_OPS_W(name) \
@@ -38,6 +39,7 @@ static const struct file_operations key_ ##name## _ops = { \
.write = key_##name##_write, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define KEY_FILE(name, format) \
@@ -53,6 +55,7 @@ static const struct file_operations key_ ##name## _ops = { \
.read = key_conf_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define KEY_CONF_FILE(name, format) \
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index fe8a7a87e513..8efa31ae7334 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -127,6 +127,7 @@ static const struct file_operations name##_ops = { \
.write = (_write), \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define _IEEE80211_IF_FILE_R_FN(name) \
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 829dcad69c2c..9ce49346c32a 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -34,6 +34,7 @@ static const struct file_operations sta_ ##name## _ops = { \
.read = sta_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define STA_OPS_RW(name) \
@@ -42,6 +43,7 @@ static const struct file_operations sta_ ##name## _ops = { \
.write = sta_##name##_write, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define STA_FILE(name, field, format) \
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 45927202c71c..bbb691119a44 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -225,6 +225,7 @@ const struct file_operations rcname_ops = {
.read = rcname_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};
#endif

diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index bebb71917742..cdb51aa460a3 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -173,6 +173,7 @@ static const struct file_operations minstrel_ht_stat_fops = {
.read = minstrel_stats_read,
.release = minstrel_stats_release,
.llseek = no_llseek,
+ .owner = THIS_MODULE,
};

static char *
@@ -311,6 +312,7 @@ static const struct file_operations minstrel_ht_stat_csv_fops = {
.read = minstrel_stats_read,
.release = minstrel_stats_release,
.llseek = no_llseek,
+ .owner = THIS_MODULE,
};

void
--
2.17.1

2020-11-07 17:24:11

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 04/21] netdevsim: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 82c93a87bf8b ("netdevsim: implement couple of testing devlink health reporters")
Fixes: 424be63ad831 ("netdevsim: add UDP tunnel port offload support")
Fixes: 4418f862d675 ("netdevsim: implement support for devlink region and snapshots")
Fixes: d3cbb907ae57 ("netdevsim: add ACL trap reporting cookie as a metadata")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/netdevsim/dev.c | 2 ++
drivers/net/netdevsim/health.c | 1 +
drivers/net/netdevsim/udp_tunnels.c | 1 +
3 files changed, 4 insertions(+)

diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index d07061417675..e7972e88ffe0 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -96,6 +96,7 @@ static const struct file_operations nsim_dev_take_snapshot_fops = {
.open = simple_open,
.write = nsim_dev_take_snapshot_write,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
@@ -188,6 +189,7 @@ static const struct file_operations nsim_dev_trap_fa_cookie_fops = {
.read = nsim_dev_trap_fa_cookie_read,
.write = nsim_dev_trap_fa_cookie_write,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 62958b238d50..21e2974660e7 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -261,6 +261,7 @@ static const struct file_operations nsim_dev_health_break_fops = {
.open = simple_open,
.write = nsim_dev_health_break_write,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

int nsim_dev_health_init(struct nsim_dev *nsim_dev, struct devlink *devlink)
diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c
index 6ab023acefd6..02dc3123eb6c 100644
--- a/drivers/net/netdevsim/udp_tunnels.c
+++ b/drivers/net/netdevsim/udp_tunnels.c
@@ -124,6 +124,7 @@ static const struct file_operations nsim_udp_tunnels_info_reset_fops = {
.open = simple_open,
.write = nsim_udp_tunnels_info_reset_write,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,
--
2.17.1

2020-11-07 17:24:55

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 08/21] wl1251: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 2f01a1f58889 ("wl12xx: add driver")
Fixes: b7339b1de0f7 ("wl1251: add tx queue status to debugfs")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/wireless/ti/wl1251/debugfs.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ti/wl1251/debugfs.c b/drivers/net/wireless/ti/wl1251/debugfs.c
index d48746e640cc..0a26cee0f287 100644
--- a/drivers/net/wireless/ti/wl1251/debugfs.c
+++ b/drivers/net/wireless/ti/wl1251/debugfs.c
@@ -35,6 +35,7 @@ static const struct file_operations name## _ops = { \
.read = name## _read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_ADD(name, parent) \
@@ -67,6 +68,7 @@ static const struct file_operations sub## _ ##name## _ops = { \
.read = sub## _ ##name## _read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_FWSTATS_ADD(sub, name) \
@@ -212,6 +214,7 @@ static const struct file_operations tx_queue_len_ops = {
.read = tx_queue_len_read,
.open = simple_open,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
@@ -234,6 +237,7 @@ static const struct file_operations tx_queue_status_ops = {
.read = tx_queue_status_read,
.open = simple_open,
.llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
};

static void wl1251_debugfs_delete_files(struct wl1251 *wl)
--
2.17.1

2020-11-07 17:25:05

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 09/21] iwlwifi: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 5ae212c9273d ("[PATCH] iwlwifi: add read rate scale table debugfs function")
Fixes: 0209dc11c769 ("[PATCH] iwlwifi: add debugfs rate scale stats")
Fixes: 712b6cf57a53 ("iwlwifi: Add debugfs to iwl core")
Fixes: 189a2b5942d6 ("iwlwifi: trigger event log from debugfs")
Fixes: 8ca151b568b6 ("iwlwifi: add the MVM driver")
Fixes: 757cf23b4b4b ("iwlwifi: mvm: add per rate tx stats")
Fixes: 2b55f43f8e47 ("iwlwifi: mvm: Add mem debugfs entry")
Fixes: 93b167c13a3a ("iwlwifi: runtime: sync FW and host clocks for logs")
Fixes: 38167459da50 ("iwlagn: show current rate scale data in debugfs")
Fixes: 87e5666c0722 ("iwlagn: transport handler can register debugfs entries")
Fixes: 16db88ba51d6 ("iwlagn: move dump_csr and dump_fh to transport layer")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c | 3 +++
drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 3 +++
drivers/net/wireless/intel/iwlwifi/fw/debugfs.c | 3 +++
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 1 +
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h | 3 +++
drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 3 +++
drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 +++
7 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
index 911049201838..a1022987eccf 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
@@ -34,6 +34,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_WRITE_FILE_OPS(name) \
@@ -41,6 +42,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.write = iwl_dbgfs_##name##_write, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};


@@ -50,6 +52,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

static ssize_t iwl_dbgfs_sram_read(struct file *file,
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
index 548540dd0c0f..1518dead1e47 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
@@ -3172,6 +3172,7 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
.read = rs_sta_dbgfs_scale_table_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};
static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
char __user *user_buf, size_t count, loff_t *ppos)
@@ -3215,6 +3216,7 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
.read = rs_sta_dbgfs_stats_table_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
@@ -3241,6 +3243,7 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
.read = rs_sta_dbgfs_rate_scale_data_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static void rs_add_debugfs(void *priv, void *priv_sta,
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
index 267ad4eddb5c..5f41c8587ac6 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
@@ -122,6 +122,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.open = _iwl_dbgfs_##name##_open, \
.llseek = generic_file_llseek, \
.release = _iwl_dbgfs_release, \
+ .owner = THIS_MODULE, \
}

#define FWRT_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype) \
@@ -150,6 +151,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.open = _iwl_dbgfs_##name##_open, \
.llseek = generic_file_llseek, \
.release = _iwl_dbgfs_release, \
+ .owner = THIS_MODULE, \
}

#define _FWRT_DEBUGFS_WRITE_FILE_OPS(name, buflen, argtype) \
@@ -160,6 +162,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.open = _iwl_dbgfs_##name##_open, \
.llseek = generic_file_llseek, \
.release = _iwl_dbgfs_release, \
+ .owner = THIS_MODULE, \
}

#define FWRT_DEBUGFS_READ_FILE_OPS(name, bufsz) \
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 3395c4675988..d4b9ef8b25ee 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -1981,6 +1981,7 @@ static const struct file_operations iwl_dbgfs_mem_ops = {
.write = iwl_dbgfs_mem_write,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
index a83d252c0602..5bf4f7801b83 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
@@ -63,6 +63,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}

#define MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype) \
@@ -87,6 +88,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define _MVM_DEBUGFS_WRITE_FILE_OPS(name, buflen, argtype) \
@@ -95,4 +97,5 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.write = _iwl_dbgfs_##name##_write, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index ed7382e7ea17..853c3969c956 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -3909,6 +3909,7 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
.read = rs_sta_dbgfs_scale_table_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};
static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
char __user *user_buf, size_t count, loff_t *ppos)
@@ -3956,6 +3957,7 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
.read = rs_sta_dbgfs_stats_table_read,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t rs_sta_dbgfs_drv_tx_stats_read(struct file *file,
@@ -4046,6 +4048,7 @@ static const struct file_operations rs_sta_dbgfs_drv_tx_stats_ops = {
.write = rs_sta_dbgfs_drv_tx_stats_write,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static ssize_t iwl_dbgfs_ss_force_read(struct file *file,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index d2e69ad53b27..250b7883703c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2476,6 +2476,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_WRITE_FILE_OPS(name) \
@@ -2483,6 +2484,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.write = iwl_dbgfs_##name##_write, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
@@ -2491,6 +2493,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
.read = iwl_dbgfs_##name##_read, \
.open = simple_open, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
};

struct iwl_dbgfs_tx_queue_priv {
--
2.17.1

2020-11-07 17:25:32

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 11/21] rtlwifi: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 610247f46feb ("rtlwifi: Improve debugging by using debugfs")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline

drivers/net/wireless/realtek/rtlwifi/debug.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c b/drivers/net/wireless/realtek/rtlwifi/debug.c
index 901cdfe3723c..c8ffd4ca9c09 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.c
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
@@ -69,6 +69,7 @@ static const struct file_operations file_ops_common = {
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
+ .owner = THIS_MODULE,
};

static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
--
2.17.1

2020-11-07 17:25:32

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 12/21] ath11k: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/wireless/ath/ath11k/debugfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 1b914e67d314..bce9f9512833 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -593,7 +593,8 @@ static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
static const struct file_operations fops_extd_tx_stats = {
.read = ath11k_read_enable_extd_tx_stats,
.write = ath11k_write_enable_extd_tx_stats,
- .open = simple_open
+ .open = simple_open,
+ .owner = THIS_MODULE,
};

static ssize_t ath11k_write_extd_rx_stats(struct file *file,
@@ -686,6 +687,7 @@ static const struct file_operations fops_extd_rx_stats = {
.read = ath11k_read_extd_rx_stats,
.write = ath11k_write_extd_rx_stats,
.open = simple_open,
+ .owner = THIS_MODULE,
};

static int ath11k_fill_bp_stats(struct ath11k_base *ab,
@@ -1047,7 +1049,8 @@ static ssize_t ath11k_write_simulate_radar(struct file *file,

static const struct file_operations fops_simulate_radar = {
.write = ath11k_write_simulate_radar,
- .open = simple_open
+ .open = simple_open,
+ .owner = THIS_MODULE,
};

int ath11k_debugfs_register(struct ath11k *ar)
--
2.17.1

2020-11-07 17:26:11

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 15/21] wil6210: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 2be7d22f0625 ("wireless: add new wil6210 802.11ad 60GHz driver")
Fixes: 0b39aaf2f203 ("wil6210: Tx mgmt frame from debugfs")
Fixes: c5b3a6582b1e ("wil6210: Add support for setting RBUFCAP configuration")
Fixes: 3277213feb1b ("wil6210: ADDBA/DELBA flows")
Fixes: dc16427bbe65 ("wil6210: Add pmc debug mechanism memory management")
Fixes: 977c45ab5f41 ("wil6210: add debugfs to show PMC ring content")
Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command")
Fixes: c33407a8c504 ("wil6210: manual FW error recovery mode")
Fixes: a24a3d6abb97 ("wil6210: add TX latency statistics")
Fixes: 0c936b3c9633 ("wil6210: add support for link statistics")
Fixes: 10d599ad84a1 ("wil6210: add support for device led configuration")
Fixes: 12bace75704e ("wil6210: extract firmware capabilities from FW file")
Fixes: 13cd9f758a55 ("wil6210: extract firmware version from file header")
Fixes: fe9ee51e6a43 ("wil6210: add support for PCIe D3hot in system suspend")
Fixes: 96c93589e2df ("wil6210: initialize TX and RX enhanced DMA rings")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/wireless/ath/wil6210/debugfs.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 2d618f90afa7..799493739771 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -678,6 +678,7 @@ static const struct file_operations fops_ioblob = {
.read = wil_read_file_ioblob,
.open = simple_open,
.llseek = default_llseek,
+ .owner = THIS_MODULE,
};

static
@@ -729,6 +730,7 @@ static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
static const struct file_operations fops_rxon = {
.write = wil_write_file_rxon,
.open = simple_open,
+ .owner = THIS_MODULE,
};

static ssize_t wil_write_file_rbufcap(struct file *file,
@@ -767,6 +769,7 @@ static ssize_t wil_write_file_rbufcap(struct file *file,
static const struct file_operations fops_rbufcap = {
.write = wil_write_file_rbufcap,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/* block ack control, write:
@@ -865,6 +868,7 @@ static const struct file_operations fops_back = {
.read = wil_read_back,
.write = wil_write_back,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/* pmc control, write:
@@ -941,12 +945,14 @@ static const struct file_operations fops_pmccfg = {
.read = wil_read_pmccfg,
.write = wil_write_pmccfg,
.open = simple_open,
+ .owner = THIS_MODULE,
};

static const struct file_operations fops_pmcdata = {
.open = simple_open,
.read = wil_pmc_read,
.llseek = wil_pmc_llseek,
+ .owner = THIS_MODULE,
};

static int wil_pmcring_seq_open(struct inode *inode, struct file *file)
@@ -959,6 +965,7 @@ static const struct file_operations fops_pmcring = {
.release = single_release,
.read = seq_read,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

/*---tx_mgmt---*/
@@ -996,6 +1003,7 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
static const struct file_operations fops_txmgmt = {
.write = wil_write_file_txmgmt,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/* Write WMI command (w/o mbox header) to this file to send it
@@ -1039,6 +1047,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
static const struct file_operations fops_wmi = {
.write = wil_write_file_wmi,
.open = simple_open,
+ .owner = THIS_MODULE,
};

static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb)
@@ -1558,6 +1567,7 @@ static const struct file_operations fops_recovery = {
.read = wil_read_file_recovery,
.write = wil_write_file_recovery,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/*---------Station matrix------------*/
@@ -1836,6 +1846,7 @@ static const struct file_operations fops_tx_latency = {
.read = seq_read,
.write = wil_tx_latency_write,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

static void wil_link_stats_print_basic(struct wil6210_vif *vif,
@@ -1999,6 +2010,7 @@ static const struct file_operations fops_link_stats = {
.read = seq_read,
.write = wil_link_stats_write,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

static int
@@ -2053,6 +2065,7 @@ static const struct file_operations fops_link_stats_global = {
.read = seq_read,
.write = wil_link_stats_global_write,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
@@ -2100,6 +2113,7 @@ static const struct file_operations fops_led_cfg = {
.read = wil_read_file_led_cfg,
.write = wil_write_file_led_cfg,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/* led_blink_time, write:
@@ -2165,6 +2179,7 @@ static const struct file_operations fops_led_blink_time = {
.read = wil_read_led_blink_time,
.write = wil_write_led_blink_time,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/*---------FW capabilities------------*/
@@ -2189,6 +2204,7 @@ static const struct file_operations fops_fw_capabilities = {
.release = single_release,
.read = seq_read,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

/*---------FW version------------*/
@@ -2215,6 +2231,7 @@ static const struct file_operations fops_fw_version = {
.release = single_release,
.read = seq_read,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

/*---------suspend_stats---------*/
@@ -2275,6 +2292,7 @@ static const struct file_operations fops_suspend_stats = {
.read = wil_read_suspend_stats,
.write = wil_write_suspend_stats,
.open = simple_open,
+ .owner = THIS_MODULE,
};

/*---------compressed_rx_status---------*/
@@ -2329,6 +2347,7 @@ static const struct file_operations fops_compressed_rx_status = {
.read = seq_read,
.write = wil_compressed_rx_status_write,
.llseek = seq_lseek,
+ .owner = THIS_MODULE,
};

/*----------------*/
--
2.17.1

2020-11-07 17:26:12

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 17/21] brcmfmac: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 2f8c8e62cd50 ("brcmfmac: add "reset" debugfs entry for testing reset")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline

drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 3dd28f5fef19..a80b28189c99 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1188,6 +1188,7 @@ static const struct file_operations bus_reset_fops = {
.open = simple_open,
.llseek = no_llseek,
.write = bus_reset_write,
+ .owner = THIS_MODULE,
};

static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
--
2.17.1

2020-11-07 17:26:16

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 18/21] b43legacy: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 75388acd0cd8 ("[B43LEGACY]: add mac80211-based driver for legacy BCM43xx devices")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline

drivers/net/wireless/broadcom/b43legacy/debugfs.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/broadcom/b43legacy/debugfs.c b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
index e7e4293c01f2..7c6e7cfeb822 100644
--- a/drivers/net/wireless/broadcom/b43legacy/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
@@ -318,6 +318,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
.read = b43legacy_debugfs_read, \
.write = b43legacy_debugfs_write, \
.llseek = generic_file_llseek, \
+ .owner = THIS_MODULE, \
}, \
.file_struct_offset = offsetof(struct b43legacy_dfsentry, \
file_##name), \
--
2.17.1

2020-11-07 17:26:23

by Taehee Yoo

[permalink] [raw]
Subject: [PATCH net v2 20/21] mwifiex: mwifiex: set .owner to THIS_MODULE

If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.

Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Signed-off-by: Taehee Yoo <[email protected]>
---

v1 -> v2:
- Change headline
- Squash patches into per-driver/subsystem

drivers/net/wireless/marvell/mwifiex/debugfs.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index dded92db1f37..641113260439 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -931,18 +931,21 @@ static const struct file_operations mwifiex_dfs_##name##_fops = { \
.read = mwifiex_##name##_read, \
.write = mwifiex_##name##_write, \
.open = simple_open, \
+ .owner = THIS_MODULE, \
};

#define MWIFIEX_DFS_FILE_READ_OPS(name) \
static const struct file_operations mwifiex_dfs_##name##_fops = { \
.read = mwifiex_##name##_read, \
.open = simple_open, \
+ .owner = THIS_MODULE, \
};

#define MWIFIEX_DFS_FILE_WRITE_OPS(name) \
static const struct file_operations mwifiex_dfs_##name##_fops = { \
.write = mwifiex_##name##_write, \
.open = simple_open, \
+ .owner = THIS_MODULE, \
};


--
2.17.1

2020-11-07 17:42:22

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH net v2 17/21] brcmfmac: set .owner to THIS_MODULE

On November 7, 2020 6:25:15 PM Taehee Yoo <[email protected]> wrote:

> If THIS_MODULE is not set, the module would be removed while debugfs is
> being used.
> It eventually makes kernel panic.

Is this really a valid concern in the context of debugs? I tend to say it
is not. Whenever I am using debugs to debug my driver I make sure to avoid
removing it.

Regards,
Arend



Attachments:
smime.p7s (4.08 kB)
S/MIME Cryptographic Signature

2020-11-07 19:53:46

by Taehee Yoo

[permalink] [raw]
Subject: Re: [PATCH net v2 00/21] net: avoid to remove module when its debugfs is being used

On Sun, 8 Nov 2020 at 04:05, Jakub Kicinski <[email protected]> wrote:
>

Hi Jakub,
Thank you for the review!

> On Sat, 7 Nov 2020 17:21:31 +0000 Taehee Yoo wrote:
> > When debugfs file is opened, its module should not be removed until
> > it's closed.
> > Because debugfs internally uses the module's data.
> > So, it could access freed memory.
> >
> > In order to avoid panic, it just sets .owner to THIS_MODULE.
> > So that all modules will be held when its debugfs file is opened.
>
> Hm, looks like some of the patches need to be revised because
> .owner is already set in the ops, and a warning gets generated.

Thanks, I found my mistake via patchwork.
I will fix this problem.

>
> Also it'd be good to mention why Johannes's approach was abandoned.

I'm sorry about skipping the explanation of the situation,
Johannes sent RFC[1], which fixes this problem in the debugfs core logic.
I tested it and it actually avoids this problem well.
And I think there would be more discussion.
So, I thought this series' approach is reasonable right now.
I think setting .owner to THIS_MODULE is a common behavior and it
doesn't hurt our logic even if Johannes's approach is merged.
I'm expecting that both approaches of this series and Johannes are
doing separately.

[1] https://www.spinics.net/lists/linux-wireless/msg204171.html

>
> When you repost please separate out all the patches for
> drivers/net/wireless/ and send that to Kalle's wireless drivers tree.
> Patch 1 needs to be split in two. Patches 2 and 3 would go via Johannes.
> The wimax patch needs to go to staging (wimax code has been moved).
> The remaining patches can be posted individually, not as a series.

Okay, I will do this.

Thanks a lot!
Taehee Yoo