File broadcom-wl.linux-6.15.patch of Package broadcom-wl (Revision f7429719e035affcb7118f75a2d3dd42)

Currently displaying revision f7429719e035affcb7118f75a2d3dd42 , Show latest

136
 
1
From a0acb522ad849b2e2a3019794a293fdeb717ba03 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <joanbrugueram@gmail.com>
3
Date: Sun, 23 Feb 2025 14:29:21 +0000
4
Subject: [PATCH] Tentative patch for broadcom-wl 6.30.223.271 driver for Linux
5
 6.15-rc1
6
7
Due to the fact that the driver is unmaintained, and can't be adapted
8
to the current Linux kernel security standards (e.g. IBT), as it has a
9
proprietary blob; and this is likely to be an ever-growing security
10
risk, I have added a warning when the module is loaded.
11
Use at your own risk; no warranty of any kind is provided.
12
See also the objtool changes on the Makefile below.
13
14
The changes to replace EXTRA_CFLAGS and EXTRA_LDFLAGS with ccflags-y
15
and ldflags-y are rel. commit "kbuild: remove EXTRA_*FLAGS support"
16
(Masahiro Yamada, 6 Feb 2025), according to which they have been
17
deprecated since 2007, so no need to add any fallback for old kernels.
18
19
NB: If the package build also contains references to EXTRA_*FLAGS
20
(e.g. Arch Linux's broadcom-wl-dkms PKGBUILD), replace those as well!
21
---
22
 Makefile              | 33 ++++++++++++++++++++++++---------
23
 src/wl/sys/wl_linux.c | 11 +++++++++++
24
 2 files changed, 35 insertions(+), 9 deletions(-)
25
26
diff --git a/Makefile b/Makefile
27
index a323a0d..3cca0ca 100644
28
--- a/Makefile
29
+++ b/Makefile
30
@@ -117,15 +117,15 @@ GCCVERSION := $(subst $(space),$(empty),$(GCCVERSION))
31
 GCCVERSION := $(shell expr `echo $(GCCVERSION)` | cut -b1-3)
32
 GE_49 := $(shell expr `echo $(GCCVERSION)` \>= 490)
33
 
34
-EXTRA_CFLAGS :=
35
+ccflags-y :=
36
 
37
 ifeq ($(APIFINAL),CFG80211)
38
-  EXTRA_CFLAGS += -DUSE_CFG80211
39
+  ccflags-y += -DUSE_CFG80211
40
   $(info Using CFG80211 API)
41
 endif
42
 
43
 ifeq ($(APIFINAL),WEXT)
44
-  EXTRA_CFLAGS += -DUSE_IW
45
+  ccflags-y += -DUSE_IW
46
   $(info Using Wireless Extension API)
47
 endif
48
 
49
@@ -137,17 +137,17 @@ wl-objs            += src/wl/sys/wl_linux.o
50
 wl-objs            += src/wl/sys/wl_iw.o
51
 wl-objs            += src/wl/sys/wl_cfg80211_hybrid.o
52
 
53
-EXTRA_CFLAGS       += -I$(src)/src/include -I$(src)/src/common/include
54
-EXTRA_CFLAGS       += -I$(src)/src/wl/sys -I$(src)/src/wl/phy -I$(src)/src/wl/ppr/include
55
-EXTRA_CFLAGS       += -I$(src)/src/shared/bcmwifi/include
56
-#EXTRA_CFLAGS       += -DBCMDBG_ASSERT -DBCMDBG_ERR
57
+ccflags-y          += -I$(src)/src/include -I$(src)/src/common/include
58
+ccflags-y          += -I$(src)/src/wl/sys -I$(src)/src/wl/phy -I$(src)/src/wl/ppr/include
59
+ccflags-y          += -I$(src)/src/shared/bcmwifi/include
60
+#ccflags-y          += -DBCMDBG_ASSERT -DBCMDBG_ERR
61
 ifeq "$(GE_49)" "1"
62
-EXTRA_CFLAGS       += -Wno-date-time
63
+ccflags-y          += -Wno-date-time
64
 endif
65
 
66
-EXTRA_CFLAGS       += -Wno-date-time
67
+ccflags-y          += -Wno-date-time
68
69
-EXTRA_LDFLAGS      := $(src)/lib/wlc_hybrid.o_shipped
70
+ldflags-y          := $(src)/lib/wlc_hybrid.o_shipped
71
 
72
 KBASE              ?= /lib/modules/${KV_FULL}
73
 KBUILD_DIR         ?= $(KBASE)/build
74
@@ -155,6 +155,21 @@ MDEST_DIR          ?= $(KBASE)/kernel/drivers/net/wireless
75
 CROSS_TOOLS        = /path/to/tools
76
 CROSS_KBUILD_DIR   = /path/to/kernel/tree
77
 
78
+# Rel. commit "objtool: Always fail on fatal errors" (Josh Poimboeuf, 31 Mar 2025)
79
+# This is a *ugly* hack to disable objtool during the final processing of wl.o.
80
+# Since is embeds the proprietary blob (wlc_hybrid.o_shipped), objtool can't
81
+# process it, as it does not follow the requirements of current kernels,
82
+# including support for critical security features. As of Linux v6.15+, it causes
83
+# a build error. Disable it, at your own risk. Note the MIT license applies:
84
+# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
90
+# SOFTWARE.
91
+wl.o: override objtool-enabled =
92
+
93
 all:
94
    KBUILD_NOPEDANTIC=1 make -C $(KBUILD_DIR) M=`pwd`
95
 
96
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
97
index 5ddbc4d..09a4af5 100644
98
--- a/src/wl/sys/wl_linux.c
99
+++ b/src/wl/sys/wl_linux.c
100
@@ -168,6 +168,8 @@ static int wl_set_radio_block(void *data, bool blocked);
101
 static void wl_report_radio_state(wl_info_t *wl);
102
 #endif
103
 
104
+// Rel. commit "modpost: require a MODULE_DESCRIPTION()" (Jeff Johnson, 11 Mar 2025)
105
+MODULE_DESCRIPTION("Broadcom-wl wireless driver [unmaintained, out-of-tree]");
106
 MODULE_LICENSE("MIXED/Proprietary");
107
 
108
 static struct pci_device_id wl_id_table[] =
109
@@ -914,6 +916,10 @@ static struct pci_driver wl_pci_driver __refdata = {
110
 static int __init
111
 wl_module_init(void)
112
 {
113
+   printk(KERN_WARNING "You are using the broadcom-wl driver, which is not "
114
+       "maintained and is incompatible with Linux kernel security mitigations. "
115
+       "It is heavily recommended to replace the hardware and remove the driver. "
116
+       "Proceed at your own risk!");
117
    int error = -ENODEV;
118
 
119
 #ifdef BCMDBG
120
@@ -2457,7 +2463,12 @@ wl_del_timer(wl_info_t *wl, wl_timer_t *t)
121
    ASSERT(t);
122
    if (t->set) {
123
        t->set = FALSE;
124
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
125
+       // Rel. commit "treewide: Switch/rename to timer_delete[_sync]()" (Thomas Gleixner, 5 Apr 2025)
126
+       if (!timer_delete(&t->timer)) {
127
+#else
128
        if (!del_timer(&t->timer)) {
129
+#endif
130
 #ifdef BCMDBG
131
            WL_INFORM(("wl%d: Failed to delete timer %s\n", wl->unit, t->name));
132
 #endif
133
-- 
134
2.49.0
135
136