Package: broadcom-sta-dkms
Version: 6.30.223.271-31
Severity: normal
Tags: patch
Dear maintainer,
broadcom-sta-dkms fails to build against Linux 7.2 because the kernel
removed strncpy() entirely. DKMS autoinstall then fails when upgrading
to a 7.2-based kernel image.
-- Steps to reproduce:
1. Install broadcom-sta-dkms and linux-headers and linux-image for kernel 7.2.
2. auto dkms build fails.
-- What happens:
Build fails with exit status 2. From make.log:
src/shared/linux_osl.c:863:17: error: implicit declaration of function 'strncpy'
src/wl/sys/wl_linux.c:1542:9: error: implicit declaration of function 'strncpy'
-- What should happen:
The wl module should compile and install for kernel 7.2.
-- Root cause:
Linux 7.2 removed strncpy() from the kernel API after migrating all
in-tree callers to strscpy(), strscpy_pad(), strtomem_pad(), etc.
See upstream commit 079a028 ("string: Remove strncpy() from the kernel").
The driver still calls strncpy() in:
src/shared/linux_osl.c - osl_strncpy(), osl_debug_malloc()
src/wl/sys/wl_linux.c - wl_get_driver_info(), _wl_add_monitor_if()
-- System information:
Kernel: Linux 7.2.0+ (uname -a output here)
Architecture: amd64
-- Proposed fix:
diff -Nurp a/src/shared/linux_osl.c b/src/shared/linux_osl.c
--- a/src/shared/linux_osl.c
+++ b/src/shared/linux_osl.c
@@ -471,8 +471,12 @@ osl_debug_malloc(osl_t *osh, uint size, int line, const
char *file)
if (!basename)
basename = file;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)
+ strscpy(p->file, basename, BCM_MEM_FILENAME_LEN);
+#else
strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
+#endif
if (osh) {
p->prev = NULL;
@@ -860,7 +864,12 @@ osl_strcpy(char *d, const char *s)
char*
osl_strncpy(char *d, const char *s, uint n)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)
+ strscpy_pad(d, s, n);
+ return d;
+#else
return (strncpy(d, s, n));
+#endif
}
char*
diff -Nurp a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -1539,8 +1539,12 @@ wl_get_driver_info(struct net_device *dev, struct
ethtool_drvinfo *info)
#endif
bzero(info, sizeof(struct ethtool_drvinfo));
snprintf(info->driver, sizeof(info->driver), "wl%d", wl->pub->unit);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)
+ strscpy(info->version, EPI_VERSION_STR, sizeof(info->version));
+#else
strncpy(info->version, EPI_VERSION_STR, sizeof(info->version));
info->version[(sizeof(info->version))-1] = '\0';
+#endif
}
static int
@@ -3027,7 +3031,11 @@ _wl_add_monitor_if(wl_info_t *wl, wl_if_t *wlif)
}
ASSERT(strlen(wlif->name) > 0);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)
+ memcpy(wlif->dev->name, wlif->name, strlen(wlif->name));
+#else
strncpy(wlif->dev->name, wlif->name, strlen(wlif->name));
+#endif
wl->monitor_dev = dev;
if (wl->monitor_type == 1)
I have verified that the patched source builds and installs successfully
against kernel 7.2
- Joshua Gatley-Dewing