From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E8D657C70C; Wed, 9 Sep 2026 14:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788963030; cv=none; b=PwEmtjTQjv2KumtHULxsIrXkFcvugeSN9WA04GmjWJsRI0ws3mUgyWFyVEi7q5eG6inB3fu+VEpsvDPeXs0AwtyA2p3pGtGp/c5BEEJugpRNul+TUPLxqsuDw5DYyAEgBX8ZR5y/RcaWELHZWemmecT72miP80B+V+IIuUWMPGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788963030; c=relaxed/simple; bh=jD3CYD14Qm9AZKWWQtPPUpk5Ac7/RRQXCULIq8ZAsoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cv3z2rATAAAo9vd/+cSlNbnC1l23zqOuHTdoXFcUOb3PBTGu0x3YjKwY8VRODDpqf4OaKBTiWeGsJsSvtqyx2E7ZTzGp36JS8q9ek1n1g4/1Gp5Jn/srpZDVenCXbhWmOk6maG1XxSbujX8/fPI37Wavb595X/SjoyYLtEh2h7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZBij7JIB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZBij7JIB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8A2D1F00A3A; Wed, 9 Sep 2026 14:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788963029; bh=WpcQawIxXfEsef8pUsYmuJFS3GB5i6OdPvj8yrll4zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZBij7JIBD+QUqAu9tQpQXrTqpfqGG4c+EcIKJW1bpSiSk9McQ4ktRslikGFHp7woN 7Z09a1WRv+rkd917uKN2CrfZnll24l/E0QLr+NBDxg1bcvihodigj1ToH0Yrl3BL/e 4yWLxUfhD1BMrz4vUpbYv3zwZ9JviVsgJcjO15WM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+916c888ba5f1a54c9526@syzkaller.appspotmail.com, Deepanshu Kartikey , Ruben Wauters Subject: [PATCH 7.2 496/556] drm/gud: NUL-terminate TV mode names read from the device Date: Wed, 9 Sep 2026 15:42:56 +0200 Message-ID: <20260909134247.929955316@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909134230.441546314@linuxfoundation.org> References: <20260909134230.441546314@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Deepanshu Kartikey commit 500cb24cd61bad8a2747ddfc49b7034899c82d94 upstream. gud_connector_add_tv_mode() reads a buffer of fixed-size mode names from the USB device and passes pointers into it to drm_mode_create_tv_properties_legacy(), which calls strlen() on each one. Nothing guarantees the device NUL-terminates a name, so strlen() can run past the end of a slot and, for the last mode, past the end of the allocation. Terminate each name at the end of its slot before use. Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver") Reported-by: syzbot+916c888ba5f1a54c9526@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=916c888ba5f1a54c9526 Tested-by: syzbot+916c888ba5f1a54c9526@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey Acked-by: Ruben Wauters Cc: Signed-off-by: Ruben Wauters Link: https://patch.msgid.link/20260816085234.22053-1-kartikey406@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/gud/gud_connector.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/gud/gud_connector.c +++ b/drivers/gpu/drm/gud/gud_connector.c @@ -396,8 +396,13 @@ static int gud_connector_add_tv_mode(str } num_modes = ret / GUD_CONNECTOR_TV_MODE_NAME_LEN; - for (i = 0; i < num_modes; i++) - modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; + for (i = 0; i < num_modes; i++) { + char *mode = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; + + /* The device is not trusted to NUL-terminate the name */ + mode[GUD_CONNECTOR_TV_MODE_NAME_LEN - 1] = '\0'; + modes[i] = mode; + } ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes); free: