Blacklisting module not working

Started by finotti, 2026/07/07, 13:02:39

Previous topic - Next topic

finotti

I am trying to disable WIFI on my system, unless I want to enable it manually.   I have:

$ inxi -n
Network:
  Device-1: Qualcomm WCN785x Wi-Fi 7 320MHz 2x2 [FastConnect 7800]
    driver: ath12k_wifi7_pci
  IF: wlan0 state: up mac: ac:f2:3c:22:da:a3
  Device-2: Realtek RTL8126 5GbE driver: r8169
  IF: enp10s0 state: up speed: 100 Mbps duplex: full mac: 34:5a:60:03:0a:a5
  IF-ID-1: docker0 state: down mac: 42:f4:6d:fe:20:31
  IF-ID-2: tailscale0 state: unknown speed: -1 duplex: full mac: N/A
So, for a long time I've had blacklisted ath12k:
# cat /etc/modprobe.d/wifi_blacklist.conf
# blacklist wifi!
# to enable:
#  modprobe -v mt7925e
blacklist mt7925e
blacklist ath12k
For a while, this had worked perfectly, but after a recent update (I think), it stopped working.
# lsmod | grep wifi
ath12k_wifi7          143360  0
ath12k                733184  1 ath12k_wifi7
mac80211            1757184  2 ath12k,ath12k_wifi7
cfg80211            1593344  3 ath12k,ath12k_wifi7,mac80211
mhi                  143360  3 ath12k,ath12k_wifi7,qrtr_mhi
Any ideas on what happened and how to fix it?

More info on the system:
$ inxi -v3
System:
  Host: debian Kernel: 7.1.3+deb14-amd64 arch: x86_64 bits: 64 compiler: gcc
    v: 15.3.0
  Desktop: KDE Plasma v: 6.6.5 Distro: siduction 2024.1.0 shine-on - kde -
    (202412261719) base: Debian GNU/Linux forky/sid
Machine:
  Type: Desktop System: Micro-Star product: MS-7E51 v: 1.0
    serial: <superuser required>
  Mobo: Micro-Star model: MAG X870 TOMAHAWK WIFI (MS-7E51) v: 1.0
    serial: <superuser required> Firmware: UEFI vendor: American Megatrends LLC.
    v: 1.A71 date: 01/13/2026
Battery:
  Device-1: hidpp_battery_0 model: Logitech Wireless Mouse M510
    charge: 55% (should be ignored) status: discharging
CPU:
  Info: 8-core model: AMD Ryzen 7 9700X bits: 64 type: MT MCP arch: Zen 5
    rev: 0 cache: L1: 640 KiB L2: 8 MiB L3: 32 MiB
  Speed (MHz): avg: 3595 min/max: 605/5582 boost: enabled cores: 1: 3595
    2: 3595 3: 3595 4: 3595 5: 3595 6: 3595 7: 3595 8: 3595 9: 3595 10: 3595
    11: 3595 12: 3595 13: 3595 14: 3595 15: 3595 16: 3595 bogomips: 121599
  Flags-basic: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a
    ssse3 svm
Graphics:
  Device-1: Advanced Micro Devices [AMD/ATI] Navi 23 [Radeon RX 6600/6600
    XT/6600M] vendor: ASRock driver: amdgpu v: kernel arch: RDNA-2
    bus-ID: 03:00.0
  Device-2: Advanced Micro Devices [AMD/ATI] Granite Ridge [Radeon Graphics]
    vendor: Micro-Star MSI driver: amdgpu v: kernel arch: RDNA-2 bus-ID: 74:00.0
    temp: 32.0 C
  Device-3: Logitech Webcam C270 driver: snd-usb-audio,uvcvideo type: USB
    bus-ID: 5-2.3.2:6
  Display: x11 server: X.Org v: 21.1.23 with: Xwayland v: 24.1.12 driver: X:
    loaded: amdgpu unloaded: fbdev,modesetting,radeon,vesa dri: radeonsi
    gpu: amdgpu resolution: 1: 1920x1080~60Hz 2: 1920x1080~60Hz
  API: OpenGL v: 4.6 vendor: amd mesa v: 26.1.4-1 glx-v: 1.4
    direct-render: yes renderer: AMD Radeon RX 6600 (radeonsi navi23 ACO DRM
    3.64 7.1.3+deb14-amd64)
  Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo
    de: kscreen-console,kscreen-doctor gpu: amdgpu_top wl: wayland-info
    x11: xdriinfo, xdpyinfo, xprop, xrandr
Network:
  Device-1: Qualcomm WCN785x Wi-Fi 7 320MHz 2x2 [FastConnect 7800]
    vendor: Foxconn Band Simultaneous Wireless driver: ath12k_wifi7_pci v: N/A
    bus-ID: 09:00.0
  IF: wlan0 state: up mac: ac:f2:3c:22:da:a3
  Device-2: Realtek RTL8126 5GbE vendor: Micro-Star MSI driver: r8169
    v: kernel port: e000 bus-ID: 0a:00.0
  IF: enp10s0 state: up speed: 100 Mbps duplex: full mac: 34:5a:60:03:0a:a5
  IF-ID-1: docker0 state: down mac: 42:f4:6d:fe:20:31
  IF-ID-2: tailscale0 state: unknown speed: -1 duplex: full mac: N/A
