⬢ DragonFlyBSD Kernel Audit
DF-4347 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/amdgpu/atom.c	2026-09-19 15:20:43.078604743 +0000
+++ b/sys/dev/drm/amd/amdgpu/atom.c	2026-09-19 15:20:43.094604538 +0000
@@ -1343,8 +1343,17 @@
 
 	str = CSTR(idx);
 	if (*str != '\0') {
-		pr_info("ATOM BIOS: %s\n", str);
-		strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+		/* never print/copy the VBIOS string unbounded: copy at most
+		 * sizeof(vbios_version)-1 bytes and always terminate (the
+		 * full fix -- requiring the NUL inside the bios image -- is
+		 * the bios_size port, see DF-4345) */
+		char *d = ctx->vbios_version;
+		int i;
+
+		for (i = 0; i < sizeof(ctx->vbios_version) - 1 && str[i]; i++)
+			d[i] = str[i];
+		d[i] = '\0';
+		pr_info("ATOM BIOS: %s\n", d);
 	}