Drives:
  Local Storage: total: 19.1 TiB used: 7.15 TiB (37.4%)
Info:
  Memory: total: 60 GiB note: est. available: 60.38 GiB used: 8.84 GiB (14.6%)
  Processes: 614 Uptime: 1h 12m Init: systemd
  Packages: 5270 Compilers: clang: 21.1.8 gcc: 15.3.0 Shell: Bash v: 5.3.9
    inxi: 3.3.41


PS: I am sorry for posting it in the wrong section of the Forum.  I meant to post in Software, but must have clicked in the wrong place.

hendrikL

Why blacklisting, If I want to disable it I use as root 'rfkill block <ID>', with 'rfkill list' you can see which ID wlan/wifi have.

What about to disable WiFi via networkmanager, nmtui, nmcli or iwctl?

Or use 'systemctl <stop/disable/mask ... unmask/enable/start> iwd.service'.

Do you have a hardware switch?

Teriarch

#2
Here is the reason, why it no longer works:
> blacklist ath12k
You blacklisted ath12k, however:

# lsmod | grep wifi
ath12k_wifi7          143360  0
ath12k                733184  1 ath12k_wifi7
mac80211            1757184  2 ath12k,ath12k_wifi7
cfg80211            1593344  3 ath12k,ath12k_wifi7,mac80211
mhi                  143360  3 ath12k,ath12k_wifi7,qrtr_mhi
ath12k_wifi7          143360  0
ath12k                733184  1 ath12k_wifi7
mac80211            1757184  2 ath12k,ath12k_wifi7
cfg80211            1593344  3 ath12k,ath12k_wifi7,mac80211
mhi                  143360  3 ath12k,ath12k_wifi7,qrtr_mhi

shows that the loading of kernel module ath12k was not triggered
by a direct kernel event.

You know how this works, do you? When the kernel detects new hardware
(either by coldplug or hotplug) it either records the event in the sys filesystem
(for later userspace systemd- udev service to catch up and force the kernel event
trigger, coldplug ) or it submits the event to a netlink socket for already running userspace
udevd to handle it (hotplug, causing a HW interrupt). In any case brave udevd reads the kernel
event by continuously polling the socket and needs to identify the module before causing
modprobe to finish off the job.
The netlink socket provides hardware specific details about the device, in your case:

The Qualcomm WCN785x Wi-Fi 7 (FastConnect 7800) uses the PCI vendor ID  17CBIts
specific PCI device ID is 1107

Hence it fires up modprobe:
/sbin/modprobe -abq pci:v000017CBd00001107sv*sd*bc*sc*i*

In order to identify the module modprobe consults  /lib/modules/7.1.3-1-siduction-amd64/modules.alias
and finds:
alias pci:v000017CBd00001107sv*sd*bc*sc*i* ath12k_wifi7
Now that it knows the name of the module to load, it checks against /etc/modprobe.d/*.conf
to see whether it's blacklisted and low and behold: It'not! But before it finally loads it, it must
also satisfy all module dependencies by consulting  /lib/modules/7.1.3-1-siduction-amd64/modules.dep:

kernel/drivers/net/wireless/ath/ath12k/wifi7/ath12k_wifi7.ko.zst: kernel/drivers/net/wireless/ath/ath12k/ath12k.ko

So prior to loading that, it first must load ath12k, and that is exactly what modprobe does, this time without
consulting the blacklist.

To summarize: Your blacklist no longer works, because ath12k no longer has any HW aliases, as you can see from:
$ sudo modinfo ath12k:

filename:      /lib/modules/7.1.3-1-siduction-amd64/kernel/drivers/net/wireless/ath/ath12k/ath12k.ko.zst
license:        Dual BSD/GPL
description:    Driver support for Qualcomm Technologies WLAN devices
firmware:      ath12k/WCN7850/hw2.0/*
firmware:      ath12k/QCN9274/hw2.0/*
depends:        mac80211,cfg80211,qmi_helpers,mhi
intree:        Y
name:          ath12k
retpoline:      Y
vermagic:      7.1.3-1-siduction-amd64 SMP preempt mod_unload
parm:          debug_mask:Debugging mask (uint)
parm:          ftm_mode:Boots up in factory test mode (bool)

But ath12k_wifi7 has:
$ sudo modinfo ath12k_wifi7

filename:      /lib/modules/7.1.3-1-siduction-amd64/kernel/drivers/net/wireless/ath/ath12k/wifi7/ath12k_wifi7.ko.zst
license:        Dual BSD/GPL
description:    Driver support for Qualcomm Technologies 802.11be WLAN devices
alias:          pci:v000017CBd00001112sv*sd*bc*sc*i*
alias:          pci:v000017CBd00001107sv*sd*bc*sc*i*
alias:          pci:v000017CBd00001109sv*sd*bc*sc*i*
depends:        ath12k,mhi,mac80211,cfg80211
intree:        Y
name:          ath12k_wifi7
retpoline:      Y
vermagic:      7.1.3-1-siduction-amd64 SMP preempt mod_unload

Solution: You should blacklist ath12k_wifi7 rather than ath12k (blacklist only works for aliases, not for
module names, when called).

HTH